import { registerPaymentMethod } from '@woocommerce/blocks-registry'; import { airwallexDropInOption } from './airwallex-dropin'; import { airwallexCardOption } from './card/airwallex-card'; import { airwallexWeChatOption } from './airwallex-wechat'; import { airwallexPOSOption } from './airwallex-pos'; import { airwallexExpressCheckoutOption } from './airwallex-express-checkout'; import { airwallexKlarnaOption } from './localPaymentMethods/airwallex-klarna'; import { airwallexAfterpayOption } from './localPaymentMethods/airwallex-afterpay'; import { registerPlugin } from '@wordpress/plugins'; import { ExperimentalOrderMeta } from '@woocommerce/blocks-checkout'; import { __ } from '@wordpress/i18n'; import { select } from '@wordpress/data'; import { PAYMENT_STORE_KEY } from '@woocommerce/block-data'; /** * The narrow slice of the `@woocommerce/block-data` payment store * selectors this entry consumes. The ambient `select(key)` is typed * as `Record unknown>` (see * `client/types/ambient-modules.d.ts`), so we project it through this * interface at the call site to expose the actual return shape. */ interface PaymentStoreSelectors { getActivePaymentMethod: () => string; } registerPaymentMethod(airwallexDropInOption); registerPaymentMethod(airwallexCardOption); registerPaymentMethod(airwallexWeChatOption); registerPaymentMethod(airwallexPOSOption); registerPaymentMethod(airwallexExpressCheckoutOption); registerPaymentMethod(airwallexKlarnaOption); registerPaymentMethod(airwallexAfterpayOption); interface CurrencySwitchingDetailProps { cart?: { cartTotal: { value: number }; currency: { code: string } }; extensions?: Record; } const CurrencySwitchingDetail = (_props: CurrencySwitchingDetailProps) => { return (
{__('You Pay', 'airwallex-online-payments-gateway')}
); }; const renderCurrencySwitching = () => { return ( ); } registerPlugin('airwallex-lpm', { render: renderCurrencySwitching, scope: 'woocommerce-checkout', }); window.addEventListener('change', (event: Event) => { const target = event?.target as HTMLInputElement | null; const activeMethod = (select(PAYMENT_STORE_KEY) as unknown as PaymentStoreSelectors).getActivePaymentMethod(); if (target?.name === 'radio-control-wc-payment-method-options' && !['airwallex_klarna', 'airwallex_afterpay'].includes(activeMethod)) { (document.getElementById('wc-block-airwallex-currency-switching-container') as HTMLElement).style.display = 'none'; } });