@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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { w, F, h, q, y, A, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { SessionMode, PaymentMethod } from "../../constant.js";
|
|
4
3
|
import "../../utils/card-brand/brands.js";
|
|
5
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
5
|
import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
|
|
6
|
+
import { deepMerge } from "../../utils/object.js";
|
|
7
|
+
import { formatPaymentResult } from "../../utils/payment.js";
|
|
7
8
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
|
+
import { SessionMode, PaymentMethod } from "../../constant.js";
|
|
8
10
|
import { getGooglePayInfo, googlePay } from "../../api/modules/google-pay/index.js";
|
|
9
11
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
10
12
|
import "../../core/context.js";
|
|
@@ -14,7 +16,7 @@ import { useRetry } from "../../hooks/useRetry.js";
|
|
|
14
16
|
import { Info } from "../internal/Info/Info.js";
|
|
15
17
|
import { loadScript } from "../../utils/load.js";
|
|
16
18
|
import { ThreeDSAuth } from "../ThreeDS/index.js";
|
|
17
|
-
function createGooglePay(checkout, pay, onClick, onCanUse) {
|
|
19
|
+
function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
18
20
|
const {
|
|
19
21
|
transAmount,
|
|
20
22
|
theme: { merchantName }
|
|
@@ -128,6 +130,7 @@ function createGooglePay(checkout, pay, onClick, onCanUse) {
|
|
|
128
130
|
paymentsClient2.isReadyToPay(getGoogleIsReadyToPayRequest()).then(function(response) {
|
|
129
131
|
if (response.result) {
|
|
130
132
|
addGooglePayButton(container);
|
|
133
|
+
onCanUse == null ? void 0 : onCanUse(true);
|
|
131
134
|
} else {
|
|
132
135
|
onCanUse == null ? void 0 : onCanUse(false);
|
|
133
136
|
}
|
|
@@ -138,10 +141,7 @@ function createGooglePay(checkout, pay, onClick, onCanUse) {
|
|
|
138
141
|
function addGooglePayButton(container) {
|
|
139
142
|
const paymentsClient2 = getGooglePaymentsClient();
|
|
140
143
|
const button = paymentsClient2.createButton({
|
|
141
|
-
|
|
142
|
-
buttonType: "pay",
|
|
143
|
-
buttonRadius: 8,
|
|
144
|
-
buttonSizeMode: "fill",
|
|
144
|
+
...googlePayConfig == null ? void 0 : googlePayConfig.button,
|
|
145
145
|
onClick: onGooglePaymentButtonClicked,
|
|
146
146
|
allowedPaymentMethods: [baseCardPaymentMethod]
|
|
147
147
|
});
|
|
@@ -175,9 +175,19 @@ const loadGooglePayJS = (onload, onerror) => {
|
|
|
175
175
|
});
|
|
176
176
|
};
|
|
177
177
|
const { bem } = useBEM("google-pay");
|
|
178
|
+
const DEFAULT_GOOGLE_PAY_CONFIG = {
|
|
179
|
+
button: {
|
|
180
|
+
buttonColor: "default",
|
|
181
|
+
buttonType: "pay",
|
|
182
|
+
buttonRadius: 8,
|
|
183
|
+
buttonSizeMode: "fill",
|
|
184
|
+
buttonBorderType: "default_border"
|
|
185
|
+
}
|
|
186
|
+
};
|
|
178
187
|
const GooglePay = w((props, ref) => {
|
|
179
188
|
var _a;
|
|
180
|
-
const { session, threeDSFrame, isDropIn } = props;
|
|
189
|
+
const { session, threeDSFrame, isDropIn, core } = props;
|
|
190
|
+
const googlePayConfig = deepMerge(DEFAULT_GOOGLE_PAY_CONFIG, props.config || {});
|
|
181
191
|
F(ref, () => ({
|
|
182
192
|
checkThreeDS
|
|
183
193
|
}));
|
|
@@ -195,15 +205,19 @@ const GooglePay = w((props, ref) => {
|
|
|
195
205
|
},
|
|
196
206
|
[i18n, props.onTimeout]
|
|
197
207
|
);
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
const processOnSuccess = (res) => {
|
|
209
|
+
var _a2, _b;
|
|
210
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
211
|
+
...res,
|
|
212
|
+
returnUrl: (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.returnUrl
|
|
213
|
+
}));
|
|
214
|
+
};
|
|
201
215
|
y(() => {
|
|
202
|
-
var _a2, _b
|
|
216
|
+
var _a2, _b;
|
|
203
217
|
if (!sessionReady) {
|
|
204
218
|
return;
|
|
205
219
|
}
|
|
206
|
-
const { status,
|
|
220
|
+
const { status, supportMethods = [], sessionMode } = (session == null ? void 0 : session.checkout) || {};
|
|
207
221
|
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
208
222
|
(_b = (_a2 = props.core.config).onInitError) == null ? void 0 : _b.call(
|
|
209
223
|
_a2,
|
|
@@ -211,7 +225,7 @@ const GooglePay = w((props, ref) => {
|
|
|
211
225
|
);
|
|
212
226
|
return;
|
|
213
227
|
}
|
|
214
|
-
if (!
|
|
228
|
+
if (!supportMethods.includes(PaymentMethod.GOOGLE_PAY)) {
|
|
215
229
|
return;
|
|
216
230
|
}
|
|
217
231
|
loadGooglePayJS(
|
|
@@ -228,7 +242,7 @@ const GooglePay = w((props, ref) => {
|
|
|
228
242
|
);
|
|
229
243
|
setHosted(sessionMode === SessionMode.HOSTED);
|
|
230
244
|
if (status === "SUCCESS") {
|
|
231
|
-
(
|
|
245
|
+
processOnSuccess(session == null ? void 0 : session.checkout);
|
|
232
246
|
}
|
|
233
247
|
}, [sessionReady]);
|
|
234
248
|
const processThreeDS = (threeDSUrl, incomplete) => {
|
|
@@ -258,50 +272,66 @@ const GooglePay = w((props, ref) => {
|
|
|
258
272
|
onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
|
|
259
273
|
}
|
|
260
274
|
);
|
|
275
|
+
const getPaymentParams = async (token, billAddress) => {
|
|
276
|
+
const phone = extractAreaCodeAndPhoneNumber(billAddress == null ? void 0 : billAddress.phoneNumber);
|
|
277
|
+
return {
|
|
278
|
+
sessionId: session.sessionId,
|
|
279
|
+
clientKey: session.clientKey,
|
|
280
|
+
payment: {
|
|
281
|
+
paymentMethod: PaymentMethod.GOOGLE_PAY,
|
|
282
|
+
tokenData: token ?? ""
|
|
283
|
+
},
|
|
284
|
+
bill: {
|
|
285
|
+
firstName: billAddress == null ? void 0 : billAddress.name,
|
|
286
|
+
addressLine1: billAddress == null ? void 0 : billAddress.address1,
|
|
287
|
+
addressLine2: (billAddress == null ? void 0 : billAddress.address2) ?? "" + (billAddress == null ? void 0 : billAddress.address3) ?? "",
|
|
288
|
+
country: billAddress == null ? void 0 : billAddress.countryCode,
|
|
289
|
+
state: billAddress == null ? void 0 : billAddress.administrativeArea,
|
|
290
|
+
city: billAddress == null ? void 0 : billAddress.locality,
|
|
291
|
+
email: billAddress == null ? void 0 : billAddress.email,
|
|
292
|
+
postalCode: billAddress == null ? void 0 : billAddress.postalCode,
|
|
293
|
+
phoneNumber: phone == null ? void 0 : phone.phoneNumber,
|
|
294
|
+
areaCode: phone == null ? void 0 : phone.areaCode
|
|
295
|
+
},
|
|
296
|
+
browser: await getBrowserParams({
|
|
297
|
+
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
298
|
+
})
|
|
299
|
+
};
|
|
300
|
+
};
|
|
261
301
|
async function pay(token, billAddress, search = false, timeout) {
|
|
262
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
302
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
263
303
|
setErrorMsg("");
|
|
264
304
|
if (!search) {
|
|
265
305
|
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props);
|
|
266
306
|
}
|
|
267
307
|
try {
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
{ locale: i18n.locale, timeout }
|
|
274
|
-
) : async function() {
|
|
275
|
-
const phone = extractAreaCodeAndPhoneNumber(billAddress == null ? void 0 : billAddress.phoneNumber);
|
|
276
|
-
return googlePay(
|
|
308
|
+
const requestOptions = { locale: i18n.locale, timeout };
|
|
309
|
+
let res = null;
|
|
310
|
+
if (search) {
|
|
311
|
+
const extraParams = (_c = (_b = core.config)._getExtraParams) == null ? void 0 : _c.call(_b, "query", PaymentMethod.GOOGLE_PAY);
|
|
312
|
+
res = await getGooglePayInfo(
|
|
277
313
|
{
|
|
278
314
|
sessionId: session.sessionId,
|
|
279
315
|
clientKey: session.clientKey,
|
|
280
|
-
|
|
281
|
-
bill: {
|
|
282
|
-
firstName: billAddress == null ? void 0 : billAddress.name,
|
|
283
|
-
addressLine1: billAddress == null ? void 0 : billAddress.address1,
|
|
284
|
-
addressLine2: (billAddress == null ? void 0 : billAddress.address2) ?? "" + (billAddress == null ? void 0 : billAddress.address3) ?? "",
|
|
285
|
-
country: billAddress == null ? void 0 : billAddress.countryCode,
|
|
286
|
-
state: billAddress == null ? void 0 : billAddress.administrativeArea,
|
|
287
|
-
city: billAddress == null ? void 0 : billAddress.locality,
|
|
288
|
-
email: billAddress == null ? void 0 : billAddress.email,
|
|
289
|
-
postalCode: billAddress == null ? void 0 : billAddress.postalCode,
|
|
290
|
-
phoneNumber: phone == null ? void 0 : phone.phoneNumber,
|
|
291
|
-
areaCode: phone == null ? void 0 : phone.areaCode
|
|
292
|
-
},
|
|
293
|
-
browser: await getBrowserParams({
|
|
294
|
-
fraudDetectionId: await (fraudDetection == null ? void 0 : fraudDetection.getFraudDetectionId())
|
|
295
|
-
})
|
|
316
|
+
paymentMethod: PaymentMethod.GOOGLE_PAY
|
|
296
317
|
},
|
|
297
|
-
|
|
298
|
-
|
|
318
|
+
extraParams,
|
|
319
|
+
requestOptions
|
|
320
|
+
);
|
|
321
|
+
} else {
|
|
322
|
+
const extraParams = (_e = (_d = core.config)._getExtraParams) == null ? void 0 : _e.call(_d, "payment", PaymentMethod.GOOGLE_PAY);
|
|
323
|
+
res = await googlePay(
|
|
324
|
+
await getPaymentParams(token, billAddress),
|
|
325
|
+
extraParams,
|
|
326
|
+
requestOptions
|
|
299
327
|
);
|
|
300
|
-
}
|
|
301
|
-
const { status, orderStatus, errorMessage,
|
|
328
|
+
}
|
|
329
|
+
const { status, orderStatus, errorMessage, payInfo = {}, errorCode, sessionId } = res;
|
|
330
|
+
const { threeDSUrl } = payInfo;
|
|
331
|
+
sessionId && (session.sessionId = sessionId);
|
|
302
332
|
if (status === "PROCESSING") {
|
|
303
333
|
if (orderStatus === "SUCCESS") {
|
|
304
|
-
(
|
|
334
|
+
processOnSuccess(res);
|
|
305
335
|
return {
|
|
306
336
|
end: true,
|
|
307
337
|
res: { transactionState: "SUCCESS" }
|
|
@@ -313,33 +343,33 @@ const GooglePay = w((props, ref) => {
|
|
|
313
343
|
res: res2.res
|
|
314
344
|
} : await startReFetchPayInfo();
|
|
315
345
|
} else if (orderStatus === "FAILURE") {
|
|
316
|
-
setErrorMsg(errorMessage);
|
|
317
|
-
(
|
|
346
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
347
|
+
(_f = props.onError) == null ? void 0 : _f.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
318
348
|
return {
|
|
319
349
|
end: true,
|
|
320
350
|
res: {
|
|
321
351
|
transactionState: "ERROR",
|
|
322
352
|
error: {
|
|
323
353
|
intent: "PAYMENT_AUTHORIZATION",
|
|
324
|
-
message: errorMessage,
|
|
354
|
+
message: errorMessage || "",
|
|
325
355
|
reason: "OTHER_ERROR"
|
|
326
356
|
}
|
|
327
357
|
}
|
|
328
358
|
};
|
|
329
359
|
} else if (orderStatus === "AUTHORIZED") {
|
|
330
|
-
(
|
|
360
|
+
(_g = props.onAuthorized) == null ? void 0 : _g.call(props);
|
|
331
361
|
return {
|
|
332
362
|
end: true,
|
|
333
363
|
res: { transactionState: "SUCCESS" }
|
|
334
364
|
};
|
|
335
365
|
} else if (orderStatus === "IN_THREED") {
|
|
336
|
-
processThreeDS(threeDSUrl, false);
|
|
366
|
+
threeDSUrl && processThreeDS(threeDSUrl, false);
|
|
337
367
|
return {
|
|
338
368
|
end: true,
|
|
339
369
|
res: { transactionState: "SUCCESS" }
|
|
340
370
|
};
|
|
341
371
|
} else if (orderStatus === "IN_PREVIOUS_THREED") {
|
|
342
|
-
processThreeDS(threeDSUrl, true);
|
|
372
|
+
threeDSUrl && processThreeDS(threeDSUrl, true);
|
|
343
373
|
return {
|
|
344
374
|
end: true,
|
|
345
375
|
res: { transactionState: "SUCCESS" }
|
|
@@ -351,19 +381,19 @@ const GooglePay = w((props, ref) => {
|
|
|
351
381
|
};
|
|
352
382
|
}
|
|
353
383
|
} else if (status === "SUCCESS") {
|
|
354
|
-
(
|
|
384
|
+
processOnSuccess(res);
|
|
355
385
|
return {
|
|
356
386
|
end: true,
|
|
357
387
|
res: { transactionState: "SUCCESS" }
|
|
358
388
|
};
|
|
359
389
|
} else if (status === "EXPIRED") {
|
|
360
|
-
(
|
|
390
|
+
(_h = props.onExpired) == null ? void 0 : _h.call(props);
|
|
361
391
|
return {
|
|
362
392
|
end: true,
|
|
363
393
|
res: { transactionState: "SUCCESS" }
|
|
364
394
|
};
|
|
365
395
|
}
|
|
366
|
-
(
|
|
396
|
+
processOnSuccess(res);
|
|
367
397
|
return {
|
|
368
398
|
end: false,
|
|
369
399
|
res: { transactionState: "SUCCESS" }
|
|
@@ -389,7 +419,7 @@ const GooglePay = w((props, ref) => {
|
|
|
389
419
|
} else {
|
|
390
420
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
391
421
|
setErrorMsg(message);
|
|
392
|
-
(
|
|
422
|
+
(_i = props.onError) == null ? void 0 : _i.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
393
423
|
return {
|
|
394
424
|
end: true,
|
|
395
425
|
res: {
|
|
@@ -416,11 +446,13 @@ const GooglePay = w((props, ref) => {
|
|
|
416
446
|
if (!session)
|
|
417
447
|
return { end: true };
|
|
418
448
|
try {
|
|
449
|
+
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", PaymentMethod.GOOGLE_PAY);
|
|
419
450
|
const res = await getGooglePayInfo(
|
|
420
451
|
{
|
|
421
452
|
sessionId: session.sessionId,
|
|
422
453
|
clientKey: session.clientKey
|
|
423
454
|
},
|
|
455
|
+
extraParams,
|
|
424
456
|
{
|
|
425
457
|
locale: i18n.locale
|
|
426
458
|
}
|
|
@@ -430,9 +462,9 @@ const GooglePay = w((props, ref) => {
|
|
|
430
462
|
if (orderStatus === "PROCESSING") {
|
|
431
463
|
startReFetchPayInfo();
|
|
432
464
|
} else if (orderStatus === "FAILURE") {
|
|
433
|
-
setErrorMsg(errorMessage);
|
|
465
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
434
466
|
} else if (orderStatus === "AUTHORIZED") {
|
|
435
|
-
(
|
|
467
|
+
(_c = props.onAuthorized) == null ? void 0 : _c.call(props);
|
|
436
468
|
} else if (orderStatus === "IN_THREED") {
|
|
437
469
|
!search && startReFetchCardPay3DSInfo();
|
|
438
470
|
return { end: false };
|
|
@@ -443,15 +475,15 @@ const GooglePay = w((props, ref) => {
|
|
|
443
475
|
stopReFetchCardPay3DSInfo();
|
|
444
476
|
return { end: true };
|
|
445
477
|
} else if (status === "SUCCESS") {
|
|
446
|
-
(
|
|
478
|
+
processOnSuccess(res);
|
|
447
479
|
stopReFetchCardPay3DSInfo();
|
|
448
480
|
return { end: true };
|
|
449
481
|
} else if (status === "EXPIRED") {
|
|
450
|
-
(
|
|
482
|
+
(_d = props.onExpired) == null ? void 0 : _d.call(props);
|
|
451
483
|
stopReFetchCardPay3DSInfo();
|
|
452
484
|
return { end: true };
|
|
453
485
|
}
|
|
454
|
-
(
|
|
486
|
+
processOnSuccess(res);
|
|
455
487
|
stopReFetchCardPay3DSInfo();
|
|
456
488
|
return { end: true };
|
|
457
489
|
} catch (error) {
|
|
@@ -475,6 +507,7 @@ const GooglePay = w((props, ref) => {
|
|
|
475
507
|
if (containRef && (session == null ? void 0 : session.checkout) && showGooglePay) {
|
|
476
508
|
const { onGooglePayLoaded } = createGooglePay(
|
|
477
509
|
session == null ? void 0 : session.checkout,
|
|
510
|
+
googlePayConfig,
|
|
478
511
|
pay,
|
|
479
512
|
props.onBtnClick,
|
|
480
513
|
props.onCanUse
|
|
@@ -493,6 +526,7 @@ const GooglePay = w((props, ref) => {
|
|
|
493
526
|
{
|
|
494
527
|
show: showThreeDSModal,
|
|
495
528
|
theme: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.theme,
|
|
529
|
+
checkoutId: core.id,
|
|
496
530
|
...threeDSInfo,
|
|
497
531
|
onClose: handleCloseThreeDSModal
|
|
498
532
|
}
|
|
@@ -3,18 +3,17 @@ 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 { getGrabPayInfo, grabPay } from "../../api/modules/grab-pay/index.js";
|
|
12
13
|
import { PayKKaError } from "../../core/error.js";
|
|
13
|
-
import { hidePaymentButton } from "../../config.js";
|
|
14
14
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
15
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
16
|
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
17
|
-
import { createAddressCore } from "../../core/Address.js";
|
|
18
17
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
19
18
|
import "../internal/Form/type.js";
|
|
20
19
|
import "../internal/Form/context.js";
|
|
@@ -26,7 +25,6 @@ import { GuideCard } from "../GuideCard/index.js";
|
|
|
26
25
|
const { bem } = useBEM("grab-pay");
|
|
27
26
|
const fieldClassNames = bem("field");
|
|
28
27
|
const GrabPay = w((props, ref) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
28
|
const {
|
|
31
29
|
session,
|
|
32
30
|
showEmail = false,
|
|
@@ -34,7 +32,8 @@ const GrabPay = w((props, ref) => {
|
|
|
34
32
|
core,
|
|
35
33
|
redirectMode = "auto",
|
|
36
34
|
autoQuery = true,
|
|
37
|
-
showGuideCard = true
|
|
35
|
+
showGuideCard = true,
|
|
36
|
+
hidePaymentButton = false
|
|
38
37
|
} = props;
|
|
39
38
|
F(ref, () => ({
|
|
40
39
|
stopRetry: () => {
|
|
@@ -46,26 +45,28 @@ const GrabPay = w((props, ref) => {
|
|
|
46
45
|
startReFetchPayInfo({ timeout });
|
|
47
46
|
},
|
|
48
47
|
updateAddress: () => {
|
|
49
|
-
var
|
|
48
|
+
var _a;
|
|
50
49
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
51
50
|
return;
|
|
52
|
-
|
|
53
|
-
(
|
|
51
|
+
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
52
|
+
setForm(newForm);
|
|
53
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
54
|
+
validateForm();
|
|
54
55
|
},
|
|
55
56
|
updateEmail: () => {
|
|
56
|
-
var
|
|
57
|
+
var _a;
|
|
57
58
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
58
59
|
return;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
(
|
|
60
|
+
const newForm = Object.assign(form, { email: emailState.email });
|
|
61
|
+
setForm(newForm);
|
|
62
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
62
63
|
validateForm();
|
|
63
64
|
},
|
|
64
65
|
payment: () => {
|
|
65
66
|
hidePaymentButton && onSubmit();
|
|
66
67
|
}
|
|
67
68
|
}));
|
|
68
|
-
const
|
|
69
|
+
const addressCore = core.getAddressCore();
|
|
69
70
|
const emailState = createEmailCore();
|
|
70
71
|
const addressFieldRef = A(null);
|
|
71
72
|
const emailFieldRef = A(null);
|
|
@@ -76,13 +77,13 @@ const GrabPay = w((props, ref) => {
|
|
|
76
77
|
const [form, setForm] = h({
|
|
77
78
|
email: "",
|
|
78
79
|
address: {
|
|
79
|
-
country:
|
|
80
|
-
province:
|
|
81
|
-
city:
|
|
82
|
-
area:
|
|
83
|
-
postCode:
|
|
84
|
-
address1:
|
|
85
|
-
address2:
|
|
80
|
+
country: void 0,
|
|
81
|
+
province: void 0,
|
|
82
|
+
city: void 0,
|
|
83
|
+
area: void 0,
|
|
84
|
+
postCode: void 0,
|
|
85
|
+
address1: void 0,
|
|
86
|
+
address2: void 0
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
const [validated, setValidated] = h(false);
|
|
@@ -100,33 +101,43 @@ const GrabPay = w((props, ref) => {
|
|
|
100
101
|
}
|
|
101
102
|
setFieldStatus({ ...field });
|
|
102
103
|
};
|
|
104
|
+
const processOnSuccess = (res) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
setSubmitButtonStatus("success");
|
|
107
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
108
|
+
...res,
|
|
109
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
103
112
|
y(() => {
|
|
104
113
|
if (!sessionReady) {
|
|
105
114
|
return;
|
|
106
115
|
}
|
|
107
|
-
const { bill = {},
|
|
108
|
-
if (!
|
|
116
|
+
const { bill = {}, supportMethods = [], country } = (session == null ? void 0 : session.checkout) || {};
|
|
117
|
+
if (!supportMethods.includes(PaymentMethod.GRAB_PAY)) {
|
|
109
118
|
return;
|
|
110
119
|
}
|
|
111
120
|
initFieldStatus();
|
|
112
121
|
setIsCheckoutEnabled(true);
|
|
122
|
+
country && addressCore.setCountry(country);
|
|
113
123
|
form.email = bill.email ?? "";
|
|
124
|
+
form.address.country = country;
|
|
114
125
|
if (autoQuery && core.processingPaymentMethod === PaymentMethod.GRAB_PAY) {
|
|
115
126
|
setSubmitButtonStatus("loading");
|
|
116
127
|
startReFetchPayInfo();
|
|
117
128
|
}
|
|
118
129
|
}, [sessionReady]);
|
|
119
130
|
const processOnError = (error) => {
|
|
120
|
-
var
|
|
121
|
-
(
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, error);
|
|
122
133
|
core.resetEnablePaymentMethod();
|
|
123
134
|
};
|
|
124
135
|
const onTimeout = q(
|
|
125
136
|
(message) => {
|
|
126
|
-
var
|
|
137
|
+
var _a;
|
|
127
138
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
128
139
|
setSubmitButtonStatus("unSubmit");
|
|
129
|
-
(
|
|
140
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props);
|
|
130
141
|
core.resetEnablePaymentMethod();
|
|
131
142
|
},
|
|
132
143
|
[i18n, props.onTimeout]
|
|
@@ -144,34 +155,49 @@ const GrabPay = w((props, ref) => {
|
|
|
144
155
|
},
|
|
145
156
|
bill: {
|
|
146
157
|
email: form.email,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
addressLine1: form.address.address1,
|
|
159
|
+
addressLine2: form.address.address2,
|
|
160
|
+
postalCode: form.address.postCode,
|
|
161
|
+
country: form.address.country,
|
|
162
|
+
district: form.address.area,
|
|
163
|
+
state: form.address.province ? addressCore.getLabel(form.address.province, addressCore.getProvinceOption()) ?? form.address.province : void 0,
|
|
164
|
+
city: form.address.city ? addressCore.getLabel(form.address.city, addressCore.getCityOptions()) ?? form.address.city : void 0
|
|
150
165
|
},
|
|
151
166
|
browser: await getBrowserParams()
|
|
152
167
|
};
|
|
153
168
|
};
|
|
154
169
|
const pay = async (search = false, timeout) => {
|
|
155
|
-
var
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
156
171
|
try {
|
|
157
|
-
const paymentParams = await getPaymentParams();
|
|
158
172
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
173
|
+
let res = null;
|
|
174
|
+
if (search) {
|
|
175
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.GRAB_PAY);
|
|
176
|
+
res = await getGrabPayInfo(
|
|
177
|
+
{
|
|
178
|
+
sessionId: session.sessionId,
|
|
179
|
+
clientKey: session.clientKey,
|
|
180
|
+
paymentMethod: PaymentMethod.GRAB_PAY
|
|
181
|
+
},
|
|
182
|
+
extraParams,
|
|
183
|
+
requestOptions
|
|
184
|
+
);
|
|
185
|
+
} else {
|
|
186
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.GRAB_PAY);
|
|
187
|
+
res = await grabPay(await getPaymentParams(), extraParams, requestOptions);
|
|
188
|
+
}
|
|
189
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
190
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
191
|
+
sessionId && (session.sessionId = sessionId);
|
|
165
192
|
if (status === "PROCESSING") {
|
|
166
193
|
if (!orderStatus) {
|
|
167
194
|
setSubmitButtonStatus("unSubmit");
|
|
168
195
|
return { end: true };
|
|
169
196
|
} else if (orderStatus === "SUCCESS") {
|
|
170
|
-
|
|
171
|
-
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
197
|
+
processOnSuccess(res);
|
|
172
198
|
return { end: true };
|
|
173
199
|
} else if (orderStatus === "FAILURE") {
|
|
174
|
-
setErrorMsg(errorMessage);
|
|
200
|
+
errorMessage && setErrorMsg(errorMessage);
|
|
175
201
|
setSubmitButtonStatus("unSubmit");
|
|
176
202
|
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
177
203
|
return { end: true };
|
|
@@ -187,17 +213,16 @@ const GrabPay = w((props, ref) => {
|
|
|
187
213
|
return { end: false };
|
|
188
214
|
} else if (orderStatus === "CANCELED") {
|
|
189
215
|
setSubmitButtonStatus("unSubmit");
|
|
190
|
-
(
|
|
216
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
191
217
|
core.resetEnablePaymentMethod();
|
|
192
218
|
return { end: true };
|
|
193
219
|
}
|
|
194
220
|
} else if (status === "SUCCESS") {
|
|
195
|
-
|
|
196
|
-
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
221
|
+
processOnSuccess(res);
|
|
197
222
|
return { end: true };
|
|
198
223
|
} else if (status === "EXPIRED") {
|
|
199
224
|
setSubmitButtonStatus("unSubmit");
|
|
200
|
-
(
|
|
225
|
+
(_g = props.onExpired) == null ? void 0 : _g.call(props);
|
|
201
226
|
return { end: true };
|
|
202
227
|
}
|
|
203
228
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -212,7 +237,7 @@ const GrabPay = w((props, ref) => {
|
|
|
212
237
|
}
|
|
213
238
|
} else {
|
|
214
239
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
215
|
-
setErrorMsg(message);
|
|
240
|
+
message && setErrorMsg(message);
|
|
216
241
|
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
217
242
|
setSubmitButtonStatus("unSubmit");
|
|
218
243
|
return { end: true };
|
|
@@ -220,8 +245,8 @@ const GrabPay = w((props, ref) => {
|
|
|
220
245
|
}
|
|
221
246
|
};
|
|
222
247
|
const validateForm = () => {
|
|
223
|
-
var
|
|
224
|
-
(
|
|
248
|
+
var _a;
|
|
249
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
225
250
|
setValidated(true);
|
|
226
251
|
}).catch(() => {
|
|
227
252
|
setValidated(false);
|
|
@@ -231,12 +256,12 @@ const GrabPay = w((props, ref) => {
|
|
|
231
256
|
validateForm();
|
|
232
257
|
}, [form]);
|
|
233
258
|
const onSubmit = async () => {
|
|
234
|
-
var
|
|
259
|
+
var _a;
|
|
235
260
|
setErrorMsg("");
|
|
236
|
-
(
|
|
237
|
-
var
|
|
238
|
-
(fieldStatus == null ? void 0 : fieldStatus.address.show) &&
|
|
239
|
-
(
|
|
261
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
262
|
+
var _a2;
|
|
263
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
264
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
240
265
|
if (errors) {
|
|
241
266
|
setSubmitButtonStatus("unSubmit");
|
|
242
267
|
return;
|
|
@@ -251,8 +276,8 @@ const GrabPay = w((props, ref) => {
|
|
|
251
276
|
dom && validateForm();
|
|
252
277
|
};
|
|
253
278
|
const Button = () => {
|
|
254
|
-
var
|
|
255
|
-
const transAmount = (
|
|
279
|
+
var _a;
|
|
280
|
+
const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
|
|
256
281
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
257
282
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
258
283
|
return /* @__PURE__ */ u(
|
|
@@ -278,24 +303,17 @@ const GrabPay = w((props, ref) => {
|
|
|
278
303
|
}
|
|
279
304
|
) }) });
|
|
280
305
|
};
|
|
281
|
-
const formStyle = {
|
|
282
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
283
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
284
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
285
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
286
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
287
|
-
};
|
|
288
306
|
const ErrorMessage = () => {
|
|
289
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
307
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
290
308
|
};
|
|
291
309
|
const Address = () => {
|
|
292
|
-
var
|
|
310
|
+
var _a, _b;
|
|
293
311
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
294
312
|
AddressField,
|
|
295
313
|
{
|
|
296
314
|
ref: addressFieldRef,
|
|
297
315
|
value: form.address,
|
|
298
|
-
country: ((
|
|
316
|
+
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),
|
|
299
317
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
300
318
|
}
|
|
301
319
|
) }) });
|
|
@@ -305,15 +323,18 @@ const GrabPay = w((props, ref) => {
|
|
|
305
323
|
{
|
|
306
324
|
value: {
|
|
307
325
|
i18n,
|
|
308
|
-
session
|
|
326
|
+
session,
|
|
327
|
+
core
|
|
309
328
|
},
|
|
310
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
329
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
311
330
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.GRAB_PAY }),
|
|
312
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
331
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
313
332
|
Email(),
|
|
314
333
|
Address(),
|
|
315
|
-
|
|
316
|
-
|
|
334
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
335
|
+
ErrorMessage(),
|
|
336
|
+
!hidePaymentButton && Button()
|
|
337
|
+
] })
|
|
317
338
|
] }) })
|
|
318
339
|
] })
|
|
319
340
|
}
|