Skip to content

Commit

Permalink
Merge pull request #848 from recurly/add_amazon_pay
Browse files Browse the repository at this point in the history
Add Amazon Pay
  • Loading branch information
douglaslise authored Sep 19, 2023
2 parents d5e1134 + 6db1ed4 commit e675bb0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/recurly.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { factory as Frame } from './recurly/frame';
import { factory as PayPal } from './recurly/paypal';
import { factory as Venmo } from './recurly/venmo';
import { factory as Risk } from './recurly/risk';
import { factory as AmazonPay } from './recurly/amazon';
import { deprecated as deprecatedPaypal } from './recurly/paypal/strategy/direct';
import { Bus } from './recurly/bus';
import { Reporter } from './recurly/reporter';
Expand Down Expand Up @@ -125,6 +126,7 @@ export class Recurly extends Emitter {
Risk = Risk;
tax = tax;
token = token;
AmazonPay = AmazonPay;
validate = require('./recurly/validate').publicMethods;

/**
Expand Down
27 changes: 27 additions & 0 deletions lib/recurly/amazon/amazon-pay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Emitter from 'component-emitter';
import { Frame } from '../frame';

class AmazonPay extends Emitter {
constructor (recurly, options) {
super();
this.recurly = recurly;
this.options = options;
}

attach (element) {
this.parent = element;
this.region = this.options?.region || 'us';
const defaultEventName = 'amazon-pay';

this.frame = this.recurly.Frame({
path: `/amazon_pay/start?region=${this.region}`,
type: Frame.TYPES.WINDOW,
defaultEventName
}).on('error', cause => console.log(cause))
.on('done', results => {
this.emit('token', results);
});
}
}

export default AmazonPay;
13 changes: 13 additions & 0 deletions lib/recurly/amazon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import AmazonPay from './amazon-pay';
/**
* Returns an Amazon instance.
*
* @param {Object} options
* @return {AmazonPay}
*/

export function factory (options) {
const recurly = this;

return new AmazonPay(recurly, options);
}

0 comments on commit e675bb0

Please sign in to comment.