@paykka/card-checkout-ui 0.13.1 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/card-checkout-ui.js +18 -18
- package/dist/card-checkout-ui.umd.cjs +18 -18
- package/dist/es/_commonjsHelpers.js +82 -1
- package/dist/es/api/modules/get-browser-params.js +4 -1
- package/dist/es/components/AliPay/index.js +29 -35
- package/dist/es/components/Boost/index.js +34 -40
- package/dist/es/components/Card/index.js +35 -39
- package/dist/es/components/EncryptedCard/index.js +5 -1
- package/dist/es/components/GooglePay/index.js +1 -0
- package/dist/es/components/GrabPay/index.js +34 -40
- package/dist/es/components/LinePay/index.js +34 -40
- package/dist/es/components/MayBankQRPay/index.js +35 -41
- package/dist/es/components/NinePay/index.js +34 -40
- package/dist/es/components/SecuredFieldsProvider/index.js +23 -7
- package/dist/es/components/SecuredIframe/index.js +36 -59
- package/dist/es/components/Sepa/index.js +17 -21
- package/dist/es/components/ShopeePay/index.js +34 -40
- package/dist/es/components/TNGWallet/index.js +34 -40
- package/dist/es/components/ThreeDS/index.js +32 -7
- package/dist/es/components/WechatPay/index.js +19 -24
- package/dist/es/components/internal/Form/FormItem.js +1 -1
- package/dist/es/components/internal/Form/util.js +1 -1
- package/dist/es/components/internal/Select/SelectMenu.js +2 -2
- package/dist/es/components/internal/icons/IconError.js +7 -4
- package/dist/es/components/wallets/GCash/GCash.js +20 -25
- package/dist/es/components/wallets/Paymaya/Paymaya.js +34 -40
- package/dist/es/components/wallets/Zalopay/Zalopay.js +16 -21
- package/dist/es/core/checkout.js +24 -1
- package/dist/es/core/create.js +1 -1
- package/dist/es/core/session.js +2 -23
- package/dist/es/core/theme.js +65 -0
- package/dist/es/index.js +7 -5
- package/dist/es/style.css +1 -1
- package/dist/es/utils/format.js +0 -5
- package/dist/es/utils/object.js +31 -1
- package/dist/es/utils/string.js +10 -0
- package/dist/es/utils/system-info/is-ua-webview.js +14 -12
- package/dist/es/utils/theme.js +7 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/get-browser-params.d.ts +1 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +5 -0
- package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +3 -1
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +2 -0
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Select/SelectMenu.d.ts +1 -1
- package/dist/types/core/checkout.d.ts +4 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/session.d.ts +1 -11
- package/dist/types/core/theme.d.ts +7 -0
- package/dist/types/types/message.d.ts +29 -25
- package/dist/types/utils/index.d.ts +3 -2
- package/dist/types/utils/object.d.ts +7 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/style.d.ts +1 -1
- package/dist/types/utils/system-info/is-ua-webview.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +4 -0
- package/package.json +1 -1
- package/dist/es/utils/deep-freeze.js +0 -13
- package/dist/es/utils/obj.js +0 -22
- package/dist/types/utils/deep-freeze.d.ts +0 -1
- package/dist/types/utils/obj.d.ts +0 -6
|
@@ -14,20 +14,23 @@ function IconError({ size, style, className }) {
|
|
|
14
14
|
viewBox: "0 0 16 16",
|
|
15
15
|
fill: "none",
|
|
16
16
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
-
style
|
|
17
|
+
style: {
|
|
18
|
+
...style,
|
|
19
|
+
marginBottom: "-2px"
|
|
20
|
+
},
|
|
18
21
|
className: normalizedClass(COMMON_CLASS_NAME, className),
|
|
19
22
|
children: [
|
|
20
|
-
/* @__PURE__ */ u("g", { id: "icon-
|
|
23
|
+
/* @__PURE__ */ u("g", { id: "icon-Error", "clip-path": "url(#clip0_765_422)", children: /* @__PURE__ */ u("g", { id: "tips/exclamation-circle-fill", children: /* @__PURE__ */ u(
|
|
21
24
|
"path",
|
|
22
25
|
{
|
|
23
26
|
id: "Vector",
|
|
24
27
|
"fill-rule": "evenodd",
|
|
25
28
|
"clip-rule": "evenodd",
|
|
26
|
-
d: "M1.
|
|
29
|
+
d: "M1.33398 7.99992C1.33398 4.31802 4.31875 1.33325 8.00065 1.33325C11.6826 1.33325 14.6673 4.31802 14.6673 7.99992C14.6673 11.6818 11.6826 14.6666 8.00065 14.6666C4.31875 14.6666 1.33398 11.6818 1.33398 7.99992ZM7.33398 9.99992V11.3333H8.66732V9.99992H7.33398ZM8.66732 9.33325L8.66732 4.66659H7.33399L7.33398 9.33325H8.66732Z",
|
|
27
30
|
fill: "#F53F3F"
|
|
28
31
|
}
|
|
29
32
|
) }) }),
|
|
30
|
-
/* @__PURE__ */ u("defs", { children: /* @__PURE__ */ u("clipPath", { id: "
|
|
33
|
+
/* @__PURE__ */ u("defs", { children: /* @__PURE__ */ u("clipPath", { id: "clip0_765_422", children: /* @__PURE__ */ u("rect", { width: "16", height: "16", fill: "white" }) }) })
|
|
31
34
|
]
|
|
32
35
|
}
|
|
33
36
|
);
|
|
@@ -4,7 +4,7 @@ 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
6
|
import { isMobile } from "../../../utils/system-info/get-system-info.js";
|
|
7
|
-
import {
|
|
7
|
+
import { normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
8
8
|
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
9
9
|
import { formatPaymentResult } from "../../../utils/payment.js";
|
|
10
10
|
import { isTimeoutError } from "../../../api/http.js";
|
|
@@ -29,7 +29,7 @@ import "./g-cash.js";
|
|
|
29
29
|
const { bem } = useBEM("gcash");
|
|
30
30
|
const fieldClassNames = bem("field");
|
|
31
31
|
const GCash = w((props, ref) => {
|
|
32
|
-
var _a
|
|
32
|
+
var _a;
|
|
33
33
|
const {
|
|
34
34
|
session,
|
|
35
35
|
showEmail = false,
|
|
@@ -110,9 +110,9 @@ const GCash = w((props, ref) => {
|
|
|
110
110
|
setFieldStatus({ ...field });
|
|
111
111
|
};
|
|
112
112
|
const processOnSuccess = (res) => {
|
|
113
|
-
var _a2,
|
|
113
|
+
var _a2, _b;
|
|
114
114
|
setSubmitButtonStatus("success");
|
|
115
|
-
(
|
|
115
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
116
116
|
...res,
|
|
117
117
|
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
118
118
|
}));
|
|
@@ -180,12 +180,12 @@ const GCash = w((props, ref) => {
|
|
|
180
180
|
};
|
|
181
181
|
};
|
|
182
182
|
const pay = async (search = false, timeout) => {
|
|
183
|
-
var _a2,
|
|
183
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
184
184
|
try {
|
|
185
185
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
186
186
|
let res = null;
|
|
187
187
|
if (search) {
|
|
188
|
-
const extraParams = (
|
|
188
|
+
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.GCASH);
|
|
189
189
|
res = await getGcashPayInfo(
|
|
190
190
|
{
|
|
191
191
|
sessionId: session.sessionId,
|
|
@@ -196,10 +196,10 @@ const GCash = w((props, ref) => {
|
|
|
196
196
|
requestOptions
|
|
197
197
|
);
|
|
198
198
|
} else {
|
|
199
|
-
const extraParams = (
|
|
199
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.GCASH);
|
|
200
200
|
res = await gcashPay(await getPaymentParams(), extraParams, requestOptions);
|
|
201
201
|
}
|
|
202
|
-
!search && ((
|
|
202
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
203
203
|
const { status, orderStatus, errorMessage, errorCode, payInfo = {}, sessionId } = res;
|
|
204
204
|
const { paymentExpiredAt } = payInfo;
|
|
205
205
|
sessionId && (session.sessionId = sessionId);
|
|
@@ -237,7 +237,7 @@ const GCash = w((props, ref) => {
|
|
|
237
237
|
return { end: false };
|
|
238
238
|
} else if (orderStatus === "CANCELED") {
|
|
239
239
|
setSubmitButtonStatus("unSubmit");
|
|
240
|
-
(
|
|
240
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
241
241
|
core.resetEnablePaymentMethod();
|
|
242
242
|
return { end: true };
|
|
243
243
|
}
|
|
@@ -248,7 +248,7 @@ const GCash = w((props, ref) => {
|
|
|
248
248
|
} else if (status === "EXPIRED") {
|
|
249
249
|
setShowQRCodeModal(false);
|
|
250
250
|
setSubmitButtonStatus("unSubmit");
|
|
251
|
-
(
|
|
251
|
+
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
252
252
|
return { end: true };
|
|
253
253
|
}
|
|
254
254
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -337,24 +337,17 @@ const GCash = w((props, ref) => {
|
|
|
337
337
|
}
|
|
338
338
|
) }) });
|
|
339
339
|
};
|
|
340
|
-
const formStyle = {
|
|
341
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
342
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
343
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
344
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
345
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
346
|
-
};
|
|
347
340
|
const ErrorMessage = () => {
|
|
348
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
341
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
349
342
|
};
|
|
350
343
|
const Address = () => {
|
|
351
|
-
var _a2,
|
|
344
|
+
var _a2, _b;
|
|
352
345
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
353
346
|
AddressField,
|
|
354
347
|
{
|
|
355
348
|
ref: addressFieldRef,
|
|
356
349
|
value: form.address,
|
|
357
|
-
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((
|
|
350
|
+
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),
|
|
358
351
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
359
352
|
}
|
|
360
353
|
) }) });
|
|
@@ -367,13 +360,15 @@ const GCash = w((props, ref) => {
|
|
|
367
360
|
session,
|
|
368
361
|
core
|
|
369
362
|
},
|
|
370
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
363
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
371
364
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.GCASH }),
|
|
372
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
365
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
373
366
|
Email(),
|
|
374
367
|
Address(),
|
|
375
|
-
|
|
376
|
-
|
|
368
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
369
|
+
ErrorMessage(),
|
|
370
|
+
!hidePaymentButton && Button()
|
|
371
|
+
] })
|
|
377
372
|
] }) }),
|
|
378
373
|
showQRCodeModal && /* @__PURE__ */ u(
|
|
379
374
|
QRCodeModal,
|
|
@@ -383,7 +378,7 @@ const GCash = w((props, ref) => {
|
|
|
383
378
|
textColor: "#FFFFFF",
|
|
384
379
|
qrCode: qrCodeInfo.qrCode,
|
|
385
380
|
icon: /* @__PURE__ */ u(IconGcashComplete, { size: 22 }),
|
|
386
|
-
amount: (
|
|
381
|
+
amount: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount,
|
|
387
382
|
expiredTime: qrCodeInfo.expiredTime,
|
|
388
383
|
onClose: handleCloseQRCodeModal
|
|
389
384
|
}
|
|
@@ -3,7 +3,7 @@ import { useBEM } from "../../../hooks/useBEM.js";
|
|
|
3
3
|
import { CoreContext } from "../../../core/context.js";
|
|
4
4
|
import "../../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import {
|
|
6
|
+
import { normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
7
7
|
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
8
8
|
import { formatPaymentResult } from "../../../utils/payment.js";
|
|
9
9
|
import { isTimeoutError } from "../../../api/http.js";
|
|
@@ -26,7 +26,6 @@ import "./paymaya2.js";
|
|
|
26
26
|
const { bem } = useBEM("paymaya");
|
|
27
27
|
const fieldClassNames = bem("field");
|
|
28
28
|
const Paymaya = w((props, ref) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
29
|
const {
|
|
31
30
|
session,
|
|
32
31
|
showEmail = false,
|
|
@@ -47,21 +46,21 @@ const Paymaya = w((props, ref) => {
|
|
|
47
46
|
startReFetchPayInfo({ timeout });
|
|
48
47
|
},
|
|
49
48
|
updateAddress: () => {
|
|
50
|
-
var
|
|
49
|
+
var _a;
|
|
51
50
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
52
51
|
return;
|
|
53
52
|
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
54
53
|
setForm(newForm);
|
|
55
|
-
(
|
|
54
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
56
55
|
validateForm();
|
|
57
56
|
},
|
|
58
57
|
updateEmail: () => {
|
|
59
|
-
var
|
|
58
|
+
var _a;
|
|
60
59
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
61
60
|
return;
|
|
62
61
|
const newForm = Object.assign(form, { email: emailState.email });
|
|
63
62
|
setForm(newForm);
|
|
64
|
-
(
|
|
63
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
65
64
|
validateForm();
|
|
66
65
|
},
|
|
67
66
|
payment: () => {
|
|
@@ -104,11 +103,11 @@ const Paymaya = w((props, ref) => {
|
|
|
104
103
|
setFieldStatus({ ...field });
|
|
105
104
|
};
|
|
106
105
|
const processOnSuccess = (res) => {
|
|
107
|
-
var
|
|
106
|
+
var _a, _b;
|
|
108
107
|
setSubmitButtonStatus("success");
|
|
109
|
-
(
|
|
108
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
110
109
|
...res,
|
|
111
|
-
returnUrl: (
|
|
110
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
112
111
|
}));
|
|
113
112
|
};
|
|
114
113
|
y(() => {
|
|
@@ -130,16 +129,16 @@ const Paymaya = w((props, ref) => {
|
|
|
130
129
|
}
|
|
131
130
|
}, [sessionReady]);
|
|
132
131
|
const processOnError = (error) => {
|
|
133
|
-
var
|
|
134
|
-
(
|
|
132
|
+
var _a;
|
|
133
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, error);
|
|
135
134
|
core.resetEnablePaymentMethod();
|
|
136
135
|
};
|
|
137
136
|
const onTimeout = q(
|
|
138
137
|
(message) => {
|
|
139
|
-
var
|
|
138
|
+
var _a;
|
|
140
139
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
141
140
|
setSubmitButtonStatus("unSubmit");
|
|
142
|
-
(
|
|
141
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props);
|
|
143
142
|
core.resetEnablePaymentMethod();
|
|
144
143
|
},
|
|
145
144
|
[i18n, props.onTimeout]
|
|
@@ -169,12 +168,12 @@ const Paymaya = w((props, ref) => {
|
|
|
169
168
|
};
|
|
170
169
|
};
|
|
171
170
|
const pay = async (search = false, timeout) => {
|
|
172
|
-
var
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
173
172
|
try {
|
|
174
173
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
175
174
|
let res = null;
|
|
176
175
|
if (search) {
|
|
177
|
-
const extraParams = (
|
|
176
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.PAYMAYA);
|
|
178
177
|
res = await getPaymayaPayInfo(
|
|
179
178
|
{
|
|
180
179
|
sessionId: session.sessionId,
|
|
@@ -185,10 +184,10 @@ const Paymaya = w((props, ref) => {
|
|
|
185
184
|
requestOptions
|
|
186
185
|
);
|
|
187
186
|
} else {
|
|
188
|
-
const extraParams = (
|
|
187
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.PAYMAYA);
|
|
189
188
|
res = await paymayaPay(await getPaymentParams(), extraParams, requestOptions);
|
|
190
189
|
}
|
|
191
|
-
!search && ((
|
|
190
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
192
191
|
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
193
192
|
sessionId && (session.sessionId = sessionId);
|
|
194
193
|
if (status === "PROCESSING") {
|
|
@@ -215,7 +214,7 @@ const Paymaya = w((props, ref) => {
|
|
|
215
214
|
return { end: false };
|
|
216
215
|
} else if (orderStatus === "CANCELED") {
|
|
217
216
|
setSubmitButtonStatus("unSubmit");
|
|
218
|
-
(
|
|
217
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
219
218
|
core.resetEnablePaymentMethod();
|
|
220
219
|
return { end: true };
|
|
221
220
|
}
|
|
@@ -247,8 +246,8 @@ const Paymaya = w((props, ref) => {
|
|
|
247
246
|
}
|
|
248
247
|
};
|
|
249
248
|
const validateForm = () => {
|
|
250
|
-
var
|
|
251
|
-
(
|
|
249
|
+
var _a;
|
|
250
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
252
251
|
setValidated(true);
|
|
253
252
|
}).catch(() => {
|
|
254
253
|
setValidated(false);
|
|
@@ -258,12 +257,12 @@ const Paymaya = w((props, ref) => {
|
|
|
258
257
|
validateForm();
|
|
259
258
|
}, [form]);
|
|
260
259
|
const onSubmit = async () => {
|
|
261
|
-
var
|
|
260
|
+
var _a;
|
|
262
261
|
setErrorMsg("");
|
|
263
|
-
(
|
|
264
|
-
var
|
|
262
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
263
|
+
var _a2;
|
|
265
264
|
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
266
|
-
(
|
|
265
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
267
266
|
if (errors) {
|
|
268
267
|
setSubmitButtonStatus("unSubmit");
|
|
269
268
|
return;
|
|
@@ -278,8 +277,8 @@ const Paymaya = w((props, ref) => {
|
|
|
278
277
|
dom && validateForm();
|
|
279
278
|
};
|
|
280
279
|
const Button = () => {
|
|
281
|
-
var
|
|
282
|
-
const transAmount = (
|
|
280
|
+
var _a;
|
|
281
|
+
const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
|
|
283
282
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
284
283
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
285
284
|
return /* @__PURE__ */ u(
|
|
@@ -305,24 +304,17 @@ const Paymaya = w((props, ref) => {
|
|
|
305
304
|
}
|
|
306
305
|
) }) });
|
|
307
306
|
};
|
|
308
|
-
const formStyle = {
|
|
309
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
310
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
311
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
312
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
313
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
314
|
-
};
|
|
315
307
|
const ErrorMessage = () => {
|
|
316
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
308
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
317
309
|
};
|
|
318
310
|
const Address = () => {
|
|
319
|
-
var
|
|
311
|
+
var _a, _b;
|
|
320
312
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
321
313
|
AddressField,
|
|
322
314
|
{
|
|
323
315
|
ref: addressFieldRef,
|
|
324
316
|
value: form.address,
|
|
325
|
-
country: ((
|
|
317
|
+
country: ((_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
|
|
326
318
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
327
319
|
}
|
|
328
320
|
) }) });
|
|
@@ -335,13 +327,15 @@ const Paymaya = w((props, ref) => {
|
|
|
335
327
|
session,
|
|
336
328
|
core
|
|
337
329
|
},
|
|
338
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
330
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
339
331
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.PAYMAYA }),
|
|
340
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
332
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
341
333
|
Email(),
|
|
342
334
|
Address(),
|
|
343
|
-
|
|
344
|
-
|
|
335
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
336
|
+
ErrorMessage(),
|
|
337
|
+
!hidePaymentButton && Button()
|
|
338
|
+
] })
|
|
345
339
|
] }) })
|
|
346
340
|
] })
|
|
347
341
|
}
|
|
@@ -4,7 +4,7 @@ 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
6
|
import { isMobile } from "../../../utils/system-info/get-system-info.js";
|
|
7
|
-
import {
|
|
7
|
+
import { normalizedClass, formatAmount } from "../../../utils/format.js";
|
|
8
8
|
import { redirectToPayment } from "../../../utils/redirect.js";
|
|
9
9
|
import { processPaymentStatus } from "../../../utils/payment.js";
|
|
10
10
|
import { isTimeoutError } from "../../../api/http.js";
|
|
@@ -30,7 +30,7 @@ import "./zalopay2.js";
|
|
|
30
30
|
const { bem } = useBEM("zalopay");
|
|
31
31
|
const fieldClassNames = bem("field");
|
|
32
32
|
const Zalopay = w((props, ref) => {
|
|
33
|
-
var _a
|
|
33
|
+
var _a;
|
|
34
34
|
const {
|
|
35
35
|
session,
|
|
36
36
|
showEmail = false,
|
|
@@ -173,12 +173,12 @@ const Zalopay = w((props, ref) => {
|
|
|
173
173
|
};
|
|
174
174
|
};
|
|
175
175
|
const pay = async (search = false, timeout) => {
|
|
176
|
-
var _a2,
|
|
176
|
+
var _a2, _b, _c, _d, _e;
|
|
177
177
|
try {
|
|
178
178
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
179
179
|
let res = null;
|
|
180
180
|
if (search) {
|
|
181
|
-
const extraParams = (
|
|
181
|
+
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.ZALOPAY);
|
|
182
182
|
res = await getZalopayPayInfo(
|
|
183
183
|
{
|
|
184
184
|
sessionId: session.sessionId,
|
|
@@ -189,10 +189,10 @@ const Zalopay = w((props, ref) => {
|
|
|
189
189
|
requestOptions
|
|
190
190
|
);
|
|
191
191
|
} else {
|
|
192
|
-
const extraParams = (
|
|
192
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.ZALOPAY);
|
|
193
193
|
res = await zalopayPay(await getPaymentParams(), extraParams, requestOptions);
|
|
194
194
|
}
|
|
195
|
-
!search && ((
|
|
195
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
196
196
|
const { errorMessage, errorCode, payInfo = {}, sessionId } = res;
|
|
197
197
|
sessionId && (session.sessionId = sessionId);
|
|
198
198
|
const { paymentExpiredAt } = payInfo;
|
|
@@ -328,24 +328,17 @@ const Zalopay = w((props, ref) => {
|
|
|
328
328
|
}
|
|
329
329
|
) }) });
|
|
330
330
|
};
|
|
331
|
-
const formStyle = {
|
|
332
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
333
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
334
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
335
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
336
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
337
|
-
};
|
|
338
331
|
const ErrorMessage = () => {
|
|
339
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
332
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
340
333
|
};
|
|
341
334
|
const Address = () => {
|
|
342
|
-
var _a2,
|
|
335
|
+
var _a2, _b;
|
|
343
336
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
344
337
|
AddressField,
|
|
345
338
|
{
|
|
346
339
|
ref: addressFieldRef,
|
|
347
340
|
value: form.address,
|
|
348
|
-
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((
|
|
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),
|
|
349
342
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
350
343
|
}
|
|
351
344
|
) }) });
|
|
@@ -358,13 +351,15 @@ const Zalopay = w((props, ref) => {
|
|
|
358
351
|
session,
|
|
359
352
|
core
|
|
360
353
|
},
|
|
361
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
354
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
362
355
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.ZALOPAY }),
|
|
363
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
356
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
364
357
|
Email(),
|
|
365
358
|
Address(),
|
|
366
|
-
|
|
367
|
-
|
|
359
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
360
|
+
ErrorMessage(),
|
|
361
|
+
!hidePaymentButton && PaymentButton()
|
|
362
|
+
] })
|
|
368
363
|
] }) }),
|
|
369
364
|
showQRCodeModal && /* @__PURE__ */ u(
|
|
370
365
|
QRCodeModal,
|
|
@@ -372,7 +367,7 @@ const Zalopay = w((props, ref) => {
|
|
|
372
367
|
title: i18n.get("qrCode.scanByZalopay"),
|
|
373
368
|
qrCode: qrCodeInfo.qrCode,
|
|
374
369
|
icon: /* @__PURE__ */ u(IconZalopayComplete, { size: 22 }),
|
|
375
|
-
amount: (
|
|
370
|
+
amount: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount,
|
|
376
371
|
expiredTime: qrCodeInfo.expiredTime,
|
|
377
372
|
onClose: handleCloseQRCodeModal
|
|
378
373
|
}
|
package/dist/es/core/checkout.js
CHANGED
|
@@ -26,7 +26,7 @@ var __privateMethod = (obj, member, method) => {
|
|
|
26
26
|
__accessCheck(obj, member, "access private method");
|
|
27
27
|
return method;
|
|
28
28
|
};
|
|
29
|
-
var _config, _envConfig, _session, _componentInsts, _addressCore, _initPromise, _doInit, doInit_fn;
|
|
29
|
+
var _id, _config, _envConfig, _session, _theme, _componentInsts, _addressCore, _initPromise, _doInit, doInit_fn;
|
|
30
30
|
import { create } from "./create.js";
|
|
31
31
|
import { Session } from "./session.js";
|
|
32
32
|
import { setApiPrefix, setApiUrl, setCDNUrl, setFraudDetectionEnv, setCustomLocale } from "../config.js";
|
|
@@ -38,8 +38,10 @@ import "../utils/card-brand/brands.js";
|
|
|
38
38
|
import "../utils/system-info/get-browser-info.js";
|
|
39
39
|
import { getUrlParam } from "../utils/location.js";
|
|
40
40
|
import { deepMerge } from "../utils/object.js";
|
|
41
|
+
import { genShortId } from "../utils/string.js";
|
|
41
42
|
import { d } from "../core.js";
|
|
42
43
|
import { AddressCore } from "./address.js";
|
|
44
|
+
import { PayKKaTheme } from "./theme.js";
|
|
43
45
|
const PROCESSING_PARAM_NAME = "m";
|
|
44
46
|
const DEFAULT_CHECKOUT_CONFIG = {
|
|
45
47
|
enableInitValidation: true,
|
|
@@ -49,9 +51,15 @@ const DEFAULT_CHECKOUT_CONFIG = {
|
|
|
49
51
|
class PayKKaCheckout {
|
|
50
52
|
constructor(config) {
|
|
51
53
|
__privateAdd(this, _doInit);
|
|
54
|
+
/**
|
|
55
|
+
* 收银台实例 ID
|
|
56
|
+
* 用于标识收银台实例,防止主题样式、iframe 通信数据等在不同收银台之间相互影响
|
|
57
|
+
*/
|
|
58
|
+
__privateAdd(this, _id, void 0);
|
|
52
59
|
__privateAdd(this, _config, void 0);
|
|
53
60
|
__privateAdd(this, _envConfig, void 0);
|
|
54
61
|
__privateAdd(this, _session, void 0);
|
|
62
|
+
__privateAdd(this, _theme, void 0);
|
|
55
63
|
__privateAdd(this, _componentInsts, []);
|
|
56
64
|
/**
|
|
57
65
|
* 地址处理
|
|
@@ -68,6 +76,7 @@ class PayKKaCheckout {
|
|
|
68
76
|
* 在 DropIn 且有正在处理的支付方式时,会设置为当前支付方式,并把其他支付方式设为禁用
|
|
69
77
|
*/
|
|
70
78
|
__publicField(this, "enablePaymentMethod", d(null));
|
|
79
|
+
__privateSet(this, _id, genShortId(6));
|
|
71
80
|
__privateSet(this, _config, config);
|
|
72
81
|
this.init();
|
|
73
82
|
}
|
|
@@ -138,6 +147,11 @@ class PayKKaCheckout {
|
|
|
138
147
|
const { locale } = __privateGet(this, _config);
|
|
139
148
|
locale && setCustomLocale(locale);
|
|
140
149
|
}
|
|
150
|
+
initTheme() {
|
|
151
|
+
var _a;
|
|
152
|
+
__privateSet(this, _theme, new PayKKaTheme(__privateGet(this, _id)));
|
|
153
|
+
__privateGet(this, _theme).init((_a = __privateGet(this, _session).checkout) == null ? void 0 : _a.theme);
|
|
154
|
+
}
|
|
141
155
|
initOtherData() {
|
|
142
156
|
const res = getUrlParam(PROCESSING_PARAM_NAME);
|
|
143
157
|
if (res) {
|
|
@@ -147,12 +161,18 @@ class PayKKaCheckout {
|
|
|
147
161
|
get session() {
|
|
148
162
|
return __privateGet(this, _session);
|
|
149
163
|
}
|
|
164
|
+
get theme() {
|
|
165
|
+
return __privateGet(this, _theme);
|
|
166
|
+
}
|
|
150
167
|
get envConfig() {
|
|
151
168
|
return __privateGet(this, _envConfig);
|
|
152
169
|
}
|
|
153
170
|
get config() {
|
|
154
171
|
return __privateGet(this, _config);
|
|
155
172
|
}
|
|
173
|
+
get id() {
|
|
174
|
+
return __privateGet(this, _id);
|
|
175
|
+
}
|
|
156
176
|
/** 创建组件,把 session 作为组件的 props 传递 */
|
|
157
177
|
create(component, props) {
|
|
158
178
|
var _a;
|
|
@@ -188,9 +208,11 @@ class PayKKaCheckout {
|
|
|
188
208
|
return __privateGet(this, _addressCore);
|
|
189
209
|
}
|
|
190
210
|
}
|
|
211
|
+
_id = new WeakMap();
|
|
191
212
|
_config = new WeakMap();
|
|
192
213
|
_envConfig = new WeakMap();
|
|
193
214
|
_session = new WeakMap();
|
|
215
|
+
_theme = new WeakMap();
|
|
194
216
|
_componentInsts = new WeakMap();
|
|
195
217
|
_addressCore = new WeakMap();
|
|
196
218
|
_initPromise = new WeakMap();
|
|
@@ -200,6 +222,7 @@ doInit_fn = async function() {
|
|
|
200
222
|
this.initEnv();
|
|
201
223
|
this.initLocale();
|
|
202
224
|
await this.initSession();
|
|
225
|
+
this.initTheme();
|
|
203
226
|
this.initOtherData();
|
|
204
227
|
};
|
|
205
228
|
export {
|
package/dist/es/core/create.js
CHANGED
|
@@ -2,7 +2,7 @@ import { _, B } from "../core.js";
|
|
|
2
2
|
import { isString } from "../utils/is.js";
|
|
3
3
|
import "../utils/card-brand/brands.js";
|
|
4
4
|
import "../utils/system-info/get-browser-info.js";
|
|
5
|
-
import { deepFreeze } from "../utils/
|
|
5
|
+
import { deepFreeze } from "../utils/object.js";
|
|
6
6
|
const internalInstMap = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
const setInternalInst = (inst, internalInst) => {
|
|
8
8
|
const _internalInst = Object.assign(
|
package/dist/es/core/session.js
CHANGED
|
@@ -22,12 +22,11 @@ var __privateMethod = (obj, member, method) => {
|
|
|
22
22
|
return method;
|
|
23
23
|
};
|
|
24
24
|
var _readyPromise, _init, init_fn, _initCheckout, initCheckout_fn;
|
|
25
|
+
import { d } from "../core.js";
|
|
25
26
|
import { isTimeoutError } from "../api/http.js";
|
|
26
27
|
import "../utils/card-brand/brands.js";
|
|
27
28
|
import "../utils/system-info/get-browser-info.js";
|
|
28
|
-
import { generateColors } from "../utils/colors.js";
|
|
29
29
|
import { createPromise } from "../utils/create-promise.js";
|
|
30
|
-
import "../core.js";
|
|
31
30
|
import { PayKKaError } from "./error.js";
|
|
32
31
|
import { querySession } from "./query.js";
|
|
33
32
|
class Session {
|
|
@@ -37,7 +36,7 @@ class Session {
|
|
|
37
36
|
__publicField(this, "sessionId");
|
|
38
37
|
__publicField(this, "clientKey");
|
|
39
38
|
__publicField(this, "checkout");
|
|
40
|
-
__publicField(this, "
|
|
39
|
+
__publicField(this, "theme", d({}));
|
|
41
40
|
__publicField(this, "extraParams", {});
|
|
42
41
|
__privateAdd(this, _readyPromise, createPromise());
|
|
43
42
|
const { sessionId, clientKey } = params;
|
|
@@ -46,25 +45,6 @@ class Session {
|
|
|
46
45
|
this.extraParams = extraParams;
|
|
47
46
|
__privateMethod(this, _init, init_fn).call(this);
|
|
48
47
|
}
|
|
49
|
-
/**
|
|
50
|
-
* 设置主题
|
|
51
|
-
* 目前的主题仅仅包含按钮背景和字体色
|
|
52
|
-
*/
|
|
53
|
-
initTheme() {
|
|
54
|
-
var _a;
|
|
55
|
-
const { payButtonBackgroundColor } = ((_a = this.checkout) == null ? void 0 : _a.theme) || {};
|
|
56
|
-
if (payButtonBackgroundColor) {
|
|
57
|
-
const colors = generateColors(payButtonBackgroundColor);
|
|
58
|
-
this.colors = {
|
|
59
|
-
primary: colors[5],
|
|
60
|
-
// 主色
|
|
61
|
-
primaryHover: colors[4],
|
|
62
|
-
// 浅一点的色,用于 hover
|
|
63
|
-
primaryActive: colors[6]
|
|
64
|
-
// 深一点的色,用于 active
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
48
|
ready() {
|
|
69
49
|
return __privateGet(this, _readyPromise);
|
|
70
50
|
}
|
|
@@ -79,7 +59,6 @@ init_fn = async function() {
|
|
|
79
59
|
const error = isTimeoutError(err) ? err : new PayKKaError("API_ERROR", err.message, { code: err.code });
|
|
80
60
|
__privateGet(this, _readyPromise).reject(error);
|
|
81
61
|
}
|
|
82
|
-
this.initTheme();
|
|
83
62
|
};
|
|
84
63
|
_initCheckout = new WeakSet();
|
|
85
64
|
initCheckout_fn = async function() {
|