@paykka/card-checkout-ui 0.13.2 → 0.13.5
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 +19 -19
- package/dist/es/_commonjsHelpers.js +1 -1
- package/dist/es/api/modules/opay-wallet/index.js +16 -0
- package/dist/es/api/modules/paga-wallet/index.js +16 -0
- package/dist/es/api/modules/pic-pay/index.js +16 -0
- package/dist/es/api/modules/pix/index.js +16 -0
- package/dist/es/api/modules/vietqr/index.js +4 -0
- package/dist/es/components/DropIn/index.js +42 -2
- package/dist/es/components/GuideCard/index.js +6 -1
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +6 -6
- package/dist/es/components/index.js +5 -0
- package/dist/es/components/internal/icons/IconOpayWallet.js +71 -0
- package/dist/es/components/internal/icons/IconPagaWallet.js +141 -0
- package/dist/es/components/internal/icons/IconPaymaya.js +42 -86
- package/dist/es/components/internal/icons/IconPicPay.js +49 -0
- package/dist/es/components/internal/icons/IconPix.js +75 -0
- package/dist/es/components/internal/icons/IconVietqr.js +45 -0
- package/dist/es/components/internal/icons/IconVietqrComplete.js +49 -0
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +346 -0
- package/dist/es/components/wallets/OpayWallet/index.js +1 -0
- package/dist/es/components/wallets/OpayWallet/opay-wallet.js +1 -0
- package/dist/es/components/wallets/OpayWallet/type.js +1 -0
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +346 -0
- package/dist/es/components/wallets/PagaWallet/index.js +1 -0
- package/dist/es/components/wallets/PagaWallet/paga-wallet.js +1 -0
- package/dist/es/components/wallets/PagaWallet/type.js +1 -0
- package/dist/es/components/wallets/PicPay/PicPay.js +346 -0
- package/dist/es/components/wallets/PicPay/index.js +1 -0
- package/dist/es/components/wallets/PicPay/pic-pay.js +1 -0
- package/dist/es/components/wallets/PicPay/type.js +1 -0
- package/dist/es/components/wallets/Pix/Pix.js +346 -0
- package/dist/es/components/wallets/Pix/index.js +1 -0
- package/dist/es/components/wallets/Pix/pix2.js +1 -0
- package/dist/es/components/wallets/Pix/type.js +1 -0
- package/dist/es/components/wallets/Vietqr/Vietqr.js +380 -0
- package/dist/es/components/wallets/Vietqr/index.js +1 -0
- package/dist/es/components/wallets/Vietqr/type.js +1 -0
- package/dist/es/components/wallets/Vietqr/vietqr2.js +1 -0
- package/dist/es/components/wallets/Zalopay/Zalopay.js +1 -0
- package/dist/es/components/wallets/index.js +8 -0
- package/dist/es/constant.js +32 -2
- package/dist/es/core.js +34 -34
- package/dist/es/i18n/locales/de-DE.js +8 -2
- package/dist/es/i18n/locales/en-GB.js +8 -2
- package/dist/es/i18n/locales/es-ES.js +8 -2
- package/dist/es/i18n/locales/fr-FR.js +8 -2
- package/dist/es/i18n/locales/ja-JP.js +8 -2
- package/dist/es/i18n/locales/ko-KR.js +8 -2
- package/dist/es/i18n/locales/nl-NL.js +8 -2
- package/dist/es/i18n/locales/pt-PT.js +8 -2
- package/dist/es/i18n/locales/ru-RU.js +8 -2
- package/dist/es/i18n/locales/zh-CN.js +10 -4
- package/dist/es/i18n/locales/zh-HK.js +10 -4
- package/dist/es/i18n/locales/zh-TW.js +10 -4
- package/dist/es/index.js +10 -0
- package/dist/es/style.css +1 -1
- package/dist/style.css +1 -1
- package/dist/types/api/modules/index.d.ts +5 -0
- package/dist/types/api/modules/opay-wallet/index.d.ts +4 -0
- package/dist/types/api/modules/paga-wallet/index.d.ts +4 -0
- package/dist/types/api/modules/pic-pay/index.d.ts +4 -0
- package/dist/types/api/modules/pix/index.d.ts +4 -0
- package/dist/types/api/modules/vietqr/index.d.ts +4 -0
- package/dist/types/components/DropIn/type.d.ts +3 -2
- package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -3
- package/dist/types/components/internal/icons/IconOpayWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPagaWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPicPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPix.d.ts +2 -0
- package/dist/types/components/internal/icons/IconVietqr.d.ts +2 -0
- package/dist/types/components/internal/icons/IconVietqrComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +6 -0
- package/dist/types/components/wallets/OpayWallet/OpayWallet.d.ts +10 -0
- package/dist/types/components/wallets/OpayWallet/index.d.ts +2 -0
- package/dist/types/components/wallets/OpayWallet/type.d.ts +40 -0
- package/dist/types/components/wallets/PagaWallet/PagaWallet.d.ts +10 -0
- package/dist/types/components/wallets/PagaWallet/index.d.ts +2 -0
- package/dist/types/components/wallets/PagaWallet/type.d.ts +40 -0
- package/dist/types/components/wallets/PicPay/PicPay.d.ts +10 -0
- package/dist/types/components/wallets/PicPay/index.d.ts +2 -0
- package/dist/types/components/wallets/PicPay/type.d.ts +40 -0
- package/dist/types/components/wallets/Pix/Pix.d.ts +10 -0
- package/dist/types/components/wallets/Pix/index.d.ts +2 -0
- package/dist/types/components/wallets/Pix/type.d.ts +40 -0
- package/dist/types/components/wallets/Vietqr/Vietqr.d.ts +10 -0
- package/dist/types/components/wallets/Vietqr/index.d.ts +2 -0
- package/dist/types/components/wallets/Vietqr/type.d.ts +39 -0
- package/dist/types/components/wallets/index.d.ts +8 -0
- package/dist/types/components/wallets/type.d.ts +9 -0
- package/dist/types/constant.d.ts +11 -1
- package/dist/types/i18n/locales/de-DE.d.ts +6 -0
- package/dist/types/i18n/locales/en-GB.d.ts +6 -0
- package/dist/types/i18n/locales/es-ES.d.ts +6 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +6 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +6 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +6 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +6 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +6 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +6 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +6 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +6 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +6 -0
- package/package.json +67 -67
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { w, F, A, h, y, q, u, b } from "../../../core.js";
|
|
2
|
+
import { useBEM } from "../../../hooks/useBEM.js";
|
|
3
|
+
import { CoreContext } from "../../../core/context.js";
|
|
4
|
+
import "../../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { isMobile } from "../../../utils/system-info/get-system-info.js";
|
|
7
|
+
import { normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
8
|
+
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
9
|
+
import { processPaymentStatus } from "../../../utils/payment.js";
|
|
10
|
+
import { isTimeoutError } from "../../../api/http.js";
|
|
11
|
+
import { getBrowserParams } from "../../../api/modules/get-browser-params.js";
|
|
12
|
+
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../../constant.js";
|
|
13
|
+
import { getZalopayPayInfo, zalopayPay } from "../../../api/modules/zalopay/index.js";
|
|
14
|
+
import { PayKKaError } from "../../../core/error.js";
|
|
15
|
+
import { usePayState } from "../../../hooks/usePayState.js";
|
|
16
|
+
import { useRetry } from "../../../hooks/useRetry.js";
|
|
17
|
+
import { usePaymentStatus } from "../../../hooks/usePayment.js";
|
|
18
|
+
import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
|
|
19
|
+
import { SubmitButton } from "../../SubmitButton/index.js";
|
|
20
|
+
import { GuideCard } from "../../GuideCard/index.js";
|
|
21
|
+
import { AddressField } from "../../AddressField/index.js";
|
|
22
|
+
import { Info } from "../../internal/Info/Info.js";
|
|
23
|
+
import "../../internal/Form/type.js";
|
|
24
|
+
import "../../internal/Form/context.js";
|
|
25
|
+
import "../../internal/Form/FormItem.js";
|
|
26
|
+
import { Form } from "../../internal/Form/Form.js";
|
|
27
|
+
import { QRCodeModal } from "../../business/QRCodeModal/QRCodeModal.js";
|
|
28
|
+
import { IconVietqrComplete } from "../../internal/icons/IconVietqrComplete.js";
|
|
29
|
+
import "./vietqr2.js";
|
|
30
|
+
const { bem } = useBEM("vietqr");
|
|
31
|
+
const fieldClassNames = bem("field");
|
|
32
|
+
const Vietqr = w((props, ref) => {
|
|
33
|
+
var _a;
|
|
34
|
+
const {
|
|
35
|
+
session,
|
|
36
|
+
showEmail = false,
|
|
37
|
+
showAddress = false,
|
|
38
|
+
core,
|
|
39
|
+
redirectMode = "auto",
|
|
40
|
+
autoQuery = true,
|
|
41
|
+
showGuideCard = true,
|
|
42
|
+
enableQRCodeModal = true,
|
|
43
|
+
hidePaymentButton = false
|
|
44
|
+
} = props;
|
|
45
|
+
F(ref, () => ({
|
|
46
|
+
stopRetry: () => {
|
|
47
|
+
setPaymentButtonStatus("unSubmit");
|
|
48
|
+
stopReFetchPayInfo();
|
|
49
|
+
},
|
|
50
|
+
startRetry: (timeout) => {
|
|
51
|
+
setPaymentButtonStatus("loading");
|
|
52
|
+
startReFetchPayInfo({ timeout });
|
|
53
|
+
},
|
|
54
|
+
updateAddress: () => {
|
|
55
|
+
var _a2;
|
|
56
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
57
|
+
return;
|
|
58
|
+
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
59
|
+
setForm(newForm);
|
|
60
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressCore.getAddressState());
|
|
61
|
+
validateForm();
|
|
62
|
+
},
|
|
63
|
+
updateEmail: () => {
|
|
64
|
+
var _a2;
|
|
65
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
66
|
+
return;
|
|
67
|
+
const newForm = Object.assign(form, { email: emailState.email });
|
|
68
|
+
setForm(newForm);
|
|
69
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
70
|
+
validateForm();
|
|
71
|
+
},
|
|
72
|
+
payment: () => {
|
|
73
|
+
hidePaymentButton && onSubmit();
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
76
|
+
const addressCore = core.getAddressCore();
|
|
77
|
+
const emailState = createEmailCore();
|
|
78
|
+
const addressFieldRef = A(null);
|
|
79
|
+
const emailFieldRef = A(null);
|
|
80
|
+
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
81
|
+
const { i18n, sessionReady } = usePayState(session);
|
|
82
|
+
const { errorMsg, setErrorMsg, paymentButtonStatus, setPaymentButtonStatus } = usePaymentStatus();
|
|
83
|
+
const formRef = A(null);
|
|
84
|
+
const [form, setForm] = h({
|
|
85
|
+
email: "",
|
|
86
|
+
address: {
|
|
87
|
+
country: void 0,
|
|
88
|
+
province: void 0,
|
|
89
|
+
city: void 0,
|
|
90
|
+
area: void 0,
|
|
91
|
+
postCode: void 0,
|
|
92
|
+
address1: void 0,
|
|
93
|
+
address2: void 0
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const [validated, setValidated] = h(false);
|
|
97
|
+
const [fieldStatus, setFieldStatus] = h();
|
|
98
|
+
const [showQRCodeModal, setShowQRCodeModal] = h(false);
|
|
99
|
+
const [qrCodeInfo, setQrCodeInfo] = h();
|
|
100
|
+
const initFieldStatus = () => {
|
|
101
|
+
const { field, sessionMode } = session.checkout;
|
|
102
|
+
const { email, address } = field;
|
|
103
|
+
if (sessionMode === SessionMode.COMPONENT) {
|
|
104
|
+
if (email.disabled) {
|
|
105
|
+
email.show = showEmail;
|
|
106
|
+
}
|
|
107
|
+
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
108
|
+
address.show = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
setFieldStatus({ ...field });
|
|
112
|
+
};
|
|
113
|
+
y(() => {
|
|
114
|
+
if (!sessionReady) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
118
|
+
if (!supportMethods.includes(PaymentMethod.VIETQR)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
initFieldStatus();
|
|
122
|
+
setIsCheckoutEnabled(true);
|
|
123
|
+
country && addressCore.setCountry(country);
|
|
124
|
+
form.email = bill.email ?? "";
|
|
125
|
+
form.address.country = country;
|
|
126
|
+
if (autoQuery && core.processingPaymentMethod === PaymentMethod.VIETQR) {
|
|
127
|
+
setPaymentButtonStatus("loading");
|
|
128
|
+
startReFetchPayInfo();
|
|
129
|
+
}
|
|
130
|
+
}, [sessionReady]);
|
|
131
|
+
const processOnError = (error) => {
|
|
132
|
+
var _a2;
|
|
133
|
+
setShowQRCodeModal(false);
|
|
134
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
135
|
+
core.resetEnablePaymentMethod();
|
|
136
|
+
};
|
|
137
|
+
const onTimeout = q(
|
|
138
|
+
(message) => {
|
|
139
|
+
var _a2;
|
|
140
|
+
setShowQRCodeModal(false);
|
|
141
|
+
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
142
|
+
setPaymentButtonStatus("unSubmit");
|
|
143
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry");
|
|
144
|
+
core.resetEnablePaymentMethod();
|
|
145
|
+
},
|
|
146
|
+
[i18n, props.onTimeout]
|
|
147
|
+
);
|
|
148
|
+
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
149
|
+
(timeout) => pay(true, timeout),
|
|
150
|
+
{
|
|
151
|
+
timeout: 10 * 60 * 1e3,
|
|
152
|
+
onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
const getPaymentParams = async () => {
|
|
156
|
+
return {
|
|
157
|
+
sessionId: session.sessionId,
|
|
158
|
+
clientKey: session.clientKey,
|
|
159
|
+
payment: {
|
|
160
|
+
paymentMethod: PaymentMethod.VIETQR
|
|
161
|
+
},
|
|
162
|
+
bill: {
|
|
163
|
+
email: form.email,
|
|
164
|
+
addressLine1: form.address.address1,
|
|
165
|
+
addressLine2: form.address.address2,
|
|
166
|
+
postalCode: form.address.postCode,
|
|
167
|
+
country: form.address.country,
|
|
168
|
+
district: form.address.area,
|
|
169
|
+
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
170
|
+
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
171
|
+
},
|
|
172
|
+
browser: await getBrowserParams()
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const pay = async (search = false, timeout) => {
|
|
176
|
+
var _a2, _b, _c, _d, _e;
|
|
177
|
+
try {
|
|
178
|
+
const requestOptions = { locale: i18n.locale, timeout };
|
|
179
|
+
let res = null;
|
|
180
|
+
if (search) {
|
|
181
|
+
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.VIETQR);
|
|
182
|
+
res = await getZalopayPayInfo(
|
|
183
|
+
{
|
|
184
|
+
sessionId: session.sessionId,
|
|
185
|
+
clientKey: session.clientKey,
|
|
186
|
+
paymentMethod: PaymentMethod.VIETQR
|
|
187
|
+
},
|
|
188
|
+
extraParams,
|
|
189
|
+
requestOptions
|
|
190
|
+
);
|
|
191
|
+
} else {
|
|
192
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.VIETQR);
|
|
193
|
+
res = await zalopayPay(await getPaymentParams(), extraParams, requestOptions);
|
|
194
|
+
}
|
|
195
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
196
|
+
const { errorMessage, errorCode, payInfo = {}, sessionId } = res;
|
|
197
|
+
sessionId && (session.sessionId = sessionId);
|
|
198
|
+
const { paymentExpiredAt } = payInfo;
|
|
199
|
+
let end = true;
|
|
200
|
+
processPaymentStatus(res, {
|
|
201
|
+
onProcessing: () => {
|
|
202
|
+
if (!search && payInfo) {
|
|
203
|
+
if (isMobile()) {
|
|
204
|
+
if (redirectMode === "auto") {
|
|
205
|
+
redirectToPayment(payInfo);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
} else {
|
|
209
|
+
if (enableQRCodeModal) {
|
|
210
|
+
setShowQRCodeModal(true);
|
|
211
|
+
setQrCodeInfo({
|
|
212
|
+
qrCode: payInfo.qr_code || payInfo.request_url,
|
|
213
|
+
expiredTime: paymentExpiredAt
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
startReFetchPayInfo();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
end = false;
|
|
220
|
+
},
|
|
221
|
+
onSuccess: () => {
|
|
222
|
+
var _a3;
|
|
223
|
+
setShowQRCodeModal(false);
|
|
224
|
+
setPaymentButtonStatus("success");
|
|
225
|
+
(_a3 = props.onSuccess) == null ? void 0 : _a3.call(props, res);
|
|
226
|
+
},
|
|
227
|
+
onFailure: () => {
|
|
228
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
229
|
+
setPaymentButtonStatus("unSubmit");
|
|
230
|
+
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
231
|
+
},
|
|
232
|
+
onCanceled: () => {
|
|
233
|
+
var _a3;
|
|
234
|
+
core.resetEnablePaymentMethod();
|
|
235
|
+
setPaymentButtonStatus("unSubmit");
|
|
236
|
+
(_a3 = props.onTimeout) == null ? void 0 : _a3.call(props, "channel");
|
|
237
|
+
},
|
|
238
|
+
onExpired: () => {
|
|
239
|
+
var _a3;
|
|
240
|
+
setShowQRCodeModal(false);
|
|
241
|
+
setPaymentButtonStatus("unSubmit");
|
|
242
|
+
(_a3 = props.onExpired) == null ? void 0 : _a3.call(props);
|
|
243
|
+
},
|
|
244
|
+
onDefault: () => {
|
|
245
|
+
setPaymentButtonStatus("unSubmit");
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
return { end };
|
|
249
|
+
} catch (error) {
|
|
250
|
+
if (isTimeoutError(error)) {
|
|
251
|
+
if (search) {
|
|
252
|
+
return { end: false };
|
|
253
|
+
} else {
|
|
254
|
+
onTimeout();
|
|
255
|
+
return { end: true };
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
259
|
+
message && setErrorMsg(message);
|
|
260
|
+
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
261
|
+
setPaymentButtonStatus("unSubmit");
|
|
262
|
+
return { end: true };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const validateForm = () => {
|
|
267
|
+
var _a2;
|
|
268
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
269
|
+
setValidated(true);
|
|
270
|
+
}).catch(() => {
|
|
271
|
+
setValidated(false);
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
y(() => {
|
|
275
|
+
validateForm();
|
|
276
|
+
}, [form]);
|
|
277
|
+
const onSubmit = async () => {
|
|
278
|
+
var _a2;
|
|
279
|
+
setErrorMsg("");
|
|
280
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
281
|
+
var _a3;
|
|
282
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
283
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
284
|
+
if (errors) {
|
|
285
|
+
setPaymentButtonStatus("unSubmit");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setErrorMsg("");
|
|
289
|
+
setPaymentButtonStatus("loading");
|
|
290
|
+
await pay();
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
const handleCloseQRCodeModal = () => {
|
|
294
|
+
var _a2;
|
|
295
|
+
setPaymentButtonStatus("unSubmit");
|
|
296
|
+
stopReFetchPayInfo();
|
|
297
|
+
setShowQRCodeModal(false);
|
|
298
|
+
setQrCodeInfo(void 0);
|
|
299
|
+
(_a2 = props.onCloseModal) == null ? void 0 : _a2.call(props);
|
|
300
|
+
};
|
|
301
|
+
const setFormRef = (dom) => {
|
|
302
|
+
formRef.current = dom;
|
|
303
|
+
dom && validateForm();
|
|
304
|
+
};
|
|
305
|
+
const PaymentButton = () => {
|
|
306
|
+
var _a2;
|
|
307
|
+
const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
|
|
308
|
+
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
309
|
+
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
310
|
+
return /* @__PURE__ */ u(
|
|
311
|
+
SubmitButton,
|
|
312
|
+
{
|
|
313
|
+
className: bem("button"),
|
|
314
|
+
status: paymentButtonStatus,
|
|
315
|
+
text,
|
|
316
|
+
onClick: onSubmit,
|
|
317
|
+
verified: validated
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
const Email = () => {
|
|
322
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
323
|
+
EmailField,
|
|
324
|
+
{
|
|
325
|
+
ref: emailFieldRef,
|
|
326
|
+
value: form.email,
|
|
327
|
+
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
328
|
+
}
|
|
329
|
+
) }) });
|
|
330
|
+
};
|
|
331
|
+
const ErrorMessage = () => {
|
|
332
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
|
|
333
|
+
};
|
|
334
|
+
const Address = () => {
|
|
335
|
+
var _a2, _b;
|
|
336
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
337
|
+
AddressField,
|
|
338
|
+
{
|
|
339
|
+
ref: addressFieldRef,
|
|
340
|
+
value: form.address,
|
|
341
|
+
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),
|
|
342
|
+
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
343
|
+
}
|
|
344
|
+
) }) });
|
|
345
|
+
};
|
|
346
|
+
return /* @__PURE__ */ u(
|
|
347
|
+
CoreContext.Provider,
|
|
348
|
+
{
|
|
349
|
+
value: {
|
|
350
|
+
i18n,
|
|
351
|
+
session,
|
|
352
|
+
core
|
|
353
|
+
},
|
|
354
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
|
|
355
|
+
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.VIETQR }),
|
|
356
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
357
|
+
Email(),
|
|
358
|
+
Address(),
|
|
359
|
+
ErrorMessage(),
|
|
360
|
+
!hidePaymentButton && PaymentButton()
|
|
361
|
+
] }) }),
|
|
362
|
+
showQRCodeModal && /* @__PURE__ */ u(
|
|
363
|
+
QRCodeModal,
|
|
364
|
+
{
|
|
365
|
+
title: i18n.get("qrCode.scanByVietqr"),
|
|
366
|
+
qrCode: qrCodeInfo.qrCode,
|
|
367
|
+
icon: /* @__PURE__ */ u(IconVietqrComplete, { size: 22 }),
|
|
368
|
+
amount: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount,
|
|
369
|
+
expiredTime: qrCodeInfo.expiredTime,
|
|
370
|
+
borderColor: "#DC2626",
|
|
371
|
+
onClose: handleCloseQRCodeModal
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] })
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
export {
|
|
379
|
+
Vietqr
|
|
380
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./Vietqr.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -369,6 +369,7 @@ const Zalopay = w((props, ref) => {
|
|
|
369
369
|
icon: /* @__PURE__ */ u(IconZalopayComplete, { size: 22 }),
|
|
370
370
|
amount: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount,
|
|
371
371
|
expiredTime: qrCodeInfo.expiredTime,
|
|
372
|
+
borderColor: "#00CF6A",
|
|
372
373
|
onClose: handleCloseQRCodeModal
|
|
373
374
|
}
|
|
374
375
|
)
|
package/dist/es/constant.js
CHANGED
|
@@ -25,6 +25,11 @@ var PaymentMethod = /* @__PURE__ */ ((PaymentMethod2) => {
|
|
|
25
25
|
PaymentMethod2["GCASH"] = "G_CASH";
|
|
26
26
|
PaymentMethod2["PAYMAYA"] = "PAYMAYA";
|
|
27
27
|
PaymentMethod2["ZALOPAY"] = "ZALOPAY";
|
|
28
|
+
PaymentMethod2["VIETQR"] = "VIETQR";
|
|
29
|
+
PaymentMethod2["PIX"] = "PIX";
|
|
30
|
+
PaymentMethod2["PIC_PAY"] = "PIC_PAY";
|
|
31
|
+
PaymentMethod2["OPAY_WALLET"] = "OPAY_WALLET";
|
|
32
|
+
PaymentMethod2["PAGA_WALLET"] = "PAGA_WALLET";
|
|
28
33
|
PaymentMethod2["SEPA_DEBIT"] = "SEPA_DEBIT";
|
|
29
34
|
return PaymentMethod2;
|
|
30
35
|
})(PaymentMethod || {});
|
|
@@ -44,7 +49,12 @@ var PaymentCategory = /* @__PURE__ */ ((PaymentCategory2) => {
|
|
|
44
49
|
PaymentCategory2["NINE_PAY"] = "ninePay";
|
|
45
50
|
PaymentCategory2["GCASH"] = "gcash";
|
|
46
51
|
PaymentCategory2["PAYMAYA"] = "paymaya";
|
|
52
|
+
PaymentCategory2["VIETQR"] = "vietqr";
|
|
47
53
|
PaymentCategory2["ZALOPAY"] = "zalopay";
|
|
54
|
+
PaymentCategory2["PIX"] = "pix";
|
|
55
|
+
PaymentCategory2["PIC_PAY"] = "picPay";
|
|
56
|
+
PaymentCategory2["OPAY_WALLET"] = "opayWallet";
|
|
57
|
+
PaymentCategory2["PAGA_WALLET"] = "pagaWallet";
|
|
48
58
|
return PaymentCategory2;
|
|
49
59
|
})(PaymentCategory || {});
|
|
50
60
|
const PaymentMethod2CategoryMap = {
|
|
@@ -107,8 +117,28 @@ const PaymentMethod2CategoryMap = {
|
|
|
107
117
|
[
|
|
108
118
|
"ZALOPAY"
|
|
109
119
|
/* ZALOPAY */
|
|
110
|
-
]: "zalopay"
|
|
111
|
-
|
|
120
|
+
]: "zalopay",
|
|
121
|
+
[
|
|
122
|
+
"VIETQR"
|
|
123
|
+
/* VIETQR */
|
|
124
|
+
]: "vietqr",
|
|
125
|
+
[
|
|
126
|
+
"PIX"
|
|
127
|
+
/* PIX */
|
|
128
|
+
]: "pix",
|
|
129
|
+
[
|
|
130
|
+
"PIC_PAY"
|
|
131
|
+
/* PIC_PAY */
|
|
132
|
+
]: "picPay",
|
|
133
|
+
[
|
|
134
|
+
"OPAY_WALLET"
|
|
135
|
+
/* OPAY_WALLET */
|
|
136
|
+
]: "opayWallet",
|
|
137
|
+
[
|
|
138
|
+
"PAGA_WALLET"
|
|
139
|
+
/* PAGA_WALLET */
|
|
140
|
+
]: "pagaWallet"
|
|
141
|
+
/* PAGA_WALLET */
|
|
112
142
|
};
|
|
113
143
|
const CardPaymentMethods = [
|
|
114
144
|
"VISA",
|
package/dist/es/core.js
CHANGED
|
@@ -695,36 +695,6 @@ l$3.diffed = function(n2) {
|
|
|
695
695
|
var t2 = n2.props, e2 = n2.__e;
|
|
696
696
|
null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value);
|
|
697
697
|
};
|
|
698
|
-
function e$1(e2, n2) {
|
|
699
|
-
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
700
|
-
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
701
|
-
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
702
|
-
return Promise.resolve(s2.responseText);
|
|
703
|
-
}, json: function() {
|
|
704
|
-
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
705
|
-
}, blob: function() {
|
|
706
|
-
return Promise.resolve(new Blob([s2.response]));
|
|
707
|
-
}, clone: e3, headers: { keys: function() {
|
|
708
|
-
return o2;
|
|
709
|
-
}, entries: function() {
|
|
710
|
-
return o2.map(function(e4) {
|
|
711
|
-
return [e4, s2.getResponseHeader(e4)];
|
|
712
|
-
});
|
|
713
|
-
}, get: function(e4) {
|
|
714
|
-
return s2.getResponseHeader(e4);
|
|
715
|
-
}, has: function(e4) {
|
|
716
|
-
return null != s2.getResponseHeader(e4);
|
|
717
|
-
} } };
|
|
718
|
-
};
|
|
719
|
-
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
720
|
-
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
721
|
-
u2[n3] || o2.push(u2[n3] = n3);
|
|
722
|
-
}), t2(a2());
|
|
723
|
-
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
724
|
-
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
725
|
-
s2.send(n2.body || null);
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
698
|
var __assign = function() {
|
|
729
699
|
__assign = Object.assign || function __assign2(t2) {
|
|
730
700
|
for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
|
|
@@ -3937,7 +3907,7 @@ function t() {
|
|
|
3937
3907
|
}
|
|
3938
3908
|
var o = void 0;
|
|
3939
3909
|
var h = void 0, s$1 = 0, f = 0, v = 0;
|
|
3940
|
-
function e(i2) {
|
|
3910
|
+
function e$1(i2) {
|
|
3941
3911
|
if (void 0 !== o) {
|
|
3942
3912
|
var t2 = i2.n;
|
|
3943
3913
|
if (void 0 === t2 || t2.t !== o) {
|
|
@@ -4028,7 +3998,7 @@ u.prototype.peek = function() {
|
|
|
4028
3998
|
}
|
|
4029
3999
|
};
|
|
4030
4000
|
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
4031
|
-
var i2 = e(this);
|
|
4001
|
+
var i2 = e$1(this);
|
|
4032
4002
|
if (void 0 !== i2)
|
|
4033
4003
|
i2.i = this.i;
|
|
4034
4004
|
return this.v;
|
|
@@ -4159,7 +4129,7 @@ y.prototype.N = function() {
|
|
|
4159
4129
|
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
4160
4130
|
if (1 & this.f)
|
|
4161
4131
|
throw new Error("Cycle detected");
|
|
4162
|
-
var i2 = e(this);
|
|
4132
|
+
var i2 = e$1(this);
|
|
4163
4133
|
this.h();
|
|
4164
4134
|
if (void 0 !== i2)
|
|
4165
4135
|
i2.i = this.i;
|
|
@@ -4442,6 +4412,36 @@ function useSignal(n2) {
|
|
|
4442
4412
|
return d$1(n2);
|
|
4443
4413
|
}, []);
|
|
4444
4414
|
}
|
|
4415
|
+
function e(e2, n2) {
|
|
4416
|
+
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
4417
|
+
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
4418
|
+
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
4419
|
+
return Promise.resolve(s2.responseText);
|
|
4420
|
+
}, json: function() {
|
|
4421
|
+
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
4422
|
+
}, blob: function() {
|
|
4423
|
+
return Promise.resolve(new Blob([s2.response]));
|
|
4424
|
+
}, clone: e3, headers: { keys: function() {
|
|
4425
|
+
return o2;
|
|
4426
|
+
}, entries: function() {
|
|
4427
|
+
return o2.map(function(e4) {
|
|
4428
|
+
return [e4, s2.getResponseHeader(e4)];
|
|
4429
|
+
});
|
|
4430
|
+
}, get: function(e4) {
|
|
4431
|
+
return s2.getResponseHeader(e4);
|
|
4432
|
+
}, has: function(e4) {
|
|
4433
|
+
return null != s2.getResponseHeader(e4);
|
|
4434
|
+
} } };
|
|
4435
|
+
};
|
|
4436
|
+
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
4437
|
+
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
4438
|
+
u2[n3] || o2.push(u2[n3] = n3);
|
|
4439
|
+
}), t2(a2());
|
|
4440
|
+
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
4441
|
+
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
4442
|
+
s2.send(n2.body || null);
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
4445
|
var browser = {};
|
|
4446
4446
|
var canPromise$1 = function() {
|
|
4447
4447
|
return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
|
|
@@ -6440,7 +6440,7 @@ export {
|
|
|
6440
6440
|
b$1 as b,
|
|
6441
6441
|
browser,
|
|
6442
6442
|
d$1 as d,
|
|
6443
|
-
e
|
|
6443
|
+
e,
|
|
6444
6444
|
h$1 as h,
|
|
6445
6445
|
index,
|
|
6446
6446
|
inputToRGB,
|
|
@@ -13,8 +13,13 @@ const deDE = {
|
|
|
13
13
|
"dropIn.linePay.label": "LinePay",
|
|
14
14
|
"dropIn.ninePay.label": "9Pay",
|
|
15
15
|
"dropIn.gcash.label": "GCash",
|
|
16
|
-
"dropIn.paymaya.label": "
|
|
16
|
+
"dropIn.paymaya.label": "Maya",
|
|
17
17
|
"dropIn.zalopay.label": "Zalopay",
|
|
18
|
+
"dropIn.vietqr.label": "VietQR",
|
|
19
|
+
"dropIn.pix.label": "Pix",
|
|
20
|
+
"dropIn.picPay.label": "PicPay",
|
|
21
|
+
"dropIn.opayWallet.label": "OPay Wallet",
|
|
22
|
+
"dropIn.pagaWallet.label": "Paga Wallet",
|
|
18
23
|
// card number
|
|
19
24
|
"card.cardNumber.label": "Kartennummer",
|
|
20
25
|
"card.cardNumber.incomplete": "Ihre Kartennummer ist unvollständig",
|
|
@@ -83,7 +88,8 @@ const deDE = {
|
|
|
83
88
|
// qrCode
|
|
84
89
|
"qrCode.expired": "Der QR-Code ist abgelaufen.",
|
|
85
90
|
"qrCode.scanByGcash": "QR-Code mit GCash scannen",
|
|
86
|
-
"qrCode.scanByZalopay": "QR-Code mit Zalopay scannen"
|
|
91
|
+
"qrCode.scanByZalopay": "QR-Code mit Zalopay scannen",
|
|
92
|
+
"qrCode.scanByVietqr": "QR-Code mit VietQR scannen"
|
|
87
93
|
};
|
|
88
94
|
export {
|
|
89
95
|
deDE as default
|
|
@@ -13,8 +13,13 @@ const enGB = {
|
|
|
13
13
|
"dropIn.linePay.label": "LinePay",
|
|
14
14
|
"dropIn.ninePay.label": "9Pay",
|
|
15
15
|
"dropIn.gcash.label": "GCash",
|
|
16
|
-
"dropIn.paymaya.label": "
|
|
16
|
+
"dropIn.paymaya.label": "Maya",
|
|
17
17
|
"dropIn.zalopay.label": "Zalopay",
|
|
18
|
+
"dropIn.vietqr.label": "VietQR",
|
|
19
|
+
"dropIn.pix.label": "Pix",
|
|
20
|
+
"dropIn.picPay.label": "PicPay",
|
|
21
|
+
"dropIn.opayWallet.label": "OPay Wallet",
|
|
22
|
+
"dropIn.pagaWallet.label": "Paga Wallet",
|
|
18
23
|
// card number
|
|
19
24
|
"card.cardNumber.label": "Card number",
|
|
20
25
|
"card.cardNumber.incomplete": "Your card number is incomplete",
|
|
@@ -83,7 +88,8 @@ const enGB = {
|
|
|
83
88
|
// qrCode
|
|
84
89
|
"qrCode.expired": "The QR code has expired.",
|
|
85
90
|
"qrCode.scanByGcash": "Scan QR code with GCash",
|
|
86
|
-
"qrCode.scanByZalopay": "Scan QR code with Zalopay"
|
|
91
|
+
"qrCode.scanByZalopay": "Scan QR code with Zalopay",
|
|
92
|
+
"qrCode.scanByVietqr": "Scan QR code with VietQR"
|
|
87
93
|
};
|
|
88
94
|
export {
|
|
89
95
|
enGB as default
|
|
@@ -13,8 +13,13 @@ const esES = {
|
|
|
13
13
|
"dropIn.linePay.label": "LinePay",
|
|
14
14
|
"dropIn.ninePay.label": "9Pay",
|
|
15
15
|
"dropIn.gcash.label": "GCash",
|
|
16
|
-
"dropIn.paymaya.label": "
|
|
16
|
+
"dropIn.paymaya.label": "Maya",
|
|
17
17
|
"dropIn.zalopay.label": "Zalopay",
|
|
18
|
+
"dropIn.vietqr.label": "VietQR",
|
|
19
|
+
"dropIn.pix.label": "Pix",
|
|
20
|
+
"dropIn.picPay.label": "PicPay",
|
|
21
|
+
"dropIn.opayWallet.label": "OPay Wallet",
|
|
22
|
+
"dropIn.pagaWallet.label": "Paga Wallet",
|
|
18
23
|
// card number
|
|
19
24
|
"card.cardNumber.label": "Número de tarjeta",
|
|
20
25
|
"card.cardNumber.incomplete": "Tu número de tarjeta está incompleto",
|
|
@@ -83,7 +88,8 @@ const esES = {
|
|
|
83
88
|
// qrCode
|
|
84
89
|
"qrCode.expired": "El código QR ha expirado.",
|
|
85
90
|
"qrCode.scanByGcash": "Escanear el código QR con GCash",
|
|
86
|
-
"qrCode.scanByZalopay": "Escanear el código QR con Zalopay"
|
|
91
|
+
"qrCode.scanByZalopay": "Escanear el código QR con Zalopay",
|
|
92
|
+
"qrCode.scanByVietqr": "Escanear el código QR con VietQR"
|
|
87
93
|
};
|
|
88
94
|
export {
|
|
89
95
|
esES as default
|
|
@@ -13,8 +13,13 @@ const frFR = {
|
|
|
13
13
|
"dropIn.linePay.label": "LinePay",
|
|
14
14
|
"dropIn.ninePay.label": "9Pay",
|
|
15
15
|
"dropIn.gcash.label": "GCash",
|
|
16
|
-
"dropIn.paymaya.label": "
|
|
16
|
+
"dropIn.paymaya.label": "Maya",
|
|
17
17
|
"dropIn.zalopay.label": "Zalopay",
|
|
18
|
+
"dropIn.vietqr.label": "VietQR",
|
|
19
|
+
"dropIn.pix.label": "Pix",
|
|
20
|
+
"dropIn.picPay.label": "PicPay",
|
|
21
|
+
"dropIn.opayWallet.label": "OPay Wallet",
|
|
22
|
+
"dropIn.pagaWallet.label": "Paga Wallet",
|
|
18
23
|
// card number
|
|
19
24
|
"card.cardNumber.label": "Numéro de carte",
|
|
20
25
|
"card.cardNumber.incomplete": "Votre numéro de carte est incomplet",
|
|
@@ -83,7 +88,8 @@ const frFR = {
|
|
|
83
88
|
// qrCode
|
|
84
89
|
"qrCode.expired": "Le code QR a expiré.",
|
|
85
90
|
"qrCode.scanByGcash": "Scanner le code QR avec GCash",
|
|
86
|
-
"qrCode.scanByZalopay": "Scanner le code QR avec Zalopay"
|
|
91
|
+
"qrCode.scanByZalopay": "Scanner le code QR avec Zalopay",
|
|
92
|
+
"qrCode.scanByVietqr": "Scanner le code QR avec VietQR"
|
|
87
93
|
};
|
|
88
94
|
export {
|
|
89
95
|
frFR as default
|