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 multi currency support for Amazon UK and EU #909

Merged
merged 1 commit into from
Dec 17, 2024
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
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
Loading