From bf5f423eeafe2edfc617763d596f6b1c71e58300 Mon Sep 17 00:00:00 2001 From: rlew421 Date: Mon, 9 May 2022 16:11:26 -0600 Subject: [PATCH] Add gatewayCode to params --- lib/recurly/paypal/strategy/direct.js | 1 + lib/recurly/paypal/strategy/index.js | 1 + test/unit/paypal/strategy/direct.test.js | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/recurly/paypal/strategy/direct.js b/lib/recurly/paypal/strategy/direct.js index 2a7244aba..db37de7eb 100644 --- a/lib/recurly/paypal/strategy/direct.js +++ b/lib/recurly/paypal/strategy/direct.js @@ -16,6 +16,7 @@ export class DirectStrategy extends PayPalStrategy { if (this.config.display.amount) payload.amount = this.config.display.amount; if (this.config.display.logoImageUrl) payload.logoImageUrl = this.config.display.logoImageUrl; if (this.config.display.headerImageUrl) payload.headerImageUrl = this.config.display.headerImageUrl; + if (this.config.gatewayCode) payload.gatewayCode = this.config.gatewayCode; return payload; } diff --git a/lib/recurly/paypal/strategy/index.js b/lib/recurly/paypal/strategy/index.js index 0fcddafb3..a1d8cc9ff 100644 --- a/lib/recurly/paypal/strategy/index.js +++ b/lib/recurly/paypal/strategy/index.js @@ -51,6 +51,7 @@ export class PayPalStrategy extends Emitter { configure (options) { if (!(options.recurly instanceof Recurly)) throw this.error('paypal-factory-only'); this.recurly = options.recurly; + if (options.gatewayCode) this.config.gatewayCode = options.gatewayCode; this.config.display = {}; diff --git a/test/unit/paypal/strategy/direct.test.js b/test/unit/paypal/strategy/direct.test.js index 3812af54c..b0ae73f00 100644 --- a/test/unit/paypal/strategy/direct.test.js +++ b/test/unit/paypal/strategy/direct.test.js @@ -51,6 +51,27 @@ describe('DirectStrategy', function () { }); }); + context('when given a gateway code', function () { + const gatewayCode = 'qn1234a5bcde'; + const gatewayOpts = { display: { displayName }, gatewayCode }; + + beforeEach(function () { + this.paypal = this.recurly.PayPal(gatewayOpts); + }); + + it('Passes the description and gateway code to the API start endpoint', function () { + this.paypal.start(); + assert(this.recurly.Frame.calledOnce); + assert(this.recurly.Frame.calledWith(sinon.match({ + path: '/paypal/start', + payload: sinon.match({ + description: displayName, + gatewayCode + }) + }))); + }); + }); + it('emits a cancel event when the window closes', function (done) { this.timeout(2500); // timeout with error if paypal doesn't emit cancel event this.paypal.on('cancel', () => done());