@paykka/card-checkout-ui 0.7.0 → 0.9.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 +27 -20
- package/dist/card-checkout-ui.umd.cjs +27 -20
- package/dist/es/_commonjsHelpers.js +1 -0
- package/dist/es/api/http.js +19 -21
- package/dist/es/api/index.js +1 -0
- 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 +29 -1
- 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 -0
- 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/sepa/index.js +19 -11
- package/dist/es/api/modules/shopee-pay/index.js +56 -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 +36 -0
- package/dist/es/components/AliPay/index.js +58 -60
- package/dist/es/components/ApplePay/index.js +29 -43
- package/dist/es/components/Boost/index.js +322 -0
- package/dist/es/components/Card/index.js +89 -75
- package/dist/es/components/CardBrands/index.js +2 -2
- package/dist/es/components/CardNumberField/index.js +113 -106
- package/dist/es/components/DropIn/index.js +365 -0
- package/dist/es/components/GooglePay/index.js +15 -7
- package/dist/es/components/GrabPay/index.js +322 -0
- package/dist/es/components/GuideCard/index.js +43 -0
- package/dist/es/components/LinePay/index.js +322 -0
- package/dist/es/components/MayBankQRPay/index.js +322 -0
- package/dist/es/components/NinePay/index.js +322 -0
- package/dist/es/components/SecuredIframe/index.js +3 -2
- package/dist/es/components/Sepa/index.js +8 -9
- package/dist/es/components/ShopeePay/index.js +322 -0
- package/dist/es/components/SubmitButton/index.js +6 -20
- package/dist/es/components/TNGWallet/index.js +322 -0
- package/dist/es/components/WechatPay/index.js +51 -61
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +41 -0
- package/dist/es/components/business/QRCodeModal/index.js +6 -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 +6 -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 +7 -0
- package/dist/es/components/internal/Accordion/type.js +10 -0
- package/dist/es/components/internal/Modal/Modal.js +17 -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 +31 -0
- package/dist/es/components/internal/QRCode/index.js +4 -0
- package/dist/es/components/internal/QRCode/type.js +1 -0
- package/dist/es/components/internal/icons/IconBoost.js +63 -0
- package/dist/es/components/internal/icons/IconCard.js +3 -0
- 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 +356 -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 +323 -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 +94 -4
- package/dist/es/core/PayKKaCheckout.js +38 -3
- package/dist/es/core/Session.js +24 -23
- package/dist/es/core/error.js +7 -0
- package/dist/es/core/query.js +3 -2
- package/dist/es/core.js +2082 -70
- package/dist/es/hooks/usePayState.js +3 -4
- package/dist/es/i18n/I18n.js +8 -2
- package/dist/es/i18n/locales/de-DE.js +19 -1
- package/dist/es/i18n/locales/en-GB.js +19 -1
- package/dist/es/i18n/locales/es-ES.js +19 -1
- package/dist/es/i18n/locales/fr-FR.js +19 -1
- package/dist/es/i18n/locales/ja-JP.js +19 -1
- package/dist/es/i18n/locales/ko-KR.js +19 -1
- package/dist/es/i18n/locales/pt-PT.js +19 -1
- package/dist/es/i18n/locales/ru-RU.js +19 -1
- package/dist/es/i18n/locales/zh-CN.js +19 -1
- package/dist/es/i18n/locales/zh-HK.js +19 -1
- package/dist/es/i18n/locales/zh-TW.js +19 -1
- package/dist/es/i18n/util.js +20 -0
- package/dist/es/index.js +24 -0
- package/dist/es/style.css +1 -1096
- package/dist/es/types/index.js +1 -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/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/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/map.d.ts +2 -1
- package/dist/types/api/modules/checkout/type.d.ts +20 -2
- 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 +9 -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/sepa/index.d.ts +2 -1
- package/dist/types/api/modules/shopee-pay/index.d.ts +24 -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/AliPay/AliPay.d.ts +2 -1
- package/dist/types/components/AliPay/type.d.ts +1 -2
- package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
- package/dist/types/components/ApplePay/type.d.ts +9 -6
- 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/Card/Card.d.ts +2 -1
- package/dist/types/components/Card/type.d.ts +2 -2
- package/dist/types/components/DropIn/DropIn.d.ts +6 -0
- package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
- package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
- package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
- package/dist/types/components/DropIn/config.d.ts +7 -0
- package/dist/types/components/DropIn/index.d.ts +2 -0
- package/dist/types/components/DropIn/type.d.ts +57 -0
- package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +20 -9
- 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/SecuredIframe/useSecuredInput.d.ts +1 -1
- package/dist/types/components/Sepa/Sepa.d.ts +2 -1
- package/dist/types/components/Sepa/type.d.ts +1 -2
- 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/WechatPay/WechatPay.d.ts +2 -1
- package/dist/types/components/WechatPay/type.d.ts +1 -2
- 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 +10 -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/index.d.ts +2 -0
- package/dist/types/components/internal/Modal/type.d.ts +3 -1
- 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/icons/IconBoost.d.ts +2 -0
- package/dist/types/components/internal/icons/IconCard.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 +14 -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 +66 -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 +38 -2
- package/dist/types/core/PayKKaCheckout.d.ts +11 -0
- package/dist/types/core/Session.d.ts +2 -0
- package/dist/types/core/error.d.ts +3 -1
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/hooks/usePayState.d.ts +0 -3
- package/dist/types/i18n/I18n.d.ts +1 -1
- package/dist/types/i18n/locales/de-DE.d.ts +15 -0
- package/dist/types/i18n/locales/en-GB.d.ts +15 -0
- package/dist/types/i18n/locales/es-ES.d.ts +15 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +15 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +15 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +15 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +15 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +15 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +15 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +15 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +15 -0
- package/dist/types/i18n/util.d.ts +10 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +34 -7
- package/dist/types/types/message.d.ts +1 -0
- 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/index.d.ts +7 -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/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 +65 -63
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { w, h, A, F, y, q, u } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
3
|
import { getAliPayInfo, aliPay } from "../../api/modules/ali-pay/index.js";
|
|
4
|
-
import { isUndefined } from "../../utils/is.js";
|
|
5
4
|
import "../../utils/card-brand/brands.js";
|
|
6
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
|
-
import { formatAmount } from "../../utils/format.js";
|
|
8
|
-
import { PaymentType } from "../../constant.js";
|
|
6
|
+
import { cssVarPrefix, normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
|
+
import { COMMON_CLASS_NAME, PaymentType } from "../../constant.js";
|
|
9
8
|
import { CoreContext } from "../../core/context.js";
|
|
10
9
|
import { PayKKaError } from "../../core/error.js";
|
|
11
10
|
import { createAddressCore } from "../../core/Address.js";
|
|
@@ -23,9 +22,10 @@ import { RecurringTip } from "../RecurringTip/index.js";
|
|
|
23
22
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
24
23
|
const { bem } = useBEM("ali-pay");
|
|
25
24
|
const AliPay = w((props, ref) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
26
26
|
const { session } = props;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const addressState = createAddressCore();
|
|
28
|
+
const emailState = createEmailCore();
|
|
29
29
|
const { setErrorMsg, i18n, errorMsg, sessionReady } = usePayState(session);
|
|
30
30
|
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
31
31
|
const formRef = A(null);
|
|
@@ -56,19 +56,19 @@ const AliPay = w((props, ref) => {
|
|
|
56
56
|
startReFetchPayInfo({ timeout });
|
|
57
57
|
},
|
|
58
58
|
updateAddress: () => {
|
|
59
|
-
var
|
|
59
|
+
var _a2;
|
|
60
60
|
setForm(Object.assign(form, { address: addressState.getAddressState() }));
|
|
61
|
-
(
|
|
61
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
|
|
62
62
|
},
|
|
63
63
|
updateEmail: () => {
|
|
64
|
-
var
|
|
64
|
+
var _a2;
|
|
65
65
|
setForm(Object.assign(form, { email: emailState.email }));
|
|
66
|
-
(
|
|
66
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
67
67
|
}
|
|
68
68
|
}));
|
|
69
69
|
function validateForm() {
|
|
70
|
-
var
|
|
71
|
-
(
|
|
70
|
+
var _a2;
|
|
71
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
72
72
|
setValidated(true);
|
|
73
73
|
}).catch(() => {
|
|
74
74
|
setValidated(false);
|
|
@@ -78,11 +78,11 @@ const AliPay = w((props, ref) => {
|
|
|
78
78
|
validateForm();
|
|
79
79
|
}, [form]);
|
|
80
80
|
y(() => {
|
|
81
|
-
var
|
|
81
|
+
var _a2;
|
|
82
82
|
if (sessionReady) {
|
|
83
83
|
if ((session == null ? void 0 : session.checkout.status) === "SUCCESS") {
|
|
84
84
|
setSubmitButtonStatus("success");
|
|
85
|
-
(
|
|
85
|
+
(_a2 = props.onSuccess) == null ? void 0 : _a2.call(props);
|
|
86
86
|
}
|
|
87
87
|
form.email = (session == null ? void 0 : session.checkout.bill.email) ?? "";
|
|
88
88
|
disabledEmail.current = !!(session == null ? void 0 : session.checkout.bill.email);
|
|
@@ -92,12 +92,15 @@ const AliPay = w((props, ref) => {
|
|
|
92
92
|
}, 100);
|
|
93
93
|
}
|
|
94
94
|
}, [sessionReady]);
|
|
95
|
-
const onTimeout = q(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const onTimeout = q(
|
|
96
|
+
(message) => {
|
|
97
|
+
var _a2;
|
|
98
|
+
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
99
|
+
setSubmitButtonStatus("unSubmit");
|
|
100
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry");
|
|
101
|
+
},
|
|
102
|
+
[i18n, props.onTimeout]
|
|
103
|
+
);
|
|
101
104
|
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
102
105
|
(timeout) => pay(true, timeout),
|
|
103
106
|
{
|
|
@@ -105,7 +108,7 @@ const AliPay = w((props, ref) => {
|
|
|
105
108
|
}
|
|
106
109
|
);
|
|
107
110
|
async function pay(search = false, timeout) {
|
|
108
|
-
var
|
|
111
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
109
112
|
try {
|
|
110
113
|
const res = search ? await getAliPayInfo(
|
|
111
114
|
{
|
|
@@ -129,56 +132,43 @@ const AliPay = w((props, ref) => {
|
|
|
129
132
|
email: form.email
|
|
130
133
|
}
|
|
131
134
|
},
|
|
135
|
+
props.core,
|
|
132
136
|
{ locale: i18n.locale, timeout }
|
|
133
137
|
);
|
|
134
138
|
const { status, orderStatus, errorMessage, errorCode } = res;
|
|
135
|
-
!search && ((
|
|
139
|
+
!search && ((_a2 = props.onSubmitResponse) == null ? void 0 : _a2.call(props, res));
|
|
136
140
|
if (status === "PROCESSING") {
|
|
137
141
|
if (!orderStatus) {
|
|
138
142
|
setSubmitButtonStatus("unSubmit");
|
|
143
|
+
return { end: true };
|
|
139
144
|
} else if (orderStatus === "SUCCESS") {
|
|
140
145
|
setSubmitButtonStatus("success");
|
|
141
|
-
(
|
|
142
|
-
return {
|
|
143
|
-
end: true
|
|
144
|
-
};
|
|
146
|
+
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
147
|
+
return { end: true };
|
|
145
148
|
} else if (orderStatus === "FAILURE") {
|
|
146
149
|
setErrorMsg(errorMessage);
|
|
147
150
|
setSubmitButtonStatus("unSubmit");
|
|
148
|
-
(
|
|
149
|
-
return {
|
|
150
|
-
end: true
|
|
151
|
-
};
|
|
151
|
+
(_c2 = props.onError) == null ? void 0 : _c2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
152
|
+
return { end: true };
|
|
152
153
|
} else if (orderStatus === "PROCESSING") {
|
|
153
154
|
!search && startReFetchPayInfo();
|
|
154
|
-
return {
|
|
155
|
-
end: false
|
|
156
|
-
};
|
|
155
|
+
return { end: false };
|
|
157
156
|
} else if (orderStatus === "CANCELED") {
|
|
158
157
|
setSubmitButtonStatus("unSubmit");
|
|
159
|
-
(
|
|
160
|
-
return {
|
|
161
|
-
end: true
|
|
162
|
-
};
|
|
158
|
+
(_d2 = props.onTimeout) == null ? void 0 : _d2.call(props, "channel");
|
|
159
|
+
return { end: true };
|
|
163
160
|
}
|
|
164
161
|
} else if (status === "SUCCESS") {
|
|
165
162
|
setSubmitButtonStatus("success");
|
|
166
|
-
(
|
|
167
|
-
return {
|
|
168
|
-
end: true
|
|
169
|
-
};
|
|
163
|
+
(_e2 = props.onSuccess) == null ? void 0 : _e2.call(props);
|
|
164
|
+
return { end: true };
|
|
170
165
|
} else if (status === "EXPIRED") {
|
|
171
166
|
setSubmitButtonStatus("unSubmit");
|
|
172
|
-
(
|
|
173
|
-
return {
|
|
174
|
-
end: true
|
|
175
|
-
};
|
|
167
|
+
(_f2 = props.onExpired) == null ? void 0 : _f2.call(props);
|
|
168
|
+
return { end: true };
|
|
176
169
|
}
|
|
177
170
|
setSubmitButtonStatus("unSubmit");
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
end: true
|
|
181
|
-
};
|
|
171
|
+
return { end: true };
|
|
182
172
|
} catch (error) {
|
|
183
173
|
if (isTimeoutError(error)) {
|
|
184
174
|
if (search) {
|
|
@@ -190,19 +180,19 @@ const AliPay = w((props, ref) => {
|
|
|
190
180
|
} else {
|
|
191
181
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
192
182
|
setErrorMsg(message);
|
|
193
|
-
(
|
|
183
|
+
(_g2 = props.onError) == null ? void 0 : _g2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
194
184
|
setSubmitButtonStatus("unSubmit");
|
|
195
185
|
return { end: true };
|
|
196
186
|
}
|
|
197
187
|
}
|
|
198
188
|
}
|
|
199
189
|
async function onSubmit() {
|
|
200
|
-
var
|
|
190
|
+
var _a2;
|
|
201
191
|
setErrorMsg("");
|
|
202
|
-
(
|
|
203
|
-
var
|
|
192
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
193
|
+
var _a3;
|
|
204
194
|
requiredBill && addressState.setValidateAllFields(true);
|
|
205
|
-
(
|
|
195
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
206
196
|
if (errors) {
|
|
207
197
|
setSubmitButtonStatus("unSubmit");
|
|
208
198
|
return;
|
|
@@ -213,11 +203,11 @@ const AliPay = w((props, ref) => {
|
|
|
213
203
|
});
|
|
214
204
|
}
|
|
215
205
|
const Button = () => {
|
|
216
|
-
const { transAmount } = (session == null ? void 0 : session.checkout) ?? {};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const text = i18n.get("common.pay") + (
|
|
206
|
+
const { transAmount, channelParams = {} } = (session == null ? void 0 : session.checkout) ?? {};
|
|
207
|
+
const { totalAmount } = channelParams.aliPay ?? {};
|
|
208
|
+
const amountObj = ((totalAmount == null ? void 0 : totalAmount.amount) ? totalAmount : transAmount) || {};
|
|
209
|
+
const amountText = (amountObj == null ? void 0 : amountObj.amount) ? formatAmount(amountObj).jointSymbol() : "";
|
|
210
|
+
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
221
211
|
return /* @__PURE__ */ u(
|
|
222
212
|
SubmitButton,
|
|
223
213
|
{
|
|
@@ -235,6 +225,13 @@ const AliPay = w((props, ref) => {
|
|
|
235
225
|
formRef.current = dom;
|
|
236
226
|
dom && validateForm();
|
|
237
227
|
};
|
|
228
|
+
const formStyle = {
|
|
229
|
+
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
230
|
+
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
231
|
+
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
232
|
+
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
233
|
+
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
234
|
+
};
|
|
238
235
|
return /* @__PURE__ */ u(
|
|
239
236
|
CoreContext.Provider,
|
|
240
237
|
{
|
|
@@ -242,7 +239,7 @@ const AliPay = w((props, ref) => {
|
|
|
242
239
|
i18n,
|
|
243
240
|
session
|
|
244
241
|
},
|
|
245
|
-
children: sessionReady && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: [
|
|
242
|
+
children: sessionReady && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
246
243
|
/* @__PURE__ */ u(
|
|
247
244
|
EmailField,
|
|
248
245
|
{
|
|
@@ -257,13 +254,14 @@ const AliPay = w((props, ref) => {
|
|
|
257
254
|
{
|
|
258
255
|
ref: addressFieldRef,
|
|
259
256
|
value: form.address,
|
|
257
|
+
country: ((_g = session == null ? void 0 : session.checkout) == null ? void 0 : _g.country) || ((_h = session == null ? void 0 : session.checkout) == null ? void 0 : _h.bill.country),
|
|
260
258
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
261
259
|
}
|
|
262
260
|
),
|
|
263
261
|
(session == null ? void 0 : session.checkout.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
264
262
|
!!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
|
|
265
263
|
Button()
|
|
266
|
-
] })
|
|
264
|
+
] }) })
|
|
267
265
|
}
|
|
268
266
|
);
|
|
269
267
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { w, h, y, q, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { PaymentMethod } from "../../constant.js";
|
|
3
|
+
import { SessionMode, PaymentMethod } from "../../constant.js";
|
|
4
|
+
import "../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
|
|
4
7
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
5
8
|
import { getApplePayInfo, applePay, getMerchantSession } from "../../api/modules/apple-pay/index.js";
|
|
6
9
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
7
10
|
import "../../core/context.js";
|
|
8
|
-
import "../../utils/card-brand/brands.js";
|
|
9
|
-
import "../../utils/system-info/get-browser-info.js";
|
|
10
|
-
import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
|
|
11
11
|
import { PayKKaError } from "../../core/error.js";
|
|
12
12
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
13
13
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
@@ -43,7 +43,7 @@ async function applePayEnv(id) {
|
|
|
43
43
|
}
|
|
44
44
|
const { bem } = useBEM("apple-pay");
|
|
45
45
|
const ApplePay = w((props) => {
|
|
46
|
-
const { session } = props;
|
|
46
|
+
const { session, isDropIn } = props;
|
|
47
47
|
let applePaySession;
|
|
48
48
|
const { i18n, sessionReady, fraudDetection } = usePayState(session);
|
|
49
49
|
const [errorMsg, setErrorMsg] = h("");
|
|
@@ -52,19 +52,26 @@ const ApplePay = w((props) => {
|
|
|
52
52
|
returnUrl: session == null ? void 0 : session.checkout.returnUrl
|
|
53
53
|
});
|
|
54
54
|
y(() => {
|
|
55
|
-
var _a;
|
|
55
|
+
var _a, _b, _c;
|
|
56
56
|
if (!sessionReady) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
const { status, paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
|
|
59
|
+
const { status, paymentMethod = [], sessionMode } = (session == null ? void 0 : session.checkout) || {};
|
|
60
|
+
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
61
|
+
(_b = (_a = props.core.config).onInitError) == null ? void 0 : _b.call(
|
|
62
|
+
_a,
|
|
63
|
+
new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
|
|
64
|
+
);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
60
67
|
if (!paymentMethod.includes(PaymentMethod.APPLE_PAY)) {
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
63
70
|
loadApplePayJS(
|
|
64
71
|
async () => {
|
|
65
|
-
var _a2,
|
|
72
|
+
var _a2, _b2, _c2, _d;
|
|
66
73
|
const envSupported = await applePayEnv(
|
|
67
|
-
(
|
|
74
|
+
(_c2 = (_b2 = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.channelParams) == null ? void 0 : _b2.applePay) == null ? void 0 : _c2.merchantIdentifier
|
|
68
75
|
);
|
|
69
76
|
if (!envSupported) {
|
|
70
77
|
return;
|
|
@@ -79,7 +86,7 @@ const ApplePay = w((props) => {
|
|
|
79
86
|
}
|
|
80
87
|
);
|
|
81
88
|
if (status === "SUCCESS") {
|
|
82
|
-
(
|
|
89
|
+
(_c = props.onSuccess) == null ? void 0 : _c.call(props, getPaymentSuccessData());
|
|
83
90
|
}
|
|
84
91
|
}, [sessionReady]);
|
|
85
92
|
const onTimeout = q(
|
|
@@ -135,24 +142,19 @@ const ApplePay = w((props) => {
|
|
|
135
142
|
fraudDetectionId: fraudDetection == null ? void 0 : fraudDetection.fraudDetectionID
|
|
136
143
|
})
|
|
137
144
|
},
|
|
145
|
+
props.core,
|
|
138
146
|
{ locale: i18n.locale }
|
|
139
147
|
);
|
|
140
148
|
}());
|
|
141
149
|
const { status, orderStatus, errorMessage, errorCode } = res;
|
|
142
150
|
if (status === "PROCESSING") {
|
|
143
151
|
if (orderStatus === "SUCCESS") {
|
|
144
|
-
applePaySession.completePayment({
|
|
145
|
-
status: 0
|
|
146
|
-
});
|
|
152
|
+
applePaySession.completePayment({ status: 0 });
|
|
147
153
|
(_a = props.onSuccess) == null ? void 0 : _a.call(props, getPaymentSuccessData());
|
|
148
|
-
return {
|
|
149
|
-
end: true
|
|
150
|
-
};
|
|
154
|
+
return { end: true };
|
|
151
155
|
} else if (orderStatus === "PROCESSING") {
|
|
152
156
|
!search && await startReFetchPayInfo();
|
|
153
|
-
return {
|
|
154
|
-
end: !search
|
|
155
|
-
};
|
|
157
|
+
return { end: !search };
|
|
156
158
|
} else if (orderStatus === "FAILURE") {
|
|
157
159
|
setErrorMsg(errorMessage);
|
|
158
160
|
(_b = props.onError) == null ? void 0 : _b.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
@@ -160,45 +162,29 @@ const ApplePay = w((props) => {
|
|
|
160
162
|
status: 1,
|
|
161
163
|
errors: [new ApplePayError("unknown", void 0, errorMessage)]
|
|
162
164
|
});
|
|
163
|
-
return {
|
|
164
|
-
end: true
|
|
165
|
-
};
|
|
165
|
+
return { end: true };
|
|
166
166
|
} else if (orderStatus === "AUTHORIZED") {
|
|
167
|
-
applePaySession.completePayment({
|
|
168
|
-
status: 0
|
|
169
|
-
});
|
|
167
|
+
applePaySession.completePayment({ status: 0 });
|
|
170
168
|
(_c = props.onAuthorized) == null ? void 0 : _c.call(props);
|
|
171
|
-
return {
|
|
172
|
-
end: true
|
|
173
|
-
};
|
|
169
|
+
return { end: true };
|
|
174
170
|
} else if (!orderStatus) {
|
|
175
171
|
applePaySession.completePayment({
|
|
176
172
|
status: 1,
|
|
177
173
|
errors: [new ApplePayError("unknown", void 0, "")]
|
|
178
174
|
});
|
|
179
|
-
return {
|
|
180
|
-
end: true
|
|
181
|
-
};
|
|
175
|
+
return { end: true };
|
|
182
176
|
}
|
|
183
177
|
} else if (status === "SUCCESS") {
|
|
184
178
|
(_d = props.onSuccess) == null ? void 0 : _d.call(props, getPaymentSuccessData());
|
|
185
|
-
applePaySession.completePayment({
|
|
186
|
-
|
|
187
|
-
});
|
|
188
|
-
return {
|
|
189
|
-
end: true
|
|
190
|
-
};
|
|
179
|
+
applePaySession.completePayment({ status: 0 });
|
|
180
|
+
return { end: true };
|
|
191
181
|
} else if (status === "EXPIRED") {
|
|
192
182
|
(_e = props.onExpired) == null ? void 0 : _e.call(props);
|
|
193
183
|
applePaySession.abort();
|
|
194
|
-
return {
|
|
195
|
-
end: true
|
|
196
|
-
};
|
|
184
|
+
return { end: true };
|
|
197
185
|
}
|
|
198
186
|
(_f = props.onSuccess) == null ? void 0 : _f.call(props, getPaymentSuccessData());
|
|
199
|
-
return {
|
|
200
|
-
end: true
|
|
201
|
-
};
|
|
187
|
+
return { end: true };
|
|
202
188
|
} catch (error) {
|
|
203
189
|
if (isTimeoutError(error)) {
|
|
204
190
|
if (search) {
|