@paykka/card-checkout-ui 0.11.6 → 0.13.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 +19 -19
- package/dist/card-checkout-ui.umd.cjs +19 -19
- package/dist/es/_commonjsHelpers.js +82 -1
- package/dist/es/api/index.js +1 -0
- package/dist/es/api/modules/address/index.js +9 -9
- package/dist/es/api/modules/ali-pay/index.js +10 -49
- package/dist/es/api/modules/apple-pay/index.js +13 -59
- package/dist/es/api/modules/boost/index.js +8 -48
- package/dist/es/api/modules/card/index.js +10 -54
- package/dist/es/api/modules/checkout/index.js +11 -9
- package/dist/es/api/modules/checkout/map.js +25 -18
- package/dist/es/api/modules/encrypted-card/index.js +3 -2
- package/dist/es/api/modules/gcash/index.js +8 -48
- package/dist/es/api/modules/get-browser-params.js +4 -1
- package/dist/es/api/modules/google-pay/index.js +10 -56
- package/dist/es/api/modules/grab-pay/index.js +8 -48
- package/dist/es/api/modules/index.js +1 -0
- package/dist/es/api/modules/line-pay/index.js +8 -48
- package/dist/es/api/modules/map.js +17 -11
- package/dist/es/api/modules/may-bank-qr-pay/index.js +8 -48
- package/dist/es/api/modules/nine-pay/index.js +8 -48
- package/dist/es/api/modules/paymaya/index.js +8 -48
- package/dist/es/api/modules/risk/index.js +2 -1
- package/dist/es/api/modules/sepa/index.js +10 -51
- package/dist/es/api/modules/shopee-pay/index.js +8 -48
- package/dist/es/api/modules/threeDS/index.js +3 -0
- package/dist/es/api/modules/tng-wallet/index.js +8 -48
- package/dist/es/api/modules/wechat-pay/index.js +10 -51
- package/dist/es/api/modules/zalopay/index.js +16 -0
- package/dist/es/api/utils/index.js +59 -0
- package/dist/es/components/AddressField/index.js +37 -37
- package/dist/es/components/AliPay/index.js +158 -111
- package/dist/es/components/ApplePay/index.js +99 -67
- package/dist/es/components/Boost/index.js +91 -70
- package/dist/es/components/Card/index.js +114 -107
- package/dist/es/components/CardSelector/index.js +1 -1
- package/dist/es/components/DropIn/index.js +12 -4
- package/dist/es/components/EncryptedCard/index.js +6 -2
- package/dist/es/components/GooglePay/index.js +94 -60
- package/dist/es/components/GrabPay/index.js +91 -70
- package/dist/es/components/GuideCard/index.js +10 -7
- package/dist/es/components/LinePay/index.js +91 -70
- package/dist/es/components/MayBankQRPay/index.js +302 -275
- package/dist/es/components/NinePay/index.js +91 -70
- package/dist/es/components/SecuredFieldsProvider/index.js +26 -9
- package/dist/es/components/SecuredIframe/index.js +40 -61
- package/dist/es/components/Sepa/index.js +72 -53
- package/dist/es/components/ShopeePay/index.js +91 -70
- package/dist/es/components/SubmitButton/index.js +8 -7
- package/dist/es/components/TNGWallet/index.js +91 -70
- package/dist/es/components/ThreeDS/index.js +32 -7
- package/dist/es/components/WechatPay/index.js +151 -102
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
- package/dist/es/components/index.js +1 -0
- package/dist/es/components/internal/Form/FormItem.js +1 -1
- package/dist/es/components/internal/Form/util.js +1 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Select/Select.js +19 -8
- package/dist/es/components/internal/Select/SelectMenu.js +2 -2
- package/dist/es/components/internal/Select/SelectMenuItem.js +12 -4
- package/dist/es/components/internal/icons/IconError.js +7 -4
- package/dist/es/components/internal/icons/IconZalopay.js +47 -0
- package/dist/es/components/internal/icons/IconZalopayComplete.js +48 -0
- package/dist/es/components/wallets/GCash/GCash.js +80 -56
- package/dist/es/components/wallets/Paymaya/Paymaya.js +91 -70
- package/dist/es/components/wallets/Zalopay/Zalopay.js +381 -0
- package/dist/es/components/wallets/Zalopay/index.js +1 -0
- package/dist/es/components/wallets/Zalopay/type.js +1 -0
- package/dist/es/components/wallets/Zalopay/zalopay2.js +1 -0
- package/dist/es/config.js +5 -5
- package/dist/es/constant.js +8 -2
- package/dist/es/core/{Address.js → address.js} +8 -16
- package/dist/es/core/{PayKKaCheckout.js → checkout.js} +101 -27
- package/dist/es/core/create.js +1 -1
- package/dist/es/core/query.js +3 -2
- package/dist/es/core/{Session.js → session.js} +28 -32
- package/dist/es/core/theme.js +65 -0
- package/dist/es/core.js +0 -4
- package/dist/es/hooks/usePayment.js +14 -0
- package/dist/es/i18n/locales/de-DE.js +3 -1
- package/dist/es/i18n/locales/en-GB.js +3 -1
- package/dist/es/i18n/locales/es-ES.js +3 -1
- package/dist/es/i18n/locales/fr-FR.js +3 -1
- package/dist/es/i18n/locales/ja-JP.js +3 -1
- package/dist/es/i18n/locales/ko-KR.js +3 -1
- package/dist/es/i18n/locales/nl-NL.js +3 -1
- package/dist/es/i18n/locales/pt-PT.js +3 -1
- package/dist/es/i18n/locales/ru-RU.js +3 -1
- package/dist/es/i18n/locales/zh-CN.js +3 -1
- package/dist/es/i18n/locales/zh-HK.js +3 -1
- package/dist/es/i18n/locales/zh-TW.js +3 -1
- package/dist/es/index.js +21 -7
- package/dist/es/style.css +1 -1
- package/dist/es/types/index.js +7 -0
- package/dist/es/utils/colors.js +5 -1
- package/dist/es/utils/format.js +0 -5
- package/dist/es/utils/object.js +31 -1
- package/dist/es/utils/payment.js +82 -0
- package/dist/es/utils/redirect.js +4 -4
- package/dist/es/utils/string.js +10 -0
- package/dist/es/utils/system-info/is-ua-webview.js +14 -12
- package/dist/es/utils/theme.js +7 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/address/index.d.ts +15 -6
- package/dist/types/api/modules/ali-pay/index.d.ts +3 -19
- package/dist/types/api/modules/apple-pay/index.d.ts +4 -14
- package/dist/types/api/modules/boost/index.d.ts +3 -23
- package/dist/types/api/modules/card/index.d.ts +3 -30
- package/dist/types/api/modules/checkout/index.d.ts +3 -3
- package/dist/types/api/modules/checkout/map.d.ts +3 -3
- package/dist/types/api/modules/checkout/type.d.ts +33 -4
- package/dist/types/api/modules/gcash/index.d.ts +3 -23
- package/dist/types/api/modules/get-browser-params.d.ts +1 -0
- package/dist/types/api/modules/google-pay/index.d.ts +3 -13
- package/dist/types/api/modules/grab-pay/index.d.ts +3 -23
- package/dist/types/api/modules/index.d.ts +1 -0
- package/dist/types/api/modules/line-pay/index.d.ts +3 -23
- package/dist/types/api/modules/map.d.ts +2 -2
- package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +3 -23
- package/dist/types/api/modules/nine-pay/index.d.ts +3 -23
- package/dist/types/api/modules/paymaya/index.d.ts +3 -23
- package/dist/types/api/modules/sepa/index.d.ts +3 -24
- package/dist/types/api/modules/shopee-pay/index.d.ts +3 -23
- package/dist/types/api/modules/tng-wallet/index.d.ts +3 -23
- package/dist/types/api/modules/type.d.ts +74 -21
- package/dist/types/api/modules/wechat-pay/index.d.ts +3 -20
- package/dist/types/api/modules/zalopay/index.d.ts +4 -0
- package/dist/types/api/utils/index.d.ts +48 -0
- package/dist/types/components/AddressField/type.d.ts +3 -9
- package/dist/types/components/AliPay/AliPay.d.ts +6 -2
- package/dist/types/components/AliPay/type.d.ts +15 -2
- package/dist/types/components/ApplePay/ApplePay.d.ts +6 -2
- package/dist/types/components/ApplePay/type.d.ts +10 -14
- package/dist/types/components/ApplePay/utils.d.ts +1 -1
- package/dist/types/components/Boost/Boost.d.ts +6 -2
- package/dist/types/components/Boost/type.d.ts +2 -24
- package/dist/types/components/Card/Card.d.ts +6 -2
- package/dist/types/components/Card/type.d.ts +3 -43
- package/dist/types/components/DropIn/DropIn.d.ts +6 -2
- package/dist/types/components/DropIn/type.d.ts +4 -10
- package/dist/types/components/GooglePay/GooglePay.d.ts +6 -2
- package/dist/types/components/GooglePay/createGooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +10 -26
- package/dist/types/components/GrabPay/GrabPay.d.ts +6 -2
- package/dist/types/components/GrabPay/type.d.ts +3 -25
- package/dist/types/components/LinePay/LinePay.d.ts +6 -2
- package/dist/types/components/LinePay/type.d.ts +3 -25
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -2
- package/dist/types/components/MayBankQRPay/type.d.ts +3 -25
- package/dist/types/components/NinePay/NinePay.d.ts +6 -2
- package/dist/types/components/NinePay/type.d.ts +3 -25
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +5 -0
- package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +3 -1
- package/dist/types/components/Sepa/Sepa.d.ts +6 -2
- package/dist/types/components/Sepa/type.d.ts +3 -2
- package/dist/types/components/ShopeePay/ShopeePay.d.ts +6 -2
- package/dist/types/components/ShopeePay/type.d.ts +3 -25
- package/dist/types/components/TNGWallet/TNGWallet.d.ts +6 -2
- package/dist/types/components/TNGWallet/type.d.ts +3 -25
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +2 -0
- package/dist/types/components/WechatPay/WechatPay.d.ts +6 -2
- package/dist/types/components/WechatPay/type.d.ts +15 -2
- package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Select/SelectMenu.d.ts +1 -1
- package/dist/types/components/internal/icons/IconZalopay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconZalopayComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +3 -0
- package/dist/types/components/wallets/GCash/GCash.d.ts +6 -2
- package/dist/types/components/wallets/GCash/type.d.ts +3 -35
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -2
- package/dist/types/components/wallets/Paymaya/type.d.ts +3 -25
- package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +10 -0
- package/dist/types/components/wallets/Zalopay/index.d.ts +2 -0
- package/dist/types/components/wallets/Zalopay/type.d.ts +39 -0
- package/dist/types/config.d.ts +2 -4
- package/dist/types/constant.d.ts +3 -1
- package/dist/types/core/{Address.d.ts → address.d.ts} +23 -24
- package/dist/types/core/{PayKKaCheckout.d.ts → checkout.d.ts} +9 -3
- package/dist/types/core/context.d.ts +3 -2
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/core/session.d.ts +23 -0
- package/dist/types/core/theme.d.ts +7 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/usePayment.d.ts +8 -0
- package/dist/types/i18n/locales/de-DE.d.ts +2 -0
- package/dist/types/i18n/locales/en-GB.d.ts +2 -0
- package/dist/types/i18n/locales/es-ES.d.ts +2 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +2 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +2 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +2 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +2 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +2 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +2 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +2 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +2 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts +70 -32
- package/dist/types/types/message.d.ts +30 -25
- package/dist/types/utils/card-brand/index.d.ts +3 -3
- package/dist/types/utils/colors.d.ts +1 -0
- package/dist/types/utils/index.d.ts +4 -2
- package/dist/types/utils/object.d.ts +7 -0
- package/dist/types/utils/payment.d.ts +37 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/style.d.ts +1 -1
- package/dist/types/utils/system-info/is-ua-webview.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +4 -0
- package/package.json +3 -3
- package/dist/es/utils/deep-freeze.js +0 -13
- package/dist/es/utils/obj.js +0 -22
- package/dist/types/core/Session.d.ts +0 -16
- package/dist/types/utils/deep-freeze.d.ts +0 -1
- package/dist/types/utils/obj.d.ts +0 -6
|
@@ -3,18 +3,17 @@ import { useBEM } from "../../hooks/useBEM.js";
|
|
|
3
3
|
import { CoreContext } from "../../core/context.js";
|
|
4
4
|
import "../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import {
|
|
6
|
+
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
7
|
import { redirectToPayment } from "../../utils/redirect.js";
|
|
8
|
+
import { formatPaymentResult } from "../../utils/payment.js";
|
|
8
9
|
import { isTimeoutError } from "../../api/http.js";
|
|
9
|
-
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../constant.js";
|
|
10
10
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
11
|
+
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../constant.js";
|
|
11
12
|
import { getNinePayInfo, ninePay } from "../../api/modules/nine-pay/index.js";
|
|
12
13
|
import { PayKKaError } from "../../core/error.js";
|
|
13
|
-
import { hidePaymentButton } from "../../config.js";
|
|
14
14
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
15
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
16
|
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
17
|
-
import { createAddressCore } from "../../core/Address.js";
|
|
18
17
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
19
18
|
import "../internal/Form/type.js";
|
|
20
19
|
import "../internal/Form/context.js";
|
|
@@ -26,7 +25,6 @@ import { GuideCard } from "../GuideCard/index.js";
|
|
|
26
25
|
const { bem } = useBEM("nine-pay");
|
|
27
26
|
const fieldClassNames = bem("field");
|
|
28
27
|
const NinePay = w((props, ref) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
28
|
const {
|
|
31
29
|
session,
|
|
32
30
|
showEmail = false,
|
|
@@ -34,7 +32,8 @@ const NinePay = w((props, ref) => {
|
|
|
34
32
|
redirectMode = "auto",
|
|
35
33
|
core,
|
|
36
34
|
autoQuery,
|
|
37
|
-
showGuideCard = true
|
|
35
|
+
showGuideCard = true,
|
|
36
|
+
hidePaymentButton = false
|
|
38
37
|
} = props;
|
|
39
38
|
F(ref, () => ({
|
|
40
39
|
stopRetry: () => {
|
|
@@ -46,26 +45,28 @@ const NinePay = w((props, ref) => {
|
|
|
46
45
|
startReFetchPayInfo({ timeout });
|
|
47
46
|
},
|
|
48
47
|
updateAddress: () => {
|
|
49
|
-
var
|
|
48
|
+
var _a;
|
|
50
49
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
51
50
|
return;
|
|
52
|
-
|
|
53
|
-
(
|
|
51
|
+
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
52
|
+
setForm(newForm);
|
|
53
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
54
|
+
validateForm();
|
|
54
55
|
},
|
|
55
56
|
updateEmail: () => {
|
|
56
|
-
var
|
|
57
|
+
var _a;
|
|
57
58
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
58
59
|
return;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(
|
|
60
|
+
const newForm = Object.assign(form, { email: emailState.email });
|
|
61
|
+
setForm(newForm);
|
|
62
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
62
63
|
validateForm();
|
|
63
64
|
},
|
|
64
65
|
payment: () => {
|
|
65
66
|
hidePaymentButton && onSubmit();
|
|
66
67
|
}
|
|
67
68
|
}));
|
|
68
|
-
const
|
|
69
|
+
const addressCore = core.getAddressCore();
|
|
69
70
|
const emailState = createEmailCore();
|
|
70
71
|
const addressFieldRef = A(null);
|
|
71
72
|
const emailFieldRef = A(null);
|
|
@@ -76,13 +77,13 @@ const NinePay = w((props, ref) => {
|
|
|
76
77
|
const [form, setForm] = h({
|
|
77
78
|
email: "",
|
|
78
79
|
address: {
|
|
79
|
-
country:
|
|
80
|
-
province:
|
|
81
|
-
city:
|
|
82
|
-
area:
|
|
83
|
-
postCode:
|
|
84
|
-
address1:
|
|
85
|
-
address2:
|
|
80
|
+
country: void 0,
|
|
81
|
+
province: void 0,
|
|
82
|
+
city: void 0,
|
|
83
|
+
area: void 0,
|
|
84
|
+
postCode: void 0,
|
|
85
|
+
address1: void 0,
|
|
86
|
+
address2: void 0
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
const [validated, setValidated] = h(false);
|
|
@@ -100,33 +101,43 @@ const NinePay = w((props, ref) => {
|
|
|
100
101
|
}
|
|
101
102
|
setFieldStatus({ ...field });
|
|
102
103
|
};
|
|
104
|
+
const processOnSuccess = (res) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
setSubmitButtonStatus("success");
|
|
107
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
108
|
+
...res,
|
|
109
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
103
112
|
y(() => {
|
|
104
113
|
if (!sessionReady) {
|
|
105
114
|
return;
|
|
106
115
|
}
|
|
107
|
-
const { bill = {},
|
|
108
|
-
if (!
|
|
116
|
+
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
117
|
+
if (!supportMethods.includes(PaymentMethod.NINE_PAY)) {
|
|
109
118
|
return;
|
|
110
119
|
}
|
|
111
120
|
setIsCheckoutEnabled(true);
|
|
112
121
|
initFieldStatus();
|
|
122
|
+
country && addressCore.setCountry(country);
|
|
113
123
|
form.email = bill.email ?? "";
|
|
124
|
+
form.address.country = country;
|
|
114
125
|
if (autoQuery && core.processingPaymentMethod === PaymentMethod.NINE_PAY) {
|
|
115
126
|
setSubmitButtonStatus("loading");
|
|
116
127
|
startReFetchPayInfo();
|
|
117
128
|
}
|
|
118
129
|
}, [sessionReady]);
|
|
119
130
|
const processOnError = (error) => {
|
|
120
|
-
var
|
|
121
|
-
(
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, error);
|
|
122
133
|
core.resetEnablePaymentMethod();
|
|
123
134
|
};
|
|
124
135
|
const onTimeout = q(
|
|
125
136
|
(message) => {
|
|
126
|
-
var
|
|
137
|
+
var _a;
|
|
127
138
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
128
139
|
setSubmitButtonStatus("unSubmit");
|
|
129
|
-
(
|
|
140
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props);
|
|
130
141
|
core.resetEnablePaymentMethod();
|
|
131
142
|
},
|
|
132
143
|
[i18n, props.onTimeout]
|
|
@@ -144,34 +155,49 @@ const NinePay = w((props, ref) => {
|
|
|
144
155
|
},
|
|
145
156
|
bill: {
|
|
146
157
|
email: form.email,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
addressLine1: form.address.address1,
|
|
159
|
+
addressLine2: form.address.address2,
|
|
160
|
+
postalCode: form.address.postCode,
|
|
161
|
+
country: form.address.country,
|
|
162
|
+
district: form.address.area,
|
|
163
|
+
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
164
|
+
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
150
165
|
},
|
|
151
166
|
browser: await getBrowserParams()
|
|
152
167
|
};
|
|
153
168
|
};
|
|
154
169
|
const pay = async (search = false, timeout) => {
|
|
155
|
-
var
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
156
171
|
try {
|
|
157
|
-
const paymentParams = await getPaymentParams();
|
|
158
172
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
173
|
+
let res = null;
|
|
174
|
+
if (search) {
|
|
175
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.NINE_PAY);
|
|
176
|
+
res = await getNinePayInfo(
|
|
177
|
+
{
|
|
178
|
+
sessionId: session.sessionId,
|
|
179
|
+
clientKey: session.clientKey,
|
|
180
|
+
paymentMethod: PaymentMethod.NINE_PAY
|
|
181
|
+
},
|
|
182
|
+
extraParams,
|
|
183
|
+
requestOptions
|
|
184
|
+
);
|
|
185
|
+
} else {
|
|
186
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.NINE_PAY);
|
|
187
|
+
res = await ninePay(await getPaymentParams(), extraParams, requestOptions);
|
|
188
|
+
}
|
|
189
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
190
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
191
|
+
sessionId && (session.sessionId = sessionId);
|
|
165
192
|
if (status === "PROCESSING") {
|
|
166
193
|
if (!orderStatus) {
|
|
167
194
|
setSubmitButtonStatus("unSubmit");
|
|
168
195
|
return { end: true };
|
|
169
196
|
} else if (orderStatus === "SUCCESS") {
|
|
170
|
-
|
|
171
|
-
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
197
|
+
processOnSuccess(res);
|
|
172
198
|
return { end: true };
|
|
173
199
|
} else if (orderStatus === "FAILURE") {
|
|
174
|
-
setErrorMsg(errorMessage);
|
|
200
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
175
201
|
setSubmitButtonStatus("unSubmit");
|
|
176
202
|
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
177
203
|
return { end: true };
|
|
@@ -187,17 +213,16 @@ const NinePay = w((props, ref) => {
|
|
|
187
213
|
return { end: false };
|
|
188
214
|
} else if (orderStatus === "CANCELED") {
|
|
189
215
|
setSubmitButtonStatus("unSubmit");
|
|
190
|
-
(
|
|
216
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
191
217
|
core.resetEnablePaymentMethod();
|
|
192
218
|
return { end: true };
|
|
193
219
|
}
|
|
194
220
|
} else if (status === "SUCCESS") {
|
|
195
|
-
|
|
196
|
-
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
221
|
+
processOnSuccess(res);
|
|
197
222
|
return { end: true };
|
|
198
223
|
} else if (status === "EXPIRED") {
|
|
199
224
|
setSubmitButtonStatus("unSubmit");
|
|
200
|
-
(
|
|
225
|
+
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
201
226
|
return { end: true };
|
|
202
227
|
}
|
|
203
228
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -212,7 +237,7 @@ const NinePay = w((props, ref) => {
|
|
|
212
237
|
}
|
|
213
238
|
} else {
|
|
214
239
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
215
|
-
setErrorMsg(message);
|
|
240
|
+
message && setErrorMsg(message);
|
|
216
241
|
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
217
242
|
setSubmitButtonStatus("unSubmit");
|
|
218
243
|
return { end: true };
|
|
@@ -220,8 +245,8 @@ const NinePay = w((props, ref) => {
|
|
|
220
245
|
}
|
|
221
246
|
};
|
|
222
247
|
const validateForm = () => {
|
|
223
|
-
var
|
|
224
|
-
(
|
|
248
|
+
var _a;
|
|
249
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
225
250
|
setValidated(true);
|
|
226
251
|
}).catch(() => {
|
|
227
252
|
setValidated(false);
|
|
@@ -231,12 +256,12 @@ const NinePay = w((props, ref) => {
|
|
|
231
256
|
validateForm();
|
|
232
257
|
}, [form]);
|
|
233
258
|
const onSubmit = async () => {
|
|
234
|
-
var
|
|
259
|
+
var _a;
|
|
235
260
|
setErrorMsg("");
|
|
236
|
-
(
|
|
237
|
-
var
|
|
238
|
-
(fieldStatus == null ? void 0 : fieldStatus.address.show) &&
|
|
239
|
-
(
|
|
261
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
262
|
+
var _a2;
|
|
263
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
264
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
240
265
|
if (errors) {
|
|
241
266
|
setSubmitButtonStatus("unSubmit");
|
|
242
267
|
return;
|
|
@@ -251,8 +276,8 @@ const NinePay = w((props, ref) => {
|
|
|
251
276
|
dom && validateForm();
|
|
252
277
|
};
|
|
253
278
|
const Button = () => {
|
|
254
|
-
var
|
|
255
|
-
const transAmount = (
|
|
279
|
+
var _a;
|
|
280
|
+
const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
|
|
256
281
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
257
282
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
258
283
|
return /* @__PURE__ */ u(
|
|
@@ -278,24 +303,17 @@ const NinePay = w((props, ref) => {
|
|
|
278
303
|
}
|
|
279
304
|
) }) });
|
|
280
305
|
};
|
|
281
|
-
const formStyle = {
|
|
282
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
283
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
284
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
285
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
286
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
287
|
-
};
|
|
288
306
|
const ErrorMessage = () => {
|
|
289
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
307
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
290
308
|
};
|
|
291
309
|
const Address = () => {
|
|
292
|
-
var
|
|
310
|
+
var _a, _b;
|
|
293
311
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
294
312
|
AddressField,
|
|
295
313
|
{
|
|
296
314
|
ref: addressFieldRef,
|
|
297
315
|
value: form.address,
|
|
298
|
-
country: ((
|
|
316
|
+
country: ((_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
|
|
299
317
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
300
318
|
}
|
|
301
319
|
) }) });
|
|
@@ -305,15 +323,18 @@ const NinePay = w((props, ref) => {
|
|
|
305
323
|
{
|
|
306
324
|
value: {
|
|
307
325
|
i18n,
|
|
308
|
-
session
|
|
326
|
+
session,
|
|
327
|
+
core
|
|
309
328
|
},
|
|
310
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
329
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
311
330
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.NINE_PAY }),
|
|
312
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
331
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
313
332
|
Email(),
|
|
314
333
|
Address(),
|
|
315
|
-
|
|
316
|
-
|
|
334
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
335
|
+
ErrorMessage(),
|
|
336
|
+
!hidePaymentButton && Button()
|
|
337
|
+
] })
|
|
317
338
|
] }) })
|
|
318
339
|
] })
|
|
319
340
|
}
|
|
@@ -8,7 +8,7 @@ import "../../utils/card-brand/brands.js";
|
|
|
8
8
|
import "../../utils/system-info/get-browser-info.js";
|
|
9
9
|
import { w, A, F, y, q, u } from "../../core.js";
|
|
10
10
|
import { SessionMode } from "../../constant.js";
|
|
11
|
-
import { cdnUrl, cdnOrigin, apiUrl } from "../../config.js";
|
|
11
|
+
import { cdnUrl, cdnOrigin, apiUrl, apiPrefix } from "../../config.js";
|
|
12
12
|
import { MessageAction } from "../../types/message.js";
|
|
13
13
|
import { createIframe, postMessageToIframe } from "../../utils/iframe.js";
|
|
14
14
|
import { safeParse } from "../../utils/index.js";
|
|
@@ -21,6 +21,8 @@ var EFieldType = /* @__PURE__ */ ((EFieldType2) => {
|
|
|
21
21
|
const SECURED_FILED_ATTR = "data-sf";
|
|
22
22
|
const SECURED_IFRAME_CLASS_NAME = "secured-iframe";
|
|
23
23
|
const HIDDEN_IFRAME_NAME = "hidden-pay-iframe";
|
|
24
|
+
const FIELD_IFRAME_NAME = "field-pay-iframe";
|
|
25
|
+
const THREE_DS_IFRAME_NAME = "three-ds-iframe";
|
|
24
26
|
const getFieldElements = (rootNode) => {
|
|
25
27
|
return rootNode ? Array.prototype.slice.call(rootNode.querySelectorAll(`[${SECURED_FILED_ATTR}]`)) : [];
|
|
26
28
|
};
|
|
@@ -35,11 +37,12 @@ class SecuredField {
|
|
|
35
37
|
}
|
|
36
38
|
/** 初始化表单区域iframe */
|
|
37
39
|
init() {
|
|
38
|
-
const { iframeSrc, iframeClassName, fieldNode } = this.config;
|
|
40
|
+
const { iframeSrc, iframeClassName, fieldNode, iframeName } = this.config;
|
|
39
41
|
const iframeEl = createIframe(iframeSrc);
|
|
40
42
|
iframeEl.width = "100%";
|
|
41
43
|
iframeEl.height = "100%";
|
|
42
44
|
iframeEl.style.border = "none";
|
|
45
|
+
iframeEl.name = iframeName;
|
|
43
46
|
fieldNode.appendChild(iframeEl);
|
|
44
47
|
const iframe = fieldNode.querySelector(`.${iframeClassName}`);
|
|
45
48
|
if (!iframe) {
|
|
@@ -51,10 +54,12 @@ class SecuredField {
|
|
|
51
54
|
/** 表单区域iframe加载回调 */
|
|
52
55
|
onFieldIframeLoad() {
|
|
53
56
|
this.iframeWindow = this.iframe.contentWindow;
|
|
54
|
-
const { fieldType, placeholder, style, hiddenIframeName, supportedCardBrands } = this.config;
|
|
57
|
+
const { fieldType, placeholder, style, hiddenIframeName, supportedCardBrands, checkoutId } = this.config;
|
|
55
58
|
const data = {
|
|
56
59
|
action: MessageAction.INIT,
|
|
60
|
+
checkoutId,
|
|
57
61
|
config: {
|
|
62
|
+
checkoutId,
|
|
58
63
|
fieldType,
|
|
59
64
|
placeholder,
|
|
60
65
|
style,
|
|
@@ -68,12 +73,13 @@ class SecuredField {
|
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
const SecuredFieldsProvider = w((props, ref) => {
|
|
71
|
-
const { sessionMode, i18n, targetElement } = props;
|
|
76
|
+
const { sessionMode, i18n, targetElement, checkoutId } = props;
|
|
72
77
|
const rootNodeRef = A(null);
|
|
73
78
|
const hiddenIframe = A(null);
|
|
74
79
|
const payment = (formData, extraParams) => {
|
|
75
80
|
const data = {
|
|
76
81
|
action: MessageAction.PAYMENT,
|
|
82
|
+
checkoutId,
|
|
77
83
|
formData,
|
|
78
84
|
extraParams,
|
|
79
85
|
locale: props.i18n.locale
|
|
@@ -102,7 +108,8 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
102
108
|
validate: () => {
|
|
103
109
|
Object.values(securedFieldMap.current).forEach((field) => {
|
|
104
110
|
const data = {
|
|
105
|
-
action: MessageAction.VALIDATE
|
|
111
|
+
action: MessageAction.VALIDATE,
|
|
112
|
+
checkoutId
|
|
106
113
|
};
|
|
107
114
|
postMessageToIframe(data, field.iframe.contentWindow, cdnOrigin);
|
|
108
115
|
});
|
|
@@ -135,7 +142,7 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
135
142
|
};
|
|
136
143
|
const initHiddenIframe = async () => {
|
|
137
144
|
const iframeEl = createIframe(`${cdnUrl}/secured-iframe.html`);
|
|
138
|
-
iframeEl.name = `${HIDDEN_IFRAME_NAME}-${Date.now()}`;
|
|
145
|
+
iframeEl.name = `${HIDDEN_IFRAME_NAME}-${checkoutId}-${Date.now()}`;
|
|
139
146
|
iframeEl.width = "0";
|
|
140
147
|
iframeEl.height = "0";
|
|
141
148
|
iframeEl.style.border = "none";
|
|
@@ -143,8 +150,10 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
143
150
|
const data = {
|
|
144
151
|
action: MessageAction.INIT,
|
|
145
152
|
hidden: true,
|
|
153
|
+
checkoutId,
|
|
146
154
|
apiUrl,
|
|
147
|
-
cdnUrl
|
|
155
|
+
cdnUrl,
|
|
156
|
+
apiPrefix
|
|
148
157
|
};
|
|
149
158
|
iframeEl.addEventListener("load", () => {
|
|
150
159
|
postMessageToIframe(data, hiddenIframe.current.contentWindow, cdnOrigin);
|
|
@@ -160,6 +169,7 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
160
169
|
hiddenIframeName: hiddenIframe.current.name,
|
|
161
170
|
rootNode: rootNodeRef.current,
|
|
162
171
|
iframeSrc: `${cdnUrl}/secured-iframe.html`,
|
|
172
|
+
iframeName: `${FIELD_IFRAME_NAME}-${checkoutId}-${Date.now()}`,
|
|
163
173
|
iframeClassName: SECURED_IFRAME_CLASS_NAME,
|
|
164
174
|
fieldType,
|
|
165
175
|
placeholder: securedFieldPlaceholderMap[fieldType],
|
|
@@ -170,7 +180,8 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
170
180
|
onAfterPayment: props.onAfterPayment,
|
|
171
181
|
onPaymentError: props.onPaymentError,
|
|
172
182
|
onPaymentTimeout: props.onPaymentTimeout,
|
|
173
|
-
onValidStatusChanged: props.onValidStatusChanged
|
|
183
|
+
onValidStatusChanged: props.onValidStatusChanged,
|
|
184
|
+
checkoutId
|
|
174
185
|
});
|
|
175
186
|
});
|
|
176
187
|
};
|
|
@@ -184,6 +195,10 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
184
195
|
if (!Reflect.has(feedbackData, "action")) {
|
|
185
196
|
return;
|
|
186
197
|
}
|
|
198
|
+
console.log(feedbackData, checkoutId);
|
|
199
|
+
if (feedbackData.checkoutId !== checkoutId) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
187
202
|
switch (feedbackData.action) {
|
|
188
203
|
case MessageAction.FOCUS:
|
|
189
204
|
(_a = props.onFocus) == null ? void 0 : _a.call(props, feedbackData);
|
|
@@ -227,8 +242,10 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
227
242
|
});
|
|
228
243
|
export {
|
|
229
244
|
EFieldType,
|
|
245
|
+
FIELD_IFRAME_NAME,
|
|
230
246
|
HIDDEN_IFRAME_NAME,
|
|
231
247
|
SECURED_FILED_ATTR,
|
|
232
248
|
SECURED_IFRAME_CLASS_NAME,
|
|
233
|
-
SecuredFieldsProvider
|
|
249
|
+
SecuredFieldsProvider,
|
|
250
|
+
THREE_DS_IFRAME_NAME
|
|
234
251
|
};
|