Skip to content

Commit

Permalink
Upgrade Braintree SDK and 3DS params
Browse files Browse the repository at this point in the history
  • Loading branch information
arzitney committed Apr 1, 2024
1 parent dbe1dbc commit f15bbf6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/const/gateway-constants.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const BRAINTREE_CLIENT_VERSION = '3.96.1';
export const BRAINTREE_CLIENT_VERSION = '3.100';
43 changes: 33 additions & 10 deletions lib/recurly/risk/three-d-secure/strategy/braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default class BraintreeStrategy extends ThreeDSecureStrategy {
return this.actionToken.transaction.amount;
}

get billingInfo () {
return this.actionToken.billing_info;
}

get bin () {
return this.actionToken.three_d_secure.params.bin;
}
Expand All @@ -51,7 +55,32 @@ export default class BraintreeStrategy extends ThreeDSecureStrategy {
this.whenReady(() => {
debug('Attempting to load braintree');

const { braintree, braintreeClientToken, amount, nonce, bin } = this;
const { braintree, braintreeClientToken, amount, nonce, bin, billingInfo } = this;

const verifyCardOptions = {
amount: amount,
nonce: nonce,
bin: bin,
challengeRequested: true,
collectDeviceData: true,
onLookupComplete: (data, next) => {
next();
}
};

if(billingInfo != null) {
verifyCardOptions.billingAddress = {
givenName: billingInfo.first_name,
surname: billingInfo.last_name,
phoneNumber: billingInfo.phone,
streetAddress: billingInfo.address1,
extendedAddress: billingInfo.address2,
locality: billingInfo.city,
region: billingInfo.state,
postalCode: billingInfo.zip,
countryCodeAlpha2: billingInfo.country
};
}

braintree.client.create({
authorization: braintreeClientToken
Expand All @@ -61,15 +90,9 @@ export default class BraintreeStrategy extends ThreeDSecureStrategy {
version: 2
});
}).then(threeDSecureInstance => {
return threeDSecureInstance.verifyCard({
amount: amount,
nonce: nonce,
bin: bin,
challengeRequested: true,
onLookupComplete: (data, next) => {
next();
}
});
return threeDSecureInstance.verifyCard(
verifyCardOptions,
);
}).then(({ nonce: paymentMethodNonce }) => this.emit('done', { paymentMethodNonce }))
.catch(cause => this.threeDSecure.error('3ds-auth-error', { cause }));
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/apple-pay.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ApplePaySessionStub.canMakePayments = () => true;

const getBraintreeStub = () => ({
client: {
VERSION: '3.96.1',
VERSION: '3.100',
create: sinon.stub().resolves('CLIENT'),
},
dataCollector: {
Expand Down
1 change: 1 addition & 0 deletions test/unit/risk/three-d-secure/strategy/braintree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('BraintreeStrategy', function () {
nonce: "test-braintree-nonce",
bin: "test-braintree-bin",
challengeRequested: true,
collectDeviceData: true,
onLookupComplete: sinon.match.func
}));

Expand Down

0 comments on commit f15bbf6

Please sign in to comment.