Skip to content

Commit

Permalink
Merge pull request #868 from recurly/frame-hostname-auth
Browse files Browse the repository at this point in the history
Adds hostname auth capability to Frame
  • Loading branch information
douglasmiller authored Jan 26, 2024
2 parents 6a42eae + baf27e3 commit 6923627
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/recurly/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export class Frame extends Emitter {
payload.event = name;
payload.key = recurly.config.publicKey;

if (recurly.config.hostname) {
payload.credentialCheckoutHostname = recurly.config.hostname;
}

const ev = res => {
this.removeRelay();
if (res.error) {
Expand Down
14 changes: 14 additions & 0 deletions test/unit/frame.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@ describe('Recurly.Frame', function () {
assert(~src.indexOf(`version=${recurly.version}`));
assert(~src.indexOf('event=recurly-frame-'));
assert(~src.indexOf('key=test'));
assert(!~src.indexOf('credentialCheckoutHostname'));
});

describe('when configured to use hostname auth', function () {
beforeEach(function (done) {
this.recurly.configure({ hostname: 'test-hostname.recurly.com' });
this.frame = this.recurly.Frame({ path, payload, type: Frame.TYPES.IFRAME, container: testBed() });
this.frame.on('done', () => done());
});

it('assigns the value in the URL', function () {
const { src } = this.frame.iframe;
assert(~src.indexOf('credentialCheckoutHostname=test-hostname.recurly.com'));
});
});

describe('Frame.destroy', function () {
Expand Down

0 comments on commit 6923627

Please sign in to comment.