Skip to content

Commit

Permalink
Merge pull request #905 from recurly/add-currency-to-preflight
Browse files Browse the repository at this point in the history
add currency to proactive preflights flow
  • Loading branch information
chrissrogers authored Nov 5, 2024
2 parents da963b7 + f512b73 commit d50249b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/recurly/risk/three-d-secure/strategy/braintree.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class BraintreeStrategy extends ThreeDSecureStrategy {
}

static preflight ({ recurly, number, month, year, cvv }) {
const { enabled, gatewayCode, amount } = recurly.config.risk.threeDSecure.proactive;
const { enabled, gatewayCode, amount, currency } = recurly.config.risk.threeDSecure.proactive;

debug('performing preflight for', { gatewayCode });

Expand All @@ -22,6 +22,7 @@ export default class BraintreeStrategy extends ThreeDSecureStrategy {
const data = {
gateway_type: BraintreeStrategy.strategyName,
gateway_code: gatewayCode,
currency: currency,
number,
month,
year,
Expand Down
41 changes: 41 additions & 0 deletions test/unit/risk/three-d-secure/strategy/braintree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,45 @@ describe('BraintreeStrategy', function () {
});
});
});

describe('preflight', function () {
beforeEach(function () {
const { recurly } = this;
this.number = '4111111111111111';
this.month = '01';
this.year = '2023';
this.cvv = '737'
recurly.config.risk.threeDSecure.proactive = {
enabled: true,
gatewayCode: 'test-gateway-code',
amount: 50,
currency: 'USD'
};
recurly.request.post = sinon.stub().resolves({
paymentMethodNonce: 'test-braintree-nonce',
clientToken: '1234',
bin: '411111',
});
});

it('sends the correct data', function (done) {
const { recurly, number, month, year, cvv } = this;

BraintreeStrategy.preflight({ recurly, number, month, year, cvv }).then(() => {
sinon.assert.calledWithMatch(recurly.request.post, {
route: '/risk/authentications',
data: {
gateway_type: BraintreeStrategy.strategyName,
gateway_code: 'test-gateway-code',
currency: 'USD',
number,
month,
year,
cvv
}
});
done();
});
});
});
});

0 comments on commit d50249b

Please sign in to comment.