Skip to content

Commit

Permalink
play with currencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gilv93 committed Nov 27, 2024
1 parent 7057f0c commit 5bcc15b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 8 additions & 5 deletions lib/recurly/amazon/amazon-pay.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AmazonPay extends Emitter {
renderButton (element) {
window.amazon.Pay.renderButton(`#${element}`, {
merchantId: this.options.merchantId,
ledgerCurrency: this.options.currency,
ledgerCurrency: this.defaultCurrency,
checkoutLanguage: this.options.locale,
productType: 'PayOnly',
placement: 'Other',
Expand All @@ -64,7 +64,7 @@ class AmazonPay extends Emitter {
const defaultEventName = 'amazon-pay';
let gatewayCode = this.options.gatewayCode || '';
this.frame = this.recurly.Frame({
path: `/amazon_pay/start?region=${this.options.region}&gateway_code=${gatewayCode}`,
path: `/amazon_pay/start?region=${this.options.region}&gateway_code=${gatewayCode}&currency=${this.options.currency}`,
type: Frame.TYPES.WINDOW,
defaultEventName
}).on('error', cause => this.emit('error', cause)) // Emitted by js/v1/amazon_pay/cancel
Expand All @@ -75,15 +75,18 @@ class AmazonPay extends Emitter {
setLocaleAndCurrency () {
switch (this.options.region) {
case 'uk':
this.options.currency = 'GBP';
this.options.currency ??= 'GBP';
this.defaultCurrency = 'GBP';
this.options.locale = 'en_GB';
break;
case 'eu':
this.options.currency = 'EUR';
this.options.currency ??= 'EUR';
this.defaultCurrency = 'EUR';
this.options.locale = 'en_GB';
break;
case 'us':
this.options.currency = 'USD';
this.options.currency ??= 'USD';
this.defaultCurrency = 'USD';
this.options.locale = 'en_US';
break;
}
Expand Down
1 change: 0 additions & 1 deletion lib/recurly/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export function tokenDispatcher (...args) {
[customerData, done] = args;
}


// Try to find the implied Elements if given an HTMLFormElement
if (!elements && (customerData instanceof HTMLFormElement)) {
const impliedElement = Element.findElementInDOMTree(customerData);
Expand Down

0 comments on commit 5bcc15b

Please sign in to comment.