@paykka/card-checkout-ui 0.13.8 → 0.13.13
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 +20 -20
- package/dist/card-checkout-ui.umd.cjs +21 -21
- package/dist/es/_commonjsHelpers.js +1 -82
- package/dist/es/api/index.js +2 -1
- package/dist/es/api/modules/checkout/map.js +1 -0
- package/dist/es/api/modules/get-browser-params.js +20 -8
- package/dist/es/api/modules/index.js +2 -1
- package/dist/es/api/modules/map.js +2 -1
- package/dist/es/api/modules/risk/index.js +21 -18
- package/dist/es/api/modules/threeDS/index.js +2 -1
- package/dist/es/api/modules/vietqr/index.js +2 -1
- package/dist/es/api/utils/index.js +4 -1
- package/dist/es/components/AccordionItem/AccordionItem.js +0 -1
- package/dist/es/components/AccountNameField/index.js +1 -1
- package/dist/es/components/AddressField/index.js +1 -2
- package/dist/es/components/AliPay/index.js +4 -2
- package/dist/es/components/ApplePay/index.js +201 -135
- package/dist/es/components/Boost/index.js +4 -2
- package/dist/es/components/CPFField/index.js +88 -0
- package/dist/es/components/Card/index.js +5 -11
- package/dist/es/components/CardBrands/index.js +0 -1
- package/dist/es/components/CardExpireDateField/index.js +1 -1
- package/dist/es/components/CardHolderNameField/index.js +1 -1
- package/dist/es/components/CardIBANField/index.js +1 -1
- package/dist/es/components/CardNo/index.js +0 -1
- package/dist/es/components/CardNumberField/index.js +1 -1
- package/dist/es/components/CardSecurityCodeField/index.js +1 -1
- package/dist/es/components/CardSelector/index.js +1 -1
- package/dist/es/components/CombinedCardInfo/index.js +1 -1
- package/dist/es/components/DropIn/index.js +0 -1
- package/dist/es/components/EmailField/EmailField.js +1 -1
- package/dist/es/components/EncryptedCard/index.js +12 -11
- package/dist/es/components/GooglePay/index.js +1 -0
- package/dist/es/components/GrabPay/index.js +4 -2
- package/dist/es/components/GuideCard/index.js +1 -1
- package/dist/es/components/LinePay/index.js +4 -2
- package/dist/es/components/MayBankQRPay/index.js +4 -2
- package/dist/es/components/NinePay/index.js +4 -2
- package/dist/es/components/RecurringTip/index.js +1 -2
- package/dist/es/components/SecuredFieldsProvider/index.js +20 -3
- package/dist/es/components/SecuredIframe/index.js +50 -22
- package/dist/es/components/Sepa/index.js +4 -2
- package/dist/es/components/ShopeePay/index.js +4 -2
- package/dist/es/components/SubmitButton/index.js +1 -1
- package/dist/es/components/TNGWallet/index.js +4 -2
- package/dist/es/components/ThreeDS/index.js +1 -2
- package/dist/es/components/Tip/index.js +18 -0
- package/dist/es/components/WechatPay/index.js +4 -2
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +1 -1
- package/dist/es/components/business/QRCodeModal/index.js +0 -1
- package/dist/es/components/business/index.js +0 -1
- package/dist/es/components/index.js +0 -1
- package/dist/es/components/internal/Accordion/index.js +0 -1
- package/dist/es/components/internal/Button/Button.js +0 -1
- package/dist/es/components/internal/Button/index.js +0 -1
- package/dist/es/components/internal/CheckBox/CheckBox.js +0 -1
- package/dist/es/components/internal/CheckBox/index.js +0 -1
- package/dist/es/components/internal/Form/type.js +0 -1
- package/dist/es/components/internal/Info/Info.js +0 -1
- package/dist/es/components/internal/Info/index.js +0 -1
- package/dist/es/components/internal/Input/Input.js +1 -1
- package/dist/es/components/internal/Input/type.js +0 -1
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -1
- package/dist/es/components/internal/LoadingCheck/index.js +0 -1
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/QRCode/QRCode.js +0 -1
- package/dist/es/components/internal/QRCode/index.js +0 -1
- package/dist/es/components/internal/Select/Select.js +14 -17
- package/dist/es/components/internal/Select/SelectMenu.js +2 -3
- package/dist/es/components/internal/Select/SelectMenuItem.js +0 -1
- package/dist/es/components/wallets/GCash/GCash.js +4 -2
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +8 -9
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +8 -9
- package/dist/es/components/wallets/Paymaya/Paymaya.js +4 -2
- package/dist/es/components/wallets/PicPay/PicPay.js +136 -72
- package/dist/es/components/wallets/Pix/Pix.js +136 -72
- package/dist/es/components/wallets/Vietqr/Vietqr.js +4 -2
- package/dist/es/components/wallets/Zalopay/Zalopay.js +4 -2
- package/dist/es/config.js +1 -1
- package/dist/es/constant.js +2 -0
- package/dist/es/core/checkout.js +15 -3
- package/dist/es/core/environment.js +10 -2
- package/dist/es/core/index.js +0 -1
- package/dist/es/core/query.js +2 -1
- package/dist/es/core/session.js +6 -2
- package/dist/es/core/theme.js +0 -1
- package/dist/es/core.js +585 -4
- package/dist/es/hooks/index.js +0 -1
- package/dist/es/hooks/useI18n.js +0 -1
- package/dist/es/hooks/usePayState.js +13 -6
- package/dist/es/i18n/locales/de-DE.js +6 -1
- package/dist/es/i18n/locales/en-GB.js +6 -1
- package/dist/es/i18n/locales/es-ES.js +6 -1
- package/dist/es/i18n/locales/fr-FR.js +7 -2
- package/dist/es/i18n/locales/ja-JP.js +6 -1
- package/dist/es/i18n/locales/ko-KR.js +6 -1
- package/dist/es/i18n/locales/nl-NL.js +6 -1
- package/dist/es/i18n/locales/pt-PT.js +6 -1
- package/dist/es/i18n/locales/ru-RU.js +6 -1
- package/dist/es/i18n/locales/zh-CN.js +6 -1
- package/dist/es/i18n/locales/zh-HK.js +7 -2
- package/dist/es/i18n/locales/zh-TW.js +7 -2
- package/dist/es/index.js +6 -3
- package/dist/es/out/base-fraud-detection.js +134 -0
- package/dist/es/out/config.js +16 -0
- package/dist/es/out/fraud-detection.js +118 -27
- package/dist/es/out/paykka-detection.js +63 -0
- package/dist/es/out/stripe-radar.js +25 -51
- package/dist/es/out/worldpay-ddc.js +52 -99
- package/dist/es/out/worldpay-jsc-origin.js +0 -1
- package/dist/es/out/worldpay-jsc.js +21 -43
- package/dist/es/style.css +1 -1
- package/dist/es/types/event.js +33 -13
- package/dist/es/types/index.js +14 -0
- package/dist/es/utils/cpf.js +48 -0
- package/dist/es/utils/encrypt.js +18 -0
- package/dist/es/utils/iframe.js +1 -1
- package/dist/es/utils/location.js +4 -2
- package/dist/es/utils/redirect.js +8 -5
- package/dist/es/utils/system-info/index.js +1 -3
- package/dist/style.css +1 -1
- package/dist/types/api/modules/checkout/type.d.ts +2 -0
- package/dist/types/api/modules/get-browser-params.d.ts +25 -1
- package/dist/types/api/modules/risk/index.d.ts +28 -12
- package/dist/types/api/modules/type.d.ts +5 -0
- package/dist/types/api/utils/index.d.ts +3 -0
- package/dist/types/components/ApplePay/config.d.ts +9 -0
- package/dist/types/components/ApplePay/hooks/useApplePay.d.ts +15 -0
- package/dist/types/components/ApplePay/type.d.ts +53 -10
- package/dist/types/components/ApplePay/utils.d.ts +8 -2
- package/dist/types/components/CPFField/CPFField.d.ts +4 -0
- package/dist/types/components/CPFField/index.d.ts +2 -0
- package/dist/types/components/CPFField/type.d.ts +21 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +8 -3
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -5
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +6 -0
- package/dist/types/components/Tip/Tip.d.ts +3 -0
- package/dist/types/components/Tip/index.d.ts +2 -0
- package/dist/types/components/Tip/type.d.ts +12 -0
- package/dist/types/constant.d.ts +3 -1
- package/dist/types/core/checkout.d.ts +1 -1
- package/dist/types/core/environment.d.ts +12 -0
- package/dist/types/core/session.d.ts +1 -0
- package/dist/types/i18n/locales/de-DE.d.ts +4 -0
- package/dist/types/i18n/locales/en-GB.d.ts +4 -0
- package/dist/types/i18n/locales/es-ES.d.ts +4 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +4 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +4 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +4 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +4 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +4 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +4 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +4 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +4 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +4 -0
- package/dist/types/out/base-fraud-detection.d.ts +53 -0
- package/dist/types/out/config.d.ts +11 -0
- package/dist/types/out/fraud-detection.d.ts +14 -3
- package/dist/types/out/paykka-detection.d.ts +20 -0
- package/dist/types/out/stripe-radar.d.ts +7 -9
- package/dist/types/out/types.d.ts +8 -2
- package/dist/types/out/worldpay-ddc.d.ts +7 -19
- package/dist/types/out/worldpay-jsc.d.ts +8 -18
- package/dist/types/types/event.d.ts +86 -39
- package/dist/types/types/fraud-detection.d.ts +1 -1
- package/dist/types/types/index.d.ts +22 -2
- package/dist/types/types/message.d.ts +12 -12
- package/dist/types/utils/app-payment.d.ts +2 -0
- package/dist/types/utils/cpf.d.ts +32 -0
- package/dist/types/utils/encrypt.d.ts +9 -0
- package/dist/types/utils/location.d.ts +1 -0
- package/dist/types/utils/system-info/index.d.ts +0 -1
- package/package.json +5 -4
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +0 -3
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +0 -6
|
@@ -3,9 +3,10 @@ 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 { normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
6
|
+
import { normalizedClass, formatAmount, limitedToNumber } from "../../../utils/format.js";
|
|
7
|
+
import { defaultInputStyleConfig } from "../../../types/index.js";
|
|
7
8
|
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
8
|
-
import { formatPaymentResult } from "../../../utils/payment.js";
|
|
9
|
+
import { processPaymentStatus, formatPaymentResult } from "../../../utils/payment.js";
|
|
9
10
|
import { isTimeoutError } from "../../../api/http.js";
|
|
10
11
|
import { getBrowserParams } from "../../../api/modules/get-browser-params.js";
|
|
11
12
|
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../../constant.js";
|
|
@@ -24,9 +25,13 @@ import "../../internal/Form/context.js";
|
|
|
24
25
|
import "../../internal/Form/FormItem.js";
|
|
25
26
|
import { Form } from "../../internal/Form/Form.js";
|
|
26
27
|
import "./pic-pay.js";
|
|
28
|
+
import { SecuredFieldsProvider } from "../../SecuredFieldsProvider/index.js";
|
|
29
|
+
import { CPFField } from "../../CPFField/index.js";
|
|
30
|
+
import { Tip } from "../../Tip/index.js";
|
|
27
31
|
const { bem } = useBEM("pic-pay");
|
|
28
32
|
const fieldClassNames = bem("field");
|
|
29
33
|
const PicPay = w((props, ref) => {
|
|
34
|
+
var _a;
|
|
30
35
|
const {
|
|
31
36
|
session,
|
|
32
37
|
showEmail = false,
|
|
@@ -47,21 +52,21 @@ const PicPay = w((props, ref) => {
|
|
|
47
52
|
startReFetchPayInfo({ timeout });
|
|
48
53
|
},
|
|
49
54
|
updateAddress: () => {
|
|
50
|
-
var
|
|
55
|
+
var _a2;
|
|
51
56
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
52
57
|
return;
|
|
53
58
|
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
54
59
|
setForm(newForm);
|
|
55
|
-
(
|
|
60
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
|
|
56
61
|
validateForm();
|
|
57
62
|
},
|
|
58
63
|
updateEmail: () => {
|
|
59
|
-
var
|
|
64
|
+
var _a2;
|
|
60
65
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
61
66
|
return;
|
|
62
67
|
const newForm = Object.assign(form, { email: emailState.email });
|
|
63
68
|
setForm(newForm);
|
|
64
|
-
(
|
|
69
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
65
70
|
validateForm();
|
|
66
71
|
},
|
|
67
72
|
payment: () => {
|
|
@@ -72,9 +77,12 @@ const PicPay = w((props, ref) => {
|
|
|
72
77
|
const emailState = createEmailCore();
|
|
73
78
|
const addressFieldRef = A(null);
|
|
74
79
|
const emailFieldRef = A(null);
|
|
80
|
+
const SFPRef = A(null);
|
|
81
|
+
const cpfFieldRef = A(null);
|
|
75
82
|
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
76
|
-
const { setErrorMsg, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
|
|
83
|
+
const { setErrorMsg, fraudDetection, i18n, errorMsg, sessionReady } = usePayState(session, props.core);
|
|
77
84
|
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
85
|
+
const [security, setSecurity] = h(false);
|
|
78
86
|
const formRef = A(null);
|
|
79
87
|
const [form, setForm] = h({
|
|
80
88
|
email: "",
|
|
@@ -86,7 +94,8 @@ const PicPay = w((props, ref) => {
|
|
|
86
94
|
postCode: void 0,
|
|
87
95
|
address1: void 0,
|
|
88
96
|
address2: void 0
|
|
89
|
-
}
|
|
97
|
+
},
|
|
98
|
+
cpf: ""
|
|
90
99
|
});
|
|
91
100
|
const [validated, setValidated] = h(false);
|
|
92
101
|
const [fieldStatus, setFieldStatus] = h();
|
|
@@ -104,22 +113,25 @@ const PicPay = w((props, ref) => {
|
|
|
104
113
|
setFieldStatus({ ...field });
|
|
105
114
|
};
|
|
106
115
|
const processOnSuccess = (res) => {
|
|
107
|
-
var
|
|
116
|
+
var _a2, _b;
|
|
108
117
|
setSubmitButtonStatus("success");
|
|
109
118
|
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
110
119
|
...res,
|
|
111
|
-
returnUrl: (
|
|
120
|
+
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
112
121
|
}));
|
|
113
122
|
};
|
|
114
123
|
y(() => {
|
|
124
|
+
var _a2;
|
|
115
125
|
if (!sessionReady) {
|
|
116
126
|
return;
|
|
117
127
|
}
|
|
118
|
-
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
128
|
+
const { bill = {}, supportMethods = [], country, sessionMode } = (session == null ? void 0 : session.checkout) || {};
|
|
119
129
|
if (!supportMethods.includes(PaymentMethod.PIC_PAY)) {
|
|
120
130
|
return;
|
|
121
131
|
}
|
|
122
132
|
initFieldStatus();
|
|
133
|
+
setSecurity(sessionMode !== SessionMode.HOSTED);
|
|
134
|
+
(_a2 = SFPRef.current) == null ? void 0 : _a2.reload();
|
|
123
135
|
setIsCheckoutEnabled(true);
|
|
124
136
|
country && addressCore.setCountry(country);
|
|
125
137
|
form.email = bill.email ?? "";
|
|
@@ -130,16 +142,16 @@ const PicPay = w((props, ref) => {
|
|
|
130
142
|
}
|
|
131
143
|
}, [sessionReady]);
|
|
132
144
|
const processOnError = (error) => {
|
|
133
|
-
var
|
|
134
|
-
(
|
|
145
|
+
var _a2;
|
|
146
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
135
147
|
core.resetEnablePaymentMethod();
|
|
136
148
|
};
|
|
137
149
|
const onTimeout = q(
|
|
138
150
|
(message) => {
|
|
139
|
-
var
|
|
151
|
+
var _a2;
|
|
140
152
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
141
153
|
setSubmitButtonStatus("unSubmit");
|
|
142
|
-
(
|
|
154
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props);
|
|
143
155
|
core.resetEnablePaymentMethod();
|
|
144
156
|
},
|
|
145
157
|
[i18n, props.onTimeout]
|
|
@@ -155,6 +167,9 @@ const PicPay = w((props, ref) => {
|
|
|
155
167
|
payment: {
|
|
156
168
|
paymentMethod: PaymentMethod.PIC_PAY
|
|
157
169
|
},
|
|
170
|
+
customer: {
|
|
171
|
+
document: limitedToNumber(form.cpf)
|
|
172
|
+
},
|
|
158
173
|
bill: {
|
|
159
174
|
email: form.email,
|
|
160
175
|
addressLine1: form.address.address1,
|
|
@@ -165,16 +180,18 @@ const PicPay = w((props, ref) => {
|
|
|
165
180
|
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
166
181
|
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
167
182
|
},
|
|
168
|
-
browser: await getBrowserParams(
|
|
183
|
+
browser: await getBrowserParams({
|
|
184
|
+
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
185
|
+
})
|
|
169
186
|
};
|
|
170
187
|
};
|
|
171
188
|
const pay = async (search = false, timeout) => {
|
|
172
|
-
var
|
|
189
|
+
var _a2, _b, _c, _d, _e;
|
|
173
190
|
try {
|
|
174
191
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
175
192
|
let res = null;
|
|
176
193
|
if (search) {
|
|
177
|
-
const extraParams = (_b = (
|
|
194
|
+
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.PIC_PAY);
|
|
178
195
|
res = await getPicPayInfo(
|
|
179
196
|
{
|
|
180
197
|
sessionId: session.sessionId,
|
|
@@ -185,50 +202,16 @@ const PicPay = w((props, ref) => {
|
|
|
185
202
|
requestOptions
|
|
186
203
|
);
|
|
187
204
|
} else {
|
|
205
|
+
const paymentParams = await getPaymentParams();
|
|
188
206
|
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.PIC_PAY);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
192
|
-
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
193
|
-
sessionId && (session.sessionId = sessionId);
|
|
194
|
-
if (status === "PROCESSING") {
|
|
195
|
-
if (!orderStatus) {
|
|
196
|
-
setSubmitButtonStatus("unSubmit");
|
|
197
|
-
return { end: true };
|
|
198
|
-
} else if (orderStatus === "SUCCESS") {
|
|
199
|
-
processOnSuccess(res);
|
|
200
|
-
return { end: true };
|
|
201
|
-
} else if (orderStatus === "FAILURE") {
|
|
202
|
-
errorMessage && setErrorMsg(errorMessage);
|
|
203
|
-
setSubmitButtonStatus("unSubmit");
|
|
204
|
-
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
205
|
-
return { end: true };
|
|
206
|
-
} else if (orderStatus === "PROCESSING") {
|
|
207
|
-
if (!search) {
|
|
208
|
-
if (redirectMode === "auto" && payInfo) {
|
|
209
|
-
redirectToPayment(payInfo);
|
|
210
|
-
return { end: true };
|
|
211
|
-
} else {
|
|
212
|
-
startReFetchPayInfo();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return { end: false };
|
|
216
|
-
} else if (orderStatus === "CANCELED") {
|
|
217
|
-
setSubmitButtonStatus("unSubmit");
|
|
218
|
-
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
219
|
-
core.resetEnablePaymentMethod();
|
|
207
|
+
if (security) {
|
|
208
|
+
(_e = SFPRef.current) == null ? void 0 : _e.payment(paymentParams, extraParams);
|
|
220
209
|
return { end: true };
|
|
210
|
+
} else {
|
|
211
|
+
res = await picPay(paymentParams, extraParams, requestOptions);
|
|
221
212
|
}
|
|
222
|
-
} else if (status === "SUCCESS") {
|
|
223
|
-
processOnSuccess(res);
|
|
224
|
-
return { end: true };
|
|
225
|
-
} else if (status === "EXPIRED") {
|
|
226
|
-
setSubmitButtonStatus("unSubmit");
|
|
227
|
-
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
228
|
-
return { end: true };
|
|
229
213
|
}
|
|
230
|
-
|
|
231
|
-
return { end: true };
|
|
214
|
+
return processAfterPayment(res, search);
|
|
232
215
|
} catch (error) {
|
|
233
216
|
if (isTimeoutError(error)) {
|
|
234
217
|
if (search) {
|
|
@@ -238,17 +221,58 @@ const PicPay = w((props, ref) => {
|
|
|
238
221
|
return { end: true };
|
|
239
222
|
}
|
|
240
223
|
} else {
|
|
241
|
-
|
|
242
|
-
message && setErrorMsg(message);
|
|
243
|
-
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
244
|
-
setSubmitButtonStatus("unSubmit");
|
|
224
|
+
processPaymentError(error);
|
|
245
225
|
return { end: true };
|
|
246
226
|
}
|
|
247
227
|
}
|
|
248
228
|
};
|
|
229
|
+
const processAfterPayment = (res, search = false) => {
|
|
230
|
+
var _a2;
|
|
231
|
+
!search && ((_a2 = props.onSubmitResponse) == null ? void 0 : _a2.call(props, res));
|
|
232
|
+
const { errorMessage, errorCode, payInfo, sessionId } = res;
|
|
233
|
+
sessionId && (session.sessionId = sessionId);
|
|
234
|
+
let end = true;
|
|
235
|
+
processPaymentStatus(res, {
|
|
236
|
+
onProcessing: () => {
|
|
237
|
+
if (redirectMode === "auto" && (payInfo == null ? void 0 : payInfo.targetUrl)) {
|
|
238
|
+
redirectToPayment(payInfo);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
!search && startReFetchPayInfo();
|
|
242
|
+
end = false;
|
|
243
|
+
},
|
|
244
|
+
onSuccess: () => {
|
|
245
|
+
processOnSuccess(res);
|
|
246
|
+
},
|
|
247
|
+
onFailure: () => {
|
|
248
|
+
processPaymentError({ message: errorMessage, code: errorCode });
|
|
249
|
+
},
|
|
250
|
+
onCanceled: () => {
|
|
251
|
+
var _a3;
|
|
252
|
+
setSubmitButtonStatus("unSubmit");
|
|
253
|
+
(_a3 = props.onTimeout) == null ? void 0 : _a3.call(props);
|
|
254
|
+
core.resetEnablePaymentMethod();
|
|
255
|
+
},
|
|
256
|
+
onExpired: () => {
|
|
257
|
+
var _a3;
|
|
258
|
+
setSubmitButtonStatus("unSubmit");
|
|
259
|
+
(_a3 = props.onExpired) == null ? void 0 : _a3.call(props);
|
|
260
|
+
},
|
|
261
|
+
onDefault: () => {
|
|
262
|
+
setSubmitButtonStatus("unSubmit");
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return { end };
|
|
266
|
+
};
|
|
267
|
+
const processPaymentError = (error) => {
|
|
268
|
+
const message = (error == null ? void 0 : error.i18nKey) ? i18n.get(error.i18nKey) : error.message;
|
|
269
|
+
message && setErrorMsg(message);
|
|
270
|
+
processOnError(new PayKKaError("API_ERROR", message, { code: error == null ? void 0 : error.code, cause: error }));
|
|
271
|
+
setSubmitButtonStatus("unSubmit");
|
|
272
|
+
};
|
|
249
273
|
const validateForm = () => {
|
|
250
|
-
var
|
|
251
|
-
(
|
|
274
|
+
var _a2;
|
|
275
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
252
276
|
setValidated(true);
|
|
253
277
|
}).catch(() => {
|
|
254
278
|
setValidated(false);
|
|
@@ -258,12 +282,12 @@ const PicPay = w((props, ref) => {
|
|
|
258
282
|
validateForm();
|
|
259
283
|
}, [form]);
|
|
260
284
|
const onSubmit = async () => {
|
|
261
|
-
var
|
|
285
|
+
var _a2;
|
|
262
286
|
setErrorMsg("");
|
|
263
|
-
(
|
|
264
|
-
var
|
|
287
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
288
|
+
var _a3;
|
|
265
289
|
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
266
|
-
(
|
|
290
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
267
291
|
if (errors) {
|
|
268
292
|
setSubmitButtonStatus("unSubmit");
|
|
269
293
|
return;
|
|
@@ -273,13 +297,36 @@ const PicPay = w((props, ref) => {
|
|
|
273
297
|
await pay();
|
|
274
298
|
});
|
|
275
299
|
};
|
|
300
|
+
const onFieldsFocus = (data) => {
|
|
301
|
+
var _a2, _b;
|
|
302
|
+
const fieldRef = cpfFieldRef;
|
|
303
|
+
if (data.focus) {
|
|
304
|
+
(_a2 = fieldRef.current) == null ? void 0 : _a2.focus();
|
|
305
|
+
} else {
|
|
306
|
+
(_b = fieldRef.current) == null ? void 0 : _b.blur();
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
const onAfterPayment = (data) => {
|
|
310
|
+
processAfterPayment(data.response);
|
|
311
|
+
};
|
|
312
|
+
const onPaymentError = (data) => {
|
|
313
|
+
processPaymentError(data.error);
|
|
314
|
+
};
|
|
315
|
+
const onFieldValidStatusChanged = (data) => {
|
|
316
|
+
var _a2;
|
|
317
|
+
const error = data.errorTip && i18n.get(data.errorTip);
|
|
318
|
+
(_a2 = cpfFieldRef.current) == null ? void 0 : _a2.resetValidation(data.status, error);
|
|
319
|
+
setTimeout(() => {
|
|
320
|
+
validateForm();
|
|
321
|
+
}, 100);
|
|
322
|
+
};
|
|
276
323
|
const setFormRef = (dom) => {
|
|
277
324
|
formRef.current = dom;
|
|
278
325
|
dom && validateForm();
|
|
279
326
|
};
|
|
280
327
|
const Button = () => {
|
|
281
|
-
var
|
|
282
|
-
const transAmount = (
|
|
328
|
+
var _a2;
|
|
329
|
+
const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
|
|
283
330
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
284
331
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
285
332
|
return /* @__PURE__ */ u(
|
|
@@ -309,13 +356,13 @@ const PicPay = w((props, ref) => {
|
|
|
309
356
|
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
310
357
|
};
|
|
311
358
|
const Address = () => {
|
|
312
|
-
var
|
|
359
|
+
var _a2, _b;
|
|
313
360
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
314
361
|
AddressField,
|
|
315
362
|
{
|
|
316
363
|
ref: addressFieldRef,
|
|
317
364
|
value: form.address,
|
|
318
|
-
country: ((
|
|
365
|
+
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
|
|
319
366
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
320
367
|
}
|
|
321
368
|
) }) });
|
|
@@ -332,7 +379,24 @@ const PicPay = w((props, ref) => {
|
|
|
332
379
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.PIC_PAY }),
|
|
333
380
|
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
334
381
|
Email(),
|
|
382
|
+
/* @__PURE__ */ u(
|
|
383
|
+
SecuredFieldsProvider,
|
|
384
|
+
{
|
|
385
|
+
ref: SFPRef,
|
|
386
|
+
i18n,
|
|
387
|
+
checkoutId: core.id,
|
|
388
|
+
style: defaultInputStyleConfig,
|
|
389
|
+
sessionMode: (_a = session.checkout) == null ? void 0 : _a.sessionMode,
|
|
390
|
+
onFocus: onFieldsFocus,
|
|
391
|
+
onAfterPayment,
|
|
392
|
+
onPaymentError,
|
|
393
|
+
onPaymentTimeout: ({ message }) => onTimeout(i18n.get(message)),
|
|
394
|
+
onValidStatusChanged: onFieldValidStatusChanged,
|
|
395
|
+
children: /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(CPFField, { ref: cpfFieldRef, security }) })
|
|
396
|
+
}
|
|
397
|
+
),
|
|
335
398
|
Address(),
|
|
399
|
+
/* @__PURE__ */ u(Tip, { text: i18n.get("iofTip") }),
|
|
336
400
|
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
337
401
|
ErrorMessage(),
|
|
338
402
|
!hidePaymentButton && Button()
|