@paykka/card-checkout-ui 0.14.0 → 0.15.1
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/README.md +1 -1
- package/dist/card-checkout-ui.js +20 -20
- package/dist/card-checkout-ui.umd.cjs +20 -20
- package/dist/es/api/http.js +1 -1
- package/dist/es/api/index.js +1 -1
- package/dist/es/api/modules/checkout/index.js +1 -3
- package/dist/es/api/modules/checkout/map.js +12 -4
- package/dist/es/api/modules/encrypted-card/index.js +3 -2
- package/dist/es/api/modules/get-browser-params.js +4 -5
- package/dist/es/api/modules/index.js +1 -1
- package/dist/es/api/modules/map.js +4 -1
- package/dist/es/components/AccordionItem/AccordionItem.js +1 -1
- package/dist/es/components/AccountNameField/index.js +1 -1
- package/dist/es/components/AddressField/index.js +1 -1
- package/dist/es/components/ApplePay/index.js +34 -21
- package/dist/es/components/CPFField/index.js +1 -1
- package/dist/es/components/Card/index.js +38 -30
- package/dist/es/components/CardBrands/index.js +1 -1
- package/dist/es/components/CardExpireDateField/index.js +1 -1
- package/dist/es/components/CardHolderNameField/index.js +1 -1
- package/dist/es/components/CardIBANField/index.js +1 -1
- package/dist/es/components/CardNo/index.js +1 -1
- package/dist/es/components/CardNumberField/index.js +1 -1
- package/dist/es/components/CardSecurityCodeField/index.js +1 -1
- package/dist/es/components/CardSelector/index.js +2 -2
- package/dist/es/components/CombinedCardInfo/index.js +1 -1
- package/dist/es/components/DropIn/index.js +117 -123
- package/dist/es/components/EmailField/EmailField.js +1 -1
- package/dist/es/components/EncryptedCard/index.js +5 -5
- package/dist/es/components/GooglePay/index.js +32 -29
- package/dist/es/components/GuideCard/index.js +2 -2
- package/dist/es/components/PaymentButton/index.js +22 -7
- package/dist/es/components/RecurringTip/index.js +1 -1
- package/dist/es/components/SecuredIframe/index.js +3 -4
- package/dist/es/components/Sepa/index.js +15 -7
- package/dist/es/components/SubmitButton/index.js +2 -2
- package/dist/es/components/ThreeDS/index.js +32 -20
- package/dist/es/components/Tip/index.js +1 -1
- package/dist/es/components/business/BlikCodeField/BlikCodeField.js +1 -1
- package/dist/es/components/business/BlikCodeField/index.js +1 -1
- package/dist/es/components/business/BlikConfirmModal/BlikConfirmModal.js +3 -3
- package/dist/es/components/business/BlikConfirmModal/index.js +2 -2
- package/dist/es/components/business/NameField/NameField.js +1 -1
- package/dist/es/components/business/NameField/index.js +1 -1
- package/dist/es/components/business/PhoneField/PhoneField.js +1 -1
- package/dist/es/components/business/PhoneField/index.js +1 -1
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +2 -2
- package/dist/es/components/business/QRCodeModal/index.js +1 -1
- package/dist/es/components/business/Tooltip/Tooltip.js +1 -1
- package/dist/es/components/business/Tooltip/index.js +1 -1
- package/dist/es/components/business/index.js +2 -2
- package/dist/es/components/index.js +4 -4
- package/dist/es/components/internal/Accordion/index.js +1 -1
- package/dist/es/components/internal/Button/{Button.js → Button2.js} +2 -2
- package/dist/es/components/internal/Button/index.js +2 -2
- package/dist/es/components/internal/CheckBox/CheckBox.js +1 -1
- package/dist/es/components/internal/CheckBox/index.js +1 -1
- package/dist/es/components/internal/Form/type.js +1 -1
- package/dist/es/components/internal/Info/Info.js +1 -1
- package/dist/es/components/internal/Info/index.js +1 -1
- package/dist/es/components/internal/Input/type.js +1 -1
- package/dist/es/components/internal/Loading/Loading2.js +20 -0
- package/dist/es/{api/modules/line-pay → components/internal/Loading}/index.js +3 -2
- package/dist/es/components/internal/Loading/loading.js +1 -0
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +1 -1
- package/dist/es/components/internal/LoadingCheck/index.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/QRCode/QRCode.js +1 -1
- package/dist/es/components/internal/QRCode/index.js +1 -1
- package/dist/es/components/internal/Select/Select.js +1 -1
- package/dist/es/components/internal/Select/SelectMenu.js +1 -1
- package/dist/es/components/internal/Select/SelectMenuItem.js +1 -1
- package/dist/es/components/internal/icons/IconAlipayPlus.js +116 -0
- package/dist/es/components/internal/icons/IconError.js +2 -2
- package/dist/es/components/internal/icons/IconSuccess.js +2 -2
- package/dist/es/components/internal/icons/IconWechatPayGlobal.js +45 -0
- package/dist/es/components/internal/icons/IconWechatPayGlobalComplete.js +107 -0
- package/dist/es/components/wallets/AliPay/AliPay.js +186 -0
- package/dist/es/components/wallets/AliPay/ali-pay.js +1 -0
- package/dist/es/components/wallets/AliPay/index.js +1 -0
- package/dist/es/components/wallets/AliPay/type.js +1 -0
- package/dist/es/components/wallets/Bancontact/Bancontact.js +7 -10
- package/dist/es/components/wallets/Blik/Blik.js +14 -11
- package/dist/es/components/wallets/Boost/Boost.js +6 -9
- package/dist/es/components/wallets/GCash/GCash.js +7 -10
- package/dist/es/components/wallets/GrabPay/GrabPay.js +7 -14
- package/dist/es/components/wallets/IDeal/IDeal.js +7 -10
- package/dist/es/components/wallets/LinePay/LinePay.js +6 -9
- package/dist/es/components/wallets/MayBankQRPay/MayBankQRPay.js +6 -9
- package/dist/es/components/wallets/NinePay/NinePay.js +6 -9
- package/dist/es/components/wallets/OVO/OVO.js +7 -10
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +6 -9
- package/dist/es/components/wallets/P24/P24.js +7 -10
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +6 -9
- package/dist/es/components/wallets/Paymaya/Paymaya.js +6 -9
- package/dist/es/components/wallets/PicPay/PicPay.js +54 -217
- package/dist/es/components/wallets/Pix/Pix.js +54 -217
- package/dist/es/components/wallets/ShopeePay/ShopeePay.js +6 -9
- package/dist/es/components/wallets/Skrill/Skrill.js +7 -10
- package/dist/es/components/wallets/TNGWallet/TNGWallet.js +6 -9
- package/dist/es/components/wallets/Trustly/Trustly.js +7 -10
- package/dist/es/components/wallets/Vietqr/Vietqr.js +14 -15
- package/dist/es/components/wallets/WechatPay/WechatPay.js +250 -0
- package/dist/es/components/wallets/WechatPay/index.js +1 -0
- package/dist/es/components/wallets/WechatPay/type.js +1 -0
- package/dist/es/components/wallets/WechatPay/util.js +47 -0
- package/dist/es/components/wallets/WechatPay/wechat-pay.js +1 -0
- package/dist/es/components/wallets/Zalopay/Zalopay.js +10 -13
- package/dist/es/components/wallets/index.js +2 -0
- package/dist/es/constant.js +7 -0
- package/dist/es/core/checkout.js +36 -9
- package/dist/es/core/create-child.js +5 -4
- package/dist/es/core/index.js +1 -1
- package/dist/es/core/logger.js +1 -1
- package/dist/es/core/payment.js +13 -0
- package/dist/es/core/preview.js +29 -0
- package/dist/es/core/query.js +12 -3
- package/dist/es/core/session.js +36 -6
- package/dist/es/core/theme.js +1 -1
- package/dist/es/hooks/index.js +1 -1
- package/dist/es/hooks/useBaseWallet.js +121 -52
- package/dist/es/hooks/useI18n.js +3 -3
- package/dist/es/i18n/locales/de-DE.js +7 -0
- package/dist/es/i18n/locales/en-GB.js +7 -0
- package/dist/es/i18n/locales/es-ES.js +7 -0
- package/dist/es/i18n/locales/fr-FR.js +7 -0
- package/dist/es/i18n/locales/ja-JP.js +7 -0
- package/dist/es/i18n/locales/ko-KR.js +7 -0
- package/dist/es/i18n/locales/nl-NL.js +7 -0
- package/dist/es/i18n/locales/pt-PT.js +7 -0
- package/dist/es/i18n/locales/ru-RU.js +7 -0
- package/dist/es/i18n/locales/zh-CN.js +7 -0
- package/dist/es/i18n/locales/zh-HK.js +7 -0
- package/dist/es/i18n/locales/zh-TW.js +7 -0
- package/dist/es/i18n/util.js +10 -10
- package/dist/es/index.js +7 -5
- package/dist/es/out/base-fraud-detection.js +1 -1
- package/dist/es/out/fraud-detection.js +59 -44
- package/dist/es/out/paykka-detection.js +5 -7
- package/dist/es/out/stripe-radar.js +1 -1
- package/dist/es/out/worldpay-ddc-manager.js +3 -0
- package/dist/es/out/worldpay-ddc.js +1 -1
- package/dist/es/style.css +1 -1
- package/dist/es/types/event.js +10 -1
- package/dist/es/types/index.js +7 -0
- package/dist/es/utils/array.js +19 -5
- package/dist/es/utils/business/amount.js +15 -0
- package/dist/es/utils/business/index.js +1 -0
- package/dist/es/utils/detect.js +8 -0
- package/dist/es/utils/index.js +7 -9
- package/dist/es/utils/location.js +8 -0
- package/dist/es/utils/number.js +19 -0
- package/dist/es/utils/redirect.js +2 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/checkout/type.d.ts +1 -1
- package/dist/types/api/modules/index.d.ts +0 -17
- package/dist/types/api/modules/threeDS/index.d.ts +13 -5
- package/dist/types/components/ApplePay/type.d.ts +6 -2
- package/dist/types/components/Card/type.d.ts +2 -18
- package/dist/types/components/DropIn/layout.d.ts +33 -0
- package/dist/types/components/DropIn/type.d.ts +6 -6
- package/dist/types/components/GooglePay/createGooglePay.d.ts +1 -1
- package/dist/types/components/GooglePay/type.d.ts +6 -2
- package/dist/types/components/PaymentButton/type.d.ts +2 -0
- package/dist/types/components/Sepa/type.d.ts +3 -4
- package/dist/types/components/business/QRCodeModal/type.d.ts +12 -3
- package/dist/types/components/index.d.ts +0 -2
- package/dist/types/components/internal/Loading/Loading.d.ts +2 -1
- package/dist/types/components/internal/Loading/type.d.ts +8 -0
- package/dist/types/components/internal/ResultMessage/ResultMessage.d.ts +3 -0
- package/dist/types/components/internal/ResultMessage/index.d.ts +2 -0
- package/dist/types/components/internal/ResultMessage/type.d.ts +13 -0
- package/dist/types/components/internal/icons/IconAlipayPlus.d.ts +2 -0
- package/dist/types/components/internal/icons/IconError.d.ts +1 -1
- package/dist/types/components/internal/icons/IconSuccess.d.ts +1 -1
- package/dist/types/components/internal/icons/IconWechatPayGlobal.d.ts +2 -0
- package/dist/types/components/internal/icons/IconWechatPayGlobalComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +3 -0
- package/dist/types/components/{AliPay → wallets/AliPay}/AliPay.d.ts +9 -4
- package/dist/types/components/wallets/AliPay/type.d.ts +7 -0
- package/dist/types/components/wallets/Bancontact/type.d.ts +2 -24
- package/dist/types/components/wallets/Blik/type.d.ts +2 -24
- package/dist/types/components/wallets/Boost/type.d.ts +2 -24
- package/dist/types/components/wallets/GCash/type.d.ts +2 -24
- package/dist/types/components/wallets/GrabPay/type.d.ts +2 -12
- package/dist/types/components/wallets/IDeal/type.d.ts +2 -24
- package/dist/types/components/wallets/LinePay/type.d.ts +2 -24
- package/dist/types/components/wallets/MayBankQRPay/type.d.ts +2 -24
- package/dist/types/components/wallets/NinePay/type.d.ts +2 -24
- package/dist/types/components/wallets/OVO/type.d.ts +2 -24
- package/dist/types/components/wallets/OpayWallet/type.d.ts +2 -24
- package/dist/types/components/wallets/P24/type.d.ts +2 -24
- package/dist/types/components/wallets/PagaWallet/type.d.ts +2 -24
- package/dist/types/components/wallets/Paymaya/type.d.ts +2 -24
- package/dist/types/components/wallets/PicPay/type.d.ts +2 -24
- package/dist/types/components/wallets/Pix/type.d.ts +2 -24
- package/dist/types/components/wallets/ShopeePay/type.d.ts +2 -24
- package/dist/types/components/wallets/Skrill/type.d.ts +2 -12
- package/dist/types/components/wallets/TNGWallet/type.d.ts +2 -24
- package/dist/types/components/wallets/Trustly/type.d.ts +2 -16
- package/dist/types/components/wallets/Vietqr/type.d.ts +2 -24
- package/dist/types/components/wallets/WechatPay/WechatPay.d.ts +16 -0
- package/dist/types/components/wallets/WechatPay/type.d.ts +12 -0
- package/dist/types/components/wallets/WechatPay/util.d.ts +13 -0
- package/dist/types/components/wallets/Zalopay/type.d.ts +2 -24
- package/dist/types/components/wallets/index.d.ts +2 -0
- package/dist/types/components/wallets/type.d.ts +0 -14
- package/dist/types/constant.d.ts +8 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/preview.d.ts +1 -0
- package/dist/types/core/session.d.ts +2 -2
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/useBaseWallet.d.ts +27 -5
- package/dist/types/hooks/useI18n.d.ts +1 -1
- package/dist/types/hooks/usePayState.d.ts +1 -4
- package/dist/types/i18n/I18n.d.ts +1 -0
- package/dist/types/i18n/locales/de-DE.d.ts +7 -0
- package/dist/types/i18n/locales/en-GB.d.ts +7 -0
- package/dist/types/i18n/locales/es-ES.d.ts +7 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +7 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +7 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +7 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +7 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +7 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +7 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +7 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +7 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +7 -0
- package/dist/types/i18n/util.d.ts +8 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/out/fraud-detection.d.ts +2 -5
- package/dist/types/out/types.d.ts +5 -6
- package/dist/types/out/worldpay-ddc-manager.d.ts +1 -0
- package/dist/types/types/event.d.ts +24 -2
- package/dist/types/types/index.d.ts +14 -0
- package/dist/types/types/message.d.ts +3 -1
- package/dist/types/types/payment.d.ts +26 -3
- package/dist/types/utils/app-payment.d.ts +1 -0
- package/dist/types/utils/array.d.ts +17 -0
- package/dist/types/utils/business/amount.d.ts +7 -0
- package/dist/types/utils/business/index.d.ts +1 -0
- package/dist/types/utils/detect.d.ts +3 -0
- package/dist/types/utils/index.d.ts +1 -6
- package/dist/types/utils/number.d.ts +4 -0
- package/dist/types/utils/redirect.d.ts +10 -0
- package/dist/types/utils/system-info/get-browser-info.d.ts +4 -0
- package/package.json +4 -2
- package/dist/es/api/modules/ali-pay/index.js +0 -16
- package/dist/es/api/modules/boost/index.js +0 -5
- package/dist/es/api/modules/gcash/index.js +0 -5
- package/dist/es/api/modules/grab-pay/index.js +0 -5
- package/dist/es/api/modules/may-bank-qr-pay/index.js +0 -5
- package/dist/es/api/modules/nine-pay/index.js +0 -5
- package/dist/es/api/modules/opay-wallet/index.js +0 -5
- package/dist/es/api/modules/paga-wallet/index.js +0 -5
- package/dist/es/api/modules/paymaya/index.js +0 -5
- package/dist/es/api/modules/pic-pay/index.js +0 -16
- package/dist/es/api/modules/pix/index.js +0 -16
- package/dist/es/api/modules/shopee-pay/index.js +0 -5
- package/dist/es/api/modules/tng-wallet/index.js +0 -5
- package/dist/es/api/modules/vietqr/index.js +0 -5
- package/dist/es/api/modules/wechat-pay/index.js +0 -16
- package/dist/es/api/modules/zalopay/index.js +0 -5
- package/dist/es/components/AliPay/index.js +0 -332
- package/dist/es/components/WechatPay/index.js +0 -340
- package/dist/es/hooks/usePayment.js +0 -1
- package/dist/types/api/modules/ali-pay/index.d.ts +0 -4
- package/dist/types/api/modules/boost/index.d.ts +0 -4
- package/dist/types/api/modules/gcash/index.d.ts +0 -4
- package/dist/types/api/modules/grab-pay/index.d.ts +0 -4
- package/dist/types/api/modules/line-pay/index.d.ts +0 -4
- package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +0 -4
- package/dist/types/api/modules/nine-pay/index.d.ts +0 -4
- package/dist/types/api/modules/opay-wallet/index.d.ts +0 -4
- package/dist/types/api/modules/paga-wallet/index.d.ts +0 -4
- package/dist/types/api/modules/paymaya/index.d.ts +0 -4
- package/dist/types/api/modules/pic-pay/index.d.ts +0 -4
- package/dist/types/api/modules/pix/index.d.ts +0 -4
- package/dist/types/api/modules/shopee-pay/index.d.ts +0 -4
- package/dist/types/api/modules/tng-wallet/index.d.ts +0 -4
- package/dist/types/api/modules/vietqr/index.d.ts +0 -4
- package/dist/types/api/modules/wechat-pay/index.d.ts +0 -4
- package/dist/types/api/modules/zalopay/index.d.ts +0 -4
- package/dist/types/components/AliPay/type.d.ts +0 -26
- package/dist/types/components/WechatPay/WechatPay.d.ts +0 -10
- package/dist/types/components/WechatPay/type.d.ts +0 -28
- package/dist/types/hooks/usePayment.d.ts +0 -8
- package/dist/types/hooks/useRetry.console-tests.d.ts +0 -41
- package/dist/types/utils/behavior-tracker.d.ts +0 -36
- /package/dist/es/components/internal/Button/{button2.js → button.js} +0 -0
- /package/dist/types/components/{AliPay → wallets/AliPay}/index.d.ts +0 -0
- /package/dist/types/components/{WechatPay → wallets/WechatPay}/index.d.ts +0 -0
|
@@ -53,9 +53,4 @@ export declare const safeStringify: (data: any, defaultValue?: string) => string
|
|
|
53
53
|
* @returns 是否过期
|
|
54
54
|
*/
|
|
55
55
|
export declare const isExpired: (expireDate: string) => boolean;
|
|
56
|
-
|
|
57
|
-
* 获取多个数组的交集
|
|
58
|
-
* @param arrays 要获取交集的数组
|
|
59
|
-
* @returns 交集数组
|
|
60
|
-
*/
|
|
61
|
-
export declare const intersection: <T>(...arrays: T[][]) => T[];
|
|
56
|
+
export declare const getReferrer: () => string;
|
|
@@ -3,3 +3,13 @@
|
|
|
3
3
|
* 根据支付方式选择使用 GET 或 POST 方式跳转
|
|
4
4
|
*/
|
|
5
5
|
export declare const redirectToPayment: (payInfo: Recordable) => void;
|
|
6
|
+
/**
|
|
7
|
+
* 使用 GET 方式跳转
|
|
8
|
+
* 直接在当前页面打开新的页面
|
|
9
|
+
*/
|
|
10
|
+
export declare const redirectByGet: (url: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 使用 POST 方式跳转
|
|
13
|
+
* 创建表单并提交
|
|
14
|
+
*/
|
|
15
|
+
export declare const redirectByPost: (baseUrl: string, params: Recordable) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paykka/card-checkout-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/paykka-card-checkout-ui.umd.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
"release:noprod": "node scripts/release.cjs noprod",
|
|
41
41
|
"release:npm": "node scripts/release.cjs npm",
|
|
42
42
|
"release:prod": "node scripts/release.cjs prod",
|
|
43
|
-
"type-check": "tsc --noEmit -p tsconfig.json --composite false"
|
|
43
|
+
"type-check": "tsc --noEmit -p tsconfig.json --composite false",
|
|
44
|
+
"prepack": "node scripts/npm-readme.cjs enable",
|
|
45
|
+
"postpack": "node scripts/npm-readme.cjs disable"
|
|
44
46
|
},
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"registry": "https://packages.aliyun.com/640edee5a84870ae9d591e48/npm/npm-registry/"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { apiPrefix } from "../../../config.js";
|
|
2
|
-
import { http } from "../../http.js";
|
|
3
|
-
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
4
|
-
import { payResMap } from "../map.js";
|
|
5
|
-
const aliPay = async (params, extraParams, options) => {
|
|
6
|
-
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
-
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
-
};
|
|
9
|
-
const getAliPayInfo = async (params, extraParams, options) => {
|
|
10
|
-
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
-
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
aliPay,
|
|
15
|
-
getAliPayInfo
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { apiPrefix } from "../../../config.js";
|
|
2
|
-
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
-
import { http } from "../../http.js";
|
|
4
|
-
import { payResMap } from "../map.js";
|
|
5
|
-
const picPay = async (params, extraParams, options) => {
|
|
6
|
-
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
-
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
-
};
|
|
9
|
-
const getPicPayInfo = async (params, extraParams, options) => {
|
|
10
|
-
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
-
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
getPicPayInfo,
|
|
15
|
-
picPay
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { apiPrefix } from "../../../config.js";
|
|
2
|
-
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
-
import { http } from "../../http.js";
|
|
4
|
-
import { payResMap } from "../map.js";
|
|
5
|
-
const pixPay = async (params, extraParams, options) => {
|
|
6
|
-
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
-
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
-
};
|
|
9
|
-
const getPixPayInfo = async (params, extraParams, options) => {
|
|
10
|
-
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
-
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
getPixPayInfo,
|
|
15
|
-
pixPay
|
|
16
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { apiPrefix } from "../../../config.js";
|
|
2
|
-
import { http } from "../../http.js";
|
|
3
|
-
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
4
|
-
import { payResMap } from "../map.js";
|
|
5
|
-
const wechatPay = async (params, extraParams, options) => {
|
|
6
|
-
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
-
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
-
};
|
|
9
|
-
const getWechatPayInfo = async (params, extraParams, options) => {
|
|
10
|
-
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
-
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
getWechatPayInfo,
|
|
15
|
-
wechatPay
|
|
16
|
-
};
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { w, h, A, F, y, q, u, b } from "../../core.js";
|
|
2
|
-
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { getAliPayInfo, aliPay } from "../../api/modules/ali-pay/index.js";
|
|
4
|
-
import "../../utils/card-brand/brands.js";
|
|
5
|
-
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
|
-
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
8
|
-
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
|
-
import { PaymentMethod, COMMON_CLASS_NAME, PaymentType, SessionMode } from "../../constant.js";
|
|
10
|
-
import { CoreContext } from "../../core/context.js";
|
|
11
|
-
import { PayKKaError } from "../../core/error.js";
|
|
12
|
-
import "../../out/worldpay-jsc-origin.js";
|
|
13
|
-
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
|
-
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
|
-
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
|
-
import { DEFAULT_ADDRESS, AddressField } from "../AddressField/index.js";
|
|
17
|
-
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
18
|
-
import "../internal/Form/type.js";
|
|
19
|
-
import "../internal/Form/context.js";
|
|
20
|
-
import "../internal/Form/FormItem.js";
|
|
21
|
-
import { Form } from "../internal/Form/Form.js";
|
|
22
|
-
import { Info } from "../internal/Info/Info.js";
|
|
23
|
-
import { RecurringTip } from "../RecurringTip/index.js";
|
|
24
|
-
import { SubmitButton } from "../SubmitButton/index.js";
|
|
25
|
-
const CURR_PAYMENT_METHOD = PaymentMethod.ALI_PAY;
|
|
26
|
-
const { bem } = useBEM("ali-pay");
|
|
27
|
-
const fieldClassNames = bem("field");
|
|
28
|
-
const AliPay = w((props, ref) => {
|
|
29
|
-
const { session, core, showEmail = false, showAddress = false, autoQuery = true } = props;
|
|
30
|
-
const addressCore = core.getAddressCore();
|
|
31
|
-
const emailState = createEmailCore();
|
|
32
|
-
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady, disabled } = usePayState(session, props.core);
|
|
33
|
-
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
34
|
-
const formRef = A(null);
|
|
35
|
-
const [form, setForm] = h({
|
|
36
|
-
email: "",
|
|
37
|
-
address: { ...DEFAULT_ADDRESS }
|
|
38
|
-
});
|
|
39
|
-
const [validated, setValidated] = h(false);
|
|
40
|
-
const [fieldStatus, setFieldStatus] = h();
|
|
41
|
-
const addressFieldRef = A(null);
|
|
42
|
-
const emailFieldRef = A(null);
|
|
43
|
-
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
44
|
-
const getPaymentMethodContext = () => {
|
|
45
|
-
return {
|
|
46
|
-
paymentMethod: CURR_PAYMENT_METHOD
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
F(ref, () => ({
|
|
50
|
-
stopRetry: () => {
|
|
51
|
-
stopReFetchPayInfo();
|
|
52
|
-
setSubmitButtonStatus("unSubmit");
|
|
53
|
-
},
|
|
54
|
-
startRetry: (timeout) => {
|
|
55
|
-
setSubmitButtonStatus("loading");
|
|
56
|
-
startReFetchPayInfo({ timeout });
|
|
57
|
-
},
|
|
58
|
-
updateAddress: () => {
|
|
59
|
-
var _a;
|
|
60
|
-
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
61
|
-
return;
|
|
62
|
-
const address = addressCore.getAddressState();
|
|
63
|
-
form.address = address;
|
|
64
|
-
setForm(form);
|
|
65
|
-
(_a = addressFieldRef.current) == null ? void 0 : _a.update(address);
|
|
66
|
-
validateFormSilently();
|
|
67
|
-
},
|
|
68
|
-
updateEmail: () => {
|
|
69
|
-
var _a;
|
|
70
|
-
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
71
|
-
return;
|
|
72
|
-
form.email = emailState.email;
|
|
73
|
-
setForm(form);
|
|
74
|
-
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
75
|
-
validateFormSilently();
|
|
76
|
-
}
|
|
77
|
-
}));
|
|
78
|
-
const validateFormSilently = () => {
|
|
79
|
-
var _a;
|
|
80
|
-
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => setValidated(true)).catch(() => setValidated(false));
|
|
81
|
-
};
|
|
82
|
-
const initFieldStatus = () => {
|
|
83
|
-
const { field, sessionMode } = session.checkout;
|
|
84
|
-
const { email, address } = field;
|
|
85
|
-
if (sessionMode === SessionMode.COMPONENT) {
|
|
86
|
-
if (email.disabled) {
|
|
87
|
-
email.show = showEmail;
|
|
88
|
-
}
|
|
89
|
-
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
90
|
-
address.show = true;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
setFieldStatus({ ...field });
|
|
94
|
-
};
|
|
95
|
-
y(() => {
|
|
96
|
-
validateFormSilently();
|
|
97
|
-
}, [form]);
|
|
98
|
-
const processOnSuccess = (res) => {
|
|
99
|
-
var _a, _b;
|
|
100
|
-
setSubmitButtonStatus("success");
|
|
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());
|
|
106
|
-
};
|
|
107
|
-
y(() => {
|
|
108
|
-
var _a;
|
|
109
|
-
if (!sessionReady) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
113
|
-
if (!supportMethods.includes(PaymentMethod.ALI_PAY)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
initFieldStatus();
|
|
117
|
-
setIsCheckoutEnabled(true);
|
|
118
|
-
country && addressCore.setCountry(country);
|
|
119
|
-
form.email = bill.email ?? "";
|
|
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
|
-
}
|
|
125
|
-
}, [sessionReady]);
|
|
126
|
-
const onTimeout = q(
|
|
127
|
-
(message) => {
|
|
128
|
-
var _a;
|
|
129
|
-
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
130
|
-
setSubmitButtonStatus("unSubmit");
|
|
131
|
-
core.payment.resetCurrPaymentMethod();
|
|
132
|
-
(_a = props.onTimeout) == null ? void 0 : _a.call(props, "retry", getPaymentMethodContext());
|
|
133
|
-
},
|
|
134
|
-
[i18n, props.onTimeout]
|
|
135
|
-
);
|
|
136
|
-
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
137
|
-
(timeout) => pay(true, timeout),
|
|
138
|
-
{
|
|
139
|
-
onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
|
|
140
|
-
}
|
|
141
|
-
);
|
|
142
|
-
const getPaymentParams = async () => {
|
|
143
|
-
return {
|
|
144
|
-
sessionId: session.sessionId,
|
|
145
|
-
clientKey: session.clientKey,
|
|
146
|
-
bill: (fieldStatus == null ? void 0 : fieldStatus.address.show) ? {
|
|
147
|
-
email: form.email,
|
|
148
|
-
addressLine1: form.address.address1,
|
|
149
|
-
addressLine2: form.address.address2,
|
|
150
|
-
postalCode: form.address.postCode,
|
|
151
|
-
country: form.address.country,
|
|
152
|
-
district: form.address.area,
|
|
153
|
-
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
154
|
-
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
155
|
-
} : {
|
|
156
|
-
email: form.email
|
|
157
|
-
},
|
|
158
|
-
payment: {
|
|
159
|
-
paymentMethod: CURR_PAYMENT_METHOD
|
|
160
|
-
},
|
|
161
|
-
browser: await getBrowserParams({
|
|
162
|
-
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
async function pay(search = false, timeout) {
|
|
167
|
-
var _a, _b, _c, _d, _e, _f;
|
|
168
|
-
try {
|
|
169
|
-
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
170
|
-
const requestOptions = { locale: i18n.locale, timeout };
|
|
171
|
-
let res = null;
|
|
172
|
-
if (search) {
|
|
173
|
-
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", CURR_PAYMENT_METHOD);
|
|
174
|
-
res = await getAliPayInfo(
|
|
175
|
-
{
|
|
176
|
-
sessionId: session.sessionId,
|
|
177
|
-
clientKey: session.clientKey,
|
|
178
|
-
paymentMethod: CURR_PAYMENT_METHOD
|
|
179
|
-
},
|
|
180
|
-
extraParams,
|
|
181
|
-
requestOptions
|
|
182
|
-
);
|
|
183
|
-
} else {
|
|
184
|
-
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", CURR_PAYMENT_METHOD);
|
|
185
|
-
res = await aliPay(await getPaymentParams(), extraParams, requestOptions);
|
|
186
|
-
}
|
|
187
|
-
const { errorMessage, errorCode, sessionId } = res;
|
|
188
|
-
sessionId && (session.sessionId = sessionId);
|
|
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: () => {
|
|
197
|
-
processOnSuccess(res);
|
|
198
|
-
},
|
|
199
|
-
onFailure: () => {
|
|
200
|
-
var _a2;
|
|
201
|
-
errorMessage && setErrorMsg(errorMessage);
|
|
202
|
-
setSubmitButtonStatus("unSubmit");
|
|
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;
|
|
212
|
-
setSubmitButtonStatus("unSubmit");
|
|
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();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
return { end };
|
|
227
|
-
} catch (error) {
|
|
228
|
-
if (isTimeoutError(error)) {
|
|
229
|
-
if (search) {
|
|
230
|
-
return { end: false };
|
|
231
|
-
} else {
|
|
232
|
-
onTimeout();
|
|
233
|
-
return { end: true };
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
237
|
-
message && setErrorMsg(message);
|
|
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
|
-
);
|
|
244
|
-
setSubmitButtonStatus("unSubmit");
|
|
245
|
-
return { end: true };
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
async function onSubmit() {
|
|
250
|
-
var _a;
|
|
251
|
-
setErrorMsg("");
|
|
252
|
-
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
253
|
-
var _a2;
|
|
254
|
-
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
255
|
-
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors, getPaymentMethodContext());
|
|
256
|
-
if (errors) {
|
|
257
|
-
setSubmitButtonStatus("unSubmit");
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
setErrorMsg("");
|
|
261
|
-
setSubmitButtonStatus("loading");
|
|
262
|
-
await pay();
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
const Button = () => {
|
|
266
|
-
const { transAmount, channelParams = {} } = (session == null ? void 0 : session.checkout) ?? {};
|
|
267
|
-
const { totalAmount } = channelParams.aliPay ?? {};
|
|
268
|
-
const amountObj = ((totalAmount == null ? void 0 : totalAmount.amount) ? totalAmount : transAmount) || {};
|
|
269
|
-
const amountText = (amountObj == null ? void 0 : amountObj.amount) ? formatAmount(amountObj).jointSymbol() : "";
|
|
270
|
-
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
271
|
-
return /* @__PURE__ */ u(
|
|
272
|
-
SubmitButton,
|
|
273
|
-
{
|
|
274
|
-
className: bem("button"),
|
|
275
|
-
status: submitButtonStatus,
|
|
276
|
-
disabled,
|
|
277
|
-
text,
|
|
278
|
-
loadingText: i18n.get("common.payProcessing"),
|
|
279
|
-
successText: i18n.get("common.paySuccess"),
|
|
280
|
-
onClick: onSubmit,
|
|
281
|
-
verified: validated
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
};
|
|
285
|
-
const setFormRef = (dom) => {
|
|
286
|
-
formRef.current = dom;
|
|
287
|
-
dom && validateFormSilently();
|
|
288
|
-
};
|
|
289
|
-
const Email = () => {
|
|
290
|
-
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
291
|
-
EmailField,
|
|
292
|
-
{
|
|
293
|
-
ref: emailFieldRef,
|
|
294
|
-
value: form.email,
|
|
295
|
-
disabled: (fieldStatus == null ? void 0 : fieldStatus.email.disabled) || disabled
|
|
296
|
-
}
|
|
297
|
-
) }) });
|
|
298
|
-
};
|
|
299
|
-
const Address = () => {
|
|
300
|
-
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
301
|
-
AddressField,
|
|
302
|
-
{
|
|
303
|
-
ref: addressFieldRef,
|
|
304
|
-
value: form.address,
|
|
305
|
-
disabled,
|
|
306
|
-
onChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
307
|
-
}
|
|
308
|
-
) }) });
|
|
309
|
-
};
|
|
310
|
-
return /* @__PURE__ */ u(
|
|
311
|
-
CoreContext.Provider,
|
|
312
|
-
{
|
|
313
|
-
value: {
|
|
314
|
-
i18n,
|
|
315
|
-
session,
|
|
316
|
-
core
|
|
317
|
-
},
|
|
318
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
319
|
-
Email(),
|
|
320
|
-
Address(),
|
|
321
|
-
(session == null ? void 0 : session.checkout.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
322
|
-
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
323
|
-
!!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
|
|
324
|
-
Button()
|
|
325
|
-
] })
|
|
326
|
-
] }) }) })
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
});
|
|
330
|
-
export {
|
|
331
|
-
AliPay
|
|
332
|
-
};
|