@paykka/card-checkout-ui 0.11.6 → 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 +19 -19
- package/dist/card-checkout-ui.umd.cjs +19 -19
- package/dist/es/_commonjsHelpers.js +82 -1
- 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/get-browser-params.js +4 -1
- 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 +158 -111
- package/dist/es/components/ApplePay/index.js +99 -67
- package/dist/es/components/Boost/index.js +91 -70
- package/dist/es/components/Card/index.js +114 -107
- 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 +6 -2
- package/dist/es/components/GooglePay/index.js +94 -60
- package/dist/es/components/GrabPay/index.js +91 -70
- package/dist/es/components/GuideCard/index.js +10 -7
- package/dist/es/components/LinePay/index.js +91 -70
- package/dist/es/components/MayBankQRPay/index.js +302 -275
- package/dist/es/components/NinePay/index.js +91 -70
- package/dist/es/components/SecuredFieldsProvider/index.js +26 -9
- package/dist/es/components/SecuredIframe/index.js +40 -61
- package/dist/es/components/Sepa/index.js +72 -53
- package/dist/es/components/ShopeePay/index.js +91 -70
- package/dist/es/components/SubmitButton/index.js +8 -7
- package/dist/es/components/TNGWallet/index.js +91 -70
- package/dist/es/components/ThreeDS/index.js +32 -7
- package/dist/es/components/WechatPay/index.js +151 -102
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
- package/dist/es/components/index.js +1 -0
- 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/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Select/Select.js +19 -8
- package/dist/es/components/internal/Select/SelectMenu.js +2 -2
- package/dist/es/components/internal/Select/SelectMenuItem.js +12 -4
- package/dist/es/components/internal/icons/IconError.js +7 -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 +80 -56
- package/dist/es/components/wallets/Paymaya/Paymaya.js +91 -70
- package/dist/es/components/wallets/Zalopay/Zalopay.js +381 -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} +101 -27
- package/dist/es/core/create.js +1 -1
- package/dist/es/core/query.js +3 -2
- package/dist/es/core/{Session.js → session.js} +28 -32
- package/dist/es/core/theme.js +65 -0
- 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 +21 -7
- 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/format.js +0 -5
- package/dist/es/utils/object.js +31 -1
- package/dist/es/utils/payment.js +82 -0
- package/dist/es/utils/redirect.js +4 -4
- 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/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/get-browser-params.d.ts +1 -0
- 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/SecuredFieldsProvider/type.d.ts +5 -0
- package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +3 -1
- 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/ThreeDS/components/ThreeDSAuth/type.d.ts +2 -0
- 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/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Select/SelectMenu.d.ts +1 -1
- 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} +9 -3
- package/dist/types/core/context.d.ts +3 -2
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/core/session.d.ts +23 -0
- package/dist/types/core/theme.d.ts +7 -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 +30 -25
- 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 +4 -2
- package/dist/types/utils/object.d.ts +7 -0
- package/dist/types/utils/payment.d.ts +37 -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 +3 -3
- package/dist/es/utils/deep-freeze.js +0 -13
- package/dist/es/utils/obj.js +0 -22
- package/dist/types/core/Session.d.ts +0 -16
- package/dist/types/utils/deep-freeze.d.ts +0 -1
- package/dist/types/utils/obj.d.ts +0 -6
|
@@ -3,17 +3,16 @@ 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
|
+
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 { getPaymayaPayInfo, paymayaPay } from "../../../api/modules/paymaya/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
|
-
import { createAddressCore } from "../../../core/Address.js";
|
|
17
16
|
import { createEmailCore, EmailField } from "../../EmailField/EmailField.js";
|
|
18
17
|
import { SubmitButton } from "../../SubmitButton/index.js";
|
|
19
18
|
import { GuideCard } from "../../GuideCard/index.js";
|
|
@@ -27,7 +26,6 @@ import "./paymaya2.js";
|
|
|
27
26
|
const { bem } = useBEM("paymaya");
|
|
28
27
|
const fieldClassNames = bem("field");
|
|
29
28
|
const Paymaya = w((props, ref) => {
|
|
30
|
-
var _a, _b, _c, _d, _e, _f;
|
|
31
29
|
const {
|
|
32
30
|
session,
|
|
33
31
|
showEmail = false,
|
|
@@ -35,7 +33,8 @@ const Paymaya = w((props, ref) => {
|
|
|
35
33
|
core,
|
|
36
34
|
redirectMode = "auto",
|
|
37
35
|
autoQuery = true,
|
|
38
|
-
showGuideCard = true
|
|
36
|
+
showGuideCard = true,
|
|
37
|
+
hidePaymentButton = false
|
|
39
38
|
} = props;
|
|
40
39
|
F(ref, () => ({
|
|
41
40
|
stopRetry: () => {
|
|
@@ -47,26 +46,28 @@ 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
|
-
|
|
54
|
-
(
|
|
52
|
+
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
53
|
+
setForm(newForm);
|
|
54
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
55
|
+
validateForm();
|
|
55
56
|
},
|
|
56
57
|
updateEmail: () => {
|
|
57
|
-
var
|
|
58
|
+
var _a;
|
|
58
59
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
59
60
|
return;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
61
|
+
const newForm = Object.assign(form, { email: emailState.email });
|
|
62
|
+
setForm(newForm);
|
|
63
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
63
64
|
validateForm();
|
|
64
65
|
},
|
|
65
66
|
payment: () => {
|
|
66
67
|
hidePaymentButton && onSubmit();
|
|
67
68
|
}
|
|
68
69
|
}));
|
|
69
|
-
const
|
|
70
|
+
const addressCore = core.getAddressCore();
|
|
70
71
|
const emailState = createEmailCore();
|
|
71
72
|
const addressFieldRef = A(null);
|
|
72
73
|
const emailFieldRef = A(null);
|
|
@@ -77,13 +78,13 @@ const Paymaya = w((props, ref) => {
|
|
|
77
78
|
const [form, setForm] = h({
|
|
78
79
|
email: "",
|
|
79
80
|
address: {
|
|
80
|
-
country:
|
|
81
|
-
province:
|
|
82
|
-
city:
|
|
83
|
-
area:
|
|
84
|
-
postCode:
|
|
85
|
-
address1:
|
|
86
|
-
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
|
|
87
88
|
}
|
|
88
89
|
});
|
|
89
90
|
const [validated, setValidated] = h(false);
|
|
@@ -101,33 +102,43 @@ const Paymaya = w((props, ref) => {
|
|
|
101
102
|
}
|
|
102
103
|
setFieldStatus({ ...field });
|
|
103
104
|
};
|
|
105
|
+
const processOnSuccess = (res) => {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
setSubmitButtonStatus("success");
|
|
108
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
109
|
+
...res,
|
|
110
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
111
|
+
}));
|
|
112
|
+
};
|
|
104
113
|
y(() => {
|
|
105
114
|
if (!sessionReady) {
|
|
106
115
|
return;
|
|
107
116
|
}
|
|
108
|
-
const { bill = {},
|
|
109
|
-
if (!
|
|
117
|
+
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
118
|
+
if (!supportMethods.includes(PaymentMethod.PAYMAYA)) {
|
|
110
119
|
return;
|
|
111
120
|
}
|
|
112
121
|
initFieldStatus();
|
|
113
122
|
setIsCheckoutEnabled(true);
|
|
123
|
+
country && addressCore.setCountry(country);
|
|
114
124
|
form.email = bill.email ?? "";
|
|
125
|
+
form.address.country = country;
|
|
115
126
|
if (autoQuery && core.processingPaymentMethod === PaymentMethod.PAYMAYA) {
|
|
116
127
|
setSubmitButtonStatus("loading");
|
|
117
128
|
startReFetchPayInfo();
|
|
118
129
|
}
|
|
119
130
|
}, [sessionReady]);
|
|
120
131
|
const processOnError = (error) => {
|
|
121
|
-
var
|
|
122
|
-
(
|
|
132
|
+
var _a;
|
|
133
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, error);
|
|
123
134
|
core.resetEnablePaymentMethod();
|
|
124
135
|
};
|
|
125
136
|
const onTimeout = q(
|
|
126
137
|
(message) => {
|
|
127
|
-
var
|
|
138
|
+
var _a;
|
|
128
139
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
129
140
|
setSubmitButtonStatus("unSubmit");
|
|
130
|
-
(
|
|
141
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props);
|
|
131
142
|
core.resetEnablePaymentMethod();
|
|
132
143
|
},
|
|
133
144
|
[i18n, props.onTimeout]
|
|
@@ -145,34 +156,49 @@ const Paymaya = w((props, ref) => {
|
|
|
145
156
|
},
|
|
146
157
|
bill: {
|
|
147
158
|
email: form.email,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
|
151
166
|
},
|
|
152
167
|
browser: await getBrowserParams()
|
|
153
168
|
};
|
|
154
169
|
};
|
|
155
170
|
const pay = async (search = false, timeout) => {
|
|
156
|
-
var
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
157
172
|
try {
|
|
158
|
-
const paymentParams = await getPaymentParams();
|
|
159
173
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
let res = null;
|
|
175
|
+
if (search) {
|
|
176
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.PAYMAYA);
|
|
177
|
+
res = await getPaymayaPayInfo(
|
|
178
|
+
{
|
|
179
|
+
sessionId: session.sessionId,
|
|
180
|
+
clientKey: session.clientKey,
|
|
181
|
+
paymentMethod: PaymentMethod.PAYMAYA
|
|
182
|
+
},
|
|
183
|
+
extraParams,
|
|
184
|
+
requestOptions
|
|
185
|
+
);
|
|
186
|
+
} else {
|
|
187
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.PAYMAYA);
|
|
188
|
+
res = await paymayaPay(await getPaymentParams(), extraParams, requestOptions);
|
|
189
|
+
}
|
|
190
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
191
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
192
|
+
sessionId && (session.sessionId = sessionId);
|
|
166
193
|
if (status === "PROCESSING") {
|
|
167
194
|
if (!orderStatus) {
|
|
168
195
|
setSubmitButtonStatus("unSubmit");
|
|
169
196
|
return { end: true };
|
|
170
197
|
} else if (orderStatus === "SUCCESS") {
|
|
171
|
-
|
|
172
|
-
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
198
|
+
processOnSuccess(res);
|
|
173
199
|
return { end: true };
|
|
174
200
|
} else if (orderStatus === "FAILURE") {
|
|
175
|
-
setErrorMsg(errorMessage);
|
|
201
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
176
202
|
setSubmitButtonStatus("unSubmit");
|
|
177
203
|
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
178
204
|
return { end: true };
|
|
@@ -188,17 +214,16 @@ const Paymaya = w((props, ref) => {
|
|
|
188
214
|
return { end: false };
|
|
189
215
|
} else if (orderStatus === "CANCELED") {
|
|
190
216
|
setSubmitButtonStatus("unSubmit");
|
|
191
|
-
(
|
|
217
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
192
218
|
core.resetEnablePaymentMethod();
|
|
193
219
|
return { end: true };
|
|
194
220
|
}
|
|
195
221
|
} else if (status === "SUCCESS") {
|
|
196
|
-
|
|
197
|
-
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
222
|
+
processOnSuccess(res);
|
|
198
223
|
return { end: true };
|
|
199
224
|
} else if (status === "EXPIRED") {
|
|
200
225
|
setSubmitButtonStatus("unSubmit");
|
|
201
|
-
(
|
|
226
|
+
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
202
227
|
return { end: true };
|
|
203
228
|
}
|
|
204
229
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -213,7 +238,7 @@ const Paymaya = w((props, ref) => {
|
|
|
213
238
|
}
|
|
214
239
|
} else {
|
|
215
240
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
216
|
-
setErrorMsg(message);
|
|
241
|
+
message && setErrorMsg(message);
|
|
217
242
|
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
218
243
|
setSubmitButtonStatus("unSubmit");
|
|
219
244
|
return { end: true };
|
|
@@ -221,8 +246,8 @@ const Paymaya = w((props, ref) => {
|
|
|
221
246
|
}
|
|
222
247
|
};
|
|
223
248
|
const validateForm = () => {
|
|
224
|
-
var
|
|
225
|
-
(
|
|
249
|
+
var _a;
|
|
250
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
226
251
|
setValidated(true);
|
|
227
252
|
}).catch(() => {
|
|
228
253
|
setValidated(false);
|
|
@@ -232,12 +257,12 @@ const Paymaya = w((props, ref) => {
|
|
|
232
257
|
validateForm();
|
|
233
258
|
}, [form]);
|
|
234
259
|
const onSubmit = async () => {
|
|
235
|
-
var
|
|
260
|
+
var _a;
|
|
236
261
|
setErrorMsg("");
|
|
237
|
-
(
|
|
238
|
-
var
|
|
239
|
-
(fieldStatus == null ? void 0 : fieldStatus.address.show) &&
|
|
240
|
-
(
|
|
262
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
263
|
+
var _a2;
|
|
264
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
265
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
241
266
|
if (errors) {
|
|
242
267
|
setSubmitButtonStatus("unSubmit");
|
|
243
268
|
return;
|
|
@@ -252,8 +277,8 @@ const Paymaya = w((props, ref) => {
|
|
|
252
277
|
dom && validateForm();
|
|
253
278
|
};
|
|
254
279
|
const Button = () => {
|
|
255
|
-
var
|
|
256
|
-
const transAmount = (
|
|
280
|
+
var _a;
|
|
281
|
+
const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
|
|
257
282
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
258
283
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
259
284
|
return /* @__PURE__ */ u(
|
|
@@ -279,24 +304,17 @@ const Paymaya = w((props, ref) => {
|
|
|
279
304
|
}
|
|
280
305
|
) }) });
|
|
281
306
|
};
|
|
282
|
-
const formStyle = {
|
|
283
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
284
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
285
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
286
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
287
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
288
|
-
};
|
|
289
307
|
const ErrorMessage = () => {
|
|
290
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
308
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
291
309
|
};
|
|
292
310
|
const Address = () => {
|
|
293
|
-
var
|
|
311
|
+
var _a, _b;
|
|
294
312
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
295
313
|
AddressField,
|
|
296
314
|
{
|
|
297
315
|
ref: addressFieldRef,
|
|
298
316
|
value: form.address,
|
|
299
|
-
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),
|
|
300
318
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
301
319
|
}
|
|
302
320
|
) }) });
|
|
@@ -306,15 +324,18 @@ const Paymaya = w((props, ref) => {
|
|
|
306
324
|
{
|
|
307
325
|
value: {
|
|
308
326
|
i18n,
|
|
309
|
-
session
|
|
327
|
+
session,
|
|
328
|
+
core
|
|
310
329
|
},
|
|
311
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
330
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
312
331
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.PAYMAYA }),
|
|
313
|
-
/* @__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: [
|
|
314
333
|
Email(),
|
|
315
334
|
Address(),
|
|
316
|
-
|
|
317
|
-
|
|
335
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
336
|
+
ErrorMessage(),
|
|
337
|
+
!hidePaymentButton && Button()
|
|
338
|
+
] })
|
|
318
339
|
] }) })
|
|
319
340
|
] })
|
|
320
341
|
}
|