Search code examples
paypalbraintreepci-compliance

Braintree PCI compliance issue


I have been continuously getting an email by brain tree on PCI Compliance regards and need confirmation on following two things which have been asked.

What is the Braintree payment integration method on our website? (Hint: It’s one of these)

  1. Drop in UI or hosted field
  2. Braintree SDK Custom integration

Following is the javascript code we've used . I went through the Braintree site on this regards but couldn't conclude upon this.

Additional Notes : We've made some changes on braintree vendor file.

var subscribed_user = "1";

$('#cc').on('click', function (e) {
    $('#cc-info').show().attr('aria-hidden', true).css('visibility', 'visible');
});
var button = document.querySelector('#paypal-button');
var button1 = document.querySelector('#card-button');
var form = document.querySelector('#checkout-form');
var authorization = 'AuthHeaderxxxxxxxx=';


// Create a client.
braintree.client.create({
    authorization: authorization
}, function (clientErr, clientInstance) {

    // Stop if there was a problem creating the client.
    // This could happen if there is a network error or if the authorization
    // is invalid.
    if (clientErr) {
        console.error('Error creating client:', clientErr);
        return;
    }
    /* Braintree - Hosted Fields component */
    braintree.hostedFields.create({
        client: clientInstance,
        styles: {
            'input': {
                'font-size': '10pt',
                'color': '#e3e3e3 !important; ',
                'border-radius': '0px'

            },
            'input.invalid': {
                'color': 'red'
            },
            'input.valid': {
                'color': 'green'
            }
        },
        fields: {
            number: {
                selector: '#card-number',
                placeholder: '4111 1111 1111 1111',

            },
            cvv: {
                selector: '#cvv',
                placeholder: '123'
            },
            expirationDate: {
                selector: '#expiration-date',
                placeholder: '10/2019'
            }
        }
    }, function (hostedFieldsErr, hostedFieldsInstance) {
        if (hostedFieldsErr) { /*Handle error in Hosted Fields creation*/
            return;
        }

        button1.addEventListener('click', function (event) {
            event.preventDefault();
            hostedFieldsInstance.tokenize(function (tokenizeErr, payload) {
                if (tokenizeErr) { /* Handle error in Hosted Fields tokenization*/
                    document.getElementById('invalid-field-error').style.display = 'inline';
                    return;
                }
                /* Put `payload.nonce` into the `payment-method-nonce` input, and thensubmit the form. Alternatively, you could send the nonce to your serverwith AJAX.*/
                /* document.querySelector('form#bt-hsf-checkout-form input[name="payment_method_nonce"]').value = payload.nonce;*/
                document.querySelector('input[name="payment-method-nonce"]').value = payload.nonce;
                form.submit();
                button1.setAttribute('disabled', 'disabled');
            });
        }, false);
    });

    // Create a PayPal component.
    braintree.paypal.create({
        client: clientInstance,
        paypal: true
    }, function (paypalErr, paypalInstance) {

        // Stop if there was a problem creating PayPal.
        // This could happen if there was a network error or if it's incorrectly
        // configured.
        if (paypalErr) {
            console.error('Error creating PayPal:', paypalErr);
            return;
        }

        if ($('select#paypal-subs-selector option:selected').val() == '') {
            button.setAttribute('disabled', 'disabled');
        }
        $('select#paypal-subs-selector').change(function () {
            if ($('select#paypal-subs-selector option:selected').val() == '') {
                button.setAttribute('disabled', 'disabled');
            } else {
                // Enable the button.
                button.removeAttribute('disabled');
            }
        });


            button.addEventListener('click', function () {
                if(subscribed_user) {
                    // Popup Error for changing subscription.
                    swal({
                        html: true,
                        title: "",
                        text: "You are cancelling in the middle of subscription.<br/>If you do so you will not be refunded remaining days of your subscription.",
                        confirmButtonColor: '#605ca8',
                        confirmButtonText: 'Yes',
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "Proceed !",
                        closeOnConfirm: true
                    }, function (isConfirm) {
                        if (isConfirm) {
                            show_payment_methods(paypalInstance);
                        }
                    });
                } else{
                    show_payment_methods(paypalInstance);
                }
            }, false);

    });
});

Any help would be highly appreciated.


Solution

  • Your code says Braintree - Hosted Field component And you don’t use anything like this which I found by searching “Braintree api”. I think you’re safe to say you use hosted fields.