Broadleaf Microservices
  • v1.0.0-latest-prod

3DS With Braintree

Braintree supports a 3DS pattern where the payment method is verified via your frontend integration prior to any attempts to execute transactions.

To enable this with your frontend integration, you will need to declare that 3DS is enabled, & provide additional customer & transaction data to Braintree. In this payload, try to pass as much data as you can. Passing more information allows Braintree/issuing banks to make a more informed decision about the need to make a 3DS challenge vs allowing a frictionless payment experience.

var threeDSecureParameters = {
  amount: '500.00',
  email: 'test@example.com',
  billingAddress: {
    givenName: 'Jill', // ASCII-printable characters required, else will throw a validation error
    surname: 'Doe', // ASCII-printable characters required, else will throw a validation error
    phoneNumber: '8101234567',
    streetAddress: '555 Smith St.',
    extendedAddress: '#5',
    locality: 'Oakland',
    region: 'CA', // ISO-3166-2 code
    postalCode: '12345',
    countryCodeAlpha2: 'US'
  },
  additionalInformation: {
    workPhoneNumber: '8101234567',
    shippingGivenName: 'Jill',
    shippingSurname: 'Doe',
    shippingPhone: '8101234567',
    shippingAddress: {
      streetAddress: '555 Smith St.',
      extendedAddress: '#5',
      locality: 'Oakland',
      region: 'CA', // ISO-3166-2 code
      postalCode: '12345',
      countryCodeAlpha2: 'US'
    }
  },
};

braintree.dropin.create({
    authorization: 'CLIENT_AUTHORIZATION',
    container: '#dropin-container',
    threeDSecure: true
}, function (err, dropinInstance) {
    if (err) {
        // Handle any errors that might've occurred when creating Drop-in
        console.error(err);
        return;
    }

    submitButton.addEventListener('click', function (e) {
        e.preventDefault();
        dropinInstance.requestPaymentMethod({
          threeDSecure: threeDSecureParameters
        }, function (err, payload) {
            if (err) {
                // Handle errors in requesting payment method
            }
            // Send payload.nonce to your server
            // The 3D Secure Authentication ID can be found
            //  at payload.threeDSecureInfo.threeDSecureAuthenticationId
        });
    });
});