@paykka/card-checkout-ui 0.7.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 +27 -20
- package/dist/card-checkout-ui.umd.cjs +27 -20
- 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 +29 -1
- 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 +58 -60
- package/dist/es/components/ApplePay/index.js +29 -43
- package/dist/es/components/Boost/index.js +322 -0
- package/dist/es/components/Card/index.js +89 -75
- 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 +365 -0
- package/dist/es/components/GooglePay/index.js +15 -7
- 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 +8 -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 +51 -61
- 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 +10 -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 +3 -0
- 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 +94 -4
- package/dist/es/core/PayKKaCheckout.js +38 -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 +3 -4
- package/dist/es/i18n/I18n.js +8 -2
- package/dist/es/i18n/locales/de-DE.js +19 -1
- package/dist/es/i18n/locales/en-GB.js +19 -1
- package/dist/es/i18n/locales/es-ES.js +19 -1
- package/dist/es/i18n/locales/fr-FR.js +19 -1
- package/dist/es/i18n/locales/ja-JP.js +19 -1
- package/dist/es/i18n/locales/ko-KR.js +19 -1
- package/dist/es/i18n/locales/pt-PT.js +19 -1
- package/dist/es/i18n/locales/ru-RU.js +19 -1
- package/dist/es/i18n/locales/zh-CN.js +19 -1
- package/dist/es/i18n/locales/zh-HK.js +19 -1
- package/dist/es/i18n/locales/zh-TW.js +19 -1
- package/dist/es/i18n/util.js +20 -0
- package/dist/es/index.js +24 -0
- package/dist/es/style.css +1 -1096
- 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/map.d.ts +2 -1
- package/dist/types/api/modules/checkout/type.d.ts +20 -2
- 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/AliPay/AliPay.d.ts +2 -1
- package/dist/types/components/AliPay/type.d.ts +1 -2
- package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
- package/dist/types/components/ApplePay/type.d.ts +9 -6
- 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/Card/Card.d.ts +2 -1
- package/dist/types/components/Card/type.d.ts +2 -2
- package/dist/types/components/DropIn/DropIn.d.ts +6 -0
- package/dist/types/components/DropIn/components/PaymentTabs/PaymentTabs.d.ts +3 -0
- package/dist/types/components/DropIn/components/PaymentTabs/index.d.ts +2 -0
- package/dist/types/components/DropIn/components/PaymentTabs/type.d.ts +11 -0
- package/dist/types/components/DropIn/config.d.ts +7 -0
- package/dist/types/components/DropIn/index.d.ts +2 -0
- package/dist/types/components/DropIn/type.d.ts +57 -0
- package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +20 -9
- 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/Sepa/Sepa.d.ts +2 -1
- package/dist/types/components/Sepa/type.d.ts +1 -2
- 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/WechatPay/WechatPay.d.ts +2 -1
- package/dist/types/components/WechatPay/type.d.ts +1 -2
- 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 +10 -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/index.d.ts +2 -0
- package/dist/types/components/internal/Modal/type.d.ts +3 -1
- 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/IconCard.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 +14 -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 +38 -2
- package/dist/types/core/PayKKaCheckout.d.ts +11 -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 +15 -0
- package/dist/types/i18n/locales/en-GB.d.ts +15 -0
- package/dist/types/i18n/locales/es-ES.d.ts +15 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +15 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +15 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +15 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +15 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +15 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +15 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +15 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +15 -0
- package/dist/types/i18n/util.d.ts +10 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +34 -7
- 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 +65 -63
|
@@ -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
|
|
@@ -11,118 +11,125 @@ import "../internal/Input/type.js";
|
|
|
11
11
|
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
12
12
|
import { getSupportedCardBrands, getSupportedCardBrandsLengths, finCardBrandInfoByCode, findCardBrandInfo } from "../../utils/card-brand/index.js";
|
|
13
13
|
import { trimAll, limitedToNumber } from "../../utils/format.js";
|
|
14
|
-
const CardNumberField = w(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}));
|
|
45
|
-
const { i18n } = useI18n();
|
|
46
|
-
const [value, setValue] = h("");
|
|
47
|
-
const [validationStatus, setValidationStatus] = h("");
|
|
48
|
-
const brands = getSupportedCardBrands(supportedCardBrands);
|
|
49
|
-
const brandLengths = getSupportedCardBrandsLengths(brands);
|
|
50
|
-
const [brandIcon, setBrandIcon] = h(void 0);
|
|
51
|
-
y(() => {
|
|
52
|
-
setBrandIcon(value ? () => {
|
|
53
|
-
var _a;
|
|
54
|
-
return (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
|
|
55
|
-
} : void 0);
|
|
56
|
-
}, [value]);
|
|
57
|
-
const rule = {
|
|
58
|
-
trigger: ["blur", "submit"],
|
|
59
|
-
validator(value2) {
|
|
60
|
-
if (security) {
|
|
61
|
-
const result = formItemRef.current.getValidateResult();
|
|
62
|
-
if (result.status === "error") {
|
|
63
|
-
throw new Error(result.errors[0].message);
|
|
64
|
-
} else if (result.status === "success") {
|
|
65
|
-
return true;
|
|
14
|
+
const CardNumberField = w(
|
|
15
|
+
(props, ref) => {
|
|
16
|
+
const { supportedCardBrands = [], className, security, showLabel } = props;
|
|
17
|
+
const inputRef = A(null);
|
|
18
|
+
const formItemRef = A(null);
|
|
19
|
+
F(ref, () => ({
|
|
20
|
+
input: inputRef.current,
|
|
21
|
+
focus: () => {
|
|
22
|
+
var _a;
|
|
23
|
+
(_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
24
|
+
},
|
|
25
|
+
blur: () => {
|
|
26
|
+
var _a;
|
|
27
|
+
(_a = inputRef.current) == null ? void 0 : _a.blur();
|
|
28
|
+
},
|
|
29
|
+
resetValidation: (status, errorTip) => {
|
|
30
|
+
var _a;
|
|
31
|
+
(_a = formItemRef.current) == null ? void 0 : _a.resetValidation(status, [{ message: errorTip }]);
|
|
32
|
+
},
|
|
33
|
+
binValueChanged: (binValue) => {
|
|
34
|
+
setValue(binValue);
|
|
35
|
+
},
|
|
36
|
+
brandChanged: (brand2) => {
|
|
37
|
+
if (brand2) {
|
|
38
|
+
const brandInfo = finCardBrandInfoByCode(brand2);
|
|
39
|
+
setBrandIcon(() => brandInfo == null ? void 0 : brandInfo.icon);
|
|
40
|
+
setBrand(brandInfo == null ? void 0 : brandInfo.code);
|
|
41
|
+
} else {
|
|
42
|
+
setBrandIcon(void 0);
|
|
43
|
+
setBrand(void 0);
|
|
66
44
|
}
|
|
45
|
+
},
|
|
46
|
+
getCardBrand: () => {
|
|
47
|
+
return findCardBrandInfo(trimAll(value), brands) || { code: brand };
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
49
|
+
}));
|
|
50
|
+
const { i18n } = useI18n();
|
|
51
|
+
const [value, setValue] = h("");
|
|
52
|
+
const [validationStatus, setValidationStatus] = h("");
|
|
53
|
+
const brands = getSupportedCardBrands(supportedCardBrands);
|
|
54
|
+
const brandLengths = getSupportedCardBrandsLengths(brands);
|
|
55
|
+
const [brandIcon, setBrandIcon] = h(void 0);
|
|
56
|
+
const [brand, setBrand] = h(void 0);
|
|
57
|
+
y(() => {
|
|
58
|
+
setBrandIcon(value ? () => {
|
|
59
|
+
var _a;
|
|
60
|
+
return (_a = findCardBrandInfo(trimAll(value), brands)) == null ? void 0 : _a.icon;
|
|
61
|
+
} : void 0);
|
|
62
|
+
}, [value]);
|
|
63
|
+
const rule = {
|
|
64
|
+
trigger: ["blur", "submit"],
|
|
65
|
+
validator(value2) {
|
|
66
|
+
if (security) {
|
|
67
|
+
const result = formItemRef.current.getValidateResult();
|
|
68
|
+
if (result.status === "error") {
|
|
69
|
+
throw new Error(result.errors[0].message);
|
|
70
|
+
} else if (result.status === "success") {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
value2 = trimAll(value2 ?? "");
|
|
75
|
+
if (!brandLengths.includes(value2.length)) {
|
|
76
|
+
throw new Error(i18n.get("card.cardNumber.incomplete"));
|
|
77
|
+
}
|
|
78
|
+
const cardBrand = findCardBrandInfo(value2, brands);
|
|
79
|
+
if (!cardBrand) {
|
|
80
|
+
throw new Error(i18n.get("card.cardNumber.invalid"));
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
71
83
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
};
|
|
85
|
+
function onInput(event) {
|
|
86
|
+
var _a;
|
|
87
|
+
const { currentTarget, inputType } = event;
|
|
88
|
+
const selectionStart = currentTarget.selectionStart;
|
|
89
|
+
let val = limitedToNumber(currentTarget.value);
|
|
90
|
+
val = val.replace(/(\d{4})(?=\d)/g, "$1 ");
|
|
91
|
+
let pos = selectionStart;
|
|
92
|
+
if (pos % 5 === 0) {
|
|
93
|
+
pos = clamp(selectionStart + (inputType === "insertText" ? 1 : -1), 0);
|
|
75
94
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function onInput(event) {
|
|
80
|
-
var _a;
|
|
81
|
-
const { currentTarget, inputType } = event;
|
|
82
|
-
const selectionStart = currentTarget.selectionStart;
|
|
83
|
-
let val = limitedToNumber(currentTarget.value);
|
|
84
|
-
val = val.replace(/(\d{4})(?=\d)/g, "$1 ");
|
|
85
|
-
let pos = selectionStart;
|
|
86
|
-
if (pos % 5 === 0) {
|
|
87
|
-
pos = clamp(selectionStart + (inputType === "insertText" ? 1 : -1), 0);
|
|
95
|
+
setValue(currentTarget.value = val);
|
|
96
|
+
currentTarget.setSelectionRange(pos, pos);
|
|
97
|
+
(_a = props.onInput) == null ? void 0 : _a.call(props, event);
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
const RightIcon = () => {
|
|
100
|
+
if (validationStatus !== "error") {
|
|
101
|
+
const Icon = brandIcon ?? IconCardNo;
|
|
102
|
+
return /* @__PURE__ */ u(Icon, { size: 32 });
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return /* @__PURE__ */ u(
|
|
106
|
+
FormItem,
|
|
107
|
+
{
|
|
108
|
+
label: i18n.get("card.cardNumber.label"),
|
|
109
|
+
showLabel,
|
|
110
|
+
path: "number",
|
|
111
|
+
ref: formItemRef,
|
|
112
|
+
rule,
|
|
113
|
+
onValidationStatusChange: setValidationStatus,
|
|
114
|
+
className,
|
|
115
|
+
children: /* @__PURE__ */ u(
|
|
116
|
+
Input,
|
|
117
|
+
{
|
|
118
|
+
type: "text",
|
|
119
|
+
inputmode: "numeric",
|
|
120
|
+
ref: inputRef,
|
|
121
|
+
maxLength: 23,
|
|
122
|
+
value,
|
|
123
|
+
onInput,
|
|
124
|
+
rightIcon: RightIcon(),
|
|
125
|
+
placeholder: i18n.get("card.cardNumber.placeholder"),
|
|
126
|
+
children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CARD_NUMBER })
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
);
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
if (validationStatus !== "error") {
|
|
95
|
-
const Icon = brandIcon ?? IconCardNo;
|
|
96
|
-
return /* @__PURE__ */ u(Icon, { size: 32 });
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return /* @__PURE__ */ u(
|
|
100
|
-
FormItem,
|
|
101
|
-
{
|
|
102
|
-
label: i18n.get("card.cardNumber.label"),
|
|
103
|
-
showLabel,
|
|
104
|
-
path: "number",
|
|
105
|
-
ref: formItemRef,
|
|
106
|
-
rule,
|
|
107
|
-
onValidationStatusChange: setValidationStatus,
|
|
108
|
-
className,
|
|
109
|
-
children: /* @__PURE__ */ u(
|
|
110
|
-
Input,
|
|
111
|
-
{
|
|
112
|
-
type: "text",
|
|
113
|
-
inputmode: "numeric",
|
|
114
|
-
ref: inputRef,
|
|
115
|
-
maxLength: 23,
|
|
116
|
-
value,
|
|
117
|
-
onInput,
|
|
118
|
-
rightIcon: RightIcon(),
|
|
119
|
-
placeholder: i18n.get("card.cardNumber.placeholder"),
|
|
120
|
-
children: security && /* @__PURE__ */ u("div", { style: "width:100%;height:100%", "data-sf": EFieldType.CARD_NUMBER })
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
});
|
|
132
|
+
);
|
|
126
133
|
export {
|
|
127
134
|
CardNumberField
|
|
128
135
|
};
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { u, w, h, A, F, y, b } from "../../core.js";
|
|
2
|
+
import "../../utils/card-brand/brands.js";
|
|
3
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
+
import { CoreContext } from "../../core/context.js";
|
|
5
|
+
import { CardPaymentMethods, PaymentMethod, PaymentCategory, SessionMode, PaymentMethod2CategoryMap } from "../../constant.js";
|
|
6
|
+
import { Card } from "../Card/index.js";
|
|
7
|
+
import { ApplePay } from "../ApplePay/index.js";
|
|
8
|
+
import { GooglePay } from "../GooglePay/index.js";
|
|
9
|
+
import { Boost } from "../Boost/index.js";
|
|
10
|
+
import { NinePay } from "../NinePay/index.js";
|
|
11
|
+
import { LinePay } from "../LinePay/index.js";
|
|
12
|
+
import { TNGWallet } from "../TNGWallet/index.js";
|
|
13
|
+
import { MayBankQRPay } from "../MayBankQRPay/index.js";
|
|
14
|
+
import { ShopeePay } from "../ShopeePay/index.js";
|
|
15
|
+
import { GrabPay } from "../GrabPay/index.js";
|
|
16
|
+
import { GCash } from "../wallets/GCash/GCash.js";
|
|
17
|
+
import { Paymaya } from "../wallets/Paymaya/Paymaya.js";
|
|
18
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
19
|
+
import { intersection } from "../../utils/index.js";
|
|
20
|
+
import { PayKKaError } from "../../core/error.js";
|
|
21
|
+
import { usePayState } from "../../hooks/usePayState.js";
|
|
22
|
+
import { Accordion } from "../internal/Accordion/Accordion.js";
|
|
23
|
+
import { AccordionItem } from "../AccordionItem/AccordionItem.js";
|
|
24
|
+
import { IconLinePay } from "../internal/icons/IconLinePay.js";
|
|
25
|
+
import { IconBoost } from "../internal/icons/IconBoost.js";
|
|
26
|
+
import { IconGrabPay } from "../internal/icons/IconGrabPay.js";
|
|
27
|
+
import { IconNinePay } from "../internal/icons/IconNinePay.js";
|
|
28
|
+
import { IconMayBankQRPay } from "../internal/icons/IconMayBankQRPay.js";
|
|
29
|
+
import { IconShopeePay } from "../internal/icons/IconShopeePay.js";
|
|
30
|
+
import { IconTNGWallet } from "../internal/icons/IconTNGWallet.js";
|
|
31
|
+
import { IconCard2 } from "../internal/icons/IconCard2.js";
|
|
32
|
+
import { IconGCash } from "../internal/icons/IconGCash.js";
|
|
33
|
+
import { IconPaymaya } from "../internal/icons/IconPaymaya.js";
|
|
34
|
+
import { removeElementFromArray } from "../../utils/array.js";
|
|
35
|
+
const dropInSupportedPaymentMethods = [
|
|
36
|
+
...CardPaymentMethods,
|
|
37
|
+
PaymentMethod.GOOGLE_PAY,
|
|
38
|
+
PaymentMethod.APPLE_PAY,
|
|
39
|
+
PaymentMethod.BOOST,
|
|
40
|
+
PaymentMethod.GRAB_PAY,
|
|
41
|
+
PaymentMethod.LINE_PAY,
|
|
42
|
+
PaymentMethod.NINE_PAY,
|
|
43
|
+
PaymentMethod.SHOPEE_PAY,
|
|
44
|
+
PaymentMethod.TNG_WALLET,
|
|
45
|
+
PaymentMethod.MAY_BANK_QR_PAY,
|
|
46
|
+
PaymentMethod.GCASH,
|
|
47
|
+
PaymentMethod.PAYMAYA
|
|
48
|
+
];
|
|
49
|
+
const PaymentComponentMap = {
|
|
50
|
+
[PaymentCategory.CARD]: Card,
|
|
51
|
+
[PaymentCategory.APPLE_PAY]: ApplePay,
|
|
52
|
+
[PaymentCategory.GOOGLE_PAY]: GooglePay,
|
|
53
|
+
[PaymentCategory.BOOST]: Boost,
|
|
54
|
+
[PaymentCategory.NINE_PAY]: NinePay,
|
|
55
|
+
[PaymentCategory.LINE_PAY]: LinePay,
|
|
56
|
+
[PaymentCategory.TNG_WALLET]: TNGWallet,
|
|
57
|
+
[PaymentCategory.MAY_BANK_QR_PAY]: MayBankQRPay,
|
|
58
|
+
[PaymentCategory.SHOPEE_PAY]: ShopeePay,
|
|
59
|
+
[PaymentCategory.GRAB_PAY]: GrabPay,
|
|
60
|
+
[PaymentCategory.GCASH]: GCash,
|
|
61
|
+
[PaymentCategory.PAYMAYA]: Paymaya
|
|
62
|
+
// [PaymentCategory.WECHAT_PAY]: WechatPay,
|
|
63
|
+
// [PaymentCategory.ALI_PAY]: AliPay,
|
|
64
|
+
// [PaymentCategory.SEPA_DEBIT]: Sepa
|
|
65
|
+
};
|
|
66
|
+
const { bem: bem$1 } = useBEM("payment-tabs");
|
|
67
|
+
const PaymentTabs = (props) => {
|
|
68
|
+
const { value, tabs, themeColor = "#4F43DF" } = props;
|
|
69
|
+
const handleClickTab = (tab) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (tab.type === value) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, tab.type);
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ u("div", { className: bem$1(), children: tabs.map((tab) => /* @__PURE__ */ u(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: bem$1("tab"),
|
|
80
|
+
style: tab.type === value ? { borderColor: themeColor } : "",
|
|
81
|
+
onClick: () => handleClickTab(tab),
|
|
82
|
+
children: [
|
|
83
|
+
tab.icon,
|
|
84
|
+
/* @__PURE__ */ u(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
className: bem$1("name"),
|
|
88
|
+
style: tab.type === value ? { color: themeColor } : "",
|
|
89
|
+
children: tab.name
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
)) });
|
|
95
|
+
};
|
|
96
|
+
const paymentCategoryOptionMap = {
|
|
97
|
+
[PaymentCategory.CARD]: {
|
|
98
|
+
icon: IconCard2,
|
|
99
|
+
nameKey: "dropIn.card.label"
|
|
100
|
+
},
|
|
101
|
+
[PaymentCategory.LINE_PAY]: {
|
|
102
|
+
icon: IconLinePay,
|
|
103
|
+
nameKey: "dropIn.linePay.label"
|
|
104
|
+
},
|
|
105
|
+
[PaymentCategory.BOOST]: {
|
|
106
|
+
icon: IconBoost,
|
|
107
|
+
nameKey: "dropIn.boost.label"
|
|
108
|
+
},
|
|
109
|
+
[PaymentCategory.GRAB_PAY]: {
|
|
110
|
+
icon: IconGrabPay,
|
|
111
|
+
nameKey: "dropIn.grabPay.label"
|
|
112
|
+
},
|
|
113
|
+
[PaymentCategory.NINE_PAY]: {
|
|
114
|
+
icon: IconNinePay,
|
|
115
|
+
nameKey: "dropIn.ninePay.label"
|
|
116
|
+
},
|
|
117
|
+
[PaymentCategory.MAY_BANK_QR_PAY]: {
|
|
118
|
+
icon: IconMayBankQRPay,
|
|
119
|
+
nameKey: "dropIn.mayBankQRPay.label"
|
|
120
|
+
},
|
|
121
|
+
[PaymentCategory.SHOPEE_PAY]: {
|
|
122
|
+
icon: IconShopeePay,
|
|
123
|
+
nameKey: "dropIn.shopeePay.label"
|
|
124
|
+
},
|
|
125
|
+
[PaymentCategory.TNG_WALLET]: {
|
|
126
|
+
icon: IconTNGWallet,
|
|
127
|
+
nameKey: "dropIn.TNGWallet.label"
|
|
128
|
+
},
|
|
129
|
+
[PaymentCategory.GCASH]: {
|
|
130
|
+
icon: IconGCash,
|
|
131
|
+
nameKey: "dropIn.gcash.label"
|
|
132
|
+
},
|
|
133
|
+
[PaymentCategory.PAYMAYA]: {
|
|
134
|
+
icon: IconPaymaya,
|
|
135
|
+
nameKey: "dropIn.paymaya.label"
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const { bem } = useBEM("drop-in");
|
|
139
|
+
const DropIn = w((props, ref) => {
|
|
140
|
+
const {
|
|
141
|
+
paymentMethods: paymentMethodsConfig,
|
|
142
|
+
layout = "accordion",
|
|
143
|
+
session,
|
|
144
|
+
core,
|
|
145
|
+
enableAccordionTransition = true
|
|
146
|
+
} = props;
|
|
147
|
+
const { i18n, sessionReady } = usePayState(session);
|
|
148
|
+
const [paymentCategoryOptions, setPaymentCategoryOptions] = h([]);
|
|
149
|
+
const [activePaymentCategory, setActivePaymentCategory] = h();
|
|
150
|
+
const [enablePaymentMethod, setEnablePaymentMethod] = h();
|
|
151
|
+
const [headerPaymentCategories, setHeaderPaymentCategories] = h(
|
|
152
|
+
[]
|
|
153
|
+
);
|
|
154
|
+
const [paymentCategories, setPaymentCategories] = h([]);
|
|
155
|
+
const componentMountRefMap = A({});
|
|
156
|
+
const componentInstMap = A({});
|
|
157
|
+
F(ref, () => ({
|
|
158
|
+
payment: () => {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
if (activePaymentCategory) {
|
|
161
|
+
const instRef = (_a = componentInstMap.current[activePaymentCategory]) == null ? void 0 : _a.ref;
|
|
162
|
+
(_b = instRef == null ? void 0 : instRef.payment) == null ? void 0 : _b.call(instRef);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}));
|
|
166
|
+
y(() => {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
if (!activePaymentCategory) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const currCompInst = componentInstMap.current[activePaymentCategory];
|
|
172
|
+
if (currCompInst) {
|
|
173
|
+
const ref2 = currCompInst.ref;
|
|
174
|
+
(_a = ref2.updateAddress) == null ? void 0 : _a.call(ref2);
|
|
175
|
+
(_b = ref2.updateEmail) == null ? void 0 : _b.call(ref2);
|
|
176
|
+
}
|
|
177
|
+
}, [activePaymentCategory]);
|
|
178
|
+
y(() => {
|
|
179
|
+
if (paymentCategories == null ? void 0 : paymentCategories.length) {
|
|
180
|
+
paymentCategories.forEach((category) => {
|
|
181
|
+
renderComponent(category);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}, [paymentCategories]);
|
|
185
|
+
y(() => {
|
|
186
|
+
if (headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) {
|
|
187
|
+
renderComponent(PaymentCategory.APPLE_PAY);
|
|
188
|
+
renderComponent(PaymentCategory.GOOGLE_PAY);
|
|
189
|
+
}
|
|
190
|
+
}, [headerPaymentCategories]);
|
|
191
|
+
const createComponent = (category) => {
|
|
192
|
+
const { onError, onSuccess, onTimeout, onExpired, onSubmit } = props;
|
|
193
|
+
return props.core.create(PaymentComponentMap[category], {
|
|
194
|
+
onError,
|
|
195
|
+
onSuccess,
|
|
196
|
+
onTimeout,
|
|
197
|
+
onExpired,
|
|
198
|
+
onSubmit,
|
|
199
|
+
...paymentMethodsConfig == null ? void 0 : paymentMethodsConfig[category],
|
|
200
|
+
isDropIn: true
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
const renderComponent = (category) => {
|
|
204
|
+
const inst = createComponent(category);
|
|
205
|
+
const container = componentMountRefMap.current[category];
|
|
206
|
+
if (container) {
|
|
207
|
+
inst.mount(container);
|
|
208
|
+
componentInstMap.current[category] = inst;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const initPaymentCategories = (enablePaymentMethods) => {
|
|
212
|
+
const cpyEnablePaymentMethods = [...enablePaymentMethods];
|
|
213
|
+
const paymentCategoryOptions2 = [];
|
|
214
|
+
const paymentCategories2 = [];
|
|
215
|
+
const headerPaymentCategories2 = [];
|
|
216
|
+
if (cpyEnablePaymentMethods.includes(PaymentMethod.APPLE_PAY)) {
|
|
217
|
+
headerPaymentCategories2.push(PaymentCategory.APPLE_PAY);
|
|
218
|
+
removeElementFromArray(cpyEnablePaymentMethods, PaymentMethod.APPLE_PAY);
|
|
219
|
+
}
|
|
220
|
+
if (cpyEnablePaymentMethods.includes(PaymentMethod.GOOGLE_PAY)) {
|
|
221
|
+
headerPaymentCategories2.push(PaymentCategory.GOOGLE_PAY);
|
|
222
|
+
removeElementFromArray(cpyEnablePaymentMethods, PaymentMethod.GOOGLE_PAY);
|
|
223
|
+
}
|
|
224
|
+
const isCardEnable = !!intersection(cpyEnablePaymentMethods, CardPaymentMethods).length;
|
|
225
|
+
if (isCardEnable) {
|
|
226
|
+
paymentCategories2.push(PaymentCategory.CARD);
|
|
227
|
+
paymentCategoryOptions2.push({
|
|
228
|
+
type: PaymentCategory.CARD,
|
|
229
|
+
icon: () => {
|
|
230
|
+
const Icon = paymentCategoryOptionMap[PaymentCategory.CARD].icon;
|
|
231
|
+
return Icon ? /* @__PURE__ */ u(Icon, { size: 24 }) : null;
|
|
232
|
+
},
|
|
233
|
+
name: i18n.get(paymentCategoryOptionMap[PaymentCategory.CARD].nameKey)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
cpyEnablePaymentMethods.forEach((method) => {
|
|
237
|
+
if (cpyEnablePaymentMethods.includes(method)) {
|
|
238
|
+
const type = PaymentMethod2CategoryMap[method];
|
|
239
|
+
if (type) {
|
|
240
|
+
paymentCategories2.push(type);
|
|
241
|
+
paymentCategoryOptions2.push({
|
|
242
|
+
type,
|
|
243
|
+
icon: () => {
|
|
244
|
+
const Icon = paymentCategoryOptionMap[type].icon;
|
|
245
|
+
return Icon ? /* @__PURE__ */ u(Icon, { size: 24 }) : null;
|
|
246
|
+
},
|
|
247
|
+
name: i18n.get(paymentCategoryOptionMap[type].nameKey)
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
if (paymentCategoryOptions2.length) {
|
|
253
|
+
setPaymentCategoryOptions(paymentCategoryOptions2);
|
|
254
|
+
setActivePaymentCategory(paymentCategoryOptions2[0].type);
|
|
255
|
+
}
|
|
256
|
+
setHeaderPaymentCategories(headerPaymentCategories2);
|
|
257
|
+
setPaymentCategories(paymentCategories2);
|
|
258
|
+
};
|
|
259
|
+
const handlePaymentCategoryChange = (newPaymentCategory) => {
|
|
260
|
+
setActivePaymentCategory(newPaymentCategory);
|
|
261
|
+
};
|
|
262
|
+
y(() => {
|
|
263
|
+
var _a, _b, _c;
|
|
264
|
+
if (!sessionReady || !i18n.ready.value) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (((_a = session.checkout) == null ? void 0 : _a.sessionMode) === SessionMode.COMPONENT) {
|
|
268
|
+
(_c = (_b = props.core.config).onInitError) == null ? void 0 : _c.call(
|
|
269
|
+
_b,
|
|
270
|
+
new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
|
|
271
|
+
);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const { paymentMethod = [] } = (session == null ? void 0 : session.checkout) || {};
|
|
275
|
+
const enablePaymentMethods = intersection(
|
|
276
|
+
paymentMethod,
|
|
277
|
+
dropInSupportedPaymentMethods
|
|
278
|
+
);
|
|
279
|
+
if (!enablePaymentMethods.length) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
initPaymentCategories(enablePaymentMethods);
|
|
283
|
+
if (core.processingPaymentMethod) {
|
|
284
|
+
const category = PaymentMethod2CategoryMap[core.processingPaymentMethod];
|
|
285
|
+
category && setActivePaymentCategory(category);
|
|
286
|
+
core.enablePaymentMethod.value = core.processingPaymentMethod;
|
|
287
|
+
}
|
|
288
|
+
}, [sessionReady, i18n.ready.value]);
|
|
289
|
+
y(() => {
|
|
290
|
+
if (core.enablePaymentMethod.value) {
|
|
291
|
+
setEnablePaymentMethod(
|
|
292
|
+
PaymentMethod2CategoryMap[core.enablePaymentMethod.value]
|
|
293
|
+
);
|
|
294
|
+
} else {
|
|
295
|
+
setEnablePaymentMethod(void 0);
|
|
296
|
+
}
|
|
297
|
+
}, [core.enablePaymentMethod.value]);
|
|
298
|
+
const HeaderField = () => {
|
|
299
|
+
return /* @__PURE__ */ u(b, { children: headerPaymentCategories == null ? void 0 : headerPaymentCategories.map((category) => /* @__PURE__ */ u(
|
|
300
|
+
"div",
|
|
301
|
+
{
|
|
302
|
+
className: bem("header-payment"),
|
|
303
|
+
ref: (el) => componentMountRefMap.current[category] = el
|
|
304
|
+
}
|
|
305
|
+
)) });
|
|
306
|
+
};
|
|
307
|
+
const OtherLine = () => {
|
|
308
|
+
return /* @__PURE__ */ u(b, { children: !!(headerPaymentCategories == null ? void 0 : headerPaymentCategories.length) && /* @__PURE__ */ u("div", { className: bem("other"), children: [
|
|
309
|
+
/* @__PURE__ */ u("div", { className: bem("other-line") }),
|
|
310
|
+
/* @__PURE__ */ u("div", { className: bem("other-text"), children: i18n.get("dropIn.otherPaymentMethod") }),
|
|
311
|
+
/* @__PURE__ */ u("div", { className: bem("other-line") })
|
|
312
|
+
] }) });
|
|
313
|
+
};
|
|
314
|
+
return /* @__PURE__ */ u(CoreContext.Provider, { value: { i18n }, children: i18n.ready.value && /* @__PURE__ */ u("div", { className: bem(), children: [
|
|
315
|
+
HeaderField(),
|
|
316
|
+
!!paymentCategoryOptions.length && /* @__PURE__ */ u(b, { children: [
|
|
317
|
+
OtherLine(),
|
|
318
|
+
layout === "accordion" ? /* @__PURE__ */ u(b, { children: /* @__PURE__ */ u("div", { className: bem("accordion-wrapper"), children: /* @__PURE__ */ u(
|
|
319
|
+
Accordion,
|
|
320
|
+
{
|
|
321
|
+
value: activePaymentCategory,
|
|
322
|
+
enableTransition: enableAccordionTransition,
|
|
323
|
+
onChange: (item) => handlePaymentCategoryChange(item),
|
|
324
|
+
children: paymentCategoryOptions.map((item) => /* @__PURE__ */ u(
|
|
325
|
+
AccordionItem,
|
|
326
|
+
{
|
|
327
|
+
title: item.name,
|
|
328
|
+
value: item.type,
|
|
329
|
+
header: /* @__PURE__ */ u("div", { className: bem("accordion-icon"), children: item.icon() }),
|
|
330
|
+
disabled: !!enablePaymentMethod && enablePaymentMethod !== item.type,
|
|
331
|
+
children: /* @__PURE__ */ u(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
style: "padding: 0 2px",
|
|
335
|
+
ref: (el) => componentMountRefMap.current[item.type] = el
|
|
336
|
+
}
|
|
337
|
+
)
|
|
338
|
+
}
|
|
339
|
+
))
|
|
340
|
+
}
|
|
341
|
+
) }) }) : /* @__PURE__ */ u(b, { children: [
|
|
342
|
+
/* @__PURE__ */ u("div", { className: bem("tabs-wrapper"), children: /* @__PURE__ */ u(
|
|
343
|
+
PaymentTabs,
|
|
344
|
+
{
|
|
345
|
+
value: activePaymentCategory,
|
|
346
|
+
tabs: paymentCategoryOptions,
|
|
347
|
+
onChange: (item) => handlePaymentCategoryChange(item)
|
|
348
|
+
}
|
|
349
|
+
) }),
|
|
350
|
+
paymentCategories == null ? void 0 : paymentCategories.map((category) => /* @__PURE__ */ u(
|
|
351
|
+
"div",
|
|
352
|
+
{
|
|
353
|
+
style: { display: category === activePaymentCategory ? "block" : "none" },
|
|
354
|
+
ref: (el) => componentMountRefMap.current[category] = el
|
|
355
|
+
}
|
|
356
|
+
))
|
|
357
|
+
] })
|
|
358
|
+
] })
|
|
359
|
+
] }) });
|
|
360
|
+
});
|
|
361
|
+
export {
|
|
362
|
+
DropIn,
|
|
363
|
+
PaymentComponentMap,
|
|
364
|
+
dropInSupportedPaymentMethods
|
|
365
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { w, F, h, q, y, A, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import {
|
|
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 { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
|
|
4
7
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
5
8
|
import { getGooglePayInfo, googlePay } from "../../api/modules/google-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 { extractAreaCodeAndPhoneNumber } 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";
|
|
@@ -176,7 +176,7 @@ const loadGooglePayJS = (onload, onerror) => {
|
|
|
176
176
|
const { bem } = useBEM("google-pay");
|
|
177
177
|
const GooglePay = w((props, ref) => {
|
|
178
178
|
var _a;
|
|
179
|
-
const { session, threeDSFrame } = props;
|
|
179
|
+
const { session, threeDSFrame, isDropIn } = props;
|
|
180
180
|
F(ref, () => ({
|
|
181
181
|
checkThreeDS
|
|
182
182
|
}));
|
|
@@ -198,11 +198,18 @@ const GooglePay = w((props, ref) => {
|
|
|
198
198
|
returnUrl: session == null ? void 0 : session.checkout.returnUrl
|
|
199
199
|
});
|
|
200
200
|
y(() => {
|
|
201
|
-
var _a2;
|
|
201
|
+
var _a2, _b, _c;
|
|
202
202
|
if (!sessionReady) {
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
const { status, paymentMethod = [], sessionMode } = (session == null ? void 0 : session.checkout) || {};
|
|
206
|
+
if (sessionMode === SessionMode.DROP_IN && !isDropIn) {
|
|
207
|
+
(_b = (_a2 = props.core.config).onInitError) == null ? void 0 : _b.call(
|
|
208
|
+
_a2,
|
|
209
|
+
new PayKKaError("ERROR", "Please send the correct session when creating the checkout")
|
|
210
|
+
);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
206
213
|
if (!paymentMethod.includes(PaymentMethod.GOOGLE_PAY)) {
|
|
207
214
|
return;
|
|
208
215
|
}
|
|
@@ -220,7 +227,7 @@ const GooglePay = w((props, ref) => {
|
|
|
220
227
|
);
|
|
221
228
|
setHosted(sessionMode === SessionMode.HOSTED);
|
|
222
229
|
if (status === "SUCCESS") {
|
|
223
|
-
(
|
|
230
|
+
(_c = props.onSuccess) == null ? void 0 : _c.call(props, getPaymentSuccessData());
|
|
224
231
|
}
|
|
225
232
|
}, [sessionReady]);
|
|
226
233
|
const processThreeDS = (threeDSUrl, incomplete) => {
|
|
@@ -286,6 +293,7 @@ const GooglePay = w((props, ref) => {
|
|
|
286
293
|
fraudDetectionId: fraudDetection == null ? void 0 : fraudDetection.fraudDetectionID
|
|
287
294
|
})
|
|
288
295
|
},
|
|
296
|
+
props.core,
|
|
289
297
|
{ locale: i18n.locale }
|
|
290
298
|
);
|
|
291
299
|
}());
|