From 56ce6fe7a4047d9bda454d4f8f32e17f45a3a6c5 Mon Sep 17 00:00:00 2001 From: gil Date: Mon, 25 Nov 2024 08:25:15 -0800 Subject: [PATCH] play with currencies --- lib/recurly/amazon/amazon-pay.js | 13 ++++++++----- lib/recurly/token.js | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/recurly/amazon/amazon-pay.js b/lib/recurly/amazon/amazon-pay.js index 85dca4e9..a1763ef1 100644 --- a/lib/recurly/amazon/amazon-pay.js +++ b/lib/recurly/amazon/amazon-pay.js @@ -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', @@ -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}¤cy=${this.options.currency}`, type: Frame.TYPES.WINDOW, defaultEventName }).on('error', cause => this.emit('error', cause)) // Emitted by js/v1/amazon_pay/cancel @@ -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; } diff --git a/lib/recurly/token.js b/lib/recurly/token.js index 2f95982d..d8118176 100644 --- a/lib/recurly/token.js +++ b/lib/recurly/token.js @@ -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);