@paykka/card-checkout-ui 0.11.6 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-checkout-ui.js +17 -17
- package/dist/card-checkout-ui.umd.cjs +17 -17
- 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/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 +143 -90
- package/dist/es/components/ApplePay/index.js +99 -67
- package/dist/es/components/Boost/index.js +66 -39
- package/dist/es/components/Card/index.js +90 -79
- 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 +1 -1
- package/dist/es/components/GooglePay/index.js +93 -60
- package/dist/es/components/GrabPay/index.js +66 -39
- package/dist/es/components/GuideCard/index.js +10 -7
- package/dist/es/components/LinePay/index.js +66 -39
- package/dist/es/components/MayBankQRPay/index.js +306 -273
- package/dist/es/components/NinePay/index.js +66 -39
- package/dist/es/components/SecuredFieldsProvider/index.js +3 -2
- package/dist/es/components/SecuredIframe/index.js +4 -2
- package/dist/es/components/Sepa/index.js +62 -39
- package/dist/es/components/ShopeePay/index.js +66 -39
- package/dist/es/components/SubmitButton/index.js +8 -7
- package/dist/es/components/TNGWallet/index.js +66 -39
- package/dist/es/components/WechatPay/index.js +146 -92
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
- package/dist/es/components/index.js +1 -0
- 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/SelectMenuItem.js +12 -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 +68 -39
- package/dist/es/components/wallets/Paymaya/Paymaya.js +66 -39
- package/dist/es/components/wallets/Zalopay/Zalopay.js +386 -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} +78 -27
- package/dist/es/core/query.js +3 -2
- package/dist/es/core/{Session.js → session.js} +37 -20
- 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 +16 -4
- 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/payment.js +82 -0
- package/dist/es/utils/redirect.js +4 -4
- 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/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/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/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/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} +5 -3
- package/dist/types/core/context.d.ts +3 -2
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/core/session.d.ts +33 -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 +1 -0
- 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 +1 -0
- package/dist/types/utils/payment.d.ts +37 -0
- package/package.json +3 -3
- package/dist/types/core/Session.d.ts +0 -16
|
@@ -5,16 +5,15 @@ import "../../utils/card-brand/brands.js";
|
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
6
|
import { cssVarPrefix, 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";
|
|
@@ -34,7 +33,8 @@ const NinePay = w((props, ref) => {
|
|
|
34
33
|
redirectMode = "auto",
|
|
35
34
|
core,
|
|
36
35
|
autoQuery,
|
|
37
|
-
showGuideCard = true
|
|
36
|
+
showGuideCard = true,
|
|
37
|
+
hidePaymentButton = false
|
|
38
38
|
} = props;
|
|
39
39
|
F(ref, () => ({
|
|
40
40
|
stopRetry: () => {
|
|
@@ -49,15 +49,17 @@ const NinePay = w((props, ref) => {
|
|
|
49
49
|
var _a2;
|
|
50
50
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
51
51
|
return;
|
|
52
|
-
|
|
53
|
-
(
|
|
52
|
+
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
53
|
+
setForm(newForm);
|
|
54
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
|
|
55
|
+
validateForm();
|
|
54
56
|
},
|
|
55
57
|
updateEmail: () => {
|
|
56
58
|
var _a2;
|
|
57
59
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
58
60
|
return;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
const newForm = Object.assign(form, { email: emailState.email });
|
|
62
|
+
setForm(newForm);
|
|
61
63
|
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
62
64
|
validateForm();
|
|
63
65
|
},
|
|
@@ -65,7 +67,7 @@ const NinePay = w((props, ref) => {
|
|
|
65
67
|
hidePaymentButton && onSubmit();
|
|
66
68
|
}
|
|
67
69
|
}));
|
|
68
|
-
const
|
|
70
|
+
const addressCore = core.getAddressCore();
|
|
69
71
|
const emailState = createEmailCore();
|
|
70
72
|
const addressFieldRef = A(null);
|
|
71
73
|
const emailFieldRef = A(null);
|
|
@@ -76,13 +78,13 @@ const NinePay = w((props, ref) => {
|
|
|
76
78
|
const [form, setForm] = h({
|
|
77
79
|
email: "",
|
|
78
80
|
address: {
|
|
79
|
-
country:
|
|
80
|
-
province:
|
|
81
|
-
city:
|
|
82
|
-
area:
|
|
83
|
-
postCode:
|
|
84
|
-
address1:
|
|
85
|
-
address2:
|
|
81
|
+
country: void 0,
|
|
82
|
+
province: void 0,
|
|
83
|
+
city: void 0,
|
|
84
|
+
area: void 0,
|
|
85
|
+
postCode: void 0,
|
|
86
|
+
address1: void 0,
|
|
87
|
+
address2: void 0
|
|
86
88
|
}
|
|
87
89
|
});
|
|
88
90
|
const [validated, setValidated] = h(false);
|
|
@@ -100,17 +102,27 @@ const NinePay = w((props, ref) => {
|
|
|
100
102
|
}
|
|
101
103
|
setFieldStatus({ ...field });
|
|
102
104
|
};
|
|
105
|
+
const processOnSuccess = (res) => {
|
|
106
|
+
var _a2, _b2;
|
|
107
|
+
setSubmitButtonStatus("success");
|
|
108
|
+
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props, formatPaymentResult({
|
|
109
|
+
...res,
|
|
110
|
+
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
111
|
+
}));
|
|
112
|
+
};
|
|
103
113
|
y(() => {
|
|
104
114
|
if (!sessionReady) {
|
|
105
115
|
return;
|
|
106
116
|
}
|
|
107
|
-
const { bill = {},
|
|
108
|
-
if (!
|
|
117
|
+
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
118
|
+
if (!supportMethods.includes(PaymentMethod.NINE_PAY)) {
|
|
109
119
|
return;
|
|
110
120
|
}
|
|
111
121
|
setIsCheckoutEnabled(true);
|
|
112
122
|
initFieldStatus();
|
|
123
|
+
country && addressCore.setCountry(country);
|
|
113
124
|
form.email = bill.email ?? "";
|
|
125
|
+
form.address.country = country;
|
|
114
126
|
if (autoQuery && core.processingPaymentMethod === PaymentMethod.NINE_PAY) {
|
|
115
127
|
setSubmitButtonStatus("loading");
|
|
116
128
|
startReFetchPayInfo();
|
|
@@ -144,34 +156,49 @@ const NinePay = w((props, ref) => {
|
|
|
144
156
|
},
|
|
145
157
|
bill: {
|
|
146
158
|
email: form.email,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
addressLine1: form.address.address1,
|
|
160
|
+
addressLine2: form.address.address2,
|
|
161
|
+
postalCode: form.address.postCode,
|
|
162
|
+
country: form.address.country,
|
|
163
|
+
district: form.address.area,
|
|
164
|
+
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
165
|
+
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
150
166
|
},
|
|
151
167
|
browser: await getBrowserParams()
|
|
152
168
|
};
|
|
153
169
|
};
|
|
154
170
|
const pay = async (search = false, timeout) => {
|
|
155
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
171
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
156
172
|
try {
|
|
157
|
-
const paymentParams = await getPaymentParams();
|
|
158
173
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
let res = null;
|
|
175
|
+
if (search) {
|
|
176
|
+
const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", PaymentMethod.NINE_PAY);
|
|
177
|
+
res = await getNinePayInfo(
|
|
178
|
+
{
|
|
179
|
+
sessionId: session.sessionId,
|
|
180
|
+
clientKey: session.clientKey,
|
|
181
|
+
paymentMethod: PaymentMethod.NINE_PAY
|
|
182
|
+
},
|
|
183
|
+
extraParams,
|
|
184
|
+
requestOptions
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
const extraParams = (_d2 = (_c2 = core.config)._getExtraParams) == null ? void 0 : _d2.call(_c2, "payment", PaymentMethod.NINE_PAY);
|
|
188
|
+
res = await ninePay(await getPaymentParams(), extraParams, requestOptions);
|
|
189
|
+
}
|
|
190
|
+
!search && ((_e2 = props.onSubmitResponse) == null ? void 0 : _e2.call(props, res));
|
|
191
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
192
|
+
sessionId && (session.sessionId = sessionId);
|
|
165
193
|
if (status === "PROCESSING") {
|
|
166
194
|
if (!orderStatus) {
|
|
167
195
|
setSubmitButtonStatus("unSubmit");
|
|
168
196
|
return { end: true };
|
|
169
197
|
} else if (orderStatus === "SUCCESS") {
|
|
170
|
-
|
|
171
|
-
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
198
|
+
processOnSuccess(res);
|
|
172
199
|
return { end: true };
|
|
173
200
|
} else if (orderStatus === "FAILURE") {
|
|
174
|
-
setErrorMsg(errorMessage);
|
|
201
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
175
202
|
setSubmitButtonStatus("unSubmit");
|
|
176
203
|
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
177
204
|
return { end: true };
|
|
@@ -187,17 +214,16 @@ const NinePay = w((props, ref) => {
|
|
|
187
214
|
return { end: false };
|
|
188
215
|
} else if (orderStatus === "CANCELED") {
|
|
189
216
|
setSubmitButtonStatus("unSubmit");
|
|
190
|
-
(
|
|
217
|
+
(_f2 = props.onTimeout) == null ? void 0 : _f2.call(props);
|
|
191
218
|
core.resetEnablePaymentMethod();
|
|
192
219
|
return { end: true };
|
|
193
220
|
}
|
|
194
221
|
} else if (status === "SUCCESS") {
|
|
195
|
-
|
|
196
|
-
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
222
|
+
processOnSuccess(res);
|
|
197
223
|
return { end: true };
|
|
198
224
|
} else if (status === "EXPIRED") {
|
|
199
225
|
setSubmitButtonStatus("unSubmit");
|
|
200
|
-
(
|
|
226
|
+
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
201
227
|
return { end: true };
|
|
202
228
|
}
|
|
203
229
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -212,7 +238,7 @@ const NinePay = w((props, ref) => {
|
|
|
212
238
|
}
|
|
213
239
|
} else {
|
|
214
240
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
215
|
-
setErrorMsg(message);
|
|
241
|
+
message && setErrorMsg(message);
|
|
216
242
|
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
217
243
|
setSubmitButtonStatus("unSubmit");
|
|
218
244
|
return { end: true };
|
|
@@ -235,7 +261,7 @@ const NinePay = w((props, ref) => {
|
|
|
235
261
|
setErrorMsg("");
|
|
236
262
|
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
237
263
|
var _a3;
|
|
238
|
-
(fieldStatus == null ? void 0 : fieldStatus.address.show) &&
|
|
264
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
239
265
|
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
240
266
|
if (errors) {
|
|
241
267
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -305,7 +331,8 @@ const NinePay = w((props, ref) => {
|
|
|
305
331
|
{
|
|
306
332
|
value: {
|
|
307
333
|
i18n,
|
|
308
|
-
session
|
|
334
|
+
session,
|
|
335
|
+
core
|
|
309
336
|
},
|
|
310
337
|
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
|
|
311
338
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.NINE_PAY }),
|
|
@@ -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";
|
|
@@ -144,7 +144,8 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
144
144
|
action: MessageAction.INIT,
|
|
145
145
|
hidden: true,
|
|
146
146
|
apiUrl,
|
|
147
|
-
cdnUrl
|
|
147
|
+
cdnUrl,
|
|
148
|
+
apiPrefix
|
|
148
149
|
};
|
|
149
150
|
iframeEl.addEventListener("load", () => {
|
|
150
151
|
postMessageToIframe(data, hiddenIframe.current.contentWindow, cdnOrigin);
|
|
@@ -4,7 +4,7 @@ import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
|
4
4
|
import { getSupportedCardBrands, getSupportedCardBrandsLengths, findCardBrand } from "../../utils/card-brand/index.js";
|
|
5
5
|
import { limitedToNumber, trimAll } from "../../utils/format.js";
|
|
6
6
|
import { isUndefined, isNil } from "../../utils/is.js";
|
|
7
|
-
import { cdnOrigin, setApiUrl, setCDNUrl } from "../../config.js";
|
|
7
|
+
import { cdnOrigin, setApiUrl, setCDNUrl, setApiPrefix } from "../../config.js";
|
|
8
8
|
import { MessageAction } from "../../types/message.js";
|
|
9
9
|
import { generateClassNameMap, style2String, createPlaceholderStyle, loadStyle } from "../../utils/style.js";
|
|
10
10
|
import { postMessageToIframe } from "../../utils/iframe.js";
|
|
@@ -371,7 +371,6 @@ const FieldIframe = (props) => {
|
|
|
371
371
|
value: value.current,
|
|
372
372
|
fieldType: props.fieldType
|
|
373
373
|
};
|
|
374
|
-
console.log(hiddenIframe, props.hiddenIframeName);
|
|
375
374
|
postMessageToIframe(validWithValueData, hiddenIframe, cdnOrigin);
|
|
376
375
|
};
|
|
377
376
|
const sendActivatedMessage = () => {
|
|
@@ -583,6 +582,9 @@ const SecuredIframe = () => {
|
|
|
583
582
|
if (feedbackData.cdnUrl) {
|
|
584
583
|
setCDNUrl(feedbackData.cdnUrl);
|
|
585
584
|
}
|
|
585
|
+
if (feedbackData.apiPrefix) {
|
|
586
|
+
setApiPrefix(feedbackData.apiPrefix);
|
|
587
|
+
}
|
|
586
588
|
window.removeEventListener("message", onReceiveMessage);
|
|
587
589
|
setHasInit(true);
|
|
588
590
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { w, A, h, F, y, q, u } from "../../core.js";
|
|
2
|
-
import { createAddressCore } from "../../core/Address.js";
|
|
3
2
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
4
3
|
import { CoreContext } from "../../core/context.js";
|
|
5
4
|
import "../../utils/card-brand/brands.js";
|
|
6
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
6
|
import { cssVarPrefix, normalizedClass, formatAmount, trimAll } from "../../utils/format.js";
|
|
7
|
+
import { formatPaymentResult } from "../../utils/payment.js";
|
|
8
8
|
import { isTimeoutError } from "../../api/http.js";
|
|
9
|
-
import { COMMON_CLASS_NAME } from "../../constant.js";
|
|
10
9
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
10
|
+
import { COMMON_CLASS_NAME, PaymentMethod } from "../../constant.js";
|
|
11
11
|
import { getSepaPayInfo, sepaPay } from "../../api/modules/sepa/index.js";
|
|
12
12
|
import { PayKKaError } from "../../core/error.js";
|
|
13
13
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
@@ -26,8 +26,8 @@ const { bem } = useBEM("sepa");
|
|
|
26
26
|
const fieldClassNames = bem("field");
|
|
27
27
|
const Sepa = w((props, ref) => {
|
|
28
28
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29
|
-
const { session } = props;
|
|
30
|
-
|
|
29
|
+
const { session, core } = props;
|
|
30
|
+
const addressCore = core.getAddressCore();
|
|
31
31
|
let emailState = createEmailCore();
|
|
32
32
|
const { i18n, sessionReady } = usePayState(session, props.core);
|
|
33
33
|
const addressFieldRef = A(null);
|
|
@@ -38,13 +38,13 @@ const Sepa = w((props, ref) => {
|
|
|
38
38
|
iban: "",
|
|
39
39
|
holderName: "",
|
|
40
40
|
address: {
|
|
41
|
-
country:
|
|
42
|
-
province:
|
|
43
|
-
city:
|
|
44
|
-
area:
|
|
45
|
-
postCode:
|
|
46
|
-
address1:
|
|
47
|
-
address2:
|
|
41
|
+
country: void 0,
|
|
42
|
+
province: void 0,
|
|
43
|
+
city: void 0,
|
|
44
|
+
area: void 0,
|
|
45
|
+
postCode: void 0,
|
|
46
|
+
address1: void 0,
|
|
47
|
+
address2: void 0
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
const [validated, setValidated] = h(false);
|
|
@@ -65,24 +65,35 @@ const Sepa = w((props, ref) => {
|
|
|
65
65
|
var _a2;
|
|
66
66
|
if (!requiredBill)
|
|
67
67
|
return;
|
|
68
|
-
setForm(Object.assign(form, { address:
|
|
69
|
-
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(
|
|
68
|
+
setForm(Object.assign(form, { address: addressCore.getAddressState() }));
|
|
69
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
|
|
70
70
|
},
|
|
71
71
|
updateEmail: () => {
|
|
72
72
|
var _a2;
|
|
73
73
|
setForm(Object.assign(form, { email: emailState.email }));
|
|
74
|
+
form.email = emailState.email;
|
|
74
75
|
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
76
|
+
validateForm();
|
|
75
77
|
}
|
|
76
78
|
}));
|
|
79
|
+
const processOnSuccess = (res) => {
|
|
80
|
+
var _a2, _b2;
|
|
81
|
+
setSubmitButtonStatus("success");
|
|
82
|
+
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props, formatPaymentResult({
|
|
83
|
+
...res,
|
|
84
|
+
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
77
87
|
y(() => {
|
|
78
88
|
session.ready().then(() => {
|
|
79
89
|
setIsCheckoutEnabled(true);
|
|
80
|
-
const { bill, status } = session.checkout;
|
|
90
|
+
const { bill, status, country } = session.checkout;
|
|
91
|
+
country && addressCore.setCountry(country);
|
|
81
92
|
form.email = bill.email ?? "";
|
|
93
|
+
form.address.country = country;
|
|
82
94
|
disabledEmail.current = !!bill.email;
|
|
83
95
|
setRequiredBill(bill.billingAddressCollection === "REQUIRED");
|
|
84
96
|
if (status === "SUCCESS") {
|
|
85
|
-
setSubmitButtonStatus("success");
|
|
86
97
|
processOnSuccess();
|
|
87
98
|
}
|
|
88
99
|
});
|
|
@@ -125,7 +136,7 @@ const Sepa = w((props, ref) => {
|
|
|
125
136
|
setErrorMsg("");
|
|
126
137
|
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
127
138
|
var _a3;
|
|
128
|
-
requiredBill &&
|
|
139
|
+
requiredBill && addressCore.setValidateAllFields(true);
|
|
129
140
|
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
130
141
|
if (errors) {
|
|
131
142
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -154,14 +165,19 @@ const Sepa = w((props, ref) => {
|
|
|
154
165
|
sessionId: session.sessionId,
|
|
155
166
|
clientKey: session.clientKey,
|
|
156
167
|
payment: {
|
|
168
|
+
paymentMethod: PaymentMethod.SEPA_DEBIT,
|
|
157
169
|
holderName: form.holderName,
|
|
158
170
|
iban: trimAll(form.iban)
|
|
159
171
|
},
|
|
160
172
|
bill: requiredBill ? {
|
|
161
173
|
email: form.email,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
174
|
+
addressLine1: form.address.address1,
|
|
175
|
+
addressLine2: form.address.address2,
|
|
176
|
+
postalCode: form.address.postCode,
|
|
177
|
+
country: form.address.country,
|
|
178
|
+
district: form.address.area,
|
|
179
|
+
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
180
|
+
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
165
181
|
} : {
|
|
166
182
|
email: form.email
|
|
167
183
|
},
|
|
@@ -169,14 +185,25 @@ const Sepa = w((props, ref) => {
|
|
|
169
185
|
};
|
|
170
186
|
};
|
|
171
187
|
async function pay(search = false, timeout) {
|
|
172
|
-
var _a2;
|
|
188
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
173
189
|
try {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
190
|
+
const requestOptions = { locale: i18n.locale, timeout };
|
|
191
|
+
let res = null;
|
|
192
|
+
if (search) {
|
|
193
|
+
const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", PaymentMethod.SEPA_DEBIT);
|
|
194
|
+
res = await getSepaPayInfo(
|
|
195
|
+
{
|
|
196
|
+
sessionId: session.sessionId,
|
|
197
|
+
clientKey: session.clientKey,
|
|
198
|
+
paymentMethod: PaymentMethod.SEPA_DEBIT
|
|
199
|
+
},
|
|
200
|
+
extraParams,
|
|
201
|
+
requestOptions
|
|
202
|
+
);
|
|
203
|
+
} else {
|
|
204
|
+
const extraParams = (_d2 = (_c2 = core.config)._getExtraParams) == null ? void 0 : _d2.call(_c2, "payment", PaymentMethod.SEPA_DEBIT);
|
|
205
|
+
res = await sepaPay(await getPaymentParams(), extraParams, requestOptions);
|
|
206
|
+
}
|
|
180
207
|
return processAfterPayment(res, search);
|
|
181
208
|
} catch (error) {
|
|
182
209
|
if (isTimeoutError(error)) {
|
|
@@ -189,7 +216,7 @@ const Sepa = w((props, ref) => {
|
|
|
189
216
|
} else {
|
|
190
217
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
191
218
|
setErrorMsg(message);
|
|
192
|
-
(
|
|
219
|
+
(_e2 = props.onError) == null ? void 0 : _e2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
193
220
|
setSubmitButtonStatus("unSubmit");
|
|
194
221
|
return { end: true };
|
|
195
222
|
}
|
|
@@ -197,23 +224,23 @@ const Sepa = w((props, ref) => {
|
|
|
197
224
|
}
|
|
198
225
|
const processAfterPayment = (res, search = false) => {
|
|
199
226
|
var _a2, _b2, _c2;
|
|
200
|
-
const { status, orderStatus, errorMessage, errorCode } = res;
|
|
227
|
+
const { status, orderStatus, errorMessage, errorCode, sessionId } = res;
|
|
228
|
+
sessionId && (session.sessionId = sessionId);
|
|
201
229
|
if (status === "PROCESSING") {
|
|
202
230
|
if (!orderStatus) {
|
|
203
231
|
setSubmitButtonStatus("unSubmit");
|
|
204
232
|
return { end: true };
|
|
205
233
|
} else if (orderStatus === "SUCCESS") {
|
|
206
|
-
|
|
207
|
-
processOnSuccess();
|
|
234
|
+
processOnSuccess(res);
|
|
208
235
|
} else if (orderStatus === "PROCESSING") {
|
|
209
236
|
if (search) {
|
|
210
|
-
processOnSuccess();
|
|
237
|
+
processOnSuccess(res);
|
|
211
238
|
} else {
|
|
212
239
|
startReFetchPayInfo();
|
|
213
240
|
}
|
|
214
241
|
return { end: search };
|
|
215
242
|
} else if (orderStatus === "FAILURE") {
|
|
216
|
-
setErrorMsg(errorMessage);
|
|
243
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
217
244
|
setSubmitButtonStatus("unSubmit");
|
|
218
245
|
(_a2 = props.onError) == null ? void 0 : _a2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
219
246
|
} else if (orderStatus === "AUTHORIZED") {
|
|
@@ -222,8 +249,7 @@ const Sepa = w((props, ref) => {
|
|
|
222
249
|
}
|
|
223
250
|
return { end: true };
|
|
224
251
|
} else if (status === "SUCCESS") {
|
|
225
|
-
|
|
226
|
-
processOnSuccess();
|
|
252
|
+
processOnSuccess(res);
|
|
227
253
|
return { end: true };
|
|
228
254
|
} else if (status === "EXPIRED") {
|
|
229
255
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -233,16 +259,13 @@ const Sepa = w((props, ref) => {
|
|
|
233
259
|
setSubmitButtonStatus("unSubmit");
|
|
234
260
|
return { end: true };
|
|
235
261
|
};
|
|
236
|
-
const processOnSuccess = () => {
|
|
237
|
-
var _a2, _b2;
|
|
238
|
-
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props, (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl);
|
|
239
|
-
};
|
|
240
262
|
return /* @__PURE__ */ u(
|
|
241
263
|
CoreContext.Provider,
|
|
242
264
|
{
|
|
243
265
|
value: {
|
|
244
266
|
i18n,
|
|
245
|
-
session
|
|
267
|
+
session,
|
|
268
|
+
core
|
|
246
269
|
},
|
|
247
270
|
children: sessionReady && isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
248
271
|
/* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|