@paykka/card-checkout-ui 0.13.16 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-checkout-ui.js +54 -26
- package/dist/card-checkout-ui.umd.cjs +54 -26
- package/dist/es/api/modules/boost/index.js +5 -16
- package/dist/es/api/modules/gcash/index.js +5 -16
- package/dist/es/api/modules/get-browser-params.js +1 -4
- package/dist/es/api/modules/grab-pay/index.js +5 -16
- package/dist/es/api/modules/line-pay/index.js +5 -16
- package/dist/es/api/modules/may-bank-qr-pay/index.js +5 -16
- package/dist/es/api/modules/nine-pay/index.js +5 -16
- package/dist/es/api/modules/opay-wallet/index.js +5 -16
- package/dist/es/api/modules/paga-wallet/index.js +5 -16
- package/dist/es/api/modules/paymaya/index.js +5 -16
- package/dist/es/api/modules/shopee-pay/index.js +5 -16
- package/dist/es/api/modules/threeDS/index.js +16 -2
- package/dist/es/api/modules/tng-wallet/index.js +5 -16
- package/dist/es/api/modules/wallet/index.js +16 -0
- package/dist/es/api/modules/zalopay/index.js +5 -16
- package/dist/es/api/utils/index.js +2 -1
- package/dist/es/components/AccordionItem/AccordionItem.js +0 -2
- package/dist/es/components/AddressField/index.js +95 -85
- package/dist/es/components/AliPay/index.js +88 -76
- package/dist/es/components/ApplePay/index.js +61 -43
- package/dist/es/components/CPFField/index.js +2 -1
- package/dist/es/components/Card/index.js +182 -143
- package/dist/es/components/CardExpireDateField/index.js +2 -1
- package/dist/es/components/CardNo/index.js +2 -2
- package/dist/es/components/CardNumberField/index.js +2 -1
- package/dist/es/components/CardSecurityCodeField/index.js +2 -1
- package/dist/es/components/CardSelector/index.js +3 -2
- package/dist/es/components/DropIn/index.js +98 -31
- package/dist/es/components/GooglePay/index.js +190 -151
- package/dist/es/components/GuideCard/index.js +8 -1
- package/dist/es/components/PaymentButton/index.js +58 -0
- package/dist/es/components/RecurringTip/index.js +3 -3
- package/dist/es/components/SecuredFieldsProvider/index.js +81 -17
- package/dist/es/components/SecuredIframe/index.js +120 -52
- package/dist/es/components/Sepa/index.js +23 -25
- package/dist/es/components/SubmitButton/index.js +1 -1
- package/dist/es/components/ThreeDS/index.js +34 -15
- package/dist/es/components/WechatPay/index.js +94 -83
- package/dist/es/components/business/BlikCodeField/BlikCodeField.js +92 -0
- package/dist/es/components/business/BlikCodeField/blik-code-field.js +1 -0
- package/dist/es/components/business/BlikCodeField/index.js +13 -0
- package/dist/es/components/business/BlikConfirmModal/BlikConfirmModal.js +45 -0
- package/dist/es/components/business/BlikConfirmModal/blik-confirm-modal.js +1 -0
- package/dist/es/components/business/BlikConfirmModal/index.js +9 -0
- package/dist/es/components/business/BlikConfirmModal/type.js +1 -0
- package/dist/es/components/business/NameField/NameField.js +51 -0
- package/dist/es/components/business/NameField/index.js +11 -0
- package/dist/es/components/business/NameField/type.js +1 -0
- package/dist/es/components/business/PhoneField/PhoneField.js +125 -0
- package/dist/es/components/business/PhoneField/config.js +33 -0
- package/dist/es/components/business/PhoneField/index.js +14 -0
- package/dist/es/components/business/PhoneField/phone-field.js +1 -0
- package/dist/es/components/business/PhoneField/type.js +1 -0
- package/dist/es/components/business/SegmentedDigitInput/SegmentedDigitInput.js +80 -0
- package/dist/es/components/business/SegmentedDigitInput/format.js +26 -0
- package/dist/es/components/business/SegmentedDigitInput/index.js +5 -0
- package/dist/es/components/business/Tooltip/Tooltip.js +18 -0
- package/dist/es/components/business/Tooltip/index.js +6 -0
- package/dist/es/components/business/Tooltip/tooltip2.js +1 -0
- package/dist/es/components/business/index.js +14 -0
- package/dist/es/components/index.js +14 -7
- package/dist/es/components/internal/CheckBox/CheckBox.js +2 -2
- package/dist/es/components/internal/Input/Input.js +1 -1
- package/dist/es/components/internal/Select/Select.js +7 -1
- package/dist/es/components/internal/icons/IconArrowDown.js +4 -4
- package/dist/es/components/internal/icons/IconBancontact.js +95 -0
- package/dist/es/components/internal/icons/IconBlik.js +567 -0
- package/dist/es/components/internal/icons/IconIdeal.js +86 -0
- package/dist/es/components/internal/icons/IconOvo.js +47 -0
- package/dist/es/components/internal/icons/IconP24.js +40 -0
- package/dist/es/components/internal/icons/IconPhone.js +56 -0
- package/dist/es/components/internal/icons/IconSkrill.js +38 -0
- package/dist/es/components/internal/icons/IconTrustly.js +37 -0
- package/dist/es/components/wallets/Bancontact/Bancontact.js +201 -0
- package/dist/es/components/wallets/Bancontact/bancontact2.js +1 -0
- package/dist/es/components/wallets/Bancontact/index.js +1 -0
- package/dist/es/components/wallets/Bancontact/type.js +1 -0
- package/dist/es/components/wallets/Blik/Blik.js +232 -0
- package/dist/es/components/wallets/Blik/blik2.js +1 -0
- package/dist/es/components/wallets/Blik/index.js +1 -0
- package/dist/es/components/wallets/Blik/type.js +1 -0
- package/dist/es/components/wallets/Boost/Boost.js +183 -0
- package/dist/es/components/wallets/Boost/boost2.js +1 -0
- package/dist/es/components/wallets/Boost/index.js +1 -0
- package/dist/es/components/wallets/Boost/type.js +1 -0
- package/dist/es/components/wallets/GCash/GCash.js +74 -252
- package/dist/es/components/wallets/GrabPay/GrabPay.js +183 -0
- package/dist/es/components/wallets/GrabPay/grab-pay.js +1 -0
- package/dist/es/components/wallets/GrabPay/index.js +1 -0
- package/dist/es/components/wallets/GrabPay/type.js +1 -0
- package/dist/es/components/wallets/IDeal/IDeal.js +201 -0
- package/dist/es/components/wallets/IDeal/ideal2.js +1 -0
- package/dist/es/components/wallets/IDeal/index.js +1 -0
- package/dist/es/components/wallets/IDeal/type.js +1 -0
- package/dist/es/components/wallets/LinePay/LinePay.js +183 -0
- package/dist/es/components/wallets/LinePay/index.js +1 -0
- package/dist/es/components/wallets/LinePay/line-pay.js +1 -0
- package/dist/es/components/wallets/LinePay/type.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/MayBankQRPay.js +187 -0
- package/dist/es/components/wallets/MayBankQRPay/index.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/may-bank-qr-pay.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/type.js +1 -0
- package/dist/es/components/wallets/NinePay/NinePay.js +185 -0
- package/dist/es/components/wallets/NinePay/index.js +1 -0
- package/dist/es/components/wallets/NinePay/nine-pay.js +1 -0
- package/dist/es/components/wallets/NinePay/type.js +1 -0
- package/dist/es/components/wallets/OVO/OVO.js +200 -0
- package/dist/es/components/wallets/OVO/index.js +1 -0
- package/dist/es/components/wallets/OVO/ovo2.js +1 -0
- package/dist/es/components/wallets/OVO/type.js +1 -0
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +57 -218
- package/dist/es/components/wallets/P24/P24.js +198 -0
- package/dist/es/components/wallets/P24/index.js +1 -0
- package/dist/es/components/wallets/P24/p242.js +1 -0
- package/dist/es/components/wallets/P24/type.js +1 -0
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +57 -218
- package/dist/es/components/wallets/Paymaya/Paymaya.js +57 -221
- package/dist/es/components/wallets/PicPay/PicPay.js +64 -55
- package/dist/es/components/wallets/Pix/Pix.js +58 -56
- package/dist/es/components/wallets/ShopeePay/ShopeePay.js +185 -0
- package/dist/es/components/wallets/ShopeePay/index.js +1 -0
- package/dist/es/components/wallets/ShopeePay/shopee-pay.js +1 -0
- package/dist/es/components/wallets/ShopeePay/type.js +1 -0
- package/dist/es/components/wallets/Skrill/Skrill.js +200 -0
- package/dist/es/components/wallets/Skrill/index.js +1 -0
- package/dist/es/components/wallets/Skrill/skrill2.js +1 -0
- package/dist/es/components/wallets/Skrill/type.js +1 -0
- package/dist/es/components/wallets/TNGWallet/TNGWallet.js +185 -0
- package/dist/es/components/wallets/TNGWallet/index.js +1 -0
- package/dist/es/components/wallets/TNGWallet/tng-wallet.js +1 -0
- package/dist/es/components/wallets/TNGWallet/type.js +1 -0
- package/dist/es/components/wallets/Trustly/Trustly.js +226 -0
- package/dist/es/components/wallets/Trustly/index.js +1 -0
- package/dist/es/components/wallets/Trustly/trustly2.js +1 -0
- package/dist/es/components/wallets/Trustly/type.js +1 -0
- package/dist/es/components/wallets/Vietqr/Vietqr.js +73 -242
- package/dist/es/components/wallets/Zalopay/Zalopay.js +73 -242
- package/dist/es/components/wallets/index.js +14 -0
- package/dist/es/constant.js +48 -2
- package/dist/es/core/address.js +7 -6
- package/dist/es/core/checkout.js +93 -41
- package/dist/es/core/create-child.js +68 -0
- package/dist/es/core/environment.js +23 -1
- package/dist/es/core/error.js +15 -2
- package/dist/es/core/logger.js +106 -0
- package/dist/es/core/payment.js +65 -0
- package/dist/es/fe-logger.min.js +1 -0
- package/dist/es/hooks/useBaseWallet.js +280 -0
- package/dist/es/hooks/usePayState.js +37 -25
- package/dist/es/hooks/usePayment.js +1 -14
- package/dist/es/hooks/useRetry.js +50 -26
- package/dist/es/i18n/locales/de-DE.js +24 -0
- package/dist/es/i18n/locales/en-GB.js +24 -0
- package/dist/es/i18n/locales/es-ES.js +24 -0
- package/dist/es/i18n/locales/fr-FR.js +24 -0
- package/dist/es/i18n/locales/ja-JP.js +24 -0
- package/dist/es/i18n/locales/ko-KR.js +24 -0
- package/dist/es/i18n/locales/nl-NL.js +24 -0
- package/dist/es/i18n/locales/pt-PT.js +24 -0
- package/dist/es/i18n/locales/ru-RU.js +24 -0
- package/dist/es/i18n/locales/zh-CN.js +24 -0
- package/dist/es/i18n/locales/zh-HK.js +24 -0
- package/dist/es/i18n/locales/zh-TW.js +24 -0
- package/dist/es/index.js +23 -8
- package/dist/es/out/base-fraud-detection.js +4 -1
- package/dist/es/out/config.js +10 -4
- package/dist/es/out/fraud-detection.js +12 -13
- package/dist/es/out/worldpay-ddc-manager.js +7 -14
- package/dist/es/out/worldpay-ddc.js +7 -5
- package/dist/es/polyfill.js +166 -0
- package/dist/es/style.css +1 -1
- package/dist/es/types/event.js +12 -3
- package/dist/es/types/message.js +3 -0
- package/dist/es/utils/iframe.js +1 -1
- package/dist/es/utils/location.js +0 -8
- package/dist/es/utils/payment.js +12 -12
- package/dist/es/utils/redirect.js +4 -5
- package/dist/es/utils/system-info/is-ua-webview.js +1 -20
- package/dist/fe-logger.min.js +1 -0
- package/dist/polyfill.js +166 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/index.d.ts +1 -0
- package/dist/types/api/modules/threeDS/index.d.ts +7 -0
- package/dist/types/api/modules/type.d.ts +2 -0
- package/dist/types/api/modules/wallet/index.d.ts +18 -0
- package/dist/types/api/utils/index.d.ts +1 -0
- package/dist/types/components/AddressField/index.d.ts +1 -0
- package/dist/types/components/AddressField/type.d.ts +17 -2
- package/dist/types/components/AddressField/utils.d.ts +22 -0
- package/dist/types/components/AliPay/type.d.ts +11 -15
- package/dist/types/components/ApplePay/type.d.ts +5 -28
- package/dist/types/components/CPFField/type.d.ts +1 -1
- package/dist/types/components/Card/type.d.ts +22 -23
- package/dist/types/components/CardExpireDateField/type.d.ts +1 -1
- package/dist/types/components/CardNo/type.d.ts +3 -2
- package/dist/types/components/CardNumberField/type.d.ts +1 -1
- package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -1
- package/dist/types/components/CardSelector/type.d.ts +4 -4
- package/dist/types/components/DropIn/type.d.ts +10 -22
- package/dist/types/components/GooglePay/createGooglePay.d.ts +4 -4
- package/dist/types/components/GooglePay/type.d.ts +10 -14
- package/dist/types/components/PaymentButton/PaymentButton.d.ts +3 -0
- package/dist/types/components/PaymentButton/index.d.ts +2 -0
- package/dist/types/components/PaymentButton/type.d.ts +13 -0
- package/dist/types/components/RecurringTip/RecurringTip.d.ts +1 -1
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +7 -1
- package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +5 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +0 -6
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +2 -0
- package/dist/types/components/WechatPay/type.d.ts +11 -15
- package/dist/types/components/business/BlikCodeField/BlikCodeField.d.ts +6 -0
- package/dist/types/components/business/BlikCodeField/index.d.ts +2 -0
- package/dist/types/components/business/BlikCodeField/type.d.ts +9 -0
- package/dist/types/components/business/BlikConfirmModal/BlikConfirmModal.d.ts +6 -0
- package/dist/types/components/business/BlikConfirmModal/index.d.ts +2 -0
- package/dist/types/components/business/BlikConfirmModal/type.d.ts +8 -0
- package/dist/types/components/business/NameField/NameField.d.ts +5 -0
- package/dist/types/components/business/NameField/index.d.ts +2 -0
- package/dist/types/components/business/NameField/type.d.ts +7 -0
- package/dist/types/components/business/PhoneField/PhoneField.d.ts +6 -0
- package/dist/types/components/business/PhoneField/config.d.ts +22 -0
- package/dist/types/components/business/PhoneField/index.d.ts +2 -0
- package/dist/types/components/business/PhoneField/type.d.ts +9 -0
- package/dist/types/components/business/SegmentedDigitInput/SegmentedDigitInput.d.ts +5 -0
- package/dist/types/components/business/SegmentedDigitInput/format.d.ts +5 -0
- package/dist/types/components/business/SegmentedDigitInput/index.d.ts +3 -0
- package/dist/types/components/business/SegmentedDigitInput/type.d.ts +13 -0
- package/dist/types/components/business/Tooltip/Tooltip.d.ts +11 -0
- package/dist/types/components/business/Tooltip/index.d.ts +1 -0
- package/dist/types/components/business/index.d.ts +6 -0
- package/dist/types/components/index.d.ts +0 -7
- package/dist/types/components/internal/CheckBox/type.d.ts +2 -1
- package/dist/types/components/internal/Form/type.d.ts +2 -1
- package/dist/types/components/internal/Select/type.d.ts +1 -1
- package/dist/types/components/internal/icons/IconArrowDown.d.ts +1 -1
- package/dist/types/components/internal/icons/IconBancontact.d.ts +2 -0
- package/dist/types/components/internal/icons/IconBlik.d.ts +2 -0
- package/dist/types/components/internal/icons/IconIdeal.d.ts +2 -0
- package/dist/types/components/internal/icons/IconOvo.d.ts +2 -0
- package/dist/types/components/internal/icons/IconP24.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPhone.d.ts +2 -0
- package/dist/types/components/internal/icons/IconSkrill.d.ts +2 -0
- package/dist/types/components/internal/icons/IconTrustly.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +8 -0
- package/dist/types/components/type.d.ts +0 -0
- package/dist/types/components/wallets/Bancontact/Bancontact.d.ts +15 -0
- package/dist/types/components/wallets/Bancontact/index.d.ts +2 -0
- package/dist/types/components/{GrabPay → wallets/Bancontact}/type.d.ts +8 -18
- package/dist/types/components/wallets/Blik/Blik.d.ts +15 -0
- package/dist/types/components/wallets/Blik/index.d.ts +2 -0
- package/dist/types/components/wallets/Blik/type.d.ts +29 -0
- package/dist/types/components/{Boost → wallets/Boost}/Boost.d.ts +9 -4
- package/dist/types/components/{Boost → wallets/Boost}/type.d.ts +3 -14
- package/dist/types/components/wallets/GCash/GCash.d.ts +5 -0
- package/dist/types/components/wallets/GCash/type.d.ts +3 -14
- package/dist/types/components/{GrabPay → wallets/GrabPay}/GrabPay.d.ts +4 -4
- package/dist/types/components/wallets/GrabPay/type.d.ts +17 -0
- package/dist/types/components/wallets/IDeal/IDeal.d.ts +15 -0
- package/dist/types/components/wallets/IDeal/index.d.ts +2 -0
- package/dist/types/components/wallets/IDeal/type.d.ts +29 -0
- package/dist/types/components/{LinePay → wallets/LinePay}/LinePay.d.ts +9 -4
- package/dist/types/components/{LinePay → wallets/LinePay}/type.d.ts +3 -14
- package/dist/types/components/wallets/MayBankQRPay/MayBankQRPay.d.ts +15 -0
- package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/type.d.ts +3 -14
- package/dist/types/components/wallets/NinePay/NinePay.d.ts +15 -0
- package/dist/types/components/{NinePay → wallets/NinePay}/type.d.ts +3 -14
- package/dist/types/components/wallets/OVO/OVO.d.ts +15 -0
- package/dist/types/components/wallets/OVO/index.d.ts +2 -0
- package/dist/types/components/wallets/OVO/type.d.ts +29 -0
- package/dist/types/components/wallets/OpayWallet/OpayWallet.d.ts +5 -0
- package/dist/types/components/wallets/OpayWallet/type.d.ts +4 -15
- package/dist/types/components/wallets/P24/P24.d.ts +15 -0
- package/dist/types/components/wallets/P24/index.d.ts +2 -0
- package/dist/types/components/wallets/P24/type.d.ts +29 -0
- package/dist/types/components/wallets/PagaWallet/PagaWallet.d.ts +5 -0
- package/dist/types/components/wallets/PagaWallet/type.d.ts +5 -16
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +5 -0
- package/dist/types/components/wallets/Paymaya/type.d.ts +3 -14
- package/dist/types/components/wallets/PicPay/type.d.ts +5 -16
- package/dist/types/components/wallets/Pix/type.d.ts +5 -16
- package/dist/types/components/{ShopeePay → wallets/ShopeePay}/ShopeePay.d.ts +9 -4
- package/dist/types/components/{ShopeePay → wallets/ShopeePay}/type.d.ts +3 -14
- package/dist/types/components/wallets/Skrill/Skrill.d.ts +15 -0
- package/dist/types/components/wallets/Skrill/index.d.ts +2 -0
- package/dist/types/components/wallets/Skrill/type.d.ts +17 -0
- package/dist/types/components/{TNGWallet → wallets/TNGWallet}/TNGWallet.d.ts +9 -4
- package/dist/types/components/{TNGWallet → wallets/TNGWallet}/type.d.ts +3 -14
- package/dist/types/components/wallets/Trustly/Trustly.d.ts +15 -0
- package/dist/types/components/wallets/Trustly/index.d.ts +2 -0
- package/dist/types/components/wallets/Trustly/type.d.ts +21 -0
- package/dist/types/components/wallets/Vietqr/Vietqr.d.ts +5 -0
- package/dist/types/components/wallets/Vietqr/type.d.ts +3 -14
- package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +5 -0
- package/dist/types/components/wallets/Zalopay/type.d.ts +3 -14
- package/dist/types/components/wallets/index.d.ts +14 -0
- package/dist/types/components/wallets/type.d.ts +18 -4
- package/dist/types/constant.d.ts +15 -1
- package/dist/types/core/address.d.ts +2 -5
- package/dist/types/core/checkout.d.ts +10 -10
- package/dist/types/core/create-child.d.ts +1 -0
- package/dist/types/core/environment.d.ts +5 -0
- package/dist/types/core/error.d.ts +9 -3
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/core/logger.d.ts +55 -0
- package/dist/types/core/payment.d.ts +21 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useBaseWallet.d.ts +54 -0
- package/dist/types/hooks/usePayState.d.ts +3 -1
- package/dist/types/hooks/useRetry.console-tests.d.ts +41 -0
- package/dist/types/hooks/useRetry.d.ts +22 -3
- package/dist/types/i18n/locales/de-DE.d.ts +23 -0
- package/dist/types/i18n/locales/en-GB.d.ts +23 -0
- package/dist/types/i18n/locales/es-ES.d.ts +23 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +23 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +23 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +23 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +23 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +23 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +23 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +23 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +23 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +23 -0
- package/dist/types/out/base-fraud-detection.d.ts +1 -0
- package/dist/types/out/config.d.ts +6 -1
- package/dist/types/out/fraud-detection.d.ts +2 -8
- package/dist/types/out/types.d.ts +3 -1
- package/dist/types/out/worldpay-ddc-manager.d.ts +6 -7
- package/dist/types/types/event.d.ts +46 -13
- package/dist/types/types/index.d.ts +8 -37
- package/dist/types/types/message.d.ts +48 -7
- package/dist/types/types/payment.d.ts +63 -0
- package/dist/types/utils/app-payment.d.ts +7 -3
- package/dist/types/utils/behavior-tracker.d.ts +36 -0
- package/dist/types/utils/env.d.ts +37 -0
- package/dist/types/utils/iframe.d.ts +1 -1
- package/dist/types/utils/payment.d.ts +10 -10
- package/package.json +12 -5
- package/dist/es/components/Boost/index.js +0 -348
- package/dist/es/components/GrabPay/index.js +0 -348
- package/dist/es/components/LinePay/index.js +0 -348
- package/dist/es/components/MayBankQRPay/index.js +0 -354
- package/dist/es/components/NinePay/index.js +0 -348
- package/dist/es/components/ShopeePay/index.js +0 -348
- package/dist/es/components/TNGWallet/index.js +0 -348
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +0 -10
- package/dist/types/components/NinePay/NinePay.d.ts +0 -10
- package/dist/types/utils/logger.d.ts +0 -14
- /package/dist/types/components/{Boost → wallets/Boost}/index.d.ts +0 -0
- /package/dist/types/components/{GrabPay → wallets/GrabPay}/index.d.ts +0 -0
- /package/dist/types/components/{LinePay → wallets/LinePay}/index.d.ts +0 -0
- /package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/index.d.ts +0 -0
- /package/dist/types/components/{NinePay → wallets/NinePay}/index.d.ts +0 -0
- /package/dist/types/components/{ShopeePay → wallets/ShopeePay}/index.d.ts +0 -0
- /package/dist/types/components/{TNGWallet → wallets/TNGWallet}/index.d.ts +0 -0
|
@@ -15,8 +15,7 @@ import "../internal/Form/Form.js";
|
|
|
15
15
|
import { Input } from "../internal/Input/Input.js";
|
|
16
16
|
import "../internal/Input/type.js";
|
|
17
17
|
import { Select } from "../internal/Select/Select.js";
|
|
18
|
-
const
|
|
19
|
-
const defaultAddress = {
|
|
18
|
+
const DEFAULT_ADDRESS = {
|
|
20
19
|
country: void 0,
|
|
21
20
|
province: void 0,
|
|
22
21
|
city: void 0,
|
|
@@ -25,23 +24,39 @@ const defaultAddress = {
|
|
|
25
24
|
address1: void 0,
|
|
26
25
|
address2: void 0
|
|
27
26
|
};
|
|
27
|
+
const filterAllowedCountryOptions = (options, allowed) => {
|
|
28
|
+
if (!(allowed == null ? void 0 : allowed.length)) {
|
|
29
|
+
return options;
|
|
30
|
+
}
|
|
31
|
+
const set = new Set(allowed);
|
|
32
|
+
return options.filter((o) => set.has(String(o.value)));
|
|
33
|
+
};
|
|
34
|
+
const pickDefaultCountryCode = (preferred, allowed) => {
|
|
35
|
+
if (!(allowed == null ? void 0 : allowed.length)) {
|
|
36
|
+
return preferred ?? "";
|
|
37
|
+
}
|
|
38
|
+
if (preferred && allowed.includes(preferred)) {
|
|
39
|
+
return preferred;
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
};
|
|
43
|
+
const { bem } = useBEM("address-field");
|
|
28
44
|
const AddressField = w((props, ref) => {
|
|
29
|
-
|
|
30
|
-
const { i18n } = useI18n();
|
|
45
|
+
var _a;
|
|
31
46
|
const context = x(CoreContext);
|
|
32
47
|
if (!(context == null ? void 0 : context.core)) {
|
|
33
48
|
throw new Error("CoreContext is not found");
|
|
34
49
|
}
|
|
50
|
+
const { onChange, allowedCountries, mode, disabled = false } = props;
|
|
51
|
+
const { i18n } = useI18n();
|
|
35
52
|
const addressCore = context.core.getAddressCore();
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
});
|
|
53
|
+
const addressMode = mode || ((_a = context.core.config._checkoutConfig) == null ? void 0 : _a.addressMode) || "address";
|
|
54
|
+
const addressLabelKey = addressMode === "address" ? "address.label" : "address.country";
|
|
55
|
+
const [addressState, setAddressState] = h({ ...addressCore.getAddressState() });
|
|
39
56
|
const [countryOptions, setCountryOptions] = h(addressCore.getCountryOption() ?? []);
|
|
40
57
|
const [provinceOptions, setProvinceOptions] = h(addressCore.getProvinceOption() ?? []);
|
|
41
58
|
const [cityOptions, setCityOptions] = h([]);
|
|
42
|
-
const [addressFormat, setAddressFormat] = h(
|
|
43
|
-
addressCore.getAddressFormat()
|
|
44
|
-
);
|
|
59
|
+
const [addressFormat, setAddressFormat] = h(addressCore.getAddressFormat());
|
|
45
60
|
const countryFormItemRef = A(null);
|
|
46
61
|
const provinceFormItemRef = A(null);
|
|
47
62
|
const cityFormItemRef = A(null);
|
|
@@ -49,50 +64,41 @@ const AddressField = w((props, ref) => {
|
|
|
49
64
|
const postCodeFormItemRef = A(null);
|
|
50
65
|
const address1FormItemRef = A(null);
|
|
51
66
|
const address2FormItemRef = A(null);
|
|
67
|
+
const visibleCountryOptions = T(
|
|
68
|
+
() => filterAllowedCountryOptions(countryOptions, allowedCountries),
|
|
69
|
+
[countryOptions, allowedCountries]
|
|
70
|
+
);
|
|
52
71
|
T(() => {
|
|
53
|
-
if (i18n.ready.value) {
|
|
54
|
-
|
|
55
|
-
addressCore.requestCountryOption();
|
|
56
|
-
addressCore.countryOptionReady().then(() => {
|
|
57
|
-
getDefaultCountry();
|
|
58
|
-
setCountryOptions(addressCore.getCountryOption());
|
|
59
|
-
});
|
|
72
|
+
if (!i18n.ready.value) {
|
|
73
|
+
return;
|
|
60
74
|
}
|
|
75
|
+
addressCore.setLocale(i18n.locale);
|
|
76
|
+
addressCore.requestCountryOption();
|
|
77
|
+
addressCore.countryOptionReady().then(() => {
|
|
78
|
+
setCountryOptions(addressCore.getCountryOption());
|
|
79
|
+
setDefaultCountry();
|
|
80
|
+
});
|
|
61
81
|
}, [i18n.ready.value]);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
[
|
|
73
|
-
setAddressState(Object.assign(addressState, { area: value }));
|
|
74
|
-
},
|
|
75
|
-
[EAddressType.POST_CODE]: (value) => {
|
|
76
|
-
setAddressState(Object.assign(addressState, { postCode: value }));
|
|
77
|
-
},
|
|
78
|
-
[EAddressType.PROVINCE]: (value) => {
|
|
79
|
-
setAddressState(Object.assign(addressState, { province: value }));
|
|
80
|
-
},
|
|
81
|
-
COUNTRY: (value) => {
|
|
82
|
-
setAddressState(Object.assign(addressState, { country: value }));
|
|
83
|
-
}
|
|
82
|
+
const setAddressStateByKey = (key, value) => {
|
|
83
|
+
const keyMap = {
|
|
84
|
+
[EAddressType.ADDRESS_1]: "address1",
|
|
85
|
+
[EAddressType.ADDRESS_2]: "address2",
|
|
86
|
+
[EAddressType.CITY]: "city",
|
|
87
|
+
[EAddressType.AREA]: "area",
|
|
88
|
+
[EAddressType.POST_CODE]: "postCode",
|
|
89
|
+
[EAddressType.PROVINCE]: "province",
|
|
90
|
+
COUNTRY: "country"
|
|
91
|
+
};
|
|
92
|
+
setAddressState(Object.assign(addressState, { [keyMap[key]]: value }));
|
|
84
93
|
};
|
|
85
|
-
|
|
86
|
-
setAddressStateMap[key](value);
|
|
87
|
-
}
|
|
88
|
-
function handleStateChange(key, value) {
|
|
94
|
+
const handleStateChange = (key, value) => {
|
|
89
95
|
setAddressStateByKey(key, value);
|
|
90
96
|
addressCore.setAddressStateByKey(key, value);
|
|
91
|
-
}
|
|
92
|
-
|
|
97
|
+
};
|
|
98
|
+
const handleAddressFormatChange = (value) => {
|
|
93
99
|
setAddressFormat(value);
|
|
94
100
|
addressCore.setAddressFormat(value);
|
|
95
|
-
}
|
|
101
|
+
};
|
|
96
102
|
F(ref, () => ({
|
|
97
103
|
update: (value) => {
|
|
98
104
|
setAddressState(value);
|
|
@@ -102,27 +108,22 @@ const AddressField = w((props, ref) => {
|
|
|
102
108
|
setCityOptions(addressCore.getCityOptions() ?? []);
|
|
103
109
|
}
|
|
104
110
|
}));
|
|
105
|
-
|
|
111
|
+
const resetField = (fields) => {
|
|
106
112
|
fields.map((f) => {
|
|
107
113
|
setAddressStateByKey(f, "");
|
|
108
114
|
addressCore.setAddressStateByKey(f, "");
|
|
109
115
|
});
|
|
110
|
-
}
|
|
111
|
-
async function
|
|
116
|
+
};
|
|
117
|
+
async function setDefaultCountry() {
|
|
112
118
|
const language = navigator.language;
|
|
113
119
|
const areaCode = language.split("-");
|
|
114
120
|
const countryCode = addressState.country || ((areaCode == null ? void 0 : areaCode[1]) ?? "US");
|
|
121
|
+
if ((allowedCountries == null ? void 0 : allowedCountries.length) && !(allowedCountries == null ? void 0 : allowedCountries.includes(countryCode))) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
115
124
|
onSelectCountry(countryCode || "");
|
|
116
|
-
|
|
125
|
+
onChange({ ...addressState });
|
|
117
126
|
}
|
|
118
|
-
const AddressFormatMap = {
|
|
119
|
-
[EAddressType.ADDRESS_1]: Address1Item,
|
|
120
|
-
[EAddressType.ADDRESS_2]: Address2Item,
|
|
121
|
-
[EAddressType.CITY]: CityItem,
|
|
122
|
-
[EAddressType.AREA]: AreaItem,
|
|
123
|
-
[EAddressType.POST_CODE]: PostCodeItem,
|
|
124
|
-
[EAddressType.PROVINCE]: ProvinceItem
|
|
125
|
-
};
|
|
126
127
|
function createRule() {
|
|
127
128
|
return {
|
|
128
129
|
trigger: ["blur", "submit"],
|
|
@@ -135,17 +136,8 @@ const AddressField = w((props, ref) => {
|
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
138
|
async function onSelectCountry(value) {
|
|
138
|
-
var _a, _b;
|
|
139
139
|
handleAddressFormatChange([]);
|
|
140
140
|
handleStateChange("COUNTRY", value);
|
|
141
|
-
const addressMode = (_b = (_a = context == null ? void 0 : context.core) == null ? void 0 : _a.config._checkoutConfig) == null ? void 0 : _b.addressMode;
|
|
142
|
-
if (addressMode === "country") {
|
|
143
|
-
onAddressChange({
|
|
144
|
-
...defaultAddress,
|
|
145
|
-
country: value
|
|
146
|
-
});
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
141
|
const format = await mergedGetAddressFormat(value, { locale: i18n.locale });
|
|
150
142
|
const addressType = [];
|
|
151
143
|
const addressArr = format.map(({ addressItem, required, description }) => {
|
|
@@ -168,8 +160,8 @@ const AddressField = w((props, ref) => {
|
|
|
168
160
|
]);
|
|
169
161
|
setCityOptions([]);
|
|
170
162
|
addressCore.setCityOptions([]);
|
|
171
|
-
|
|
172
|
-
...
|
|
163
|
+
onChange({
|
|
164
|
+
...DEFAULT_ADDRESS,
|
|
173
165
|
country: value
|
|
174
166
|
});
|
|
175
167
|
}
|
|
@@ -189,12 +181,12 @@ const AddressField = w((props, ref) => {
|
|
|
189
181
|
});
|
|
190
182
|
}
|
|
191
183
|
async function onSelectProvince(value) {
|
|
192
|
-
var
|
|
184
|
+
var _a2;
|
|
193
185
|
handleStateChange(EAddressType.PROVINCE, value);
|
|
194
186
|
getCityData(value);
|
|
195
187
|
resetField([EAddressType.CITY]);
|
|
196
|
-
(
|
|
197
|
-
|
|
188
|
+
(_a2 = cityFormItemRef.current) == null ? void 0 : _a2.validateChange("");
|
|
189
|
+
onChange({
|
|
198
190
|
...addressState,
|
|
199
191
|
province: value,
|
|
200
192
|
city: ""
|
|
@@ -210,19 +202,17 @@ const AddressField = w((props, ref) => {
|
|
|
210
202
|
}
|
|
211
203
|
function onSelectCity(value) {
|
|
212
204
|
handleStateChange(EAddressType.CITY, value);
|
|
213
|
-
|
|
205
|
+
onChange({
|
|
214
206
|
...addressState,
|
|
215
207
|
city: value
|
|
216
208
|
});
|
|
217
209
|
}
|
|
218
210
|
function CountryItem() {
|
|
219
|
-
var _a, _b;
|
|
220
|
-
const addressMode = (_b = (_a = context == null ? void 0 : context.core) == null ? void 0 : _a.config._checkoutConfig) == null ? void 0 : _b.addressMode;
|
|
221
211
|
return /* @__PURE__ */ u(
|
|
222
212
|
FormItem,
|
|
223
213
|
{
|
|
224
214
|
ref: countryFormItemRef,
|
|
225
|
-
label: i18n.get(
|
|
215
|
+
label: i18n.get(addressLabelKey),
|
|
226
216
|
path: "address.country",
|
|
227
217
|
rule: createRule(),
|
|
228
218
|
showErrorMessage: false,
|
|
@@ -230,11 +220,12 @@ const AddressField = w((props, ref) => {
|
|
|
230
220
|
Select,
|
|
231
221
|
{
|
|
232
222
|
value: addressState.country,
|
|
223
|
+
disabled,
|
|
233
224
|
filterable: true,
|
|
234
|
-
options:
|
|
225
|
+
options: visibleCountryOptions,
|
|
235
226
|
onSelect: (value) => onSelectCountry(value),
|
|
236
227
|
placeholder: i18n.get("address.country"),
|
|
237
|
-
inputClassName: bem("first-item", { "no-bottom-radius": addressMode === "address" }),
|
|
228
|
+
inputClassName: bem("first-item", { "no-bottom-radius": addressMode === "address" && (addressFormat == null ? void 0 : addressFormat.length) }),
|
|
238
229
|
noDataTip: i18n.get("common.noData")
|
|
239
230
|
}
|
|
240
231
|
)
|
|
@@ -253,6 +244,7 @@ const AddressField = w((props, ref) => {
|
|
|
253
244
|
Input,
|
|
254
245
|
{
|
|
255
246
|
value: addressState.address1,
|
|
247
|
+
disabled,
|
|
256
248
|
onInput: (event) => handleStateChange(EAddressType.ADDRESS_1, event.currentTarget.value),
|
|
257
249
|
placeholder: description,
|
|
258
250
|
inputClassName: className
|
|
@@ -273,6 +265,7 @@ const AddressField = w((props, ref) => {
|
|
|
273
265
|
Input,
|
|
274
266
|
{
|
|
275
267
|
value: addressState.address2,
|
|
268
|
+
disabled,
|
|
276
269
|
onInput: (event) => handleStateChange(EAddressType.ADDRESS_2, event.currentTarget.value),
|
|
277
270
|
placeholder: description,
|
|
278
271
|
inputClassName: className
|
|
@@ -294,6 +287,7 @@ const AddressField = w((props, ref) => {
|
|
|
294
287
|
Input,
|
|
295
288
|
{
|
|
296
289
|
value: addressState.postCode,
|
|
290
|
+
disabled,
|
|
297
291
|
onInput: (event) => handleStateChange(EAddressType.POST_CODE, event.currentTarget.value),
|
|
298
292
|
placeholder: description,
|
|
299
293
|
inputClassName: className
|
|
@@ -315,6 +309,7 @@ const AddressField = w((props, ref) => {
|
|
|
315
309
|
Input,
|
|
316
310
|
{
|
|
317
311
|
value: addressState.area,
|
|
312
|
+
disabled,
|
|
318
313
|
onInput: (event) => handleStateChange(EAddressType.AREA, event.currentTarget.value),
|
|
319
314
|
placeholder: description,
|
|
320
315
|
inputClassName: className
|
|
@@ -332,10 +327,11 @@ const AddressField = w((props, ref) => {
|
|
|
332
327
|
path: "address.city",
|
|
333
328
|
rule: createRule(),
|
|
334
329
|
showErrorMessage: false,
|
|
335
|
-
children: isArray(cityOptions) && cityOptions.length
|
|
330
|
+
children: isArray(cityOptions) && cityOptions.length ? /* @__PURE__ */ u(
|
|
336
331
|
Select,
|
|
337
332
|
{
|
|
338
333
|
value: addressState.city,
|
|
334
|
+
disabled,
|
|
339
335
|
filterable: true,
|
|
340
336
|
options: cityOptions,
|
|
341
337
|
onSelect: (value) => onSelectCity(value),
|
|
@@ -347,6 +343,7 @@ const AddressField = w((props, ref) => {
|
|
|
347
343
|
Input,
|
|
348
344
|
{
|
|
349
345
|
value: addressState.city,
|
|
346
|
+
disabled,
|
|
350
347
|
onInput: (event) => handleStateChange(EAddressType.CITY, event.currentTarget.value),
|
|
351
348
|
placeholder: description,
|
|
352
349
|
inputClassName: className
|
|
@@ -364,10 +361,11 @@ const AddressField = w((props, ref) => {
|
|
|
364
361
|
path: "address.province",
|
|
365
362
|
rule: createRule(),
|
|
366
363
|
showErrorMessage: false,
|
|
367
|
-
children: isArray(provinceOptions) && provinceOptions.length
|
|
364
|
+
children: isArray(provinceOptions) && provinceOptions.length ? /* @__PURE__ */ u(
|
|
368
365
|
Select,
|
|
369
366
|
{
|
|
370
367
|
value: addressState.province,
|
|
368
|
+
disabled,
|
|
371
369
|
filterable: true,
|
|
372
370
|
options: provinceOptions,
|
|
373
371
|
onSelect: (value) => onSelectProvince(value),
|
|
@@ -379,6 +377,7 @@ const AddressField = w((props, ref) => {
|
|
|
379
377
|
Input,
|
|
380
378
|
{
|
|
381
379
|
value: addressState.province,
|
|
380
|
+
disabled,
|
|
382
381
|
onInput: (event) => handleStateChange(EAddressType.PROVINCE, event.currentTarget.value),
|
|
383
382
|
placeholder: description,
|
|
384
383
|
inputClassName: className
|
|
@@ -388,7 +387,15 @@ const AddressField = w((props, ref) => {
|
|
|
388
387
|
"address.province"
|
|
389
388
|
);
|
|
390
389
|
}
|
|
391
|
-
|
|
390
|
+
const AddressFormatMap = {
|
|
391
|
+
[EAddressType.ADDRESS_1]: Address1Item,
|
|
392
|
+
[EAddressType.ADDRESS_2]: Address2Item,
|
|
393
|
+
[EAddressType.CITY]: CityItem,
|
|
394
|
+
[EAddressType.AREA]: AreaItem,
|
|
395
|
+
[EAddressType.POST_CODE]: PostCodeItem,
|
|
396
|
+
[EAddressType.PROVINCE]: ProvinceItem
|
|
397
|
+
};
|
|
398
|
+
const computedStyle = (index) => {
|
|
392
399
|
const len = addressFormat == null ? void 0 : addressFormat.length;
|
|
393
400
|
if (isNil(len) || len === 1)
|
|
394
401
|
return "";
|
|
@@ -396,17 +403,20 @@ const AddressField = w((props, ref) => {
|
|
|
396
403
|
return bem("last-item");
|
|
397
404
|
}
|
|
398
405
|
return bem("mid-item");
|
|
399
|
-
}
|
|
406
|
+
};
|
|
400
407
|
return /* @__PURE__ */ u("div", { style: "width: 100%", children: [
|
|
401
408
|
CountryItem(),
|
|
402
|
-
addressFormat == null ? void 0 : addressFormat.map(
|
|
409
|
+
addressMode === "address" && (addressFormat == null ? void 0 : addressFormat.map(
|
|
403
410
|
(item, index) => AddressFormatMap[item.addressItem]({
|
|
404
411
|
description: item.description,
|
|
405
412
|
className: computedStyle(index)
|
|
406
413
|
})
|
|
407
|
-
)
|
|
414
|
+
))
|
|
408
415
|
] });
|
|
409
416
|
});
|
|
410
417
|
export {
|
|
411
|
-
AddressField
|
|
418
|
+
AddressField,
|
|
419
|
+
DEFAULT_ADDRESS,
|
|
420
|
+
filterAllowedCountryOptions,
|
|
421
|
+
pickDefaultCountryCode
|
|
412
422
|
};
|
|
@@ -4,16 +4,16 @@ import { getAliPayInfo, aliPay } from "../../api/modules/ali-pay/index.js";
|
|
|
4
4
|
import "../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
6
|
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
|
-
import { formatPaymentResult } from "../../utils/payment.js";
|
|
7
|
+
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
8
8
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
|
-
import { COMMON_CLASS_NAME, PaymentType,
|
|
9
|
+
import { PaymentMethod, COMMON_CLASS_NAME, PaymentType, SessionMode } from "../../constant.js";
|
|
10
10
|
import { CoreContext } from "../../core/context.js";
|
|
11
11
|
import { PayKKaError } from "../../core/error.js";
|
|
12
12
|
import "../../out/worldpay-jsc-origin.js";
|
|
13
13
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
14
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
15
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
|
-
import { AddressField } from "../AddressField/index.js";
|
|
16
|
+
import { DEFAULT_ADDRESS, AddressField } from "../AddressField/index.js";
|
|
17
17
|
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
18
18
|
import "../internal/Form/type.js";
|
|
19
19
|
import "../internal/Form/context.js";
|
|
@@ -22,32 +22,30 @@ import { Form } from "../internal/Form/Form.js";
|
|
|
22
22
|
import { Info } from "../internal/Info/Info.js";
|
|
23
23
|
import { RecurringTip } from "../RecurringTip/index.js";
|
|
24
24
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
25
|
+
const CURR_PAYMENT_METHOD = PaymentMethod.ALI_PAY;
|
|
25
26
|
const { bem } = useBEM("ali-pay");
|
|
26
27
|
const fieldClassNames = bem("field");
|
|
27
28
|
const AliPay = w((props, ref) => {
|
|
28
|
-
const { session, core, showEmail = false, showAddress = false } = props;
|
|
29
|
+
const { session, core, showEmail = false, showAddress = false, autoQuery = true } = props;
|
|
29
30
|
const addressCore = core.getAddressCore();
|
|
30
31
|
const emailState = createEmailCore();
|
|
31
|
-
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
|
|
32
|
+
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady, disabled } = usePayState(session, props.core);
|
|
32
33
|
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
33
34
|
const formRef = A(null);
|
|
34
35
|
const [form, setForm] = h({
|
|
35
36
|
email: "",
|
|
36
|
-
address: {
|
|
37
|
-
country: void 0,
|
|
38
|
-
province: void 0,
|
|
39
|
-
city: void 0,
|
|
40
|
-
area: void 0,
|
|
41
|
-
postCode: void 0,
|
|
42
|
-
address1: void 0,
|
|
43
|
-
address2: void 0
|
|
44
|
-
}
|
|
37
|
+
address: { ...DEFAULT_ADDRESS }
|
|
45
38
|
});
|
|
46
39
|
const [validated, setValidated] = h(false);
|
|
47
40
|
const [fieldStatus, setFieldStatus] = h();
|
|
48
41
|
const addressFieldRef = A(null);
|
|
49
42
|
const emailFieldRef = A(null);
|
|
50
43
|
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
44
|
+
const getPaymentMethodContext = () => {
|
|
45
|
+
return {
|
|
46
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
47
|
+
};
|
|
48
|
+
};
|
|
51
49
|
F(ref, () => ({
|
|
52
50
|
stopRetry: () => {
|
|
53
51
|
stopReFetchPayInfo();
|
|
@@ -61,29 +59,26 @@ const AliPay = w((props, ref) => {
|
|
|
61
59
|
var _a;
|
|
62
60
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
63
61
|
return;
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
|
|
62
|
+
const address = addressCore.getAddressState();
|
|
63
|
+
form.address = address;
|
|
64
|
+
setForm(form);
|
|
65
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(address);
|
|
66
|
+
validateFormSilently();
|
|
68
67
|
},
|
|
69
68
|
updateEmail: () => {
|
|
70
69
|
var _a;
|
|
71
70
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
72
71
|
return;
|
|
73
|
-
|
|
74
|
-
setForm(
|
|
72
|
+
form.email = emailState.email;
|
|
73
|
+
setForm(form);
|
|
75
74
|
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
76
|
-
|
|
75
|
+
validateFormSilently();
|
|
77
76
|
}
|
|
78
77
|
}));
|
|
79
|
-
|
|
78
|
+
const validateFormSilently = () => {
|
|
80
79
|
var _a;
|
|
81
|
-
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() =>
|
|
82
|
-
|
|
83
|
-
}).catch(() => {
|
|
84
|
-
setValidated(false);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
80
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => setValidated(true)).catch(() => setValidated(false));
|
|
81
|
+
};
|
|
87
82
|
const initFieldStatus = () => {
|
|
88
83
|
const { field, sessionMode } = session.checkout;
|
|
89
84
|
const { email, address } = field;
|
|
@@ -98,20 +93,19 @@ const AliPay = w((props, ref) => {
|
|
|
98
93
|
setFieldStatus({ ...field });
|
|
99
94
|
};
|
|
100
95
|
y(() => {
|
|
101
|
-
|
|
96
|
+
validateFormSilently();
|
|
102
97
|
}, [form]);
|
|
103
98
|
const processOnSuccess = (res) => {
|
|
104
99
|
var _a, _b;
|
|
105
100
|
setSubmitButtonStatus("success");
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
);
|
|
101
|
+
const result = formatPaymentResult({
|
|
102
|
+
...res,
|
|
103
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
104
|
+
});
|
|
105
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, result, getPaymentMethodContext());
|
|
113
106
|
};
|
|
114
107
|
y(() => {
|
|
108
|
+
var _a;
|
|
115
109
|
if (!sessionReady) {
|
|
116
110
|
return;
|
|
117
111
|
}
|
|
@@ -124,13 +118,18 @@ const AliPay = w((props, ref) => {
|
|
|
124
118
|
country && addressCore.setCountry(country);
|
|
125
119
|
form.email = bill.email ?? "";
|
|
126
120
|
form.address.country = country;
|
|
121
|
+
if (autoQuery && ((_a = core.payment) == null ? void 0 : _a.currPaymentMethod.value) === CURR_PAYMENT_METHOD) {
|
|
122
|
+
setSubmitButtonStatus("loading");
|
|
123
|
+
startReFetchPayInfo();
|
|
124
|
+
}
|
|
127
125
|
}, [sessionReady]);
|
|
128
126
|
const onTimeout = q(
|
|
129
127
|
(message) => {
|
|
130
128
|
var _a;
|
|
131
129
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
132
130
|
setSubmitButtonStatus("unSubmit");
|
|
133
|
-
|
|
131
|
+
core.payment.resetCurrPaymentMethod();
|
|
132
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props, "retry", getPaymentMethodContext());
|
|
134
133
|
},
|
|
135
134
|
[i18n, props.onTimeout]
|
|
136
135
|
);
|
|
@@ -157,7 +156,7 @@ const AliPay = w((props, ref) => {
|
|
|
157
156
|
email: form.email
|
|
158
157
|
},
|
|
159
158
|
payment: {
|
|
160
|
-
paymentMethod:
|
|
159
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
161
160
|
},
|
|
162
161
|
browser: await getBrowserParams({
|
|
163
162
|
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
@@ -165,58 +164,66 @@ const AliPay = w((props, ref) => {
|
|
|
165
164
|
};
|
|
166
165
|
};
|
|
167
166
|
async function pay(search = false, timeout) {
|
|
168
|
-
var _a, _b, _c, _d, _e, _f
|
|
167
|
+
var _a, _b, _c, _d, _e, _f;
|
|
169
168
|
try {
|
|
169
|
+
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
170
170
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
171
171
|
let res = null;
|
|
172
172
|
if (search) {
|
|
173
|
-
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query",
|
|
173
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", CURR_PAYMENT_METHOD);
|
|
174
174
|
res = await getAliPayInfo(
|
|
175
175
|
{
|
|
176
176
|
sessionId: session.sessionId,
|
|
177
177
|
clientKey: session.clientKey,
|
|
178
|
-
paymentMethod:
|
|
178
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
179
179
|
},
|
|
180
180
|
extraParams,
|
|
181
181
|
requestOptions
|
|
182
182
|
);
|
|
183
183
|
} else {
|
|
184
|
-
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment",
|
|
184
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", CURR_PAYMENT_METHOD);
|
|
185
185
|
res = await aliPay(await getPaymentParams(), extraParams, requestOptions);
|
|
186
186
|
}
|
|
187
|
-
const {
|
|
187
|
+
const { errorMessage, errorCode, sessionId } = res;
|
|
188
188
|
sessionId && (session.sessionId = sessionId);
|
|
189
|
-
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res, getPaymentMethodContext()));
|
|
190
|
+
let end = true;
|
|
191
|
+
await processPaymentStatus(res, {
|
|
192
|
+
onProcessing: () => {
|
|
193
|
+
!search && startReFetchPayInfo();
|
|
194
|
+
end = false;
|
|
195
|
+
},
|
|
196
|
+
onSuccess: () => {
|
|
195
197
|
processOnSuccess(res);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
},
|
|
199
|
+
onFailure: () => {
|
|
200
|
+
var _a2;
|
|
198
201
|
errorMessage && setErrorMsg(errorMessage);
|
|
199
202
|
setSubmitButtonStatus("unSubmit");
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
core.payment.resetCurrPaymentMethod();
|
|
204
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(
|
|
205
|
+
props,
|
|
206
|
+
new PayKKaError("API_ERROR", errorMessage, { code: errorCode }),
|
|
207
|
+
getPaymentMethodContext()
|
|
208
|
+
);
|
|
209
|
+
},
|
|
210
|
+
onCanceled: () => {
|
|
211
|
+
var _a2;
|
|
206
212
|
setSubmitButtonStatus("unSubmit");
|
|
207
|
-
(
|
|
208
|
-
|
|
213
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "channel", getPaymentMethodContext());
|
|
214
|
+
core.payment.resetCurrPaymentMethod();
|
|
215
|
+
},
|
|
216
|
+
onExpired: () => {
|
|
217
|
+
var _a2;
|
|
218
|
+
setSubmitButtonStatus("unSubmit");
|
|
219
|
+
(_a2 = props.onExpired) == null ? void 0 : _a2.call(props, getPaymentMethodContext());
|
|
220
|
+
},
|
|
221
|
+
onDefault: () => {
|
|
222
|
+
setSubmitButtonStatus("unSubmit");
|
|
223
|
+
core.payment.resetCurrPaymentMethod();
|
|
209
224
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return { end: true };
|
|
213
|
-
} else if (status === "EXPIRED") {
|
|
214
|
-
setSubmitButtonStatus("unSubmit");
|
|
215
|
-
(_h = props.onExpired) == null ? void 0 : _h.call(props);
|
|
216
|
-
return { end: true };
|
|
217
|
-
}
|
|
218
|
-
setSubmitButtonStatus("unSubmit");
|
|
219
|
-
return { end: true };
|
|
225
|
+
});
|
|
226
|
+
return { end };
|
|
220
227
|
} catch (error) {
|
|
221
228
|
if (isTimeoutError(error)) {
|
|
222
229
|
if (search) {
|
|
@@ -228,7 +235,12 @@ const AliPay = w((props, ref) => {
|
|
|
228
235
|
} else {
|
|
229
236
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
230
237
|
message && setErrorMsg(message);
|
|
231
|
-
|
|
238
|
+
core.payment.resetCurrPaymentMethod();
|
|
239
|
+
(_f = props.onError) == null ? void 0 : _f.call(
|
|
240
|
+
props,
|
|
241
|
+
new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
|
|
242
|
+
getPaymentMethodContext()
|
|
243
|
+
);
|
|
232
244
|
setSubmitButtonStatus("unSubmit");
|
|
233
245
|
return { end: true };
|
|
234
246
|
}
|
|
@@ -240,7 +252,7 @@ const AliPay = w((props, ref) => {
|
|
|
240
252
|
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
241
253
|
var _a2;
|
|
242
254
|
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
243
|
-
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
255
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors, getPaymentMethodContext());
|
|
244
256
|
if (errors) {
|
|
245
257
|
setSubmitButtonStatus("unSubmit");
|
|
246
258
|
return;
|
|
@@ -261,6 +273,7 @@ const AliPay = w((props, ref) => {
|
|
|
261
273
|
{
|
|
262
274
|
className: bem("button"),
|
|
263
275
|
status: submitButtonStatus,
|
|
276
|
+
disabled,
|
|
264
277
|
text,
|
|
265
278
|
loadingText: i18n.get("common.payProcessing"),
|
|
266
279
|
successText: i18n.get("common.paySuccess"),
|
|
@@ -271,7 +284,7 @@ const AliPay = w((props, ref) => {
|
|
|
271
284
|
};
|
|
272
285
|
const setFormRef = (dom) => {
|
|
273
286
|
formRef.current = dom;
|
|
274
|
-
dom &&
|
|
287
|
+
dom && validateFormSilently();
|
|
275
288
|
};
|
|
276
289
|
const Email = () => {
|
|
277
290
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
@@ -279,19 +292,18 @@ const AliPay = w((props, ref) => {
|
|
|
279
292
|
{
|
|
280
293
|
ref: emailFieldRef,
|
|
281
294
|
value: form.email,
|
|
282
|
-
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
295
|
+
disabled: (fieldStatus == null ? void 0 : fieldStatus.email.disabled) || disabled
|
|
283
296
|
}
|
|
284
297
|
) }) });
|
|
285
298
|
};
|
|
286
299
|
const Address = () => {
|
|
287
|
-
var _a, _b;
|
|
288
300
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
289
301
|
AddressField,
|
|
290
302
|
{
|
|
291
303
|
ref: addressFieldRef,
|
|
292
304
|
value: form.address,
|
|
293
|
-
|
|
294
|
-
|
|
305
|
+
disabled,
|
|
306
|
+
onChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
295
307
|
}
|
|
296
308
|
) }) });
|
|
297
309
|
};
|