Skip to content

Commit

Permalink
Merge pull request #727 from recurly/select_paypal_gateway
Browse files Browse the repository at this point in the history
Select PayPal gateway
  • Loading branch information
mroman-recurly authored May 20, 2022
2 parents 65f3a99 + bf5f423 commit 4d702a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/recurly/paypal/strategy/direct.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions lib/recurly/paypal/strategy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down
21 changes: 21 additions & 0 deletions test/unit/paypal/strategy/direct.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 4d702a0

Please sign in to comment.