Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Braintree SDK #877

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.101.0';
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.101.0',
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
Loading