@paykka/card-checkout-ui 0.13.17 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-checkout-ui.js +53 -25
- package/dist/card-checkout-ui.umd.cjs +53 -25
- package/dist/es/api/modules/boost/index.js +5 -16
- package/dist/es/api/modules/gcash/index.js +5 -16
- package/dist/es/api/modules/get-browser-params.js +1 -4
- package/dist/es/api/modules/grab-pay/index.js +5 -16
- package/dist/es/api/modules/line-pay/index.js +5 -16
- package/dist/es/api/modules/may-bank-qr-pay/index.js +5 -16
- package/dist/es/api/modules/nine-pay/index.js +5 -16
- package/dist/es/api/modules/opay-wallet/index.js +5 -16
- package/dist/es/api/modules/paga-wallet/index.js +5 -16
- package/dist/es/api/modules/paymaya/index.js +5 -16
- package/dist/es/api/modules/shopee-pay/index.js +5 -16
- package/dist/es/api/modules/threeDS/index.js +16 -2
- package/dist/es/api/modules/tng-wallet/index.js +5 -16
- package/dist/es/api/modules/zalopay/index.js +5 -16
- package/dist/es/components/AccordionItem/AccordionItem.js +0 -2
- package/dist/es/components/AddressField/index.js +13 -3
- package/dist/es/components/AliPay/index.js +64 -62
- package/dist/es/components/ApplePay/index.js +42 -39
- package/dist/es/components/CPFField/index.js +2 -1
- package/dist/es/components/Card/index.js +160 -133
- package/dist/es/components/CardExpireDateField/index.js +2 -1
- package/dist/es/components/CardNo/index.js +2 -2
- package/dist/es/components/CardNumberField/index.js +2 -1
- package/dist/es/components/CardSecurityCodeField/index.js +2 -1
- package/dist/es/components/CardSelector/index.js +3 -2
- package/dist/es/components/DropIn/index.js +24 -21
- package/dist/es/components/GooglePay/index.js +97 -88
- package/dist/es/components/PaymentButton/index.js +1 -1
- package/dist/es/components/SecuredFieldsProvider/index.js +31 -9
- package/dist/es/components/SecuredIframe/index.js +40 -23
- package/dist/es/components/SubmitButton/index.js +1 -1
- package/dist/es/components/ThreeDS/index.js +29 -12
- package/dist/es/components/WechatPay/index.js +70 -69
- package/dist/es/components/business/PhoneField/PhoneField.js +1 -0
- package/dist/es/components/index.js +7 -7
- package/dist/es/components/internal/CheckBox/CheckBox.js +2 -2
- package/dist/es/components/internal/Input/Input.js +1 -1
- package/dist/es/components/internal/Select/Select.js +4 -1
- package/dist/es/components/internal/icons/IconArrowDown.js +4 -4
- package/dist/es/components/internal/icons/IconBancontact.js +69 -14
- package/dist/es/components/internal/icons/IconBlik.js +541 -21
- package/dist/es/components/internal/icons/IconIdeal.js +61 -29
- package/dist/es/components/internal/icons/IconSkrill.js +14 -7
- package/dist/es/components/internal/icons/IconTrustly.js +11 -44
- package/dist/es/components/wallets/Bancontact/Bancontact.js +11 -8
- package/dist/es/components/wallets/Blik/Blik.js +12 -9
- package/dist/es/components/wallets/Boost/Boost.js +183 -0
- package/dist/es/components/wallets/Boost/boost2.js +1 -0
- package/dist/es/components/wallets/Boost/index.js +1 -0
- package/dist/es/components/wallets/Boost/type.js +1 -0
- package/dist/es/components/wallets/GCash/GCash.js +62 -252
- package/dist/es/components/wallets/GrabPay/GrabPay.js +183 -0
- package/dist/es/components/wallets/GrabPay/grab-pay.js +1 -0
- package/dist/es/components/wallets/GrabPay/index.js +1 -0
- package/dist/es/components/wallets/GrabPay/type.js +1 -0
- package/dist/es/components/wallets/IDeal/IDeal.js +11 -8
- package/dist/es/components/wallets/LinePay/LinePay.js +183 -0
- package/dist/es/components/wallets/LinePay/index.js +1 -0
- package/dist/es/components/wallets/LinePay/line-pay.js +1 -0
- package/dist/es/components/wallets/LinePay/type.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/MayBankQRPay.js +187 -0
- package/dist/es/components/wallets/MayBankQRPay/index.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/may-bank-qr-pay.js +1 -0
- package/dist/es/components/wallets/MayBankQRPay/type.js +1 -0
- package/dist/es/components/wallets/NinePay/NinePay.js +185 -0
- package/dist/es/components/wallets/NinePay/index.js +1 -0
- package/dist/es/components/wallets/NinePay/nine-pay.js +1 -0
- package/dist/es/components/wallets/NinePay/type.js +1 -0
- package/dist/es/components/wallets/OVO/OVO.js +7 -5
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +56 -218
- package/dist/es/components/wallets/P24/P24.js +11 -8
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +56 -218
- package/dist/es/components/wallets/Paymaya/Paymaya.js +56 -221
- package/dist/es/components/wallets/PicPay/PicPay.js +50 -47
- package/dist/es/components/wallets/Pix/Pix.js +44 -48
- package/dist/es/components/wallets/ShopeePay/ShopeePay.js +185 -0
- package/dist/es/components/wallets/ShopeePay/index.js +1 -0
- package/dist/es/components/wallets/ShopeePay/shopee-pay.js +1 -0
- package/dist/es/components/wallets/ShopeePay/type.js +1 -0
- package/dist/es/components/wallets/Skrill/Skrill.js +28 -26
- package/dist/es/components/wallets/TNGWallet/TNGWallet.js +185 -0
- package/dist/es/components/wallets/TNGWallet/index.js +1 -0
- package/dist/es/components/wallets/TNGWallet/tng-wallet.js +1 -0
- package/dist/es/components/wallets/TNGWallet/type.js +1 -0
- package/dist/es/components/wallets/Trustly/Trustly.js +15 -15
- package/dist/es/components/wallets/Vietqr/Vietqr.js +60 -248
- package/dist/es/components/wallets/Zalopay/Zalopay.js +61 -249
- package/dist/es/components/wallets/index.js +7 -0
- package/dist/es/core/checkout.js +19 -45
- package/dist/es/core/logger.js +1 -1
- package/dist/es/core/payment.js +65 -0
- package/dist/es/hooks/useBaseWallet.js +20 -18
- package/dist/es/hooks/usePayState.js +37 -25
- package/dist/es/hooks/usePayment.js +1 -14
- package/dist/es/hooks/useRetry.js +50 -26
- package/dist/es/index.js +7 -7
- package/dist/es/out/base-fraud-detection.js +4 -1
- package/dist/es/out/fraud-detection.js +12 -13
- package/dist/es/out/worldpay-ddc-manager.js +7 -14
- package/dist/es/out/worldpay-ddc.js +7 -5
- package/dist/es/style.css +1 -1
- package/dist/es/types/event.js +1 -0
- package/dist/es/types/message.js +2 -0
- package/dist/es/utils/payment.js +12 -12
- package/dist/es/utils/system-info/is-ua-webview.js +1 -20
- package/dist/style.css +1 -1
- package/dist/types/api/modules/threeDS/index.d.ts +7 -0
- package/dist/types/components/AddressField/type.d.ts +2 -2
- package/dist/types/components/CPFField/type.d.ts +1 -1
- package/dist/types/components/CardExpireDateField/type.d.ts +1 -1
- package/dist/types/components/CardNo/type.d.ts +3 -2
- package/dist/types/components/CardNumberField/type.d.ts +1 -1
- package/dist/types/components/CardSecurityCodeField/type.d.ts +1 -1
- package/dist/types/components/CardSelector/type.d.ts +4 -4
- package/dist/types/components/GooglePay/createGooglePay.d.ts +1 -1
- package/dist/types/components/GooglePay/type.d.ts +6 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +0 -6
- package/dist/types/components/index.d.ts +0 -7
- package/dist/types/components/internal/CheckBox/type.d.ts +2 -1
- package/dist/types/components/internal/Select/type.d.ts +1 -1
- package/dist/types/components/internal/icons/IconArrowDown.d.ts +1 -1
- package/dist/types/components/{Boost → wallets/Boost}/Boost.d.ts +9 -4
- package/dist/types/components/{Boost → wallets/Boost}/type.d.ts +2 -2
- package/dist/types/components/wallets/GCash/GCash.d.ts +5 -0
- package/dist/types/components/{GrabPay → wallets/GrabPay}/GrabPay.d.ts +4 -4
- package/dist/types/components/wallets/GrabPay/type.d.ts +17 -0
- package/dist/types/components/{LinePay → wallets/LinePay}/LinePay.d.ts +9 -4
- package/dist/types/components/{LinePay → wallets/LinePay}/type.d.ts +2 -2
- package/dist/types/components/wallets/MayBankQRPay/MayBankQRPay.d.ts +15 -0
- package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/type.d.ts +2 -2
- package/dist/types/components/wallets/NinePay/NinePay.d.ts +15 -0
- package/dist/types/components/{NinePay → wallets/NinePay}/type.d.ts +2 -2
- package/dist/types/components/wallets/OpayWallet/OpayWallet.d.ts +5 -0
- package/dist/types/components/wallets/PagaWallet/PagaWallet.d.ts +5 -0
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +5 -0
- package/dist/types/components/{ShopeePay → wallets/ShopeePay}/ShopeePay.d.ts +9 -4
- package/dist/types/components/{ShopeePay → wallets/ShopeePay}/type.d.ts +2 -2
- package/dist/types/components/wallets/Skrill/type.d.ts +0 -12
- package/dist/types/components/{TNGWallet → wallets/TNGWallet}/TNGWallet.d.ts +9 -4
- package/dist/types/components/{TNGWallet → wallets/TNGWallet}/type.d.ts +2 -2
- package/dist/types/components/wallets/Vietqr/Vietqr.d.ts +5 -0
- package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +5 -0
- package/dist/types/components/wallets/index.d.ts +7 -0
- package/dist/types/core/checkout.d.ts +2 -9
- package/dist/types/core/payment.d.ts +21 -0
- package/dist/types/hooks/useBaseWallet.d.ts +2 -2
- package/dist/types/hooks/usePayState.d.ts +3 -1
- package/dist/types/hooks/useRetry.console-tests.d.ts +41 -0
- package/dist/types/hooks/useRetry.d.ts +22 -3
- package/dist/types/out/base-fraud-detection.d.ts +1 -0
- package/dist/types/out/config.d.ts +1 -1
- package/dist/types/out/fraud-detection.d.ts +2 -8
- package/dist/types/out/types.d.ts +3 -1
- package/dist/types/out/worldpay-ddc-manager.d.ts +6 -7
- package/dist/types/types/event.d.ts +6 -1
- package/dist/types/types/message.d.ts +24 -3
- package/dist/types/types/payment.d.ts +4 -0
- package/dist/types/utils/iframe.d.ts +1 -1
- package/dist/types/utils/payment.d.ts +10 -10
- package/package.json +9 -5
- package/dist/es/components/Boost/index.js +0 -349
- package/dist/es/components/GrabPay/index.js +0 -349
- package/dist/es/components/LinePay/index.js +0 -349
- package/dist/es/components/MayBankQRPay/index.js +0 -355
- package/dist/es/components/NinePay/index.js +0 -349
- package/dist/es/components/ShopeePay/index.js +0 -349
- package/dist/es/components/TNGWallet/index.js +0 -349
- package/dist/types/components/GrabPay/type.d.ts +0 -28
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +0 -10
- package/dist/types/components/NinePay/NinePay.d.ts +0 -10
- /package/dist/types/components/{Boost → wallets/Boost}/index.d.ts +0 -0
- /package/dist/types/components/{GrabPay → wallets/GrabPay}/index.d.ts +0 -0
- /package/dist/types/components/{LinePay → wallets/LinePay}/index.d.ts +0 -0
- /package/dist/types/components/{MayBankQRPay → wallets/MayBankQRPay}/index.d.ts +0 -0
- /package/dist/types/components/{NinePay → wallets/NinePay}/index.d.ts +0 -0
- /package/dist/types/components/{ShopeePay → wallets/ShopeePay}/index.d.ts +0 -0
- /package/dist/types/components/{TNGWallet → wallets/TNGWallet}/index.d.ts +0 -0
|
@@ -4,7 +4,7 @@ import { getAliPayInfo, aliPay } from "../../api/modules/ali-pay/index.js";
|
|
|
4
4
|
import "../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
6
|
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
|
-
import { formatPaymentResult } from "../../utils/payment.js";
|
|
7
|
+
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
8
8
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
9
|
import { PaymentMethod, COMMON_CLASS_NAME, PaymentType, SessionMode } from "../../constant.js";
|
|
10
10
|
import { CoreContext } from "../../core/context.js";
|
|
@@ -13,7 +13,7 @@ import "../../out/worldpay-jsc-origin.js";
|
|
|
13
13
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
14
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
15
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
|
-
import { AddressField } from "../AddressField/index.js";
|
|
16
|
+
import { DEFAULT_ADDRESS, AddressField } from "../AddressField/index.js";
|
|
17
17
|
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
18
18
|
import "../internal/Form/type.js";
|
|
19
19
|
import "../internal/Form/context.js";
|
|
@@ -26,23 +26,15 @@ const CURR_PAYMENT_METHOD = PaymentMethod.ALI_PAY;
|
|
|
26
26
|
const { bem } = useBEM("ali-pay");
|
|
27
27
|
const fieldClassNames = bem("field");
|
|
28
28
|
const AliPay = w((props, ref) => {
|
|
29
|
-
const { session, core, showEmail = false, showAddress = false } = props;
|
|
29
|
+
const { session, core, showEmail = false, showAddress = false, autoQuery = true } = props;
|
|
30
30
|
const addressCore = core.getAddressCore();
|
|
31
31
|
const emailState = createEmailCore();
|
|
32
|
-
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
|
|
32
|
+
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady, disabled } = usePayState(session, props.core);
|
|
33
33
|
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
34
34
|
const formRef = A(null);
|
|
35
35
|
const [form, setForm] = h({
|
|
36
36
|
email: "",
|
|
37
|
-
address: {
|
|
38
|
-
country: void 0,
|
|
39
|
-
province: void 0,
|
|
40
|
-
city: void 0,
|
|
41
|
-
area: void 0,
|
|
42
|
-
postCode: void 0,
|
|
43
|
-
address1: void 0,
|
|
44
|
-
address2: void 0
|
|
45
|
-
}
|
|
37
|
+
address: { ...DEFAULT_ADDRESS }
|
|
46
38
|
});
|
|
47
39
|
const [validated, setValidated] = h(false);
|
|
48
40
|
const [fieldStatus, setFieldStatus] = h();
|
|
@@ -67,29 +59,26 @@ const AliPay = w((props, ref) => {
|
|
|
67
59
|
var _a;
|
|
68
60
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
69
61
|
return;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
|
|
62
|
+
const address = addressCore.getAddressState();
|
|
63
|
+
form.address = address;
|
|
64
|
+
setForm(form);
|
|
65
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(address);
|
|
66
|
+
validateFormSilently();
|
|
74
67
|
},
|
|
75
68
|
updateEmail: () => {
|
|
76
69
|
var _a;
|
|
77
70
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
78
71
|
return;
|
|
79
|
-
|
|
80
|
-
setForm(
|
|
72
|
+
form.email = emailState.email;
|
|
73
|
+
setForm(form);
|
|
81
74
|
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
82
|
-
|
|
75
|
+
validateFormSilently();
|
|
83
76
|
}
|
|
84
77
|
}));
|
|
85
|
-
|
|
78
|
+
const validateFormSilently = () => {
|
|
86
79
|
var _a;
|
|
87
|
-
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() =>
|
|
88
|
-
|
|
89
|
-
}).catch(() => {
|
|
90
|
-
setValidated(false);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
80
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => setValidated(true)).catch(() => setValidated(false));
|
|
81
|
+
};
|
|
93
82
|
const initFieldStatus = () => {
|
|
94
83
|
const { field, sessionMode } = session.checkout;
|
|
95
84
|
const { email, address } = field;
|
|
@@ -104,7 +93,7 @@ const AliPay = w((props, ref) => {
|
|
|
104
93
|
setFieldStatus({ ...field });
|
|
105
94
|
};
|
|
106
95
|
y(() => {
|
|
107
|
-
|
|
96
|
+
validateFormSilently();
|
|
108
97
|
}, [form]);
|
|
109
98
|
const processOnSuccess = (res) => {
|
|
110
99
|
var _a, _b;
|
|
@@ -116,6 +105,7 @@ const AliPay = w((props, ref) => {
|
|
|
116
105
|
(_b = props.onSuccess) == null ? void 0 : _b.call(props, result, getPaymentMethodContext());
|
|
117
106
|
};
|
|
118
107
|
y(() => {
|
|
108
|
+
var _a;
|
|
119
109
|
if (!sessionReady) {
|
|
120
110
|
return;
|
|
121
111
|
}
|
|
@@ -128,12 +118,17 @@ const AliPay = w((props, ref) => {
|
|
|
128
118
|
country && addressCore.setCountry(country);
|
|
129
119
|
form.email = bill.email ?? "";
|
|
130
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
|
+
}
|
|
131
125
|
}, [sessionReady]);
|
|
132
126
|
const onTimeout = q(
|
|
133
127
|
(message) => {
|
|
134
128
|
var _a;
|
|
135
129
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
136
130
|
setSubmitButtonStatus("unSubmit");
|
|
131
|
+
core.payment.resetCurrPaymentMethod();
|
|
137
132
|
(_a = props.onTimeout) == null ? void 0 : _a.call(props, "retry", getPaymentMethodContext());
|
|
138
133
|
},
|
|
139
134
|
[i18n, props.onTimeout]
|
|
@@ -161,7 +156,7 @@ const AliPay = w((props, ref) => {
|
|
|
161
156
|
email: form.email
|
|
162
157
|
},
|
|
163
158
|
payment: {
|
|
164
|
-
paymentMethod:
|
|
159
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
165
160
|
},
|
|
166
161
|
browser: await getBrowserParams({
|
|
167
162
|
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
@@ -169,62 +164,66 @@ const AliPay = w((props, ref) => {
|
|
|
169
164
|
};
|
|
170
165
|
};
|
|
171
166
|
async function pay(search = false, timeout) {
|
|
172
|
-
var _a, _b, _c, _d, _e, _f
|
|
167
|
+
var _a, _b, _c, _d, _e, _f;
|
|
173
168
|
try {
|
|
169
|
+
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
174
170
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
175
171
|
let res = null;
|
|
176
172
|
if (search) {
|
|
177
|
-
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query",
|
|
173
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", CURR_PAYMENT_METHOD);
|
|
178
174
|
res = await getAliPayInfo(
|
|
179
175
|
{
|
|
180
176
|
sessionId: session.sessionId,
|
|
181
177
|
clientKey: session.clientKey,
|
|
182
|
-
paymentMethod:
|
|
178
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
183
179
|
},
|
|
184
180
|
extraParams,
|
|
185
181
|
requestOptions
|
|
186
182
|
);
|
|
187
183
|
} else {
|
|
188
|
-
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment",
|
|
184
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", CURR_PAYMENT_METHOD);
|
|
189
185
|
res = await aliPay(await getPaymentParams(), extraParams, requestOptions);
|
|
190
186
|
}
|
|
191
|
-
const {
|
|
187
|
+
const { errorMessage, errorCode, sessionId } = res;
|
|
192
188
|
sessionId && (session.sessionId = sessionId);
|
|
193
189
|
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res, getPaymentMethodContext()));
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
let end = true;
|
|
191
|
+
await processPaymentStatus(res, {
|
|
192
|
+
onProcessing: () => {
|
|
193
|
+
!search && startReFetchPayInfo();
|
|
194
|
+
end = false;
|
|
195
|
+
},
|
|
196
|
+
onSuccess: () => {
|
|
199
197
|
processOnSuccess(res);
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
},
|
|
199
|
+
onFailure: () => {
|
|
200
|
+
var _a2;
|
|
202
201
|
errorMessage && setErrorMsg(errorMessage);
|
|
203
202
|
setSubmitButtonStatus("unSubmit");
|
|
204
|
-
|
|
203
|
+
core.payment.resetCurrPaymentMethod();
|
|
204
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(
|
|
205
205
|
props,
|
|
206
206
|
new PayKKaError("API_ERROR", errorMessage, { code: errorCode }),
|
|
207
207
|
getPaymentMethodContext()
|
|
208
208
|
);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return { end: false };
|
|
213
|
-
} else if (orderStatus === "CANCELED") {
|
|
209
|
+
},
|
|
210
|
+
onCanceled: () => {
|
|
211
|
+
var _a2;
|
|
214
212
|
setSubmitButtonStatus("unSubmit");
|
|
215
|
-
(
|
|
216
|
-
|
|
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();
|
|
217
224
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return { end: true };
|
|
221
|
-
} else if (status === "EXPIRED") {
|
|
222
|
-
setSubmitButtonStatus("unSubmit");
|
|
223
|
-
(_h = props.onExpired) == null ? void 0 : _h.call(props, getPaymentMethodContext());
|
|
224
|
-
return { end: true };
|
|
225
|
-
}
|
|
226
|
-
setSubmitButtonStatus("unSubmit");
|
|
227
|
-
return { end: true };
|
|
225
|
+
});
|
|
226
|
+
return { end };
|
|
228
227
|
} catch (error) {
|
|
229
228
|
if (isTimeoutError(error)) {
|
|
230
229
|
if (search) {
|
|
@@ -236,7 +235,8 @@ const AliPay = w((props, ref) => {
|
|
|
236
235
|
} else {
|
|
237
236
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
238
237
|
message && setErrorMsg(message);
|
|
239
|
-
|
|
238
|
+
core.payment.resetCurrPaymentMethod();
|
|
239
|
+
(_f = props.onError) == null ? void 0 : _f.call(
|
|
240
240
|
props,
|
|
241
241
|
new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
|
|
242
242
|
getPaymentMethodContext()
|
|
@@ -273,6 +273,7 @@ const AliPay = w((props, ref) => {
|
|
|
273
273
|
{
|
|
274
274
|
className: bem("button"),
|
|
275
275
|
status: submitButtonStatus,
|
|
276
|
+
disabled,
|
|
276
277
|
text,
|
|
277
278
|
loadingText: i18n.get("common.payProcessing"),
|
|
278
279
|
successText: i18n.get("common.paySuccess"),
|
|
@@ -283,7 +284,7 @@ const AliPay = w((props, ref) => {
|
|
|
283
284
|
};
|
|
284
285
|
const setFormRef = (dom) => {
|
|
285
286
|
formRef.current = dom;
|
|
286
|
-
dom &&
|
|
287
|
+
dom && validateFormSilently();
|
|
287
288
|
};
|
|
288
289
|
const Email = () => {
|
|
289
290
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
@@ -291,7 +292,7 @@ const AliPay = w((props, ref) => {
|
|
|
291
292
|
{
|
|
292
293
|
ref: emailFieldRef,
|
|
293
294
|
value: form.email,
|
|
294
|
-
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
295
|
+
disabled: (fieldStatus == null ? void 0 : fieldStatus.email.disabled) || disabled
|
|
295
296
|
}
|
|
296
297
|
) }) });
|
|
297
298
|
};
|
|
@@ -301,6 +302,7 @@ const AliPay = w((props, ref) => {
|
|
|
301
302
|
{
|
|
302
303
|
ref: addressFieldRef,
|
|
303
304
|
value: form.address,
|
|
305
|
+
disabled,
|
|
304
306
|
onChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
305
307
|
}
|
|
306
308
|
) }) });
|
|
@@ -3,16 +3,15 @@ import { isTimeoutError } from "../../api/http.js";
|
|
|
3
3
|
import "../../utils/card-brand/brands.js";
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ApplePayEventType } from "../../types/event.js";
|
|
7
7
|
import { deepMerge } from "../../utils/object.js";
|
|
8
|
-
import { formatPaymentResult } from "../../utils/payment.js";
|
|
8
|
+
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
9
9
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
10
10
|
import { PaymentMethod, SessionMode } from "../../constant.js";
|
|
11
11
|
import { getApplePayInfo, applePay, getMerchantSession } from "../../api/modules/apple-pay/index.js";
|
|
12
12
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
13
13
|
import "../../core/context.js";
|
|
14
14
|
import { PayKKaError } from "../../core/error.js";
|
|
15
|
-
import { ApplePayEventType } from "../../types/event.js";
|
|
16
15
|
import "../../out/worldpay-jsc-origin.js";
|
|
17
16
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
18
17
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
@@ -118,7 +117,7 @@ const { bem } = useBEM("apple-pay");
|
|
|
118
117
|
const ApplePay = w((props) => {
|
|
119
118
|
const { session, isDropIn, core, config } = props;
|
|
120
119
|
const { applePaySession, initApplePaySession, reportSuccess2ApplePay, reportFailure2ApplePay } = useApplePaySession();
|
|
121
|
-
const { i18n, sessionReady, fraudDetection } = usePayState(session, props.core);
|
|
120
|
+
const { i18n, sessionReady, fraudDetection, disabled } = usePayState(session, props.core);
|
|
122
121
|
const [errorMsg, setErrorMsg] = h("");
|
|
123
122
|
const [showApplePay, setShowApplePay] = h(false);
|
|
124
123
|
const applePayConfig = deepMerge(DEFAULT_APPLE_PAY_CONFIG, config || {});
|
|
@@ -148,7 +147,7 @@ const ApplePay = w((props) => {
|
|
|
148
147
|
);
|
|
149
148
|
return;
|
|
150
149
|
}
|
|
151
|
-
if (!supportMethods.includes(
|
|
150
|
+
if (!supportMethods.includes(CURR_PAYMENT_METHOD)) {
|
|
152
151
|
return;
|
|
153
152
|
}
|
|
154
153
|
loadApplePayJS(
|
|
@@ -175,6 +174,7 @@ const ApplePay = w((props) => {
|
|
|
175
174
|
const onTimeout = q(
|
|
176
175
|
(message) => {
|
|
177
176
|
var _a;
|
|
177
|
+
core.payment.resetCurrPaymentMethod();
|
|
178
178
|
const timeoutMessage = message || i18n.get("common.payTimeout");
|
|
179
179
|
reportFailure2ApplePay(timeoutMessage);
|
|
180
180
|
setErrorMsg(timeoutMessage);
|
|
@@ -205,7 +205,7 @@ const ApplePay = w((props) => {
|
|
|
205
205
|
country: billingContact == null ? void 0 : billingContact.countryCode
|
|
206
206
|
},
|
|
207
207
|
payment: {
|
|
208
|
-
paymentMethod:
|
|
208
|
+
paymentMethod: CURR_PAYMENT_METHOD,
|
|
209
209
|
tokenData: JSON.stringify({ token })
|
|
210
210
|
},
|
|
211
211
|
browser: await getBrowserParams({
|
|
@@ -214,70 +214,71 @@ const ApplePay = w((props) => {
|
|
|
214
214
|
};
|
|
215
215
|
};
|
|
216
216
|
async function pay(search = false, timeout, token, billingContact, shippingContact) {
|
|
217
|
-
var _a, _b, _c, _d, _e, _f
|
|
217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
218
218
|
setErrorMsg("");
|
|
219
219
|
try {
|
|
220
|
+
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
220
221
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
221
222
|
let res = null;
|
|
222
223
|
if (search) {
|
|
223
|
-
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query",
|
|
224
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", CURR_PAYMENT_METHOD);
|
|
224
225
|
res = await getApplePayInfo(
|
|
225
226
|
{
|
|
226
227
|
sessionId: session.sessionId,
|
|
227
228
|
clientKey: session.clientKey,
|
|
228
|
-
paymentMethod:
|
|
229
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
229
230
|
},
|
|
230
231
|
extraParams,
|
|
231
232
|
requestOptions
|
|
232
233
|
);
|
|
233
234
|
} else {
|
|
234
|
-
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment",
|
|
235
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", CURR_PAYMENT_METHOD);
|
|
235
236
|
res = await applePay(
|
|
236
237
|
await getPaymentParams(token, billingContact, shippingContact),
|
|
237
238
|
extraParams,
|
|
238
239
|
requestOptions
|
|
239
240
|
);
|
|
240
241
|
}
|
|
241
|
-
const {
|
|
242
|
+
const { errorMessage, errorCode, sessionId } = res;
|
|
242
243
|
sessionId && (session.sessionId = sessionId);
|
|
243
244
|
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res, getPaymentMethodContext()));
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
let end = true;
|
|
246
|
+
await processPaymentStatus(res, {
|
|
247
|
+
onProcessing: async () => {
|
|
248
|
+
!search && await startReFetchPayInfo();
|
|
249
|
+
end = false;
|
|
250
|
+
},
|
|
251
|
+
onSuccess: () => {
|
|
246
252
|
reportSuccess2ApplePay();
|
|
247
253
|
processOnSuccess(res);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return { end: !search };
|
|
252
|
-
} else if (orderStatus === PaymentStatus.FAILURE) {
|
|
254
|
+
},
|
|
255
|
+
onFailure: () => {
|
|
256
|
+
var _a2;
|
|
253
257
|
errorMessage && setErrorMsg(errorMessage);
|
|
254
|
-
(
|
|
258
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(
|
|
255
259
|
props,
|
|
256
260
|
new PayKKaError("API_ERROR", errorMessage, { code: errorCode }),
|
|
257
261
|
getPaymentMethodContext()
|
|
258
262
|
);
|
|
263
|
+
core.payment.resetCurrPaymentMethod();
|
|
259
264
|
reportFailure2ApplePay(errorMessage);
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
},
|
|
266
|
+
onAuthorized: () => {
|
|
267
|
+
var _a2;
|
|
262
268
|
reportSuccess2ApplePay();
|
|
263
|
-
(
|
|
264
|
-
|
|
265
|
-
|
|
269
|
+
(_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props, getPaymentMethodContext());
|
|
270
|
+
},
|
|
271
|
+
onExpired: () => {
|
|
272
|
+
var _a2, _b2;
|
|
273
|
+
(_a2 = props.onExpired) == null ? void 0 : _a2.call(props, getPaymentMethodContext());
|
|
274
|
+
(_b2 = applePaySession.current) == null ? void 0 : _b2.abort();
|
|
275
|
+
},
|
|
276
|
+
onDefault: () => {
|
|
266
277
|
reportFailure2ApplePay();
|
|
267
|
-
|
|
278
|
+
core.payment.resetCurrPaymentMethod();
|
|
268
279
|
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
processOnSuccess(res);
|
|
272
|
-
return { end: true };
|
|
273
|
-
} else if (status === PaymentStatus.EXPIRED) {
|
|
274
|
-
(_h = props.onExpired) == null ? void 0 : _h.call(props, getPaymentMethodContext());
|
|
275
|
-
(_i = applePaySession.current) == null ? void 0 : _i.abort();
|
|
276
|
-
return { end: true };
|
|
277
|
-
} else {
|
|
278
|
-
reportFailure2ApplePay();
|
|
279
|
-
return { end: true };
|
|
280
|
-
}
|
|
280
|
+
});
|
|
281
|
+
return { end };
|
|
281
282
|
} catch (error) {
|
|
282
283
|
if (isTimeoutError(error)) {
|
|
283
284
|
if (search) {
|
|
@@ -289,12 +290,13 @@ const ApplePay = w((props) => {
|
|
|
289
290
|
} else {
|
|
290
291
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
291
292
|
message && setErrorMsg(message);
|
|
292
|
-
(
|
|
293
|
+
(_f = props.onError) == null ? void 0 : _f.call(
|
|
293
294
|
props,
|
|
294
295
|
new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
|
|
295
296
|
getPaymentMethodContext()
|
|
296
297
|
);
|
|
297
298
|
reportFailure2ApplePay(message);
|
|
299
|
+
core.payment.resetCurrPaymentMethod();
|
|
298
300
|
return { end: true };
|
|
299
301
|
}
|
|
300
302
|
}
|
|
@@ -352,6 +354,7 @@ const ApplePay = w((props) => {
|
|
|
352
354
|
onCancel: () => {
|
|
353
355
|
var _a2;
|
|
354
356
|
onEvent == null ? void 0 : onEvent(ApplePayEventType.APPLE_PAY_CANCELLED);
|
|
357
|
+
core.payment.resetCurrPaymentMethod();
|
|
355
358
|
(_a2 = props.onCancel) == null ? void 0 : _a2.call(props);
|
|
356
359
|
}
|
|
357
360
|
});
|
|
@@ -361,7 +364,7 @@ const ApplePay = w((props) => {
|
|
|
361
364
|
var _a, _b;
|
|
362
365
|
const buttonStyle = (_a = applePayConfig.button) == null ? void 0 : _a.buttonStyle;
|
|
363
366
|
const buttonType = (_b = applePayConfig.button) == null ? void 0 : _b.buttonType;
|
|
364
|
-
return /* @__PURE__ */ u("div", { className: bem("button"), children: canUseApplePaySDK ? /* @__PURE__ */ u(b, { children: /* @__PURE__ */ u(
|
|
367
|
+
return /* @__PURE__ */ u("div", { className: bem("button", { disabled }), children: canUseApplePaySDK ? /* @__PURE__ */ u(b, { children: /* @__PURE__ */ u(
|
|
365
368
|
"apple-pay-button",
|
|
366
369
|
{
|
|
367
370
|
buttonstyle: buttonStyle,
|
|
@@ -14,7 +14,7 @@ import { Input } from "../internal/Input/Input.js";
|
|
|
14
14
|
import "../internal/Input/type.js";
|
|
15
15
|
import { CNPJ_FULL_LENGTH, CPF_FULL_LENGTH, formatCPFOnInsert } from "../../utils/cpf.js";
|
|
16
16
|
const CPFField = w((props, ref) => {
|
|
17
|
-
const { className, style, security } = props;
|
|
17
|
+
const { className, style, security, disabled } = props;
|
|
18
18
|
const { i18n } = useI18n();
|
|
19
19
|
const inputRef = A(null);
|
|
20
20
|
const formItemRef = A(null);
|
|
@@ -71,6 +71,7 @@ const CPFField = w((props, ref) => {
|
|
|
71
71
|
Input,
|
|
72
72
|
{
|
|
73
73
|
type: "text",
|
|
74
|
+
disabled,
|
|
74
75
|
inputmode: "numeric",
|
|
75
76
|
ref: inputRef,
|
|
76
77
|
maxLength: CNPJ_FULL_LENGTH,
|