Skip to content

Commit 4232a14

Browse files
fix no currency switcher in Afterpay
1 parent b38c405 commit 4232a14

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "airwallex/payments-plugin-magento",
33
"type": "magento2-module",
44
"description": "",
5-
"version": "1.12.0",
5+
"version": "1.12.1",
66
"require": {
77
"ext-json": "*",
88
"php": "^7.4|^8.0",

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22

33
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
4-
<module name="Airwallex_Payments" setup_version="1.12.0">
4+
<module name="Airwallex_Payments" setup_version="1.12.1">
55
<sequence>
66
<module name="Magento_Sales"/>
77
<module name="Magento_Payment"/>

view/frontend/web/js/view/payment/redirect-method.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,33 @@ define([
264264
$body.trigger('processStop');
265265
return false;
266266
}
267+
const entityToCurrency = window.checkoutConfig.payment.airwallex_payments.afterpay_support_entity_to_currency;
268+
const countryToCurrency = window.checkoutConfig.payment.airwallex_payments.afterpay_support_countries;
269+
270+
let currencies = JSON.parse(window.checkoutConfig.payment.airwallex_payments.available_currencies);
271+
console.log(currencies, currencies.length)
272+
if (!currencies.length) {
273+
let countryID = quote.billingAddress() ? quote.billingAddress().countryId : '';
274+
let currency = countryToCurrency[countryID];
275+
if (!currency) {
276+
this.validationError(utils.awxAlert('Afterpay is not available in your country.'));
277+
this.disableCheckoutButton();
278+
$body.trigger('processStop');
279+
return false;
280+
}
281+
if (currency !== window.checkoutConfig.quoteData.quote_currency_code) {
282+
this.validationError(utils.awxAlert("Afterpay is not available in " + window.checkoutConfig.quoteData.quote_currency_code
283+
+ " for your billing country. Please use a different payment method to complete your purchase."));
284+
this.disableCheckoutButton();
285+
$body.trigger('processStop');
286+
return false;
287+
}
288+
}
267289
if (entity !== 'AIRWALLEX_HK') {
268290
$(".awx-billing-confirm-tip").hide();
269291
} else {
270292
$(".awx-billing-confirm-tip").show();
271293
}
272-
const entityToCurrency = window.checkoutConfig.payment.airwallex_payments.afterpay_support_entity_to_currency;
273-
const countryToCurrency = window.checkoutConfig.payment.airwallex_payments.afterpay_support_countries;
274294
if (!entityToCurrency[entity]) {
275295
throw new Error("Afterpay is not available in your country.");
276296
}

0 commit comments

Comments
 (0)