@@ -264,13 +264,33 @@ define([
264
264
$body . trigger ( 'processStop' ) ;
265
265
return false ;
266
266
}
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
+ }
267
289
if ( entity !== 'AIRWALLEX_HK' ) {
268
290
$ ( ".awx-billing-confirm-tip" ) . hide ( ) ;
269
291
} else {
270
292
$ ( ".awx-billing-confirm-tip" ) . show ( ) ;
271
293
}
272
- const entityToCurrency = window . checkoutConfig . payment . airwallex_payments . afterpay_support_entity_to_currency ;
273
- const countryToCurrency = window . checkoutConfig . payment . airwallex_payments . afterpay_support_countries ;
274
294
if ( ! entityToCurrency [ entity ] ) {
275
295
throw new Error ( "Afterpay is not available in your country." ) ;
276
296
}
0 commit comments