@paykka/card-checkout-ui 0.6.0 → 0.8.0
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/api/index.js +0 -2
- package/dist/es/api/modules/checkout/index.js +1 -15
- package/dist/es/api/modules/checkout/map.js +31 -3
- package/dist/es/api/modules/index.js +0 -2
- package/dist/es/components/AccountNameField/index.js +0 -3
- package/dist/es/components/AddressField/index.js +2 -7
- package/dist/es/components/AliPay/index.js +45 -34
- package/dist/es/components/ApplePay/index.js +19 -13
- package/dist/es/components/Card/index.js +334 -155
- package/dist/es/components/CardBrands/index.js +0 -2
- package/dist/es/components/CardExpireDateField/index.js +1 -4
- package/dist/es/components/CardHolderNameField/index.js +3 -5
- package/dist/es/components/CardIBANField/index.js +0 -3
- package/dist/es/components/CardNo/index.js +0 -2
- package/dist/es/components/CardNumberField/index.js +1 -4
- package/dist/es/components/CardSecurityCodeField/index.js +1 -4
- package/dist/es/components/CardSelector/index.js +0 -3
- package/dist/es/components/CombinedCardInfo/index.js +99 -0
- package/dist/es/components/DropIn/index.js +210 -0
- package/dist/es/components/EmailField/EmailField.js +0 -3
- package/dist/es/components/EncryptedCard/index.js +35 -75
- package/dist/es/components/GooglePay/index.js +69 -28
- package/dist/es/components/RecurringTip/index.js +0 -2
- package/dist/es/components/SecuredFieldsProvider/index.js +230 -1
- package/dist/es/components/SecuredIframe/index.js +3 -1
- package/dist/es/components/Sepa/index.js +26 -30
- package/dist/es/components/SubmitButton/index.js +0 -2
- package/dist/es/components/ThreeDS/index.js +94 -0
- package/dist/es/components/WechatPay/index.js +48 -38
- package/dist/es/components/index.js +2 -3
- package/dist/es/components/internal/Button/Button.js +0 -2
- package/dist/es/components/internal/Button/index.js +0 -2
- package/dist/es/components/internal/CheckBox/CheckBox.js +0 -2
- package/dist/es/components/internal/CheckBox/index.js +0 -2
- package/dist/es/components/internal/Form/type.js +0 -2
- package/dist/es/components/internal/Info/Info.js +0 -2
- package/dist/es/components/internal/Info/index.js +0 -2
- package/dist/es/components/internal/Input/Input.js +2 -2
- package/dist/es/components/internal/Input/type.js +0 -2
- package/dist/es/components/internal/LoadingCheck/LoadingCheck.js +0 -2
- package/dist/es/components/internal/LoadingCheck/index.js +0 -2
- package/dist/es/components/internal/Modal/Modal.js +40 -0
- package/dist/es/components/internal/Modal/modal2.js +1 -0
- package/dist/es/components/internal/Select/Select.js +0 -2
- package/dist/es/components/internal/Select/SelectMenu.js +0 -2
- package/dist/es/components/internal/Select/SelectMenuItem.js +0 -2
- package/dist/es/components/internal/icons/Icon3DSFail.js +3 -0
- package/dist/es/components/internal/icons/Icon3DSInfo.js +62 -0
- package/dist/es/components/internal/icons/Icon3DSSuccess.js +3 -0
- package/dist/es/components/internal/icons/IconCard.js +42 -0
- package/dist/es/config.js +0 -2
- package/dist/es/constant.js +13 -2
- package/dist/es/core/PayKKaCheckout.js +106 -42
- package/dist/es/core/Session.js +7 -6
- package/dist/es/core/environment.js +26 -0
- package/dist/es/core/error.js +21 -0
- package/dist/es/core/index.js +0 -2
- package/dist/es/core/query.js +0 -2
- package/dist/es/core.js +34 -34
- package/dist/es/hooks/index.js +0 -2
- package/dist/es/hooks/useBreakpoints.js +57 -0
- package/dist/es/hooks/useI18n.js +1 -2
- package/dist/es/hooks/usePayState.js +20 -24
- package/dist/es/i18n/index.js +0 -2
- package/dist/es/i18n/locales/de-DE.js +14 -1
- package/dist/es/i18n/locales/en-GB.js +14 -1
- package/dist/es/i18n/locales/es-ES.js +14 -1
- package/dist/es/i18n/locales/fr-FR.js +14 -1
- package/dist/es/i18n/locales/index.js +8 -6
- package/dist/es/i18n/locales/ja-JP.js +14 -1
- package/dist/es/i18n/locales/ko-KR.js +14 -1
- package/dist/es/i18n/locales/pt-PT.js +14 -1
- package/dist/es/i18n/locales/ru-RU.js +14 -1
- package/dist/es/i18n/locales/zh-CN.js +14 -1
- package/dist/es/i18n/locales/zh-HK.js +14 -1
- package/dist/es/i18n/locales/zh-TW.js +14 -1
- package/dist/es/i18n/util.js +22 -8
- package/dist/es/index.js +8 -2
- package/dist/es/style.css +289 -11
- package/dist/es/types/message.js +28 -0
- package/dist/es/utils/card-brand/brands.js +12 -10
- package/dist/es/utils/card-brand/index.js +3 -2
- package/dist/es/utils/iframe.js +23 -0
- package/dist/es/utils/index.js +0 -1
- package/dist/es/utils/style.js +47 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/checkout/map.d.ts +2 -1
- package/dist/types/api/modules/checkout/type.d.ts +24 -2
- package/dist/types/api/modules/get-browser-params.d.ts +1 -1
- package/dist/types/components/AddressField/type.d.ts +1 -0
- package/dist/types/components/AliPay/AliPay.d.ts +2 -1
- package/dist/types/components/AliPay/type.d.ts +2 -1
- package/dist/types/components/ApplePay/ApplePay.d.ts +2 -1
- package/dist/types/components/ApplePay/type.d.ts +9 -5
- package/dist/types/components/Card/Card.d.ts +2 -1
- package/dist/types/components/Card/type.d.ts +55 -9
- package/dist/types/components/CardHolderNameField/type.d.ts +1 -1
- package/dist/types/components/CombinedCardInfo/CombinedCardInfo.d.ts +5 -0
- package/dist/types/components/CombinedCardInfo/index.d.ts +2 -0
- package/dist/types/components/{CombinedEncryptedField → CombinedCardInfo}/type.d.ts +3 -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/index.d.ts +2 -0
- package/dist/types/components/DropIn/type.d.ts +49 -0
- package/dist/types/components/GooglePay/GooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +20 -8
- package/dist/types/components/SecuredFieldsProvider/index.d.ts +1 -0
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +1 -153
- package/dist/types/components/SecuredFieldsProvider/utils/index.d.ts +1 -1
- package/dist/types/components/SecuredIframe/useSecuredInput.d.ts +2 -1
- package/dist/types/components/Sepa/Sepa.d.ts +2 -1
- package/dist/types/components/Sepa/type.d.ts +2 -1
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/ThreeDSAuth.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/index.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +17 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/ThreeDSIframe.d.ts +2 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/index.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/type.d.ts +5 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/ThreeDSStatus.d.ts +3 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/output.d.ts +1 -0
- package/dist/types/components/ThreeDS/components/ThreeDSStatus/type.d.ts +6 -0
- package/dist/types/components/ThreeDS/index.d.ts +1 -0
- package/dist/types/components/WechatPay/WechatPay.d.ts +2 -1
- package/dist/types/components/WechatPay/type.d.ts +2 -1
- package/dist/types/components/index.d.ts +2 -1
- package/dist/types/components/internal/Input/type.d.ts +1 -0
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Loading/index.d.ts +1 -0
- package/dist/types/components/internal/Modal/Modal.d.ts +5 -0
- package/dist/types/components/internal/Modal/index.d.ts +2 -0
- package/dist/types/components/internal/Modal/type.d.ts +20 -0
- package/dist/types/components/internal/icons/Icon3DSFail.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSInfo.d.ts +2 -0
- package/dist/types/components/internal/icons/Icon3DSSuccess.d.ts +2 -0
- package/dist/types/components/internal/icons/IconCard.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +4 -0
- package/dist/types/constant.d.ts +17 -2
- package/dist/types/core/PayKKaCheckout.d.ts +23 -6
- package/dist/types/core/Session.d.ts +1 -1
- package/dist/types/core/context.d.ts +1 -0
- package/dist/types/core/environment.d.ts +4 -0
- package/dist/types/core/error.d.ts +16 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useBreakpoints.d.ts +15 -0
- package/dist/types/hooks/usePayState.d.ts +3 -6
- package/dist/types/i18n/locales/de-DE.d.ts +10 -0
- package/dist/types/i18n/locales/en-GB.d.ts +10 -0
- package/dist/types/i18n/locales/es-ES.d.ts +10 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +10 -0
- package/dist/types/i18n/locales/index.d.ts +2 -2
- package/dist/types/i18n/locales/ja-JP.d.ts +10 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +10 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +10 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +10 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +10 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +10 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +10 -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 +59 -8
- package/dist/types/types/message.d.ts +170 -0
- package/dist/types/utils/card-brand/brands.d.ts +1 -8
- package/dist/types/utils/card-brand/index.d.ts +2 -2
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/style.d.ts +12 -0
- package/package.json +2 -2
- package/dist/es/components/CombinedEncryptedField/index.js +0 -75
- package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -268
- package/dist/types/components/CombinedEncryptedField/CombinedEncryptedField.d.ts +0 -4
- package/dist/types/components/CombinedEncryptedField/index.d.ts +0 -2
- /package/dist/types/{components/SecuredFieldsProvider/utils → utils}/iframe.d.ts +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { h, A, T, y, u } from "../../core.js";
|
|
2
|
+
import "../../utils/card-brand/brands.js";
|
|
3
|
+
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
+
import "../../core/context.js";
|
|
5
|
+
import { Modal } from "../internal/Modal/Modal.js";
|
|
6
|
+
import "../internal/Button/button2.js";
|
|
7
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
8
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
9
|
+
import { MessageAction } from "../../types/message.js";
|
|
10
|
+
import { cdnOrigin } from "../../config.js";
|
|
11
|
+
import { safeParse } from "../../utils/index.js";
|
|
12
|
+
import { useBreakpoints } from "../../hooks/useBreakpoints.js";
|
|
13
|
+
import { Icon3DSInfo } from "../internal/icons/Icon3DSInfo.js";
|
|
14
|
+
import { Button } from "../internal/Button/Button.js";
|
|
15
|
+
const { bem } = useBEM("three-ds-auth");
|
|
16
|
+
const ThreeDSAuth = (props) => {
|
|
17
|
+
const { show = false, onClose, url, incomplete = true, width, height = "72vh", theme } = props;
|
|
18
|
+
const breakpoints = useBreakpoints();
|
|
19
|
+
const [continueThreeDs, setContinueThreeDs] = h(false);
|
|
20
|
+
const messageHandler = A();
|
|
21
|
+
const iframeRef = A(null);
|
|
22
|
+
const { i18n } = useI18n();
|
|
23
|
+
const handleLastThreeDs = () => {
|
|
24
|
+
setContinueThreeDs(true);
|
|
25
|
+
};
|
|
26
|
+
const onChange = (status) => {
|
|
27
|
+
!status && (onClose == null ? void 0 : onClose());
|
|
28
|
+
};
|
|
29
|
+
const modalWidth = T(() => {
|
|
30
|
+
if (!show) {
|
|
31
|
+
return "0";
|
|
32
|
+
}
|
|
33
|
+
return width || (breakpoints.smaller("sm") ? "90vw" : "600px");
|
|
34
|
+
}, [show, width, breakpoints.matches]);
|
|
35
|
+
y(() => {
|
|
36
|
+
if (show) {
|
|
37
|
+
if (messageHandler.current) {
|
|
38
|
+
window.removeEventListener("message", messageHandler.current);
|
|
39
|
+
}
|
|
40
|
+
messageHandler.current = (event) => {
|
|
41
|
+
const { data, origin } = event;
|
|
42
|
+
if (origin !== cdnOrigin) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const feedbackData = safeParse(data);
|
|
46
|
+
switch (feedbackData.action) {
|
|
47
|
+
case MessageAction.CHECK_THREE_DS: {
|
|
48
|
+
onChange(false);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
window.addEventListener("message", messageHandler.current);
|
|
54
|
+
} else {
|
|
55
|
+
messageHandler.current && window.removeEventListener("message", messageHandler.current);
|
|
56
|
+
}
|
|
57
|
+
}, [show]);
|
|
58
|
+
return /* @__PURE__ */ u(
|
|
59
|
+
Modal,
|
|
60
|
+
{
|
|
61
|
+
show,
|
|
62
|
+
onChange,
|
|
63
|
+
width: modalWidth,
|
|
64
|
+
height,
|
|
65
|
+
style: {
|
|
66
|
+
maxWidth: "100vw",
|
|
67
|
+
maxHeight: "100vh",
|
|
68
|
+
minHeight: "500px",
|
|
69
|
+
minWidth: "350px"
|
|
70
|
+
},
|
|
71
|
+
children: /* @__PURE__ */ u("div", { className: bem("content"), children: !incomplete || continueThreeDs ? /* @__PURE__ */ u("iframe", { ref: iframeRef, width: "100%", height: "100%", frameBorder: 0, src: url }) : /* @__PURE__ */ u("div", { className: bem("last-three-ds"), children: [
|
|
72
|
+
/* @__PURE__ */ u(Icon3DSInfo, { size: 60 }),
|
|
73
|
+
/* @__PURE__ */ u("div", { className: bem("last-three-ds-title"), children: [
|
|
74
|
+
/* @__PURE__ */ u("div", { children: i18n.get("threeDS.paymentIncomplete") }),
|
|
75
|
+
/* @__PURE__ */ u("div", { children: i18n.get("threeDS.completeFirst") })
|
|
76
|
+
] }),
|
|
77
|
+
/* @__PURE__ */ u("div", { children: /* @__PURE__ */ u(
|
|
78
|
+
Button,
|
|
79
|
+
{
|
|
80
|
+
style: {
|
|
81
|
+
backgroundColor: theme == null ? void 0 : theme.payButtonBackgroundColor,
|
|
82
|
+
color: theme == null ? void 0 : theme.payButtonTextColor
|
|
83
|
+
},
|
|
84
|
+
onClick: handleLastThreeDs,
|
|
85
|
+
children: i18n.get("common.confirm")
|
|
86
|
+
}
|
|
87
|
+
) })
|
|
88
|
+
] }) })
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
ThreeDSAuth
|
|
94
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { w, A, F, h, y, q, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { PaymentType } from "../../constant.js";
|
|
3
|
+
import { COMMON_CLASS_NAME, PaymentType } from "../../constant.js";
|
|
4
4
|
import { isUndefined } from "../../utils/is.js";
|
|
5
5
|
import "../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
|
-
import { formatAmount } from "../../utils/format.js";
|
|
7
|
+
import { cssVarPrefix, normalizedClass, formatAmount } from "../../utils/format.js";
|
|
8
8
|
import { getWechatPayInfo, wechatPay } from "../../api/modules/wechat-pay/index.js";
|
|
9
9
|
import { CoreContext } from "../../core/context.js";
|
|
10
|
-
import "../../
|
|
11
|
-
import "../../i18n/locales/index.js";
|
|
10
|
+
import { PayKKaError } from "../../core/error.js";
|
|
12
11
|
import { createAddressCore } from "../../core/Address.js";
|
|
13
12
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
13
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
@@ -24,6 +23,8 @@ import { RecurringTip } from "../RecurringTip/index.js";
|
|
|
24
23
|
import { SubmitButton } from "../SubmitButton/index.js";
|
|
25
24
|
const { bem } = useBEM("wechat-pay");
|
|
26
25
|
const WechatPay = w((props, ref) => {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
27
|
+
const { session } = props;
|
|
27
28
|
let addressState = createAddressCore();
|
|
28
29
|
let emailState = createEmailCore();
|
|
29
30
|
const emailFieldRef = A(null);
|
|
@@ -39,25 +40,24 @@ const WechatPay = w((props, ref) => {
|
|
|
39
40
|
});
|
|
40
41
|
},
|
|
41
42
|
updateAddress: () => {
|
|
42
|
-
var
|
|
43
|
+
var _a2;
|
|
43
44
|
setForm(Object.assign(form, { address: addressState.getAddressState() }));
|
|
44
|
-
(
|
|
45
|
+
(_a2 = addressFieldRef.current) == null ? void 0 : _a2.update(addressState.getAddressState());
|
|
45
46
|
},
|
|
46
47
|
updateEmail: () => {
|
|
47
|
-
var
|
|
48
|
+
var _a2;
|
|
48
49
|
setForm(Object.assign(form, { email: emailState.email }));
|
|
49
|
-
(
|
|
50
|
+
(_a2 = emailFieldRef.current) == null ? void 0 : _a2.update(emailState.email);
|
|
50
51
|
}
|
|
51
52
|
}));
|
|
52
53
|
const {
|
|
53
54
|
setErrorMsg,
|
|
54
55
|
setSubmitButtonStatus,
|
|
55
56
|
i18n,
|
|
56
|
-
session,
|
|
57
57
|
submitButtonStatus,
|
|
58
58
|
errorMsg,
|
|
59
59
|
sessionReady
|
|
60
|
-
} = usePayState();
|
|
60
|
+
} = usePayState(session);
|
|
61
61
|
const formRef = A(null);
|
|
62
62
|
const [form, setForm] = h({
|
|
63
63
|
email: "",
|
|
@@ -76,8 +76,8 @@ const WechatPay = w((props, ref) => {
|
|
|
76
76
|
const [requiredBill, setRequiredBill] = h(false);
|
|
77
77
|
const addressFieldRef = A(null);
|
|
78
78
|
function validateForm() {
|
|
79
|
-
var
|
|
80
|
-
(
|
|
79
|
+
var _a2;
|
|
80
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(void 0, false).then(() => {
|
|
81
81
|
setValidated(true);
|
|
82
82
|
}).catch(() => {
|
|
83
83
|
setValidated(false);
|
|
@@ -87,11 +87,11 @@ const WechatPay = w((props, ref) => {
|
|
|
87
87
|
validateForm();
|
|
88
88
|
}, [form]);
|
|
89
89
|
y(() => {
|
|
90
|
-
var
|
|
90
|
+
var _a2;
|
|
91
91
|
if (sessionReady) {
|
|
92
92
|
if ((session == null ? void 0 : session.checkout.status) === "SUCCESS") {
|
|
93
93
|
setSubmitButtonStatus("success");
|
|
94
|
-
(
|
|
94
|
+
(_a2 = props.onSuccess) == null ? void 0 : _a2.call(props);
|
|
95
95
|
}
|
|
96
96
|
form.email = (session == null ? void 0 : session.checkout.bill.email) ?? "";
|
|
97
97
|
disabledEmail.current = !!(session == null ? void 0 : session.checkout.bill.email);
|
|
@@ -102,10 +102,10 @@ const WechatPay = w((props, ref) => {
|
|
|
102
102
|
}
|
|
103
103
|
}, [sessionReady]);
|
|
104
104
|
const onTimeout = q((message) => {
|
|
105
|
-
var
|
|
105
|
+
var _a2;
|
|
106
106
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
107
107
|
setSubmitButtonStatus("unSubmit");
|
|
108
|
-
(
|
|
108
|
+
(_a2 = props.onTimeout) == null ? void 0 : _a2.call(props, "retry");
|
|
109
109
|
}, [i18n, props.onTimeout]);
|
|
110
110
|
const { start: startReFetchPayInfo, stop: stopReFetchPayInfo } = useRetry(
|
|
111
111
|
(timeout) => pay(true, timeout),
|
|
@@ -115,7 +115,7 @@ const WechatPay = w((props, ref) => {
|
|
|
115
115
|
}
|
|
116
116
|
);
|
|
117
117
|
async function pay(search = false, timeout) {
|
|
118
|
-
var
|
|
118
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j;
|
|
119
119
|
try {
|
|
120
120
|
const res = search ? await getWechatPayInfo(
|
|
121
121
|
{
|
|
@@ -138,31 +138,31 @@ const WechatPay = w((props, ref) => {
|
|
|
138
138
|
} : {
|
|
139
139
|
email: form.email
|
|
140
140
|
},
|
|
141
|
-
channelUserId: await ((
|
|
141
|
+
channelUserId: await ((_a2 = props.onGetOpenId) == null ? void 0 : _a2.call(props))
|
|
142
142
|
},
|
|
143
143
|
{ locale: i18n.locale, timeout }
|
|
144
144
|
);
|
|
145
|
-
const { status, orderStatus, errorMessage, payInfo } = res;
|
|
146
|
-
!search && ((
|
|
145
|
+
const { status, orderStatus, errorMessage, payInfo, errorCode } = res;
|
|
146
|
+
!search && ((_b2 = props.onSubmitResponse) == null ? void 0 : _b2.call(props, res));
|
|
147
147
|
if (status === "PROCESSING") {
|
|
148
148
|
if (!orderStatus) {
|
|
149
149
|
setSubmitButtonStatus("unSubmit");
|
|
150
150
|
} else if (orderStatus === "SUCCESS") {
|
|
151
151
|
setSubmitButtonStatus("success");
|
|
152
|
-
(
|
|
152
|
+
(_c2 = props.onSuccess) == null ? void 0 : _c2.call(props);
|
|
153
153
|
return {
|
|
154
154
|
end: true
|
|
155
155
|
};
|
|
156
156
|
} else if (orderStatus === "FAILURE") {
|
|
157
157
|
setErrorMsg(errorMessage);
|
|
158
158
|
setSubmitButtonStatus("unSubmit");
|
|
159
|
-
(
|
|
159
|
+
(_d2 = props.onError) == null ? void 0 : _d2.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
160
160
|
return {
|
|
161
161
|
end: true
|
|
162
162
|
};
|
|
163
163
|
} else if (orderStatus === "PROCESSING") {
|
|
164
164
|
if (!search) {
|
|
165
|
-
await ((
|
|
165
|
+
await ((_e2 = props.onCallWxPayBox) == null ? void 0 : _e2.call(props, payInfo));
|
|
166
166
|
startReFetchPayInfo();
|
|
167
167
|
}
|
|
168
168
|
return {
|
|
@@ -170,26 +170,26 @@ const WechatPay = w((props, ref) => {
|
|
|
170
170
|
};
|
|
171
171
|
} else if (orderStatus === "CANCELED") {
|
|
172
172
|
setSubmitButtonStatus("unSubmit");
|
|
173
|
-
(
|
|
173
|
+
(_f2 = props.onTimeout) == null ? void 0 : _f2.call(props, "channel");
|
|
174
174
|
return {
|
|
175
175
|
end: true
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
} else if (status === "SUCCESS") {
|
|
179
179
|
setSubmitButtonStatus("success");
|
|
180
|
-
(
|
|
180
|
+
(_g2 = props.onSuccess) == null ? void 0 : _g2.call(props);
|
|
181
181
|
return {
|
|
182
182
|
end: true
|
|
183
183
|
};
|
|
184
184
|
} else if (status === "EXPIRED") {
|
|
185
185
|
setSubmitButtonStatus("unSubmit");
|
|
186
|
-
(
|
|
186
|
+
(_h2 = props.onExpired) == null ? void 0 : _h2.call(props);
|
|
187
187
|
return {
|
|
188
188
|
end: true
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
setSubmitButtonStatus("unSubmit");
|
|
192
|
-
(
|
|
192
|
+
(_i2 = props.onSuccess) == null ? void 0 : _i2.call(props);
|
|
193
193
|
return {
|
|
194
194
|
end: true
|
|
195
195
|
};
|
|
@@ -202,20 +202,21 @@ const WechatPay = w((props, ref) => {
|
|
|
202
202
|
return { end: true };
|
|
203
203
|
}
|
|
204
204
|
} else {
|
|
205
|
-
|
|
206
|
-
(
|
|
205
|
+
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
206
|
+
setErrorMsg(message);
|
|
207
|
+
(_j = props.onError) == null ? void 0 : _j.call(props, new PayKKaError("API_ERROR", message, { code: error.code, cause: error }));
|
|
207
208
|
setSubmitButtonStatus("unSubmit");
|
|
208
209
|
return { end: true };
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
async function onSubmit() {
|
|
213
|
-
var
|
|
214
|
+
var _a2;
|
|
214
215
|
setErrorMsg("");
|
|
215
|
-
(
|
|
216
|
-
var
|
|
216
|
+
(_a2 = formRef.current) == null ? void 0 : _a2.validate(async (errors) => {
|
|
217
|
+
var _a3;
|
|
217
218
|
requiredBill && addressState.setValidateAllFields(true);
|
|
218
|
-
(
|
|
219
|
+
(_a3 = props.onSubmit) == null ? void 0 : _a3.call(props, errors);
|
|
219
220
|
if (errors) {
|
|
220
221
|
setSubmitButtonStatus("unSubmit");
|
|
221
222
|
return;
|
|
@@ -228,9 +229,10 @@ const WechatPay = w((props, ref) => {
|
|
|
228
229
|
const Button = () => {
|
|
229
230
|
const { transAmount } = (session == null ? void 0 : session.checkout) ?? {};
|
|
230
231
|
let { symbol = "", amount = "", digits } = transAmount ?? {};
|
|
232
|
+
let amountStr = "";
|
|
231
233
|
if (amount && !isUndefined(digits))
|
|
232
|
-
|
|
233
|
-
const text = i18n.get("common.pay") + (Number(amount) ? ` ${symbol}${
|
|
234
|
+
amountStr = formatAmount(+amount, digits);
|
|
235
|
+
const text = i18n.get("common.pay") + (Number(amount) ? ` ${symbol}${amountStr}` : "");
|
|
234
236
|
return /* @__PURE__ */ u(
|
|
235
237
|
SubmitButton,
|
|
236
238
|
{
|
|
@@ -249,6 +251,13 @@ const WechatPay = w((props, ref) => {
|
|
|
249
251
|
formRef.current = dom;
|
|
250
252
|
dom && validateForm();
|
|
251
253
|
};
|
|
254
|
+
const formStyle = {
|
|
255
|
+
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
256
|
+
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
257
|
+
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
258
|
+
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
259
|
+
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
260
|
+
};
|
|
252
261
|
return /* @__PURE__ */ u(
|
|
253
262
|
CoreContext.Provider,
|
|
254
263
|
{
|
|
@@ -256,7 +265,7 @@ const WechatPay = w((props, ref) => {
|
|
|
256
265
|
i18n,
|
|
257
266
|
session
|
|
258
267
|
},
|
|
259
|
-
children: sessionReady && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: [
|
|
268
|
+
children: sessionReady && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), style: formStyle, children: [
|
|
260
269
|
/* @__PURE__ */ u(
|
|
261
270
|
EmailField,
|
|
262
271
|
{
|
|
@@ -271,13 +280,14 @@ const WechatPay = w((props, ref) => {
|
|
|
271
280
|
{
|
|
272
281
|
ref: addressFieldRef,
|
|
273
282
|
value: form.address,
|
|
283
|
+
country: ((_g = session == null ? void 0 : session.checkout) == null ? void 0 : _g.country) || ((_h = session == null ? void 0 : session.checkout) == null ? void 0 : _h.bill.country),
|
|
274
284
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
275
285
|
}
|
|
276
286
|
),
|
|
277
|
-
(session == null ? void 0 : session.checkout.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
287
|
+
((_i = session == null ? void 0 : session.checkout) == null ? void 0 : _i.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
278
288
|
!!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
|
|
279
289
|
Button()
|
|
280
|
-
] })
|
|
290
|
+
] }) })
|
|
281
291
|
}
|
|
282
292
|
);
|
|
283
293
|
});
|
|
@@ -6,8 +6,6 @@ import "./CardBrands/index.js";
|
|
|
6
6
|
import "../utils/card-brand/brands.js";
|
|
7
7
|
import "../utils/system-info/get-browser-info.js";
|
|
8
8
|
import "../core/context.js";
|
|
9
|
-
import "../i18n/util.js";
|
|
10
|
-
import "../i18n/locales/index.js";
|
|
11
9
|
import "./CardExpireDateField/index.js";
|
|
12
10
|
import "./internal/Form/type.js";
|
|
13
11
|
import "./internal/Form/context.js";
|
|
@@ -28,4 +26,5 @@ import "./ApplePay/index.js";
|
|
|
28
26
|
import "./GooglePay/index.js";
|
|
29
27
|
import "./Sepa/index.js";
|
|
30
28
|
import "./EncryptedCard/index.js";
|
|
31
|
-
import "./
|
|
29
|
+
import "./CombinedCardInfo/index.js";
|
|
30
|
+
import "./DropIn/index.js";
|
|
@@ -6,8 +6,6 @@ import "../../../core/context.js";
|
|
|
6
6
|
import "../../../utils/card-brand/brands.js";
|
|
7
7
|
import "../../../utils/system-info/get-browser-info.js";
|
|
8
8
|
import { normalizedClass } from "../../../utils/format.js";
|
|
9
|
-
import "../../../i18n/util.js";
|
|
10
|
-
import "../../../i18n/locales/index.js";
|
|
11
9
|
const { bem } = useBEM("button");
|
|
12
10
|
function Button(props) {
|
|
13
11
|
const { style, className, children, icon, loading, disabled, dashed } = props;
|
|
@@ -5,8 +5,6 @@ import "../../../core/context.js";
|
|
|
5
5
|
import "../../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../../utils/system-info/get-browser-info.js";
|
|
7
7
|
import { normalizedClass } from "../../../utils/format.js";
|
|
8
|
-
import "../../../i18n/util.js";
|
|
9
|
-
import "../../../i18n/locales/index.js";
|
|
10
8
|
import { COMMON_CLASS_NAME } from "../../../constant.js";
|
|
11
9
|
import { IconChecked } from "../icons/iconChecked.js";
|
|
12
10
|
const { bem } = useBEM("check-box");
|
|
@@ -3,8 +3,6 @@ import "../../../core.js";
|
|
|
3
3
|
import "../../../core/context.js";
|
|
4
4
|
import "../../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import "../../../i18n/util.js";
|
|
7
|
-
import "../../../i18n/locales/index.js";
|
|
8
6
|
const formItemBEM = useBEM("form-item");
|
|
9
7
|
const formItemLabelClassName = formItemBEM.bem("label");
|
|
10
8
|
const formItemErrorMessageClassName = formItemBEM.bem("error-text");
|
|
@@ -6,8 +6,6 @@ import "../../../core/context.js";
|
|
|
6
6
|
import "../../../utils/card-brand/brands.js";
|
|
7
7
|
import "../../../utils/system-info/get-browser-info.js";
|
|
8
8
|
import { normalizedClass } from "../../../utils/format.js";
|
|
9
|
-
import "../../../i18n/util.js";
|
|
10
|
-
import "../../../i18n/locales/index.js";
|
|
11
9
|
import { IconError } from "../icons/IconError.js";
|
|
12
10
|
const { bem } = useBEM("info");
|
|
13
11
|
const iconMap = {
|
|
@@ -16,7 +16,7 @@ const statusIconMap = {
|
|
|
16
16
|
success: IconSuccess
|
|
17
17
|
};
|
|
18
18
|
const Input = w((props, ref) => {
|
|
19
|
-
const { inputClassName, style, disabled, children } = props;
|
|
19
|
+
const { inputClassName, style, disabled, children, showStatus = true } = props;
|
|
20
20
|
F(ref, () => ({
|
|
21
21
|
input: inputRef.current,
|
|
22
22
|
focus: () => {
|
|
@@ -40,7 +40,7 @@ const Input = w((props, ref) => {
|
|
|
40
40
|
if (status === "unValidate")
|
|
41
41
|
status = void 0;
|
|
42
42
|
let { rightIcon } = props;
|
|
43
|
-
if (
|
|
43
|
+
if (showStatus && status) {
|
|
44
44
|
const StatusIcon = statusIconMap[status];
|
|
45
45
|
rightIcon = /* @__PURE__ */ u(StatusIcon, { size: 16 });
|
|
46
46
|
}
|
|
@@ -3,8 +3,6 @@ import "../../../core.js";
|
|
|
3
3
|
import "../../../core/context.js";
|
|
4
4
|
import "../../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import "../../../i18n/util.js";
|
|
7
|
-
import "../../../i18n/locales/index.js";
|
|
8
6
|
const inputBEM = useBEM("input");
|
|
9
7
|
const inputWrapperClassName = inputBEM.bem("input-wrapper");
|
|
10
8
|
export {
|
|
@@ -7,8 +7,6 @@ import { isUndefined } from "../../../utils/is.js";
|
|
|
7
7
|
import "../../../utils/card-brand/brands.js";
|
|
8
8
|
import "../../../utils/system-info/get-browser-info.js";
|
|
9
9
|
import { normalizedClass, normalizedStyle } from "../../../utils/format.js";
|
|
10
|
-
import "../../../i18n/util.js";
|
|
11
|
-
import "../../../i18n/locales/index.js";
|
|
12
10
|
const SIZE = 40;
|
|
13
11
|
const SVG_VIEW_BOX = `0 0 ${SIZE} ${SIZE}`;
|
|
14
12
|
const CIRCLE_STROKE_WIDTH = 3.3;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { w, h, T, u, b } from "../../../core.js";
|
|
2
|
+
import { useBEM } from "../../../hooks/useBEM.js";
|
|
3
|
+
import { useI18n } from "../../../hooks/useI18n.js";
|
|
4
|
+
import "../../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import "./modal2.js";
|
|
7
|
+
const { bem } = useBEM("modal");
|
|
8
|
+
const Modal = w((props) => {
|
|
9
|
+
const { show = false, width, height, maskClosable, header, children, onChange, style } = props;
|
|
10
|
+
const [modalWidth, setModalWidth] = h();
|
|
11
|
+
const [modalHeight, setModalHeight] = h();
|
|
12
|
+
const { i18n } = useI18n();
|
|
13
|
+
T(() => {
|
|
14
|
+
setModalWidth(typeof width === "number" ? `${width}px` : width);
|
|
15
|
+
setModalHeight(typeof height === "number" ? `${height}px` : height);
|
|
16
|
+
}, [width, height]);
|
|
17
|
+
const handleClickMask = () => {
|
|
18
|
+
maskClosable && (onChange == null ? void 0 : onChange(false));
|
|
19
|
+
};
|
|
20
|
+
const handleClickClose = () => {
|
|
21
|
+
onChange == null ? void 0 : onChange(false);
|
|
22
|
+
};
|
|
23
|
+
return /* @__PURE__ */ u(b, { children: show && /* @__PURE__ */ u("div", { className: bem(), children: [
|
|
24
|
+
/* @__PURE__ */ u("div", { className: bem("mask"), onClick: handleClickMask }),
|
|
25
|
+
/* @__PURE__ */ u(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
className: bem("content"),
|
|
29
|
+
style: { width: modalWidth, height: modalHeight, ...style },
|
|
30
|
+
children: [
|
|
31
|
+
header || /* @__PURE__ */ u("div", { className: bem("header"), children: /* @__PURE__ */ u("div", { className: bem("close"), onClick: handleClickClose, children: i18n.get("common.cancel") }) }),
|
|
32
|
+
/* @__PURE__ */ u("div", { className: bem("body"), children })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
] }) });
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
Modal
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -4,8 +4,6 @@ import "../../../core/context.js";
|
|
|
4
4
|
import { isNil } from "../../../utils/is.js";
|
|
5
5
|
import "../../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../../utils/system-info/get-browser-info.js";
|
|
7
|
-
import "../../../i18n/util.js";
|
|
8
|
-
import "../../../i18n/locales/index.js";
|
|
9
7
|
import "../Form/type.js";
|
|
10
8
|
import { FormItemContext } from "../Form/context.js";
|
|
11
9
|
import "../Form/FormItem.js";
|
|
@@ -4,8 +4,6 @@ import { useBEM } from "../../../hooks/useBEM.js";
|
|
|
4
4
|
import "../../../core/context.js";
|
|
5
5
|
import "../../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../../utils/system-info/get-browser-info.js";
|
|
7
|
-
import "../../../i18n/util.js";
|
|
8
|
-
import "../../../i18n/locales/index.js";
|
|
9
7
|
const { bem } = useBEM("select");
|
|
10
8
|
function SelectMenu(props) {
|
|
11
9
|
const { style, children } = props;
|
|
@@ -5,8 +5,6 @@ import "../../../core/context.js";
|
|
|
5
5
|
import { isFunction } from "../../../utils/is.js";
|
|
6
6
|
import "../../../utils/card-brand/brands.js";
|
|
7
7
|
import "../../../utils/system-info/get-browser-info.js";
|
|
8
|
-
import "../../../i18n/util.js";
|
|
9
|
-
import "../../../i18n/locales/index.js";
|
|
10
8
|
import { IconTick } from "../icons/IconTick.js";
|
|
11
9
|
const { bem } = useBEM("select");
|
|
12
10
|
function SelectMenuItem(props) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { u } from "../../../core.js";
|
|
2
|
+
import { COMMON_CLASS_NAME } from "../../../constant.js";
|
|
3
|
+
import { isUndefined } from "../../../utils/is.js";
|
|
4
|
+
import "../../../utils/card-brand/brands.js";
|
|
5
|
+
import "../../../utils/system-info/get-browser-info.js";
|
|
6
|
+
import { normalizedClass } from "../../../utils/format.js";
|
|
7
|
+
function Icon3DSInfo({ size, style, className }) {
|
|
8
|
+
const computedSize = !isUndefined(size) ? `${size}px` : "1em";
|
|
9
|
+
return /* @__PURE__ */ u(
|
|
10
|
+
"svg",
|
|
11
|
+
{
|
|
12
|
+
width: computedSize,
|
|
13
|
+
height: computedSize,
|
|
14
|
+
viewBox: "0 0 64 64",
|
|
15
|
+
style,
|
|
16
|
+
fill: "none",
|
|
17
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
18
|
+
className: normalizedClass(COMMON_CLASS_NAME, className),
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ u("g", { id: "icon-warning", "clip-path": "url(#clip0_25_1509)", children: [
|
|
21
|
+
/* @__PURE__ */ u(
|
|
22
|
+
"path",
|
|
23
|
+
{
|
|
24
|
+
id: "Vector",
|
|
25
|
+
d: "M32 0.5C14.3437 0.5 0 14.8437 0 32.5C0 50.1563 14.3437 64.5 32 64.5C49.6563 64.5 64 50.1563 64 32.5C64 14.8437 49.6563 0.5 32 0.5ZM32 3.28261C48.1524 3.28261 61.2174 16.3476 61.2174 32.5C61.2174 48.6524 48.1524 61.7174 32 61.7174C15.8476 61.7174 2.78261 48.6524 2.78261 32.5C2.78261 16.3476 15.8476 3.28261 32 3.28261Z",
|
|
26
|
+
fill: "#FCA605"
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ u(
|
|
30
|
+
"path",
|
|
31
|
+
{
|
|
32
|
+
id: "Vector_2",
|
|
33
|
+
d: "M32 15.5V39.5",
|
|
34
|
+
stroke: "#FCA605",
|
|
35
|
+
"stroke-width": "2.8",
|
|
36
|
+
"stroke-linecap": "round",
|
|
37
|
+
"stroke-linejoin": "round"
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
/* @__PURE__ */ u(
|
|
41
|
+
"circle",
|
|
42
|
+
{
|
|
43
|
+
id: "Ellipse 642",
|
|
44
|
+
cx: "32",
|
|
45
|
+
cy: "47.5",
|
|
46
|
+
r: "1",
|
|
47
|
+
fill: "#FCA605",
|
|
48
|
+
stroke: "#FCA605",
|
|
49
|
+
"stroke-width": "2.8",
|
|
50
|
+
"stroke-linecap": "round",
|
|
51
|
+
"stroke-linejoin": "round"
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
] }),
|
|
55
|
+
/* @__PURE__ */ u("defs", { children: /* @__PURE__ */ u("clipPath", { id: "clip0_25_1509", children: /* @__PURE__ */ u("rect", { width: "64", height: "64", fill: "white", transform: "translate(0 0.5)" }) }) })
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
Icon3DSInfo
|
|
62
|
+
};
|