@paykka/card-checkout-ui 0.8.0 → 0.11.2
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 +21 -14
- package/dist/card-checkout-ui.umd.cjs +21 -14
- package/dist/es/_commonjsHelpers.js +1 -0
- package/dist/es/api/http.js +19 -21
- package/dist/es/api/index.js +1 -1
- package/dist/es/api/modules/ali-pay/index.js +19 -11
- package/dist/es/api/modules/apple-pay/index.js +10 -26
- package/dist/es/api/modules/boost/index.js +56 -0
- package/dist/es/api/modules/card/index.js +17 -11
- package/dist/es/api/modules/checkout/index.js +6 -6
- package/dist/es/api/modules/checkout/map.js +23 -6
- package/dist/es/api/modules/gcash/index.js +56 -0
- package/dist/es/api/modules/get-browser-params.js +2 -2
- package/dist/es/api/modules/google-pay/index.js +10 -26
- package/dist/es/api/modules/grab-pay/index.js +56 -0
- package/dist/es/api/modules/index.js +1 -1
- package/dist/es/api/modules/line-pay/index.js +56 -0
- package/dist/es/api/modules/may-bank-qr-pay/index.js +56 -0
- package/dist/es/api/modules/nine-pay/index.js +56 -0
- package/dist/es/api/modules/paymaya/index.js +56 -0
- package/dist/es/api/modules/risk/index.js +13 -0
- package/dist/es/api/modules/sepa/index.js +19 -11
- package/dist/es/api/modules/shopee-pay/index.js +56 -0
- package/dist/es/api/modules/threeDS/index.js +1 -0
- package/dist/es/api/modules/tng-wallet/index.js +56 -0
- package/dist/es/api/modules/wechat-pay/index.js +18 -31
- package/dist/es/components/AccordionItem/AccordionItem.js +37 -0
- package/dist/es/components/AccountNameField/index.js +1 -0
- package/dist/es/components/AddressField/index.js +1 -0
- package/dist/es/components/AliPay/index.js +28 -40
- package/dist/es/components/ApplePay/index.js +18 -39
- package/dist/es/components/Boost/index.js +324 -0
- package/dist/es/components/Card/index.js +80 -48
- package/dist/es/components/CardBrands/index.js +3 -2
- package/dist/es/components/CardExpireDateField/index.js +1 -0
- package/dist/es/components/CardHolderNameField/index.js +1 -0
- package/dist/es/components/CardIBANField/index.js +1 -0
- package/dist/es/components/CardNo/index.js +1 -0
- package/dist/es/components/CardNumberField/index.js +124 -106
- package/dist/es/components/CardSecurityCodeField/index.js +1 -0
- package/dist/es/components/CardSelector/index.js +1 -0
- package/dist/es/components/CombinedCardInfo/index.js +4 -0
- package/dist/es/components/DropIn/index.js +206 -50
- package/dist/es/components/EmailField/EmailField.js +14 -15
- package/dist/es/components/EncryptedCard/index.js +1 -0
- package/dist/es/components/GooglePay/index.js +7 -6
- package/dist/es/components/GrabPay/index.js +324 -0
- package/dist/es/components/GuideCard/index.js +44 -0
- package/dist/es/components/LinePay/index.js +324 -0
- package/dist/es/components/MayBankQRPay/index.js +324 -0
- package/dist/es/components/NinePay/index.js +324 -0
- package/dist/es/components/RecurringTip/index.js +1 -0
- package/dist/es/components/SecuredFieldsProvider/index.js +2 -1
- package/dist/es/components/SecuredIframe/index.js +57 -4
- package/dist/es/components/Sepa/index.js +7 -10
- package/dist/es/components/ShopeePay/index.js +324 -0
- package/dist/es/components/SubmitButton/index.js +7 -20
- package/dist/es/components/TNGWallet/index.js +324 -0
- package/dist/es/components/ThreeDS/index.js +1 -0
- package/dist/es/components/WechatPay/index.js +30 -49
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +42 -0
- package/dist/es/components/business/QRCodeModal/index.js +7 -0
- package/dist/es/components/business/QRCodeModal/qr-code-modal.js +1 -0
- package/dist/es/components/business/QRCodeModal/type.js +1 -0
- package/dist/es/components/business/index.js +7 -0
- package/dist/es/components/index.js +10 -0
- package/dist/es/components/internal/Accordion/Accordion.js +14 -0
- package/dist/es/components/internal/Accordion/accordion2.js +1 -0
- package/dist/es/components/internal/Accordion/accordionTransition.js +26 -0
- package/dist/es/components/internal/Accordion/index.js +8 -0
- package/dist/es/components/internal/Accordion/type.js +10 -0
- package/dist/es/components/internal/Button/Button.js +1 -0
- package/dist/es/components/internal/Button/index.js +1 -0
- package/dist/es/components/internal/CheckBox/CheckBox.js +1 -0
- package/dist/es/components/internal/CheckBox/index.js +1 -0
- package/dist/es/components/internal/Form/type.js +1 -0
- package/dist/es/components/internal/Info/Info.js +1 -0
- package/dist/es/components/internal/Info/index.js +1 -0
- package/dist/es/components/internal/Input/type.js +1 -0
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +1 -0
- package/dist/es/components/internal/LoadingCheck/index.js +1 -0
- package/dist/es/components/internal/Modal/Modal.js +18 -3
- package/dist/es/components/internal/Modal/index.js +1 -0
- package/dist/es/components/internal/Modal/type.js +1 -0
- package/dist/es/components/internal/QRCode/QRCode.js +32 -0
- package/dist/es/components/internal/QRCode/index.js +5 -0
- package/dist/es/components/internal/QRCode/type.js +1 -0
- package/dist/es/components/internal/Select/Select.js +11 -9
- package/dist/es/components/internal/Select/SelectMenu.js +1 -0
- package/dist/es/components/internal/Select/SelectMenuItem.js +1 -0
- package/dist/es/components/internal/icons/IconBoost.js +63 -0
- package/dist/es/components/internal/icons/IconCard.js +1 -40
- package/dist/es/components/internal/icons/IconCard2.js +60 -0
- package/dist/es/components/internal/icons/IconGCash.js +196 -0
- package/dist/es/components/internal/icons/IconGcashComplete.js +184 -0
- package/dist/es/components/internal/icons/IconGrabPay.js +59 -0
- package/dist/es/components/internal/icons/IconLinePay.js +99 -0
- package/dist/es/components/internal/icons/IconMayBankQRPay.js +69 -0
- package/dist/es/components/internal/icons/IconNinePay.js +255 -0
- package/dist/es/components/internal/icons/IconPaymaya.js +114 -0
- package/dist/es/components/internal/icons/IconRedirect.js +58 -0
- package/dist/es/components/internal/icons/IconScan.js +102 -0
- package/dist/es/components/internal/icons/IconShopeePay.js +108 -0
- package/dist/es/components/internal/icons/IconTNGWallet.js +119 -0
- package/dist/es/components/internal/icons/IconUnionPay.js +65 -0
- package/dist/es/components/wallets/GCash/GCash.js +368 -0
- package/dist/es/components/wallets/GCash/g-cash.js +1 -0
- package/dist/es/components/wallets/GCash/index.js +1 -0
- package/dist/es/components/wallets/GCash/type.js +1 -0
- package/dist/es/components/wallets/Paymaya/Paymaya.js +325 -0
- package/dist/es/components/wallets/Paymaya/index.js +1 -0
- package/dist/es/components/wallets/Paymaya/paymaya2.js +1 -0
- package/dist/es/components/wallets/Paymaya/type.js +1 -0
- package/dist/es/config.js +12 -12
- package/dist/es/constant.js +84 -4
- package/dist/es/core/PayKKaCheckout.js +35 -5
- package/dist/es/core/Session.js +24 -23
- package/dist/es/core/error.js +7 -0
- package/dist/es/core/index.js +1 -0
- package/dist/es/core/query.js +3 -3
- package/dist/es/core.js +2082 -70
- package/dist/es/hooks/index.js +1 -0
- package/dist/es/hooks/useI18n.js +1 -0
- package/dist/es/hooks/usePayState.js +7 -5
- package/dist/es/i18n/I18n.js +8 -2
- package/dist/es/i18n/locales/de-DE.js +16 -1
- package/dist/es/i18n/locales/en-GB.js +16 -1
- package/dist/es/i18n/locales/es-ES.js +16 -1
- package/dist/es/i18n/locales/fr-FR.js +16 -1
- package/dist/es/i18n/locales/index.js +2 -1
- package/dist/es/i18n/locales/ja-JP.js +16 -1
- package/dist/es/i18n/locales/ko-KR.js +16 -1
- package/dist/es/i18n/locales/nl-NL.js +88 -0
- package/dist/es/i18n/locales/pt-PT.js +16 -1
- package/dist/es/i18n/locales/ru-RU.js +16 -1
- package/dist/es/i18n/locales/zh-CN.js +16 -1
- package/dist/es/i18n/locales/zh-HK.js +16 -1
- package/dist/es/i18n/locales/zh-TW.js +16 -1
- package/dist/es/i18n/util.js +12 -3
- package/dist/es/index.js +22 -0
- package/dist/es/out/fraud-detection.js +39 -13
- package/dist/es/out/worldpay-ddc.js +143 -0
- package/dist/es/style.css +1 -1192
- package/dist/es/types/event.js +15 -0
- package/dist/es/types/fraud-detection.js +1 -0
- package/dist/es/types/index.js +1 -0
- package/dist/es/types/message.js +3 -0
- package/dist/es/utils/array.js +9 -0
- package/dist/es/utils/card-brand/brands.js +11 -1
- package/dist/es/utils/card-brand/index.js +4 -3
- package/dist/es/utils/card-brand/luhn.js +25 -0
- package/dist/es/utils/date.js +25 -0
- package/dist/es/utils/detect.js +6 -0
- package/dist/es/utils/format.js +28 -12
- package/dist/es/utils/iframe.js +1 -1
- package/dist/es/utils/index.js +9 -1
- package/dist/es/utils/location.js +37 -0
- package/dist/es/utils/object.js +14 -0
- package/dist/es/utils/redirect.js +32 -0
- package/dist/es/utils/reg-exp.js +4 -0
- package/dist/es/utils/system-info/get-browser-info.js +4 -4
- package/dist/es/utils/system-info/get-system-info.js +11 -7
- package/dist/es/utils/system-info/index.js +4 -4
- package/dist/style.css +1 -1
- package/dist/types/api/http.d.ts +4 -10
- package/dist/types/api/modules/ali-pay/index.d.ts +2 -1
- package/dist/types/api/modules/apple-pay/index.d.ts +2 -1
- package/dist/types/api/modules/boost/index.d.ts +24 -0
- package/dist/types/api/modules/card/index.d.ts +1 -1
- package/dist/types/api/modules/checkout/index.d.ts +2 -2
- package/dist/types/api/modules/checkout/type.d.ts +9 -0
- package/dist/types/api/modules/gcash/index.d.ts +24 -0
- package/dist/types/api/modules/get-browser-params.d.ts +2 -2
- package/dist/types/api/modules/google-pay/index.d.ts +2 -1
- package/dist/types/api/modules/grab-pay/index.d.ts +24 -0
- package/dist/types/api/modules/index.d.ts +11 -0
- package/dist/types/api/modules/line-pay/index.d.ts +24 -0
- package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +24 -0
- package/dist/types/api/modules/nine-pay/index.d.ts +24 -0
- package/dist/types/api/modules/paymaya/index.d.ts +24 -0
- package/dist/types/api/modules/risk/index.d.ts +8 -0
- package/dist/types/api/modules/sepa/index.d.ts +2 -1
- package/dist/types/api/modules/shopee-pay/index.d.ts +24 -0
- package/dist/types/api/modules/threeDS/index.d.ts +3 -0
- package/dist/types/api/modules/tng-wallet/index.d.ts +24 -0
- package/dist/types/api/modules/wechat-pay/index.d.ts +2 -1
- package/dist/types/components/Boost/Boost.d.ts +7 -0
- package/dist/types/components/Boost/index.d.ts +2 -0
- package/dist/types/components/Boost/type.d.ts +61 -0
- package/dist/types/components/CardNumberField/type.d.ts +7 -1
- package/dist/types/components/CombinedCardInfo/type.d.ts +1 -0
- package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +1 -1
- package/dist/types/components/DropIn/config.d.ts +7 -0
- package/dist/types/components/DropIn/type.d.ts +11 -3
- package/dist/types/components/GrabPay/GrabPay.d.ts +7 -0
- package/dist/types/components/GrabPay/index.d.ts +2 -0
- package/dist/types/components/GrabPay/type.d.ts +61 -0
- package/dist/types/components/GuideCard/GuideCard.d.ts +3 -0
- package/dist/types/components/GuideCard/index.d.ts +2 -0
- package/dist/types/components/GuideCard/type.d.ts +4 -0
- package/dist/types/components/LinePay/LinePay.d.ts +7 -0
- package/dist/types/components/LinePay/index.d.ts +2 -0
- package/dist/types/components/LinePay/type.d.ts +61 -0
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -0
- package/dist/types/components/MayBankQRPay/index.d.ts +2 -0
- package/dist/types/components/MayBankQRPay/type.d.ts +61 -0
- package/dist/types/components/NinePay/NinePay.d.ts +6 -0
- package/dist/types/components/NinePay/index.d.ts +2 -0
- package/dist/types/components/NinePay/type.d.ts +61 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -1
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +1 -1
- package/dist/types/components/ShopeePay/ShopeePay.d.ts +7 -0
- package/dist/types/components/ShopeePay/index.d.ts +2 -0
- package/dist/types/components/ShopeePay/type.d.ts +61 -0
- package/dist/types/components/SubmitButton/SubmitButton.d.ts +1 -1
- package/dist/types/components/TNGWallet/TNGWallet.d.ts +7 -0
- package/dist/types/components/TNGWallet/index.d.ts +2 -0
- package/dist/types/components/TNGWallet/type.d.ts +61 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -1
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +13 -3
- package/dist/types/components/business/QRCodeModal/QRCodeModal.d.ts +3 -0
- package/dist/types/components/business/QRCodeModal/index.d.ts +2 -0
- package/dist/types/components/business/QRCodeModal/type.d.ts +18 -0
- package/dist/types/components/business/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +9 -0
- package/dist/types/components/internal/Accordion/Accordion.d.ts +3 -0
- package/dist/types/components/internal/Accordion/accordionTransition.d.ts +8 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/AccordionItem.d.ts +3 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/index.d.ts +2 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/type.d.ts +18 -0
- package/dist/types/components/internal/Accordion/index.d.ts +3 -0
- package/dist/types/components/internal/Accordion/type.d.ts +18 -0
- package/dist/types/components/internal/Modal/type.d.ts +2 -0
- package/dist/types/components/internal/QRCode/QRCode.d.ts +2 -0
- package/dist/types/components/internal/QRCode/index.d.ts +2 -0
- package/dist/types/components/internal/QRCode/type.d.ts +9 -0
- package/dist/types/components/internal/Select/Select.d.ts +1 -17
- package/dist/types/components/internal/Select/type.d.ts +26 -1
- package/dist/types/components/internal/icons/IconBoost.d.ts +2 -0
- package/dist/types/components/internal/icons/IconCard2.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGCash.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGcashComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGrabPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconLinePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconMayBankQRPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconNinePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPaymaya.d.ts +2 -0
- package/dist/types/components/internal/icons/IconRedirect.d.ts +2 -0
- package/dist/types/components/internal/icons/IconScan.d.ts +2 -0
- package/dist/types/components/internal/icons/IconShopeePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconTNGWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconUnionPay.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +13 -0
- package/dist/types/components/wallets/GCash/GCash.d.ts +6 -0
- package/dist/types/components/wallets/GCash/index.d.ts +2 -0
- package/dist/types/components/wallets/GCash/type.d.ts +71 -0
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -0
- package/dist/types/components/wallets/Paymaya/index.d.ts +2 -0
- package/dist/types/components/wallets/Paymaya/type.d.ts +61 -0
- package/dist/types/config.d.ts +9 -9
- package/dist/types/constant.d.ts +28 -3
- package/dist/types/core/PayKKaCheckout.d.ts +10 -0
- package/dist/types/core/Session.d.ts +2 -0
- package/dist/types/core/error.d.ts +15 -2
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/hooks/usePayState.d.ts +5 -5
- package/dist/types/i18n/I18n.d.ts +1 -1
- package/dist/types/i18n/locales/de-DE.d.ts +13 -0
- package/dist/types/i18n/locales/en-GB.d.ts +13 -0
- package/dist/types/i18n/locales/es-ES.d.ts +13 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +13 -0
- package/dist/types/i18n/locales/index.d.ts +2 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +13 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +13 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +71 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +13 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +13 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +13 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +13 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +13 -0
- package/dist/types/i18n/util.d.ts +5 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/out/fraud-detection.d.ts +5 -1
- package/dist/types/out/types.d.ts +4 -0
- package/dist/types/out/worldpay-ddc-iframe.d.ts +1 -0
- package/dist/types/out/worldpay-ddc.d.ts +37 -0
- package/dist/types/types/event.d.ts +26 -0
- package/dist/types/types/fraud-detection.d.ts +3 -1
- package/dist/types/types/index.d.ts +23 -4
- package/dist/types/types/message.d.ts +22 -2
- package/dist/types/utils/array.d.ts +1 -0
- package/dist/types/utils/card-brand/brands.d.ts +4 -3
- package/dist/types/utils/card-brand/index.d.ts +9 -6
- package/dist/types/utils/card-brand/luhn.d.ts +9 -0
- package/dist/types/utils/date.d.ts +9 -0
- package/dist/types/utils/detect.d.ts +1 -0
- package/dist/types/utils/format.d.ts +7 -1
- package/dist/types/utils/iframe.d.ts +1 -1
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/location.d.ts +7 -0
- package/dist/types/utils/object.d.ts +1 -0
- package/dist/types/utils/redirect.d.ts +5 -0
- package/dist/types/utils/reg-exp.d.ts +1 -0
- package/dist/types/utils/system-info/get-browser-info.d.ts +1 -1
- package/dist/types/utils/system-info/get-system-info.d.ts +3 -2
- package/dist/types/utils/system-info/index.d.ts +3 -3
- package/package.json +6 -2
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { w, F, A, h, y, q, u, b } from "../../../core.js";
|
|
2
|
+
import { useBEM } from "../../../hooks/useBEM.js";
|
|
3
|
+
import { CoreContext } from "../../../core/context.js";
|
|
4
|
+
import "../../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { cssVarPrefix, normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
7
|
+
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
8
|
+
import { isTimeoutError } from "../../../api/http.js";
|
|
9
|
+
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../../constant.js";
|
|
10
|
+
import { getBrowserParams } from "../../../api/modules/get-browser-params.js";
|
|
11
|
+
import { getPaymayaPayInfo, paymayaPay } from "../../../api/modules/paymaya/index.js";
|
|
12
|
+
import { PayKKaError } from "../../../core/error.js";
|
|
13
|
+
import { hidePaymentButton } from "../../../config.js";
|
|
14
|
+
import { usePayState } from "../../../hooks/usePayState.js";
|
|
15
|
+
import { useRetry } from "../../../hooks/useRetry.js";
|
|
16
|
+
import { createAddressCore } from "../../../core/Address.js";
|
|
17
|
+
import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
|
|
18
|
+
import { SubmitButton } from "../../SubmitButton/index.js";
|
|
19
|
+
import { GuideCard } from "../../GuideCard/index.js";
|
|
20
|
+
import { AddressField } from "../../AddressField/index.js";
|
|
21
|
+
import { Info } from "../../internal/Info/Info.js";
|
|
22
|
+
import "../../internal/Form/type.js";
|
|
23
|
+
import "../../internal/Form/context.js";
|
|
24
|
+
import "../../internal/Form/FormItem.js";
|
|
25
|
+
import { Form } from "../../internal/Form/Form.js";
|
|
26
|
+
import "./paymaya2.js";
|
|
27
|
+
const { bem } = useBEM("paymaya");
|
|
28
|
+
const fieldClassNames = bem("field");
|
|
29
|
+
const Paymaya = w((props, ref) => {
|
|
30
|
+
var _a, _b, _c, _d, _e, _f;
|
|
31
|
+
const {
|
|
32
|
+
session,
|
|
33
|
+
showEmail = false,
|
|
34
|
+
showAddress = false,
|
|
35
|
+
core,
|
|
36
|
+
redirectMode = "auto",
|
|
37
|
+
autoQuery = true,
|
|
38
|
+
showGuideCard = true
|
|
39
|
+
} = props;
|
|
40
|
+
F(ref, () => ({
|
|
41
|
+
stopRetry: () => {
|
|
42
|
+
setSubmitButtonStatus("unSubmit");
|
|
43
|
+
stopReFetchPayInfo();
|
|
44
|
+
},
|
|
45
|
+
startRetry: (timeout) => {
|
|
46
|
+
setSubmitButtonStatus("loading");
|
|
47
|
+
startReFetchPayInfo({ timeout });
|
|
48
|
+
},
|
|
49
|
+
updateAddress: () => {
|
|
50
|
+
var _a2;
|
|
51
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
52
|
+
return;
|
|
53
|
+
setForm(Object.assign(form, { address: addressState.getAddressState() }));
|
|
54
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
|
|
55
|
+
},
|
|
56
|
+
updateEmail: () => {
|
|
57
|
+
var _a2;
|
|
58
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
59
|
+
return;
|
|
60
|
+
setForm(Object.assign(form, { email: emailState.email }));
|
|
61
|
+
form.email = emailState.email;
|
|
62
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
63
|
+
validateForm();
|
|
64
|
+
},
|
|
65
|
+
payment: () => {
|
|
66
|
+
hidePaymentButton && onSubmit();
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
const addressState = createAddressCore();
|
|
70
|
+
const emailState = createEmailCore();
|
|
71
|
+
const addressFieldRef = A(null);
|
|
72
|
+
const emailFieldRef = A(null);
|
|
73
|
+
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
74
|
+
const { setErrorMsg, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
|
|
75
|
+
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
76
|
+
const formRef = A(null);
|
|
77
|
+
const [form, setForm] = h({
|
|
78
|
+
email: "",
|
|
79
|
+
address: {
|
|
80
|
+
country: "",
|
|
81
|
+
province: "",
|
|
82
|
+
city: "",
|
|
83
|
+
area: "",
|
|
84
|
+
postCode: "",
|
|
85
|
+
address1: "",
|
|
86
|
+
address2: ""
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const [validated, setValidated] = h(false);
|
|
90
|
+
const [fieldStatus, setFieldStatus] = h();
|
|
91
|
+
const initFieldStatus = () => {
|
|
92
|
+
const { field, sessionMode } = session.checkout;
|
|
93
|
+
const { email, address } = field;
|
|
94
|
+
if (sessionMode === SessionMode.COMPONENT) {
|
|
95
|
+
if (email.disabled) {
|
|
96
|
+
email.show = showEmail;
|
|
97
|
+
}
|
|
98
|
+
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
99
|
+
address.show = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
setFieldStatus({ ...field });
|
|
103
|
+
};
|
|
104
|
+
y(() => {
|
|
105
|
+
if (!sessionReady) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const { bill = {}, paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
|
|
109
|
+
if (!paymentMethod.includes(PaymentMethod.PAYMAYA)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
initFieldStatus();
|
|
113
|
+
setIsCheckoutEnabled(true);
|
|
114
|
+
form.email = bill.email ?? "";
|
|
115
|
+
if (autoQuery && core.processingPaymentMethod === PaymentMethod.PAYMAYA) {
|
|
116
|
+
setSubmitButtonStatus("loading");
|
|
117
|
+
startReFetchPayInfo();
|
|
118
|
+
}
|
|
119
|
+
}, [sessionReady]);
|
|
120
|
+
const processOnError = (error) => {
|
|
121
|
+
var _a2;
|
|
122
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
123
|
+
core.resetEnablePaymentMethod();
|
|
124
|
+
};
|
|
125
|
+
const onTimeout = q(
|
|
126
|
+
(message) => {
|
|
127
|
+
var _a2;
|
|
128
|
+
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
129
|
+
setSubmitButtonStatus("unSubmit");
|
|
130
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props);
|
|
131
|
+
core.resetEnablePaymentMethod();
|
|
132
|
+
},
|
|
133
|
+
[i18n, props.onTimeout]
|
|
134
|
+
);
|
|
135
|
+
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
136
|
+
(timeout) => pay(true, timeout),
|
|
137
|
+
{ onTimeout: () => onTimeout(i18n.get("common.queryTimeout")) }
|
|
138
|
+
);
|
|
139
|
+
const getPaymentParams = async () => {
|
|
140
|
+
return {
|
|
141
|
+
sessionId: session.sessionId,
|
|
142
|
+
clientKey: session.clientKey,
|
|
143
|
+
payment: {
|
|
144
|
+
paymentMethod: PaymentMethod.PAYMAYA
|
|
145
|
+
},
|
|
146
|
+
bill: {
|
|
147
|
+
email: form.email,
|
|
148
|
+
...form.address,
|
|
149
|
+
province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
|
|
150
|
+
city: addressState.getLabel(form.address.city, addressState.getCityOptions()) ?? form.address.city
|
|
151
|
+
},
|
|
152
|
+
browser: await getBrowserParams()
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const pay = async (search = false, timeout) => {
|
|
156
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
157
|
+
try {
|
|
158
|
+
const paymentParams = await getPaymentParams();
|
|
159
|
+
const requestOptions = { locale: i18n.locale, timeout };
|
|
160
|
+
const res = search ? await getPaymayaPayInfo(
|
|
161
|
+
{ sessionId: session.sessionId, clientKey: session.clientKey },
|
|
162
|
+
requestOptions
|
|
163
|
+
) : await paymayaPay(paymentParams, props.core, requestOptions);
|
|
164
|
+
!search && ((_a2 = props.onSubmitResponse) == null ? void 0 : _a2.call(props, res));
|
|
165
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo } = res;
|
|
166
|
+
if (status === "PROCESSING") {
|
|
167
|
+
if (!orderStatus) {
|
|
168
|
+
setSubmitButtonStatus("unSubmit");
|
|
169
|
+
return { end: true };
|
|
170
|
+
} else if (orderStatus === "SUCCESS") {
|
|
171
|
+
setSubmitButtonStatus("success");
|
|
172
|
+
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
173
|
+
return { end: true };
|
|
174
|
+
} else if (orderStatus === "FAILURE") {
|
|
175
|
+
setErrorMsg(errorMessage);
|
|
176
|
+
setSubmitButtonStatus("unSubmit");
|
|
177
|
+
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
178
|
+
return { end: true };
|
|
179
|
+
} else if (orderStatus === "PROCESSING") {
|
|
180
|
+
if (!search) {
|
|
181
|
+
if (redirectMode === "auto" && payInfo) {
|
|
182
|
+
redirectToPayment(payInfo);
|
|
183
|
+
return { end: true };
|
|
184
|
+
} else {
|
|
185
|
+
startReFetchPayInfo();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { end: false };
|
|
189
|
+
} else if (orderStatus === "CANCELED") {
|
|
190
|
+
setSubmitButtonStatus("unSubmit");
|
|
191
|
+
(_c2 = props.onTimeout) == null ? void 0 : _c2.call(props);
|
|
192
|
+
core.resetEnablePaymentMethod();
|
|
193
|
+
return { end: true };
|
|
194
|
+
}
|
|
195
|
+
} else if (status === "SUCCESS") {
|
|
196
|
+
setSubmitButtonStatus("success");
|
|
197
|
+
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
198
|
+
return { end: true };
|
|
199
|
+
} else if (status === "EXPIRED") {
|
|
200
|
+
setSubmitButtonStatus("unSubmit");
|
|
201
|
+
(_e2 = props.onExpired) == null ? void 0 : _e2.call(props);
|
|
202
|
+
return { end: true };
|
|
203
|
+
}
|
|
204
|
+
setSubmitButtonStatus("unSubmit");
|
|
205
|
+
return { end: true };
|
|
206
|
+
} catch (error) {
|
|
207
|
+
if (isTimeoutError(error)) {
|
|
208
|
+
if (search) {
|
|
209
|
+
return { end: false };
|
|
210
|
+
} else {
|
|
211
|
+
onTimeout();
|
|
212
|
+
return { end: true };
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
216
|
+
setErrorMsg(message);
|
|
217
|
+
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
218
|
+
setSubmitButtonStatus("unSubmit");
|
|
219
|
+
return { end: true };
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const validateForm = () => {
|
|
224
|
+
var _a2;
|
|
225
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
226
|
+
setValidated(true);
|
|
227
|
+
}).catch(() => {
|
|
228
|
+
setValidated(false);
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
y(() => {
|
|
232
|
+
validateForm();
|
|
233
|
+
}, [form]);
|
|
234
|
+
const onSubmit = async () => {
|
|
235
|
+
var _a2;
|
|
236
|
+
setErrorMsg("");
|
|
237
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
238
|
+
var _a3;
|
|
239
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
|
|
240
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
241
|
+
if (errors) {
|
|
242
|
+
setSubmitButtonStatus("unSubmit");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
setErrorMsg("");
|
|
246
|
+
setSubmitButtonStatus("loading");
|
|
247
|
+
await pay();
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const setFormRef = (dom) => {
|
|
251
|
+
formRef.current = dom;
|
|
252
|
+
dom && validateForm();
|
|
253
|
+
};
|
|
254
|
+
const Button = () => {
|
|
255
|
+
var _a2;
|
|
256
|
+
const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
|
|
257
|
+
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
258
|
+
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
259
|
+
return /* @__PURE__ */ u(
|
|
260
|
+
SubmitButton,
|
|
261
|
+
{
|
|
262
|
+
className: bem("button"),
|
|
263
|
+
status: submitButtonStatus,
|
|
264
|
+
text,
|
|
265
|
+
loadingText: i18n.get("common.payProcessing"),
|
|
266
|
+
successText: i18n.get("common.paySuccess"),
|
|
267
|
+
onClick: onSubmit,
|
|
268
|
+
verified: validated
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
const Email = () => {
|
|
273
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
274
|
+
EmailField,
|
|
275
|
+
{
|
|
276
|
+
ref: emailFieldRef,
|
|
277
|
+
value: form.email,
|
|
278
|
+
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
279
|
+
}
|
|
280
|
+
) }) });
|
|
281
|
+
};
|
|
282
|
+
const formStyle = {
|
|
283
|
+
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
284
|
+
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
285
|
+
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
286
|
+
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
287
|
+
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
288
|
+
};
|
|
289
|
+
const ErrorMessage = () => {
|
|
290
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
|
|
291
|
+
};
|
|
292
|
+
const Address = () => {
|
|
293
|
+
var _a2, _b2;
|
|
294
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
295
|
+
AddressField,
|
|
296
|
+
{
|
|
297
|
+
ref: addressFieldRef,
|
|
298
|
+
value: form.address,
|
|
299
|
+
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.bill.country),
|
|
300
|
+
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
301
|
+
}
|
|
302
|
+
) }) });
|
|
303
|
+
};
|
|
304
|
+
return /* @__PURE__ */ u(
|
|
305
|
+
CoreContext.Provider,
|
|
306
|
+
{
|
|
307
|
+
value: {
|
|
308
|
+
i18n,
|
|
309
|
+
session
|
|
310
|
+
},
|
|
311
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
|
|
312
|
+
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.PAYMAYA }),
|
|
313
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
314
|
+
Email(),
|
|
315
|
+
Address(),
|
|
316
|
+
ErrorMessage(),
|
|
317
|
+
!hidePaymentButton && Button()
|
|
318
|
+
] }) })
|
|
319
|
+
] })
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
export {
|
|
324
|
+
Paymaya
|
|
325
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./Paymaya.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/es/config.js
CHANGED
|
@@ -9,27 +9,27 @@ let fraudDetectionEnv = void 0;
|
|
|
9
9
|
let customReqHeaders = {};
|
|
10
10
|
let customLocale = void 0;
|
|
11
11
|
let hidePaymentButton = false;
|
|
12
|
-
|
|
12
|
+
const setApiUrl = (url) => {
|
|
13
13
|
apiUrl = url;
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
};
|
|
15
|
+
const setCDNUrl = (url) => {
|
|
16
16
|
const urlInfo = new URL(url);
|
|
17
17
|
cdnOrigin = urlInfo.origin;
|
|
18
18
|
cdnDir = urlInfo.pathname;
|
|
19
19
|
cdnUrl = `${cdnOrigin}${cdnDir === "/" ? "" : cdnDir}`;
|
|
20
|
-
}
|
|
21
|
-
|
|
20
|
+
};
|
|
21
|
+
const setFraudDetectionEnv = (env) => {
|
|
22
22
|
fraudDetectionEnv = env;
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
};
|
|
24
|
+
const setCustomReqHeaders = (headers) => {
|
|
25
25
|
customReqHeaders = headers;
|
|
26
|
-
}
|
|
27
|
-
|
|
26
|
+
};
|
|
27
|
+
const setCustomLocale = (locale) => {
|
|
28
28
|
customLocale = locale;
|
|
29
|
-
}
|
|
30
|
-
|
|
29
|
+
};
|
|
30
|
+
const setCheckoutConfig = (params) => {
|
|
31
31
|
hidePaymentButton = params.hidePaymentButton || false;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
export {
|
|
34
34
|
apiUrl,
|
|
35
35
|
cdnOrigin,
|
package/dist/es/constant.js
CHANGED
|
@@ -2,8 +2,6 @@ const PREFIX = "paykka-card-checkout";
|
|
|
2
2
|
const COMMON_CLASS_NAME = PREFIX;
|
|
3
3
|
var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
4
4
|
PaymentMethod2["ALL"] = "ALL";
|
|
5
|
-
PaymentMethod2["ALI_PAY"] = "ALIPAY_PLUS";
|
|
6
|
-
PaymentMethod2["WECHAT_PAY"] = "WECHAT_PAY_GLOBAL";
|
|
7
5
|
PaymentMethod2["APPLE_PAY"] = "APPLE_PAY";
|
|
8
6
|
PaymentMethod2["GOOGLE_PAY"] = "GOOGLE_PAY";
|
|
9
7
|
PaymentMethod2["BANKCARD"] = "BANKCARD";
|
|
@@ -14,6 +12,18 @@ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
|
14
12
|
PaymentMethod2["DINERS_CLUB"] = "DINERS_CLUB";
|
|
15
13
|
PaymentMethod2["DISCOVER"] = "DISCOVER";
|
|
16
14
|
PaymentMethod2["BOC"] = "BOC";
|
|
15
|
+
PaymentMethod2["CHINA_UNION_PAY"] = "CHINA_UNION_PAY";
|
|
16
|
+
PaymentMethod2["ALI_PAY"] = "ALIPAY_PLUS";
|
|
17
|
+
PaymentMethod2["WECHAT_PAY"] = "WECHAT_PAY_GLOBAL";
|
|
18
|
+
PaymentMethod2["BOOST"] = "BOOST";
|
|
19
|
+
PaymentMethod2["GRAB_PAY"] = "GRABPAY";
|
|
20
|
+
PaymentMethod2["TNG_WALLET"] = "TNG_EWALLET";
|
|
21
|
+
PaymentMethod2["MAY_BANK_QR_PAY"] = "MAYBANK_QRPAY";
|
|
22
|
+
PaymentMethod2["SHOPEE_PAY"] = "SHOPEE_PAY";
|
|
23
|
+
PaymentMethod2["LINE_PAY"] = "LINE_PAY";
|
|
24
|
+
PaymentMethod2["NINE_PAY"] = "NINE_PAY";
|
|
25
|
+
PaymentMethod2["GCASH"] = "G_CASH";
|
|
26
|
+
PaymentMethod2["PAYMAYA"] = "PAYMAYA";
|
|
17
27
|
PaymentMethod2["SEPA_DEBIT"] = "SEPA_DEBIT";
|
|
18
28
|
return PaymentMethod2;
|
|
19
29
|
})(PaymentMethod || {});
|
|
@@ -24,16 +34,85 @@ var PaymentCategory = /* @__PURE__ */ ((PaymentCategory2) => {
|
|
|
24
34
|
PaymentCategory2["SEPA_DEBIT"] = "sepaDebit";
|
|
25
35
|
PaymentCategory2["WECHAT_PAY"] = "wechatPay";
|
|
26
36
|
PaymentCategory2["ALI_PAY"] = "aliPay";
|
|
37
|
+
PaymentCategory2["BOOST"] = "boost";
|
|
38
|
+
PaymentCategory2["GRAB_PAY"] = "grabPay";
|
|
39
|
+
PaymentCategory2["TNG_WALLET"] = "tngEWallet";
|
|
40
|
+
PaymentCategory2["MAY_BANK_QR_PAY"] = "mayBankQRPay";
|
|
41
|
+
PaymentCategory2["SHOPEE_PAY"] = "shopeePay";
|
|
42
|
+
PaymentCategory2["LINE_PAY"] = "linePay";
|
|
43
|
+
PaymentCategory2["NINE_PAY"] = "ninePay";
|
|
44
|
+
PaymentCategory2["GCASH"] = "gcash";
|
|
45
|
+
PaymentCategory2["PAYMAYA"] = "paymaya";
|
|
27
46
|
return PaymentCategory2;
|
|
28
47
|
})(PaymentCategory || {});
|
|
48
|
+
const PaymentMethod2CategoryMap = {
|
|
49
|
+
[
|
|
50
|
+
"APPLE_PAY"
|
|
51
|
+
/* APPLE_PAY */
|
|
52
|
+
]: "applePay",
|
|
53
|
+
[
|
|
54
|
+
"GOOGLE_PAY"
|
|
55
|
+
/* GOOGLE_PAY */
|
|
56
|
+
]: "googlePay",
|
|
57
|
+
[
|
|
58
|
+
"SEPA_DEBIT"
|
|
59
|
+
/* SEPA_DEBIT */
|
|
60
|
+
]: "sepaDebit",
|
|
61
|
+
[
|
|
62
|
+
"WECHAT_PAY_GLOBAL"
|
|
63
|
+
/* WECHAT_PAY */
|
|
64
|
+
]: "wechatPay",
|
|
65
|
+
[
|
|
66
|
+
"ALIPAY_PLUS"
|
|
67
|
+
/* ALI_PAY */
|
|
68
|
+
]: "aliPay",
|
|
69
|
+
[
|
|
70
|
+
"BOOST"
|
|
71
|
+
/* BOOST */
|
|
72
|
+
]: "boost",
|
|
73
|
+
[
|
|
74
|
+
"GRABPAY"
|
|
75
|
+
/* GRAB_PAY */
|
|
76
|
+
]: "grabPay",
|
|
77
|
+
[
|
|
78
|
+
"TNG_EWALLET"
|
|
79
|
+
/* TNG_WALLET */
|
|
80
|
+
]: "tngEWallet",
|
|
81
|
+
[
|
|
82
|
+
"MAYBANK_QRPAY"
|
|
83
|
+
/* MAY_BANK_QR_PAY */
|
|
84
|
+
]: "mayBankQRPay",
|
|
85
|
+
[
|
|
86
|
+
"SHOPEE_PAY"
|
|
87
|
+
/* SHOPEE_PAY */
|
|
88
|
+
]: "shopeePay",
|
|
89
|
+
[
|
|
90
|
+
"LINE_PAY"
|
|
91
|
+
/* LINE_PAY */
|
|
92
|
+
]: "linePay",
|
|
93
|
+
[
|
|
94
|
+
"NINE_PAY"
|
|
95
|
+
/* NINE_PAY */
|
|
96
|
+
]: "ninePay",
|
|
97
|
+
[
|
|
98
|
+
"G_CASH"
|
|
99
|
+
/* GCASH */
|
|
100
|
+
]: "gcash",
|
|
101
|
+
[
|
|
102
|
+
"PAYMAYA"
|
|
103
|
+
/* PAYMAYA */
|
|
104
|
+
]: "paymaya"
|
|
105
|
+
/* PAYMAYA */
|
|
106
|
+
};
|
|
29
107
|
const CardPaymentMethods = [
|
|
30
108
|
"VISA",
|
|
31
109
|
"MASTER_CARD",
|
|
32
110
|
"JCB",
|
|
33
111
|
"AMEX",
|
|
34
112
|
"DINERS_CLUB",
|
|
35
|
-
"DISCOVER"
|
|
36
|
-
|
|
113
|
+
"DISCOVER",
|
|
114
|
+
"CHINA_UNION_PAY"
|
|
115
|
+
/* CHINA_UNION_PAY */
|
|
37
116
|
];
|
|
38
117
|
var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
39
118
|
PaymentType2["PURCHASE"] = "PURCHASE";
|
|
@@ -64,6 +143,7 @@ export {
|
|
|
64
143
|
PREFIX,
|
|
65
144
|
PaymentCategory,
|
|
66
145
|
PaymentMethod,
|
|
146
|
+
PaymentMethod2CategoryMap,
|
|
67
147
|
PaymentType,
|
|
68
148
|
SessionMode
|
|
69
149
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
var __accessCheck = (obj, member, msg) => {
|
|
2
8
|
if (!member.has(obj))
|
|
3
9
|
throw TypeError("Cannot " + msg);
|
|
@@ -22,15 +28,27 @@ import { Session } from "./Session.js";
|
|
|
22
28
|
import { setApiUrl, setCDNUrl, setFraudDetectionEnv, setCheckoutConfig, setCustomLocale } from "../config.js";
|
|
23
29
|
import { PayKKaError } from "./error.js";
|
|
24
30
|
import { apiEnv, cdnEnv, fraudDetectionEnv } from "./environment.js";
|
|
31
|
+
import "../api/http.js";
|
|
25
32
|
import { isEmptyObject } from "../utils/is.js";
|
|
26
33
|
import "../utils/card-brand/brands.js";
|
|
27
34
|
import "../utils/system-info/get-browser-info.js";
|
|
35
|
+
import { getUrlParam } from "../utils/location.js";
|
|
36
|
+
import { d } from "../core.js";
|
|
37
|
+
const PROCESSING_PARAM_NAME = "m";
|
|
28
38
|
class PayKKaCheckout {
|
|
29
39
|
constructor(config) {
|
|
30
40
|
__privateAdd(this, _config, void 0);
|
|
31
41
|
__privateAdd(this, _envConfig, void 0);
|
|
32
42
|
__privateAdd(this, _session, void 0);
|
|
33
43
|
__privateAdd(this, _componentInsts, []);
|
|
44
|
+
// TODO: 这俩属性不应该放在这里,但他们是在 PayKKaCheckout 实例中保持唯一的数据,还没想好放哪里
|
|
45
|
+
/** 当前正在处理的支付方式,在第三方支付页面跳回收银台时,会通过 url 参数传递过来 */
|
|
46
|
+
__publicField(this, "processingPaymentMethod", null);
|
|
47
|
+
/**
|
|
48
|
+
* 当前启用的支付方式(禁用则展示禁用样式)
|
|
49
|
+
* 在 DropIn 且有正在处理的支付方式时,会设置为当前支付方式,并把其他支付方式设为禁用
|
|
50
|
+
*/
|
|
51
|
+
__publicField(this, "enablePaymentMethod", d(null));
|
|
34
52
|
__privateSet(this, _config, config);
|
|
35
53
|
this.init();
|
|
36
54
|
}
|
|
@@ -39,9 +57,10 @@ class PayKKaCheckout {
|
|
|
39
57
|
this.initLocale();
|
|
40
58
|
this.initExtraParams();
|
|
41
59
|
this.initSession();
|
|
60
|
+
this.initOtherData();
|
|
42
61
|
}
|
|
43
62
|
initSession() {
|
|
44
|
-
const { sessionId, clientKey, onPaymentMethodsReady, onInitError } = __privateGet(this, _config);
|
|
63
|
+
const { sessionId, clientKey, onPaymentMethodsReady, onInitError, onSuccess } = __privateGet(this, _config);
|
|
45
64
|
if (!sessionId) {
|
|
46
65
|
onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "SessionId is required"));
|
|
47
66
|
return;
|
|
@@ -53,7 +72,11 @@ class PayKKaCheckout {
|
|
|
53
72
|
onInitError == null ? void 0 : onInitError(new PayKKaError("ERROR", "Checkout is empty"));
|
|
54
73
|
return;
|
|
55
74
|
}
|
|
56
|
-
const { paymentMethod = [] } = ((_b = __privateGet(this, _session)) == null ? void 0 : _b.checkout) || {};
|
|
75
|
+
const { paymentMethod = [], status } = ((_b = __privateGet(this, _session)) == null ? void 0 : _b.checkout) || {};
|
|
76
|
+
if (status === "SUCCESS") {
|
|
77
|
+
onSuccess == null ? void 0 : onSuccess({});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
57
80
|
onPaymentMethodsReady == null ? void 0 : onPaymentMethodsReady(paymentMethod);
|
|
58
81
|
}).catch((error) => {
|
|
59
82
|
onInitError == null ? void 0 : onInitError(error);
|
|
@@ -79,9 +102,13 @@ class PayKKaCheckout {
|
|
|
79
102
|
}
|
|
80
103
|
initExtraParams() {
|
|
81
104
|
const { hidePaymentButton = false } = __privateGet(this, _config);
|
|
82
|
-
setCheckoutConfig({
|
|
83
|
-
|
|
84
|
-
|
|
105
|
+
setCheckoutConfig({ hidePaymentButton });
|
|
106
|
+
}
|
|
107
|
+
initOtherData() {
|
|
108
|
+
const res = getUrlParam(PROCESSING_PARAM_NAME);
|
|
109
|
+
if (res) {
|
|
110
|
+
this.processingPaymentMethod = res;
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
get session() {
|
|
87
114
|
return __privateGet(this, _session);
|
|
@@ -116,6 +143,9 @@ class PayKKaCheckout {
|
|
|
116
143
|
threeDSFrame: __privateGet(this, _config).threeDSFrame
|
|
117
144
|
};
|
|
118
145
|
}
|
|
146
|
+
resetEnablePaymentMethod() {
|
|
147
|
+
this.enablePaymentMethod.value = null;
|
|
148
|
+
}
|
|
119
149
|
}
|
|
120
150
|
_config = new WeakMap();
|
|
121
151
|
_envConfig = new WeakMap();
|
package/dist/es/core/Session.js
CHANGED
|
@@ -21,18 +21,17 @@ var __privateMethod = (obj, member, method) => {
|
|
|
21
21
|
__accessCheck(obj, member, "access private method");
|
|
22
22
|
return method;
|
|
23
23
|
};
|
|
24
|
-
var _readyPromise, _init, init_fn
|
|
24
|
+
var _readyPromise, _init, init_fn;
|
|
25
|
+
import { isTimeoutError } from "../api/http.js";
|
|
25
26
|
import "../utils/card-brand/brands.js";
|
|
26
27
|
import "../utils/system-info/get-browser-info.js";
|
|
27
28
|
import { generateColors } from "../utils/colors.js";
|
|
28
29
|
import { createPromise } from "../utils/create-promise.js";
|
|
29
|
-
import "../core.js";
|
|
30
30
|
import { PayKKaError } from "./error.js";
|
|
31
31
|
import { querySession } from "./query.js";
|
|
32
32
|
class Session {
|
|
33
33
|
constructor(sessionId, clientKey) {
|
|
34
34
|
__privateAdd(this, _init);
|
|
35
|
-
__privateAdd(this, _genColors);
|
|
36
35
|
__publicField(this, "sessionId");
|
|
37
36
|
__publicField(this, "clientKey");
|
|
38
37
|
__publicField(this, "checkout");
|
|
@@ -41,11 +40,29 @@ class Session {
|
|
|
41
40
|
this.sessionId = sessionId;
|
|
42
41
|
this.clientKey = clientKey;
|
|
43
42
|
__privateMethod(this, _init, init_fn).call(this).then(() => __privateGet(this, _readyPromise).resolve(true)).catch((err) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
if (isTimeoutError(err)) {
|
|
44
|
+
__privateGet(this, _readyPromise).reject(err);
|
|
45
|
+
} else {
|
|
46
|
+
__privateGet(this, _readyPromise).reject(new PayKKaError("API_ERROR", err.message, { code: err.code }));
|
|
47
|
+
}
|
|
47
48
|
});
|
|
48
49
|
}
|
|
50
|
+
/** 生成主题色 */
|
|
51
|
+
genColors() {
|
|
52
|
+
var _a;
|
|
53
|
+
const { payButtonBackgroundColor } = ((_a = this.checkout) == null ? void 0 : _a.theme) || {};
|
|
54
|
+
if (payButtonBackgroundColor) {
|
|
55
|
+
const colors = generateColors(payButtonBackgroundColor, {
|
|
56
|
+
theme: "default",
|
|
57
|
+
backgroundColor: "#fff"
|
|
58
|
+
});
|
|
59
|
+
this.colors = {
|
|
60
|
+
primary: colors[5],
|
|
61
|
+
primaryHover: colors[4],
|
|
62
|
+
primaryActive: colors[6]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
49
66
|
ready() {
|
|
50
67
|
return __privateGet(this, _readyPromise);
|
|
51
68
|
}
|
|
@@ -57,23 +74,7 @@ init_fn = async function() {
|
|
|
57
74
|
sessionId: this.sessionId,
|
|
58
75
|
clientKey: this.clientKey
|
|
59
76
|
});
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
_genColors = new WeakSet();
|
|
63
|
-
genColors_fn = function() {
|
|
64
|
-
var _a;
|
|
65
|
-
const { payButtonBackgroundColor } = ((_a = this.checkout) == null ? void 0 : _a.theme) || {};
|
|
66
|
-
if (payButtonBackgroundColor) {
|
|
67
|
-
const colors = generateColors(payButtonBackgroundColor, {
|
|
68
|
-
theme: "default",
|
|
69
|
-
backgroundColor: "#fff"
|
|
70
|
-
});
|
|
71
|
-
this.colors = {
|
|
72
|
-
primary: colors[5],
|
|
73
|
-
primaryHover: colors[4],
|
|
74
|
-
primaryActive: colors[6]
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
+
this.genColors();
|
|
77
78
|
};
|
|
78
79
|
export {
|
|
79
80
|
Session
|
package/dist/es/core/error.js
CHANGED
|
@@ -4,6 +4,12 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
+
var EPayKKaError = /* @__PURE__ */ ((EPayKKaError2) => {
|
|
8
|
+
EPayKKaError2["ERROR"] = "ERROR";
|
|
9
|
+
EPayKKaError2["API_ERROR"] = "API_ERROR";
|
|
10
|
+
EPayKKaError2["TIMEOUT"] = "TIMEOUT";
|
|
11
|
+
return EPayKKaError2;
|
|
12
|
+
})(EPayKKaError || {});
|
|
7
13
|
class PayKKaError extends Error {
|
|
8
14
|
constructor(type, message, info) {
|
|
9
15
|
super(message);
|
|
@@ -17,5 +23,6 @@ class PayKKaError extends Error {
|
|
|
17
23
|
}
|
|
18
24
|
}
|
|
19
25
|
export {
|
|
26
|
+
EPayKKaError,
|
|
20
27
|
PayKKaError
|
|
21
28
|
};
|
package/dist/es/core/index.js
CHANGED