@paykka/card-checkout-ui 0.8.0 → 0.9.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 +20 -13
- package/dist/card-checkout-ui.umd.cjs +20 -13
- package/dist/es/_commonjsHelpers.js +1 -0
- package/dist/es/api/http.js +19 -21
- package/dist/es/api/index.js +1 -0
- package/dist/es/api/modules/ali-pay/index.js +19 -11
- package/dist/es/api/modules/apple-pay/index.js +10 -26
- package/dist/es/api/modules/boost/index.js +56 -0
- package/dist/es/api/modules/card/index.js +17 -11
- package/dist/es/api/modules/checkout/index.js +6 -6
- package/dist/es/api/modules/checkout/map.js +23 -6
- package/dist/es/api/modules/gcash/index.js +56 -0
- package/dist/es/api/modules/get-browser-params.js +2 -2
- package/dist/es/api/modules/google-pay/index.js +10 -26
- package/dist/es/api/modules/grab-pay/index.js +56 -0
- package/dist/es/api/modules/index.js +1 -0
- package/dist/es/api/modules/line-pay/index.js +56 -0
- package/dist/es/api/modules/may-bank-qr-pay/index.js +56 -0
- package/dist/es/api/modules/nine-pay/index.js +56 -0
- package/dist/es/api/modules/paymaya/index.js +56 -0
- package/dist/es/api/modules/sepa/index.js +19 -11
- package/dist/es/api/modules/shopee-pay/index.js +56 -0
- package/dist/es/api/modules/tng-wallet/index.js +56 -0
- package/dist/es/api/modules/wechat-pay/index.js +18 -31
- package/dist/es/components/AccordionItem/AccordionItem.js +36 -0
- package/dist/es/components/AliPay/index.js +27 -39
- package/dist/es/components/ApplePay/index.js +16 -37
- package/dist/es/components/Boost/index.js +322 -0
- package/dist/es/components/Card/index.js +52 -41
- package/dist/es/components/CardBrands/index.js +2 -2
- package/dist/es/components/CardNumberField/index.js +113 -106
- package/dist/es/components/DropIn/index.js +204 -49
- package/dist/es/components/GooglePay/index.js +5 -4
- package/dist/es/components/GrabPay/index.js +322 -0
- package/dist/es/components/GuideCard/index.js +43 -0
- package/dist/es/components/LinePay/index.js +322 -0
- package/dist/es/components/MayBankQRPay/index.js +322 -0
- package/dist/es/components/NinePay/index.js +322 -0
- package/dist/es/components/SecuredIframe/index.js +3 -2
- package/dist/es/components/Sepa/index.js +6 -9
- package/dist/es/components/ShopeePay/index.js +322 -0
- package/dist/es/components/SubmitButton/index.js +6 -20
- package/dist/es/components/TNGWallet/index.js +322 -0
- package/dist/es/components/WechatPay/index.js +30 -49
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +41 -0
- package/dist/es/components/business/QRCodeModal/index.js +6 -0
- package/dist/es/components/business/QRCodeModal/qr-code-modal.js +1 -0
- package/dist/es/components/business/QRCodeModal/type.js +1 -0
- package/dist/es/components/business/index.js +6 -0
- package/dist/es/components/index.js +9 -0
- package/dist/es/components/internal/Accordion/Accordion.js +14 -0
- package/dist/es/components/internal/Accordion/accordion2.js +1 -0
- package/dist/es/components/internal/Accordion/accordionTransition.js +26 -0
- package/dist/es/components/internal/Accordion/index.js +7 -0
- package/dist/es/components/internal/Accordion/type.js +10 -0
- package/dist/es/components/internal/Modal/Modal.js +17 -3
- package/dist/es/components/internal/Modal/index.js +1 -0
- package/dist/es/components/internal/Modal/type.js +1 -0
- package/dist/es/components/internal/QRCode/QRCode.js +31 -0
- package/dist/es/components/internal/QRCode/index.js +4 -0
- package/dist/es/components/internal/QRCode/type.js +1 -0
- package/dist/es/components/internal/icons/IconBoost.js +63 -0
- package/dist/es/components/internal/icons/IconCard.js +1 -40
- package/dist/es/components/internal/icons/IconCard2.js +60 -0
- package/dist/es/components/internal/icons/IconGCash.js +196 -0
- package/dist/es/components/internal/icons/IconGcashComplete.js +184 -0
- package/dist/es/components/internal/icons/IconGrabPay.js +59 -0
- package/dist/es/components/internal/icons/IconLinePay.js +99 -0
- package/dist/es/components/internal/icons/IconMayBankQRPay.js +69 -0
- package/dist/es/components/internal/icons/IconNinePay.js +255 -0
- package/dist/es/components/internal/icons/IconPaymaya.js +114 -0
- package/dist/es/components/internal/icons/IconRedirect.js +58 -0
- package/dist/es/components/internal/icons/IconScan.js +102 -0
- package/dist/es/components/internal/icons/IconShopeePay.js +108 -0
- package/dist/es/components/internal/icons/IconTNGWallet.js +119 -0
- package/dist/es/components/internal/icons/IconUnionPay.js +65 -0
- package/dist/es/components/wallets/GCash/GCash.js +356 -0
- package/dist/es/components/wallets/GCash/g-cash.js +1 -0
- package/dist/es/components/wallets/GCash/index.js +1 -0
- package/dist/es/components/wallets/GCash/type.js +1 -0
- package/dist/es/components/wallets/Paymaya/Paymaya.js +323 -0
- package/dist/es/components/wallets/Paymaya/index.js +1 -0
- package/dist/es/components/wallets/Paymaya/paymaya2.js +1 -0
- package/dist/es/components/wallets/Paymaya/type.js +1 -0
- package/dist/es/config.js +12 -12
- package/dist/es/constant.js +84 -4
- package/dist/es/core/PayKKaCheckout.js +28 -3
- package/dist/es/core/Session.js +24 -23
- package/dist/es/core/error.js +7 -0
- package/dist/es/core/query.js +3 -2
- package/dist/es/core.js +2082 -70
- package/dist/es/hooks/usePayState.js +0 -3
- package/dist/es/i18n/I18n.js +8 -2
- package/dist/es/i18n/locales/de-DE.js +16 -1
- package/dist/es/i18n/locales/en-GB.js +16 -1
- package/dist/es/i18n/locales/es-ES.js +16 -1
- package/dist/es/i18n/locales/fr-FR.js +16 -1
- package/dist/es/i18n/locales/ja-JP.js +16 -1
- package/dist/es/i18n/locales/ko-KR.js +16 -1
- package/dist/es/i18n/locales/pt-PT.js +16 -1
- package/dist/es/i18n/locales/ru-RU.js +16 -1
- package/dist/es/i18n/locales/zh-CN.js +16 -1
- package/dist/es/i18n/locales/zh-HK.js +16 -1
- package/dist/es/i18n/locales/zh-TW.js +16 -1
- package/dist/es/i18n/util.js +12 -3
- package/dist/es/index.js +20 -0
- package/dist/es/style.css +1 -1192
- package/dist/es/types/index.js +1 -0
- package/dist/es/utils/array.js +9 -0
- package/dist/es/utils/card-brand/brands.js +11 -1
- package/dist/es/utils/card-brand/index.js +4 -3
- package/dist/es/utils/card-brand/luhn.js +25 -0
- package/dist/es/utils/date.js +25 -0
- package/dist/es/utils/detect.js +6 -0
- package/dist/es/utils/format.js +28 -12
- package/dist/es/utils/index.js +9 -1
- package/dist/es/utils/location.js +37 -0
- package/dist/es/utils/object.js +14 -0
- package/dist/es/utils/redirect.js +32 -0
- package/dist/es/utils/system-info/get-browser-info.js +4 -4
- package/dist/es/utils/system-info/get-system-info.js +11 -7
- package/dist/es/utils/system-info/index.js +4 -4
- package/dist/style.css +1 -1
- package/dist/types/api/http.d.ts +4 -10
- package/dist/types/api/modules/ali-pay/index.d.ts +2 -1
- package/dist/types/api/modules/apple-pay/index.d.ts +2 -1
- package/dist/types/api/modules/boost/index.d.ts +24 -0
- package/dist/types/api/modules/card/index.d.ts +1 -1
- package/dist/types/api/modules/checkout/index.d.ts +2 -2
- package/dist/types/api/modules/checkout/type.d.ts +9 -0
- package/dist/types/api/modules/gcash/index.d.ts +24 -0
- package/dist/types/api/modules/get-browser-params.d.ts +2 -2
- package/dist/types/api/modules/google-pay/index.d.ts +2 -1
- package/dist/types/api/modules/grab-pay/index.d.ts +24 -0
- package/dist/types/api/modules/index.d.ts +9 -0
- package/dist/types/api/modules/line-pay/index.d.ts +24 -0
- package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +24 -0
- package/dist/types/api/modules/nine-pay/index.d.ts +24 -0
- package/dist/types/api/modules/paymaya/index.d.ts +24 -0
- package/dist/types/api/modules/sepa/index.d.ts +2 -1
- package/dist/types/api/modules/shopee-pay/index.d.ts +24 -0
- package/dist/types/api/modules/tng-wallet/index.d.ts +24 -0
- package/dist/types/api/modules/wechat-pay/index.d.ts +2 -1
- package/dist/types/components/Boost/Boost.d.ts +7 -0
- package/dist/types/components/Boost/index.d.ts +2 -0
- package/dist/types/components/Boost/type.d.ts +61 -0
- package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +1 -1
- package/dist/types/components/DropIn/config.d.ts +7 -0
- package/dist/types/components/DropIn/type.d.ts +11 -3
- package/dist/types/components/GrabPay/GrabPay.d.ts +7 -0
- package/dist/types/components/GrabPay/index.d.ts +2 -0
- package/dist/types/components/GrabPay/type.d.ts +61 -0
- package/dist/types/components/GuideCard/GuideCard.d.ts +3 -0
- package/dist/types/components/GuideCard/index.d.ts +2 -0
- package/dist/types/components/GuideCard/type.d.ts +4 -0
- package/dist/types/components/LinePay/LinePay.d.ts +7 -0
- package/dist/types/components/LinePay/index.d.ts +2 -0
- package/dist/types/components/LinePay/type.d.ts +61 -0
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -0
- package/dist/types/components/MayBankQRPay/index.d.ts +2 -0
- package/dist/types/components/MayBankQRPay/type.d.ts +61 -0
- package/dist/types/components/NinePay/NinePay.d.ts +6 -0
- package/dist/types/components/NinePay/index.d.ts +2 -0
- package/dist/types/components/NinePay/type.d.ts +61 -0
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +1 -1
- package/dist/types/components/ShopeePay/ShopeePay.d.ts +7 -0
- package/dist/types/components/ShopeePay/index.d.ts +2 -0
- package/dist/types/components/ShopeePay/type.d.ts +61 -0
- package/dist/types/components/SubmitButton/SubmitButton.d.ts +1 -1
- package/dist/types/components/TNGWallet/TNGWallet.d.ts +7 -0
- package/dist/types/components/TNGWallet/index.d.ts +2 -0
- package/dist/types/components/TNGWallet/type.d.ts +61 -0
- package/dist/types/components/business/QRCodeModal/QRCodeModal.d.ts +3 -0
- package/dist/types/components/business/QRCodeModal/index.d.ts +2 -0
- package/dist/types/components/business/QRCodeModal/type.d.ts +18 -0
- package/dist/types/components/business/index.d.ts +1 -0
- package/dist/types/components/index.d.ts +9 -0
- package/dist/types/components/internal/Accordion/Accordion.d.ts +3 -0
- package/dist/types/components/internal/Accordion/accordionTransition.d.ts +8 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/AccordionItem.d.ts +3 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/index.d.ts +2 -0
- package/dist/types/components/internal/Accordion/components/AccordionItem/type.d.ts +18 -0
- package/dist/types/components/internal/Accordion/index.d.ts +3 -0
- package/dist/types/components/internal/Accordion/type.d.ts +18 -0
- package/dist/types/components/internal/Modal/type.d.ts +2 -0
- package/dist/types/components/internal/QRCode/QRCode.d.ts +2 -0
- package/dist/types/components/internal/QRCode/index.d.ts +2 -0
- package/dist/types/components/internal/QRCode/type.d.ts +9 -0
- package/dist/types/components/internal/icons/IconBoost.d.ts +2 -0
- package/dist/types/components/internal/icons/IconCard2.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGCash.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGcashComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/IconGrabPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconLinePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconMayBankQRPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconNinePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPaymaya.d.ts +2 -0
- package/dist/types/components/internal/icons/IconRedirect.d.ts +2 -0
- package/dist/types/components/internal/icons/IconScan.d.ts +2 -0
- package/dist/types/components/internal/icons/IconShopeePay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconTNGWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconUnionPay.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +13 -0
- package/dist/types/components/wallets/GCash/GCash.d.ts +6 -0
- package/dist/types/components/wallets/GCash/index.d.ts +2 -0
- package/dist/types/components/wallets/GCash/type.d.ts +66 -0
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -0
- package/dist/types/components/wallets/Paymaya/index.d.ts +2 -0
- package/dist/types/components/wallets/Paymaya/type.d.ts +61 -0
- package/dist/types/config.d.ts +9 -9
- package/dist/types/constant.d.ts +28 -3
- package/dist/types/core/PayKKaCheckout.d.ts +10 -0
- package/dist/types/core/Session.d.ts +2 -0
- package/dist/types/core/error.d.ts +3 -1
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/hooks/usePayState.d.ts +0 -3
- package/dist/types/i18n/I18n.d.ts +1 -1
- package/dist/types/i18n/locales/de-DE.d.ts +13 -0
- package/dist/types/i18n/locales/en-GB.d.ts +13 -0
- package/dist/types/i18n/locales/es-ES.d.ts +13 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +13 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +13 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +13 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +13 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +13 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +13 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +13 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +13 -0
- package/dist/types/i18n/util.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +10 -3
- package/dist/types/types/message.d.ts +1 -0
- package/dist/types/utils/array.d.ts +1 -0
- package/dist/types/utils/card-brand/brands.d.ts +4 -3
- package/dist/types/utils/card-brand/index.d.ts +9 -6
- package/dist/types/utils/card-brand/luhn.d.ts +9 -0
- package/dist/types/utils/date.d.ts +9 -0
- package/dist/types/utils/detect.d.ts +1 -0
- package/dist/types/utils/format.d.ts +7 -1
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/location.d.ts +7 -0
- package/dist/types/utils/object.d.ts +1 -0
- package/dist/types/utils/redirect.d.ts +5 -0
- package/dist/types/utils/system-info/get-browser-info.d.ts +1 -1
- package/dist/types/utils/system-info/get-system-info.d.ts +3 -2
- package/dist/types/utils/system-info/index.d.ts +3 -3
- package/package.json +4 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { w, h, y, q, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
3
|
import { SessionMode, PaymentMethod } from "../../constant.js";
|
|
4
|
+
import "../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
|
|
4
7
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
5
8
|
import { getApplePayInfo, applePay, getMerchantSession } from "../../api/modules/apple-pay/index.js";
|
|
6
9
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
7
10
|
import "../../core/context.js";
|
|
8
|
-
import "../../utils/card-brand/brands.js";
|
|
9
|
-
import "../../utils/system-info/get-browser-info.js";
|
|
10
|
-
import { parseE164, underscoreToUpperCamelCase } from "../../utils/format.js";
|
|
11
11
|
import { PayKKaError } from "../../core/error.js";
|
|
12
12
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
13
13
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
@@ -60,7 +60,7 @@ const ApplePay = w((props) => {
|
|
|
60
60
|
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
61
61
|
(_b = (_a = props.core.config).onInitError) == null ? void 0 : _b.call(
|
|
62
62
|
_a,
|
|
63
|
-
new PayKKaError("ERROR", "Please send the correct
|
|
63
|
+
new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
|
|
64
64
|
);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -142,24 +142,19 @@ const ApplePay = w((props) => {
|
|
|
142
142
|
fraudDetectionId: fraudDetection == null ? void 0 : fraudDetection.fraudDetectionID
|
|
143
143
|
})
|
|
144
144
|
},
|
|
145
|
+
props.core,
|
|
145
146
|
{ locale: i18n.locale }
|
|
146
147
|
);
|
|
147
148
|
}());
|
|
148
149
|
const { status, orderStatus, errorMessage, errorCode } = res;
|
|
149
150
|
if (status === "PROCESSING") {
|
|
150
151
|
if (orderStatus === "SUCCESS") {
|
|
151
|
-
applePaySession.completePayment({
|
|
152
|
-
status: 0
|
|
153
|
-
});
|
|
152
|
+
applePaySession.completePayment({ status: 0 });
|
|
154
153
|
(_a = props.onSuccess) == null ? void 0 : _a.call(props, getPaymentSuccessData());
|
|
155
|
-
return {
|
|
156
|
-
end: true
|
|
157
|
-
};
|
|
154
|
+
return { end: true };
|
|
158
155
|
} else if (orderStatus === "PROCESSING") {
|
|
159
156
|
!search && await startReFetchPayInfo();
|
|
160
|
-
return {
|
|
161
|
-
end: !search
|
|
162
|
-
};
|
|
157
|
+
return { end: !search };
|
|
163
158
|
} else if (orderStatus === "FAILURE") {
|
|
164
159
|
setErrorMsg(errorMessage);
|
|
165
160
|
(_b = props.onError) == null ? void 0 : _b.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
@@ -167,45 +162,29 @@ const ApplePay = w((props) => {
|
|
|
167
162
|
status: 1,
|
|
168
163
|
errors: [new ApplePayError("unknown", void 0, errorMessage)]
|
|
169
164
|
});
|
|
170
|
-
return {
|
|
171
|
-
end: true
|
|
172
|
-
};
|
|
165
|
+
return { end: true };
|
|
173
166
|
} else if (orderStatus === "AUTHORIZED") {
|
|
174
|
-
applePaySession.completePayment({
|
|
175
|
-
status: 0
|
|
176
|
-
});
|
|
167
|
+
applePaySession.completePayment({ status: 0 });
|
|
177
168
|
(_c = props.onAuthorized) == null ? void 0 : _c.call(props);
|
|
178
|
-
return {
|
|
179
|
-
end: true
|
|
180
|
-
};
|
|
169
|
+
return { end: true };
|
|
181
170
|
} else if (!orderStatus) {
|
|
182
171
|
applePaySession.completePayment({
|
|
183
172
|
status: 1,
|
|
184
173
|
errors: [new ApplePayError("unknown", void 0, "")]
|
|
185
174
|
});
|
|
186
|
-
return {
|
|
187
|
-
end: true
|
|
188
|
-
};
|
|
175
|
+
return { end: true };
|
|
189
176
|
}
|
|
190
177
|
} else if (status === "SUCCESS") {
|
|
191
178
|
(_d = props.onSuccess) == null ? void 0 : _d.call(props, getPaymentSuccessData());
|
|
192
|
-
applePaySession.completePayment({
|
|
193
|
-
|
|
194
|
-
});
|
|
195
|
-
return {
|
|
196
|
-
end: true
|
|
197
|
-
};
|
|
179
|
+
applePaySession.completePayment({ status: 0 });
|
|
180
|
+
return { end: true };
|
|
198
181
|
} else if (status === "EXPIRED") {
|
|
199
182
|
(_e = props.onExpired) == null ? void 0 : _e.call(props);
|
|
200
183
|
applePaySession.abort();
|
|
201
|
-
return {
|
|
202
|
-
end: true
|
|
203
|
-
};
|
|
184
|
+
return { end: true };
|
|
204
185
|
}
|
|
205
186
|
(_f = props.onSuccess) == null ? void 0 : _f.call(props, getPaymentSuccessData());
|
|
206
|
-
return {
|
|
207
|
-
end: true
|
|
208
|
-
};
|
|
187
|
+
return { end: true };
|
|
209
188
|
} catch (error) {
|
|
210
189
|
if (isTimeoutError(error)) {
|
|
211
190
|
if (search) {
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { w, F, A, h, y, q, u, b } from "../../core.js";
|
|
2
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
3
|
+
import { CoreContext } from "../../core/context.js";
|
|
4
|
+
import "../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { cssVarPrefix, normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
|
+
import { redirectToPayment } from "../../utils/redirect.js";
|
|
8
|
+
import { isTimeoutError } from "../../api/http.js";
|
|
9
|
+
import { PaymentCategory, COMMON_CLASS_NAME, PaymentMethod, SessionMode } from "../../constant.js";
|
|
10
|
+
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
11
|
+
import { getBoostPayInfo, boostPay } from "../../api/modules/boost/index.js";
|
|
12
|
+
import { PayKKaError } from "../../core/error.js";
|
|
13
|
+
import { hidePaymentButton } from "../../config.js";
|
|
14
|
+
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
|
+
import { useRetry } from "../../hooks/useRetry.js";
|
|
16
|
+
import { createEmailCore, EmailField } from "../EmailField/EmailField.js";
|
|
17
|
+
import { createAddressCore } from "../../core/Address.js";
|
|
18
|
+
import { SubmitButton } from "../SubmitButton/index.js";
|
|
19
|
+
import "../internal/Form/type.js";
|
|
20
|
+
import "../internal/Form/context.js";
|
|
21
|
+
import "../internal/Form/FormItem.js";
|
|
22
|
+
import { Form } from "../internal/Form/Form.js";
|
|
23
|
+
import { AddressField } from "../AddressField/index.js";
|
|
24
|
+
import { Info } from "../internal/Info/Info.js";
|
|
25
|
+
import { GuideCard } from "../GuideCard/index.js";
|
|
26
|
+
const { bem } = useBEM("boost");
|
|
27
|
+
const fieldClassNames = bem("field");
|
|
28
|
+
const Boost = w((props, ref) => {
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
|
+
const {
|
|
31
|
+
session,
|
|
32
|
+
showEmail = false,
|
|
33
|
+
showAddress = false,
|
|
34
|
+
redirectMode = "auto",
|
|
35
|
+
core,
|
|
36
|
+
autoQuery = true,
|
|
37
|
+
showGuideCard = true
|
|
38
|
+
} = props;
|
|
39
|
+
F(ref, () => ({
|
|
40
|
+
stopRetry: () => {
|
|
41
|
+
setSubmitButtonStatus("unSubmit");
|
|
42
|
+
stopReFetchPayInfo();
|
|
43
|
+
},
|
|
44
|
+
startRetry: (timeout) => {
|
|
45
|
+
setSubmitButtonStatus("loading");
|
|
46
|
+
startReFetchPayInfo({ timeout });
|
|
47
|
+
},
|
|
48
|
+
updateAddress: () => {
|
|
49
|
+
var _a2;
|
|
50
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
51
|
+
return;
|
|
52
|
+
setForm(Object.assign(form, { address: addressState.getAddressState() }));
|
|
53
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
|
|
54
|
+
},
|
|
55
|
+
updateEmail: () => {
|
|
56
|
+
var _a2;
|
|
57
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
58
|
+
return;
|
|
59
|
+
setForm(Object.assign(form, { email: emailState.email }));
|
|
60
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
61
|
+
},
|
|
62
|
+
payment: () => {
|
|
63
|
+
hidePaymentButton && onSubmit();
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
const addressState = createAddressCore();
|
|
67
|
+
const emailState = createEmailCore();
|
|
68
|
+
const addressFieldRef = A(null);
|
|
69
|
+
const emailFieldRef = A(null);
|
|
70
|
+
const [isCheckoutEnabled, setIsCheckoutEnabled] = h(false);
|
|
71
|
+
const { setErrorMsg, i18n, errorMsg, sessionReady } = usePayState(session);
|
|
72
|
+
const [submitButtonStatus, setSubmitButtonStatus] = h("unSubmit");
|
|
73
|
+
const formRef = A(null);
|
|
74
|
+
const [form, setForm] = h({
|
|
75
|
+
email: "",
|
|
76
|
+
address: {
|
|
77
|
+
country: "",
|
|
78
|
+
province: "",
|
|
79
|
+
city: "",
|
|
80
|
+
area: "",
|
|
81
|
+
postCode: "",
|
|
82
|
+
address1: "",
|
|
83
|
+
address2: ""
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const [validated, setValidated] = h(false);
|
|
87
|
+
const [fieldStatus, setFieldStatus] = h();
|
|
88
|
+
const initFieldStatus = () => {
|
|
89
|
+
const { field, sessionMode } = session.checkout;
|
|
90
|
+
const { email, address } = field;
|
|
91
|
+
if (sessionMode === SessionMode.COMPONENT) {
|
|
92
|
+
if (email.disabled) {
|
|
93
|
+
email.show = showEmail;
|
|
94
|
+
}
|
|
95
|
+
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
96
|
+
address.show = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
setFieldStatus({ ...field });
|
|
100
|
+
};
|
|
101
|
+
y(() => {
|
|
102
|
+
if (!sessionReady) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const { bill = {}, paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
|
|
106
|
+
if (!paymentMethod.includes(PaymentMethod.BOOST)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
initFieldStatus();
|
|
110
|
+
setIsCheckoutEnabled(true);
|
|
111
|
+
form.email = bill.email ?? "";
|
|
112
|
+
if (autoQuery && core.processingPaymentMethod === PaymentMethod.BOOST) {
|
|
113
|
+
setSubmitButtonStatus("loading");
|
|
114
|
+
startReFetchPayInfo();
|
|
115
|
+
}
|
|
116
|
+
}, [sessionReady]);
|
|
117
|
+
const processOnError = (error) => {
|
|
118
|
+
var _a2;
|
|
119
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
120
|
+
core.resetEnablePaymentMethod();
|
|
121
|
+
};
|
|
122
|
+
const onTimeout = q(
|
|
123
|
+
(message) => {
|
|
124
|
+
var _a2;
|
|
125
|
+
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
126
|
+
setSubmitButtonStatus("unSubmit");
|
|
127
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props);
|
|
128
|
+
core.resetEnablePaymentMethod();
|
|
129
|
+
},
|
|
130
|
+
[i18n, props.onTimeout]
|
|
131
|
+
);
|
|
132
|
+
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
133
|
+
(timeout) => pay(true, timeout),
|
|
134
|
+
{ onTimeout: () => onTimeout(i18n.get("common.queryTimeout")) }
|
|
135
|
+
);
|
|
136
|
+
const getPaymentParams = async () => {
|
|
137
|
+
return {
|
|
138
|
+
sessionId: session.sessionId,
|
|
139
|
+
clientKey: session.clientKey,
|
|
140
|
+
payment: {
|
|
141
|
+
paymentMethod: PaymentMethod.BOOST
|
|
142
|
+
},
|
|
143
|
+
bill: {
|
|
144
|
+
email: form.email,
|
|
145
|
+
...form.address,
|
|
146
|
+
province: addressState.getLabel(form.address.province, addressState.getProvinceOption()) ?? form.address.province,
|
|
147
|
+
city: addressState.getLabel(form.address.city, addressState.getCityOptions()) ?? form.address.city
|
|
148
|
+
},
|
|
149
|
+
browser: await getBrowserParams()
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const pay = async (search = false, timeout) => {
|
|
153
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
154
|
+
try {
|
|
155
|
+
const paymentParams = await getPaymentParams();
|
|
156
|
+
const requestOptions = { locale: i18n.locale, timeout };
|
|
157
|
+
const res = search ? await getBoostPayInfo(
|
|
158
|
+
{ sessionId: session.sessionId, clientKey: session.clientKey },
|
|
159
|
+
requestOptions
|
|
160
|
+
) : await boostPay(paymentParams, props.core, requestOptions);
|
|
161
|
+
!search && ((_a2 = props.onSubmitResponse) == null ? void 0 : _a2.call(props, res));
|
|
162
|
+
const { status, orderStatus, errorMessage, errorCode, payInfo } = res;
|
|
163
|
+
if (status === "PROCESSING") {
|
|
164
|
+
if (!orderStatus) {
|
|
165
|
+
setSubmitButtonStatus("unSubmit");
|
|
166
|
+
return { end: true };
|
|
167
|
+
} else if (orderStatus === "SUCCESS") {
|
|
168
|
+
setSubmitButtonStatus("success");
|
|
169
|
+
(_b2 = props.onSuccess) == null ? void 0 : _b2.call(props);
|
|
170
|
+
return { end: true };
|
|
171
|
+
} else if (orderStatus === "FAILURE") {
|
|
172
|
+
setErrorMsg(errorMessage);
|
|
173
|
+
setSubmitButtonStatus("unSubmit");
|
|
174
|
+
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
175
|
+
return { end: true };
|
|
176
|
+
} else if (orderStatus === "PROCESSING") {
|
|
177
|
+
if (!search) {
|
|
178
|
+
if (redirectMode === "auto" && payInfo) {
|
|
179
|
+
redirectToPayment(payInfo);
|
|
180
|
+
return { end: true };
|
|
181
|
+
} else {
|
|
182
|
+
startReFetchPayInfo();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { end: false };
|
|
186
|
+
} else if (orderStatus === "CANCELED") {
|
|
187
|
+
setSubmitButtonStatus("unSubmit");
|
|
188
|
+
(_c2 = props.onTimeout) == null ? void 0 : _c2.call(props);
|
|
189
|
+
core.resetEnablePaymentMethod();
|
|
190
|
+
return { end: true };
|
|
191
|
+
}
|
|
192
|
+
} else if (status === "SUCCESS") {
|
|
193
|
+
setSubmitButtonStatus("success");
|
|
194
|
+
(_d2 = props.onSuccess) == null ? void 0 : _d2.call(props);
|
|
195
|
+
return { end: true };
|
|
196
|
+
} else if (status === "EXPIRED") {
|
|
197
|
+
setSubmitButtonStatus("unSubmit");
|
|
198
|
+
(_e2 = props.onExpired) == null ? void 0 : _e2.call(props);
|
|
199
|
+
return { end: true };
|
|
200
|
+
}
|
|
201
|
+
setSubmitButtonStatus("unSubmit");
|
|
202
|
+
return { end: true };
|
|
203
|
+
} catch (error) {
|
|
204
|
+
if (isTimeoutError(error)) {
|
|
205
|
+
if (search) {
|
|
206
|
+
return { end: false };
|
|
207
|
+
} else {
|
|
208
|
+
onTimeout();
|
|
209
|
+
return { end: true };
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
213
|
+
setErrorMsg(message);
|
|
214
|
+
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
215
|
+
setSubmitButtonStatus("unSubmit");
|
|
216
|
+
return { end: true };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const validateForm = () => {
|
|
221
|
+
var _a2;
|
|
222
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
223
|
+
setValidated(true);
|
|
224
|
+
}).catch(() => {
|
|
225
|
+
setValidated(false);
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
y(() => {
|
|
229
|
+
validateForm();
|
|
230
|
+
}, [form]);
|
|
231
|
+
const onSubmit = async () => {
|
|
232
|
+
var _a2;
|
|
233
|
+
setErrorMsg("");
|
|
234
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
235
|
+
var _a3;
|
|
236
|
+
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressState.setValidateAllFields(true);
|
|
237
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
238
|
+
if (errors) {
|
|
239
|
+
setSubmitButtonStatus("unSubmit");
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
setErrorMsg("");
|
|
243
|
+
setSubmitButtonStatus("loading");
|
|
244
|
+
await pay();
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
const setFormRef = (dom) => {
|
|
248
|
+
formRef.current = dom;
|
|
249
|
+
dom && validateForm();
|
|
250
|
+
};
|
|
251
|
+
const Button = () => {
|
|
252
|
+
var _a2;
|
|
253
|
+
const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
|
|
254
|
+
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
255
|
+
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
256
|
+
return /* @__PURE__ */ u(
|
|
257
|
+
SubmitButton,
|
|
258
|
+
{
|
|
259
|
+
className: bem("button"),
|
|
260
|
+
status: submitButtonStatus,
|
|
261
|
+
text,
|
|
262
|
+
loadingText: i18n.get("common.payProcessing"),
|
|
263
|
+
successText: i18n.get("common.paySuccess"),
|
|
264
|
+
onClick: onSubmit,
|
|
265
|
+
verified: validated
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
const Email = () => {
|
|
270
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
271
|
+
EmailField,
|
|
272
|
+
{
|
|
273
|
+
ref: emailFieldRef,
|
|
274
|
+
value: form.email,
|
|
275
|
+
disabled: fieldStatus == null ? void 0 : fieldStatus.email.disabled
|
|
276
|
+
}
|
|
277
|
+
) }) });
|
|
278
|
+
};
|
|
279
|
+
const formStyle = {
|
|
280
|
+
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
281
|
+
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
282
|
+
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
283
|
+
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
284
|
+
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
285
|
+
};
|
|
286
|
+
const ErrorMessage = () => {
|
|
287
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg, style: { marginTop: "12px" } }) });
|
|
288
|
+
};
|
|
289
|
+
const Address = () => {
|
|
290
|
+
var _a2, _b2;
|
|
291
|
+
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
292
|
+
AddressField,
|
|
293
|
+
{
|
|
294
|
+
ref: addressFieldRef,
|
|
295
|
+
value: form.address,
|
|
296
|
+
country: ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.country) || ((_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.bill.country),
|
|
297
|
+
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
298
|
+
}
|
|
299
|
+
) }) });
|
|
300
|
+
};
|
|
301
|
+
return /* @__PURE__ */ u(
|
|
302
|
+
CoreContext.Provider,
|
|
303
|
+
{
|
|
304
|
+
value: {
|
|
305
|
+
i18n,
|
|
306
|
+
session
|
|
307
|
+
},
|
|
308
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(b, { children: [
|
|
309
|
+
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.BOOST }),
|
|
310
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
311
|
+
Email(),
|
|
312
|
+
Address(),
|
|
313
|
+
ErrorMessage(),
|
|
314
|
+
!hidePaymentButton && Button()
|
|
315
|
+
] }) })
|
|
316
|
+
] })
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
export {
|
|
321
|
+
Boost
|
|
322
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { w, A, h, F, y, q, T, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
3
|
import { PaymentType, SessionMode, CardPaymentMethods, COMMON_CLASS_NAME, PaymentMethod } from "../../constant.js";
|
|
4
|
+
import { intersection } from "../../utils/index.js";
|
|
4
5
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
5
6
|
import { getCardPayInfo, cardPay } from "../../api/modules/card/index.js";
|
|
6
7
|
import { CoreContext } from "../../core/context.js";
|
|
7
|
-
import { intersection } from "../../utils/index.js";
|
|
8
8
|
import { PayKKaError } from "../../core/error.js";
|
|
9
9
|
import { hidePaymentButton } from "../../config.js";
|
|
10
10
|
import { defaultInputStyleConfig } from "../../types/index.js";
|
|
@@ -37,7 +37,6 @@ import { findCardBrand } from "../../utils/card-brand/index.js";
|
|
|
37
37
|
import { separateInputStyle } from "../../utils/style.js";
|
|
38
38
|
import { createPromise } from "../../utils/create-promise.js";
|
|
39
39
|
import { cssVarPrefix, normalizedClass, trimAll, formatAmount } from "../../utils/format.js";
|
|
40
|
-
import { isUndefined } from "../../utils/is.js";
|
|
41
40
|
const { bem } = useBEM("card");
|
|
42
41
|
const fieldClassNames = bem("field");
|
|
43
42
|
const Card = w((props, ref) => {
|
|
@@ -52,10 +51,11 @@ const Card = w((props, ref) => {
|
|
|
52
51
|
threeDSFrame,
|
|
53
52
|
styles,
|
|
54
53
|
enable3DSModal = true,
|
|
55
|
-
isDropIn
|
|
54
|
+
isDropIn,
|
|
55
|
+
core
|
|
56
56
|
} = props;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const addressState = createAddressCore();
|
|
58
|
+
const emailState = createEmailCore();
|
|
59
59
|
const { i18n, fraudDetection, sessionReady } = usePayState(session);
|
|
60
60
|
const addressFieldRef = A(null);
|
|
61
61
|
const emailFieldRef = A(null);
|
|
@@ -103,6 +103,8 @@ const Card = w((props, ref) => {
|
|
|
103
103
|
},
|
|
104
104
|
updateEmail: () => {
|
|
105
105
|
var _a2;
|
|
106
|
+
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
107
|
+
return;
|
|
106
108
|
setForm(Object.assign(form, { email: emailState.email }));
|
|
107
109
|
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
108
110
|
},
|
|
@@ -117,18 +119,19 @@ const Card = w((props, ref) => {
|
|
|
117
119
|
};
|
|
118
120
|
};
|
|
119
121
|
const initFieldStatus = () => {
|
|
120
|
-
const field = session.checkout
|
|
122
|
+
const { field, sessionMode } = session.checkout;
|
|
121
123
|
const { email, address, holderName } = field;
|
|
122
|
-
if (
|
|
123
|
-
email.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
if (sessionMode === SessionMode.COMPONENT) {
|
|
125
|
+
if (email.disabled) {
|
|
126
|
+
email.show = showEmail;
|
|
127
|
+
}
|
|
128
|
+
if (showAddress && !(address == null ? void 0 : address.show)) {
|
|
129
|
+
address.show = true;
|
|
130
|
+
}
|
|
131
|
+
if (showHolderName && !(holderName == null ? void 0 : holderName.show)) {
|
|
132
|
+
holderName.show = true;
|
|
133
|
+
holderName.disabled = true;
|
|
134
|
+
}
|
|
132
135
|
}
|
|
133
136
|
setFieldStatus({ ...field });
|
|
134
137
|
};
|
|
@@ -148,7 +151,7 @@ const Card = w((props, ref) => {
|
|
|
148
151
|
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
149
152
|
(_b2 = (_a2 = props.core.config).onInitError) == null ? void 0 : _b2.call(
|
|
150
153
|
_a2,
|
|
151
|
-
new PayKKaError("ERROR", "Please send the correct
|
|
154
|
+
new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
|
|
152
155
|
);
|
|
153
156
|
return;
|
|
154
157
|
}
|
|
@@ -172,6 +175,7 @@ const Card = w((props, ref) => {
|
|
|
172
175
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
173
176
|
setSubmitButtonStatus("unSubmit");
|
|
174
177
|
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props);
|
|
178
|
+
core.resetEnablePaymentMethod();
|
|
175
179
|
},
|
|
176
180
|
[i18n, props.onTimeout]
|
|
177
181
|
);
|
|
@@ -179,6 +183,11 @@ const Card = w((props, ref) => {
|
|
|
179
183
|
var _a2;
|
|
180
184
|
(_a2 = props.onSuccess) == null ? void 0 : _a2.call(props, getPaymentSuccessData());
|
|
181
185
|
};
|
|
186
|
+
const processOnError = (error) => {
|
|
187
|
+
var _a2;
|
|
188
|
+
(_a2 = props.onError) == null ? void 0 : _a2.call(props, error);
|
|
189
|
+
core.resetEnablePaymentMethod();
|
|
190
|
+
};
|
|
182
191
|
const { start: startReFetchPayInfo } = useRetry((timeout) => pay(true, timeout), {
|
|
183
192
|
onTimeout: () => onTimeout(i18n.get("common.queryTimeout"))
|
|
184
193
|
});
|
|
@@ -277,7 +286,7 @@ const Card = w((props, ref) => {
|
|
|
277
286
|
};
|
|
278
287
|
};
|
|
279
288
|
async function pay(search = false, timeout) {
|
|
280
|
-
var _a2, _b2;
|
|
289
|
+
var _a2, _b2, _c2, _d2;
|
|
281
290
|
try {
|
|
282
291
|
const paymentParams = await getPaymentParams();
|
|
283
292
|
if (!search && security) {
|
|
@@ -285,10 +294,16 @@ const Card = w((props, ref) => {
|
|
|
285
294
|
return { end: true };
|
|
286
295
|
}
|
|
287
296
|
const options = { locale: i18n.locale, timeout };
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
297
|
+
let res = {};
|
|
298
|
+
if (search) {
|
|
299
|
+
res = await getCardPayInfo(
|
|
300
|
+
{ sessionId: session.sessionId, clientKey: session.clientKey },
|
|
301
|
+
options
|
|
302
|
+
);
|
|
303
|
+
} else {
|
|
304
|
+
const extraParams = (_c2 = (_b2 = core.config)._getExtraParams) == null ? void 0 : _c2.call(_b2, "payment", paymentParams.payment.paymentMethod);
|
|
305
|
+
res = await cardPay(paymentParams, extraParams, options);
|
|
306
|
+
}
|
|
292
307
|
return processAfterPayment(res, search);
|
|
293
308
|
} catch (error) {
|
|
294
309
|
if (isTimeoutError(error)) {
|
|
@@ -301,7 +316,7 @@ const Card = w((props, ref) => {
|
|
|
301
316
|
} else {
|
|
302
317
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
303
318
|
setErrorMsg(message);
|
|
304
|
-
(
|
|
319
|
+
(_d2 = props.onError) == null ? void 0 : _d2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
305
320
|
setSubmitButtonStatus("unSubmit");
|
|
306
321
|
stopReFetchCardPay3DSInfo();
|
|
307
322
|
return { end: true };
|
|
@@ -330,7 +345,7 @@ const Card = w((props, ref) => {
|
|
|
330
345
|
checkThreeDS();
|
|
331
346
|
};
|
|
332
347
|
const processAfterPayment = (res, search = false) => {
|
|
333
|
-
var _a2, _b2
|
|
348
|
+
var _a2, _b2;
|
|
334
349
|
const { status, orderStatus, errorMessage, errorCode, threeDSUrl } = res;
|
|
335
350
|
if (status === "PROCESSING") {
|
|
336
351
|
if (!orderStatus) {
|
|
@@ -344,10 +359,10 @@ const Card = w((props, ref) => {
|
|
|
344
359
|
} else if (orderStatus === "FAILURE") {
|
|
345
360
|
setErrorMsg(errorMessage);
|
|
346
361
|
setSubmitButtonStatus("unSubmit");
|
|
347
|
-
(
|
|
362
|
+
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
348
363
|
} else if (orderStatus === "AUTHORIZED") {
|
|
349
364
|
setSubmitButtonStatus("unSubmit");
|
|
350
|
-
(
|
|
365
|
+
(_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
|
|
351
366
|
} else if (orderStatus === "IN_THREED") {
|
|
352
367
|
processThreeDS(threeDSUrl, false);
|
|
353
368
|
} else if (orderStatus === "IN_PREVIOUS_THREED") {
|
|
@@ -360,19 +375,17 @@ const Card = w((props, ref) => {
|
|
|
360
375
|
return { end: true };
|
|
361
376
|
} else if (status === "EXPIRED") {
|
|
362
377
|
setSubmitButtonStatus("unSubmit");
|
|
363
|
-
(
|
|
378
|
+
(_b2 = props.onExpired) == null ? void 0 : _b2.call(props);
|
|
364
379
|
return { end: true };
|
|
365
380
|
}
|
|
366
381
|
setSubmitButtonStatus("unSubmit");
|
|
367
|
-
processOnSuccess();
|
|
368
382
|
return { end: true };
|
|
369
383
|
};
|
|
370
384
|
const processPaymentError = (error) => {
|
|
371
|
-
var _a2;
|
|
372
385
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
373
386
|
setErrorMsg(message);
|
|
374
387
|
setSubmitButtonStatus("unSubmit");
|
|
375
|
-
(
|
|
388
|
+
processOnError(new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
376
389
|
};
|
|
377
390
|
const validateForm = () => {
|
|
378
391
|
var _a2;
|
|
@@ -386,12 +399,10 @@ const Card = w((props, ref) => {
|
|
|
386
399
|
validateForm();
|
|
387
400
|
}, [form]);
|
|
388
401
|
const Button = () => {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
amountStr = formatAmount(+amount, digits);
|
|
394
|
-
const text = i18n.get("common.pay") + (Number(amount) ? ` ${symbol}${amountStr}` : "");
|
|
402
|
+
var _a2;
|
|
403
|
+
const transAmount = (_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.transAmount;
|
|
404
|
+
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
405
|
+
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
395
406
|
return /* @__PURE__ */ u(
|
|
396
407
|
SubmitButton,
|
|
397
408
|
{
|
|
@@ -420,7 +431,7 @@ const Card = w((props, ref) => {
|
|
|
420
431
|
}
|
|
421
432
|
);
|
|
422
433
|
async function checkThreeDS(search = false, timeout = 2e4) {
|
|
423
|
-
var _a2, _b2, _c2
|
|
434
|
+
var _a2, _b2, _c2;
|
|
424
435
|
if (!session)
|
|
425
436
|
return { end: true };
|
|
426
437
|
try {
|
|
@@ -441,10 +452,10 @@ const Card = w((props, ref) => {
|
|
|
441
452
|
} else if (orderStatus === "FAILURE") {
|
|
442
453
|
setErrorMsg(errorMessage);
|
|
443
454
|
setSubmitButtonStatus("unSubmit");
|
|
444
|
-
(
|
|
455
|
+
processOnError(new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
445
456
|
} else if (orderStatus === "AUTHORIZED") {
|
|
446
457
|
setSubmitButtonStatus("unSubmit");
|
|
447
|
-
(
|
|
458
|
+
(_a2 = props.onAuthorized) == null ? void 0 : _a2.call(props);
|
|
448
459
|
} else if (orderStatus === "IN_THREED") {
|
|
449
460
|
setSubmitButtonStatus("loading");
|
|
450
461
|
!search && startReFetchCardPay3DSInfo();
|
|
@@ -464,7 +475,7 @@ const Card = w((props, ref) => {
|
|
|
464
475
|
return { end: true };
|
|
465
476
|
} else if (status === "EXPIRED") {
|
|
466
477
|
setSubmitButtonStatus("unSubmit");
|
|
467
|
-
(
|
|
478
|
+
(_b2 = props.onExpired) == null ? void 0 : _b2.call(props);
|
|
468
479
|
stopReFetchCardPay3DSInfo();
|
|
469
480
|
return { end: true };
|
|
470
481
|
}
|
|
@@ -483,7 +494,7 @@ const Card = w((props, ref) => {
|
|
|
483
494
|
} else {
|
|
484
495
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
485
496
|
setErrorMsg(message);
|
|
486
|
-
(
|
|
497
|
+
(_c2 = props.onError) == null ? void 0 : _c2.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
487
498
|
setSubmitButtonStatus("unSubmit");
|
|
488
499
|
stopReFetchCardPay3DSInfo();
|
|
489
500
|
return { end: true };
|
|
@@ -33,8 +33,8 @@ function CardBrands(props) {
|
|
|
33
33
|
};
|
|
34
34
|
}, []);
|
|
35
35
|
return /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem(), className), style, children: [
|
|
36
|
-
brands.slice(0, max - 1).map((brand) => /* @__PURE__ */ u(brand.icon, { size: 32 }, brand.code)),
|
|
37
|
-
!!lastBrand && /* @__PURE__ */ u(lastBrand.icon, { size: 32 }, lastBrand.code),
|
|
36
|
+
brands.slice(0, max - 1).map((brand) => brand.icon && /* @__PURE__ */ u(brand.icon, { size: 32 }, brand.code)),
|
|
37
|
+
!!(lastBrand == null ? void 0 : lastBrand.icon) && /* @__PURE__ */ u(lastBrand.icon, { size: 32 }, lastBrand.code),
|
|
38
38
|
left > 0 && /* @__PURE__ */ u("div", { className: bem("more"), children: [
|
|
39
39
|
"+",
|
|
40
40
|
left
|