Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Amazon Pay #848

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Loading