@paykka/card-checkout-ui 0.13.1 → 0.13.5
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 +21 -21
- package/dist/card-checkout-ui.umd.cjs +21 -21
- package/dist/es/_commonjsHelpers.js +82 -1
- package/dist/es/api/modules/get-browser-params.js +4 -1
- package/dist/es/api/modules/opay-wallet/index.js +16 -0
- package/dist/es/api/modules/paga-wallet/index.js +16 -0
- package/dist/es/api/modules/pic-pay/index.js +16 -0
- package/dist/es/api/modules/pix/index.js +16 -0
- package/dist/es/api/modules/vietqr/index.js +4 -0
- package/dist/es/components/AliPay/index.js +29 -35
- package/dist/es/components/Boost/index.js +34 -40
- package/dist/es/components/Card/index.js +35 -39
- package/dist/es/components/DropIn/index.js +42 -2
- package/dist/es/components/EncryptedCard/index.js +5 -1
- package/dist/es/components/GooglePay/index.js +1 -0
- package/dist/es/components/GrabPay/index.js +34 -40
- package/dist/es/components/GuideCard/index.js +6 -1
- package/dist/es/components/LinePay/index.js +34 -40
- package/dist/es/components/MayBankQRPay/index.js +35 -41
- package/dist/es/components/NinePay/index.js +34 -40
- package/dist/es/components/SecuredFieldsProvider/index.js +23 -7
- package/dist/es/components/SecuredIframe/index.js +36 -59
- package/dist/es/components/Sepa/index.js +17 -21
- package/dist/es/components/ShopeePay/index.js +34 -40
- package/dist/es/components/TNGWallet/index.js +34 -40
- package/dist/es/components/ThreeDS/index.js +32 -7
- package/dist/es/components/WechatPay/index.js +19 -24
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +6 -6
- package/dist/es/components/index.js +5 -0
- package/dist/es/components/internal/Form/FormItem.js +1 -1
- package/dist/es/components/internal/Form/util.js +1 -1
- package/dist/es/components/internal/Select/SelectMenu.js +2 -2
- package/dist/es/components/internal/icons/IconError.js +7 -4
- package/dist/es/components/internal/icons/IconOpayWallet.js +71 -0
- package/dist/es/components/internal/icons/IconPagaWallet.js +141 -0
- package/dist/es/components/internal/icons/IconPaymaya.js +42 -86
- package/dist/es/components/internal/icons/IconPicPay.js +49 -0
- package/dist/es/components/internal/icons/IconPix.js +75 -0
- package/dist/es/components/internal/icons/IconVietqr.js +45 -0
- package/dist/es/components/internal/icons/IconVietqrComplete.js +49 -0
- package/dist/es/components/wallets/GCash/GCash.js +20 -25
- package/dist/es/components/wallets/OpayWallet/OpayWallet.js +346 -0
- package/dist/es/components/wallets/OpayWallet/index.js +1 -0
- package/dist/es/components/wallets/OpayWallet/opay-wallet.js +1 -0
- package/dist/es/components/wallets/OpayWallet/type.js +1 -0
- package/dist/es/components/wallets/PagaWallet/PagaWallet.js +346 -0
- package/dist/es/components/wallets/PagaWallet/index.js +1 -0
- package/dist/es/components/wallets/PagaWallet/paga-wallet.js +1 -0
- package/dist/es/components/wallets/PagaWallet/type.js +1 -0
- package/dist/es/components/wallets/Paymaya/Paymaya.js +34 -40
- package/dist/es/components/wallets/PicPay/PicPay.js +346 -0
- package/dist/es/components/wallets/PicPay/index.js +1 -0
- package/dist/es/components/wallets/PicPay/pic-pay.js +1 -0
- package/dist/es/components/wallets/PicPay/type.js +1 -0
- package/dist/es/components/wallets/Pix/Pix.js +346 -0
- package/dist/es/components/wallets/Pix/index.js +1 -0
- package/dist/es/components/wallets/Pix/pix2.js +1 -0
- package/dist/es/components/wallets/Pix/type.js +1 -0
- package/dist/es/components/wallets/Vietqr/Vietqr.js +380 -0
- package/dist/es/components/wallets/Vietqr/index.js +1 -0
- package/dist/es/components/wallets/Vietqr/type.js +1 -0
- package/dist/es/components/wallets/Vietqr/vietqr2.js +1 -0
- package/dist/es/components/wallets/Zalopay/Zalopay.js +17 -21
- package/dist/es/components/wallets/index.js +8 -0
- package/dist/es/constant.js +32 -2
- package/dist/es/core/checkout.js +24 -1
- package/dist/es/core/create.js +1 -1
- package/dist/es/core/session.js +2 -23
- package/dist/es/core/theme.js +65 -0
- package/dist/es/core.js +34 -34
- package/dist/es/i18n/locales/de-DE.js +8 -2
- package/dist/es/i18n/locales/en-GB.js +8 -2
- package/dist/es/i18n/locales/es-ES.js +8 -2
- package/dist/es/i18n/locales/fr-FR.js +8 -2
- package/dist/es/i18n/locales/ja-JP.js +8 -2
- package/dist/es/i18n/locales/ko-KR.js +8 -2
- package/dist/es/i18n/locales/nl-NL.js +8 -2
- package/dist/es/i18n/locales/pt-PT.js +8 -2
- package/dist/es/i18n/locales/ru-RU.js +8 -2
- package/dist/es/i18n/locales/zh-CN.js +10 -4
- package/dist/es/i18n/locales/zh-HK.js +10 -4
- package/dist/es/i18n/locales/zh-TW.js +10 -4
- package/dist/es/index.js +17 -5
- package/dist/es/style.css +1 -1
- package/dist/es/utils/format.js +0 -5
- package/dist/es/utils/object.js +31 -1
- package/dist/es/utils/string.js +10 -0
- package/dist/es/utils/system-info/is-ua-webview.js +14 -12
- package/dist/es/utils/theme.js +7 -0
- package/dist/style.css +1 -1
- package/dist/types/api/modules/get-browser-params.d.ts +1 -0
- package/dist/types/api/modules/index.d.ts +5 -0
- package/dist/types/api/modules/opay-wallet/index.d.ts +4 -0
- package/dist/types/api/modules/paga-wallet/index.d.ts +4 -0
- package/dist/types/api/modules/pic-pay/index.d.ts +4 -0
- package/dist/types/api/modules/pix/index.d.ts +4 -0
- package/dist/types/api/modules/vietqr/index.d.ts +4 -0
- package/dist/types/components/DropIn/type.d.ts +3 -2
- package/dist/types/components/SecuredFieldsProvider/type.d.ts +5 -0
- package/dist/types/components/SecuredIframe/HiddenIframe.d.ts +3 -1
- package/dist/types/components/ThreeDS/components/ThreeDSAuth/type.d.ts +2 -0
- package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -3
- package/dist/types/components/internal/Loading/Loading.d.ts +1 -0
- package/dist/types/components/internal/Select/SelectMenu.d.ts +1 -1
- package/dist/types/components/internal/icons/IconOpayWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPagaWallet.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPicPay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconPix.d.ts +2 -0
- package/dist/types/components/internal/icons/IconVietqr.d.ts +2 -0
- package/dist/types/components/internal/icons/IconVietqrComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +6 -0
- package/dist/types/components/wallets/OpayWallet/OpayWallet.d.ts +10 -0
- package/dist/types/components/wallets/OpayWallet/index.d.ts +2 -0
- package/dist/types/components/wallets/OpayWallet/type.d.ts +40 -0
- package/dist/types/components/wallets/PagaWallet/PagaWallet.d.ts +10 -0
- package/dist/types/components/wallets/PagaWallet/index.d.ts +2 -0
- package/dist/types/components/wallets/PagaWallet/type.d.ts +40 -0
- package/dist/types/components/wallets/PicPay/PicPay.d.ts +10 -0
- package/dist/types/components/wallets/PicPay/index.d.ts +2 -0
- package/dist/types/components/wallets/PicPay/type.d.ts +40 -0
- package/dist/types/components/wallets/Pix/Pix.d.ts +10 -0
- package/dist/types/components/wallets/Pix/index.d.ts +2 -0
- package/dist/types/components/wallets/Pix/type.d.ts +40 -0
- package/dist/types/components/wallets/Vietqr/Vietqr.d.ts +10 -0
- package/dist/types/components/wallets/Vietqr/index.d.ts +2 -0
- package/dist/types/components/wallets/Vietqr/type.d.ts +39 -0
- package/dist/types/components/wallets/index.d.ts +8 -0
- package/dist/types/components/wallets/type.d.ts +9 -0
- package/dist/types/constant.d.ts +11 -1
- package/dist/types/core/checkout.d.ts +4 -0
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/session.d.ts +1 -11
- package/dist/types/core/theme.d.ts +7 -0
- package/dist/types/i18n/locales/de-DE.d.ts +6 -0
- package/dist/types/i18n/locales/en-GB.d.ts +6 -0
- package/dist/types/i18n/locales/es-ES.d.ts +6 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +6 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +6 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +6 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +6 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +6 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +6 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +6 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +6 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +6 -0
- package/dist/types/types/message.d.ts +29 -25
- package/dist/types/utils/index.d.ts +3 -2
- package/dist/types/utils/object.d.ts +7 -0
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/style.d.ts +1 -1
- package/dist/types/utils/system-info/is-ua-webview.d.ts +1 -1
- package/dist/types/utils/theme.d.ts +4 -0
- package/package.json +67 -67
- package/dist/es/utils/deep-freeze.js +0 -13
- package/dist/es/utils/obj.js +0 -22
- package/dist/types/utils/deep-freeze.d.ts +0 -1
- package/dist/types/utils/obj.d.ts +0 -6
|
@@ -1 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
const name = "@paykka/card-checkout-ui";
|
|
2
|
+
const version = "0.13.5";
|
|
3
|
+
const type = "module";
|
|
4
|
+
const main = "dist/paykka-card-checkout-ui.umd.js";
|
|
5
|
+
const module = "dist/es/index.js";
|
|
6
|
+
const typings = "dist/types/index.d.ts";
|
|
7
|
+
const exports = {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/es/index.js",
|
|
10
|
+
require: "./dist/paykka-card-checkout-ui.umd.js",
|
|
11
|
+
types: "./dist/types/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./*": "./dist/*"
|
|
14
|
+
};
|
|
15
|
+
const files = [
|
|
16
|
+
"dist"
|
|
17
|
+
];
|
|
18
|
+
const scripts = {
|
|
19
|
+
dev: "vite --host",
|
|
20
|
+
build: "pnpm type-check && pnpm build:npm && pnpm build:inner && pnpm copy-dist-to-cdn && pnpm build:outer",
|
|
21
|
+
"build:npm": "tsx ./build/run.ts",
|
|
22
|
+
"build:inner": "tsx ./build/runInner.ts",
|
|
23
|
+
"build:outer": "tsx ./build/runOuter.ts",
|
|
24
|
+
"build:type": "tsc -p ./tsconfig.build.json",
|
|
25
|
+
"copy-dist-to-cdn": "tsx ./build/copyDist2CDN.ts",
|
|
26
|
+
changeset: "changeset",
|
|
27
|
+
"changeset:pre": "changeset pre enter beta",
|
|
28
|
+
"changeset:pre-exit": "changeset pre exit",
|
|
29
|
+
"changeset:version": "changeset version",
|
|
30
|
+
"changeset:release": "changeset publish",
|
|
31
|
+
"changeset:prelease": "changeset publish --tag beta",
|
|
32
|
+
"release:prod": "pnpm build && pnpm changeset:release",
|
|
33
|
+
"release:noprod": "pnpm build && pnpm changeset:pre-exit && pnpm changeset:prelease",
|
|
34
|
+
"type-check": "tsc --noEmit -p tsconfig.json --composite false",
|
|
35
|
+
"release:npm": "node scripts/release-npm.cjs"
|
|
36
|
+
};
|
|
37
|
+
const publishConfig = {
|
|
38
|
+
registry: "https://packages.aliyun.com/640edee5a84870ae9d591e48/npm/npm-registry/"
|
|
39
|
+
};
|
|
40
|
+
const dependencies = {
|
|
41
|
+
"@ctrl/tinycolor": "^4.0.3",
|
|
42
|
+
"@fingerprintjs/fingerprintjs": "^4.2.2",
|
|
43
|
+
"@preact/signals": "^1.3.0",
|
|
44
|
+
"@types/applepayjs": "^14.0.9",
|
|
45
|
+
"@types/googlepay": "^0.7.7",
|
|
46
|
+
"@types/qrcode": "^1.5.5",
|
|
47
|
+
preact: "^10.24.3",
|
|
48
|
+
qrcode: "^1.5.4",
|
|
49
|
+
"ts-toolbelt": "^9.6.0",
|
|
50
|
+
unfetch: "^5.0.0",
|
|
51
|
+
"vue-tsc": "^2.1.10"
|
|
52
|
+
};
|
|
53
|
+
const devDependencies = {
|
|
54
|
+
"@changesets/cli": "^2.27.1",
|
|
55
|
+
"@preact/preset-vite": "^2.9.1",
|
|
56
|
+
"@types/node": "^20.12.7",
|
|
57
|
+
autoprefixer: "^10.4.18",
|
|
58
|
+
execa: "^8.0.1",
|
|
59
|
+
"fast-glob": "^3.3.2",
|
|
60
|
+
sass: "^1.71.1",
|
|
61
|
+
terser: "^5.42.0",
|
|
62
|
+
tsx: "^4.7.3",
|
|
63
|
+
typescript: "^5.4.5",
|
|
64
|
+
vite: "^5.2.10"
|
|
65
|
+
};
|
|
66
|
+
const packageJson = {
|
|
67
|
+
name,
|
|
68
|
+
version,
|
|
69
|
+
type,
|
|
70
|
+
main,
|
|
71
|
+
module,
|
|
72
|
+
typings,
|
|
73
|
+
exports,
|
|
74
|
+
files,
|
|
75
|
+
scripts,
|
|
76
|
+
publishConfig,
|
|
77
|
+
dependencies,
|
|
78
|
+
devDependencies
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
packageJson
|
|
82
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../../utils/card-brand/brands.js";
|
|
2
2
|
import { getBrowser } from "../../utils/system-info/index.js";
|
|
3
|
+
import { packageJson } from "../../_commonjsHelpers.js";
|
|
3
4
|
import { isUaWebview } from "../../utils/system-info/is-ua-webview.js";
|
|
4
5
|
const getBrowserParams = async (params = {}) => {
|
|
5
6
|
const { fraudDetectionId } = params;
|
|
@@ -30,7 +31,9 @@ const getBrowserParams = async (params = {}) => {
|
|
|
30
31
|
device_os: browser.osName,
|
|
31
32
|
device_finger_print_id: browser.deviceFingerprintId,
|
|
32
33
|
terminal_type: terminalType,
|
|
33
|
-
fraud_detection_id: fraudDetectionId
|
|
34
|
+
fraud_detection_id: fraudDetectionId,
|
|
35
|
+
// 当前组件库版本
|
|
36
|
+
app_version: packageJson.version
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
export {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
+
import { http } from "../../http.js";
|
|
4
|
+
import { payResMap } from "../map.js";
|
|
5
|
+
const opayWalletPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getOpayWalletPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getOpayWalletPayInfo,
|
|
15
|
+
opayWalletPay
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
+
import { http } from "../../http.js";
|
|
4
|
+
import { payResMap } from "../map.js";
|
|
5
|
+
const pagaWalletPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getPagaWalletPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getPagaWalletPayInfo,
|
|
15
|
+
pagaWalletPay
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
+
import { http } from "../../http.js";
|
|
4
|
+
import { payResMap } from "../map.js";
|
|
5
|
+
const picPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getPicPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getPicPayInfo,
|
|
15
|
+
picPay
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
3
|
+
import { http } from "../../http.js";
|
|
4
|
+
import { payResMap } from "../map.js";
|
|
5
|
+
const pixPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getPixPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
getPixPayInfo,
|
|
15
|
+
pixPay
|
|
16
|
+
};
|
|
@@ -3,7 +3,7 @@ import { isTimeoutError } from "../../api/http.js";
|
|
|
3
3
|
import { getAliPayInfo, aliPay } from "../../api/modules/ali-pay/index.js";
|
|
4
4
|
import "../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import {
|
|
6
|
+
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
7
|
import { formatPaymentResult } from "../../utils/payment.js";
|
|
8
8
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
9
|
import { COMMON_CLASS_NAME, PaymentType, PaymentMethod, SessionMode } from "../../constant.js";
|
|
@@ -24,7 +24,6 @@ import { SubmitButton } from "../SubmitButton/index.js";
|
|
|
24
24
|
const { bem } = useBEM("ali-pay");
|
|
25
25
|
const fieldClassNames = bem("field");
|
|
26
26
|
const AliPay = w((props, ref) => {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f;
|
|
28
27
|
const { session, core, showEmail = false, showAddress = false } = props;
|
|
29
28
|
const addressCore = core.getAddressCore();
|
|
30
29
|
const emailState = createEmailCore();
|
|
@@ -58,27 +57,27 @@ const AliPay = w((props, ref) => {
|
|
|
58
57
|
startReFetchPayInfo({ timeout });
|
|
59
58
|
},
|
|
60
59
|
updateAddress: () => {
|
|
61
|
-
var
|
|
60
|
+
var _a;
|
|
62
61
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
63
62
|
return;
|
|
64
63
|
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
65
64
|
setForm(newForm);
|
|
66
|
-
(
|
|
65
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
67
66
|
validateForm();
|
|
68
67
|
},
|
|
69
68
|
updateEmail: () => {
|
|
70
|
-
var
|
|
69
|
+
var _a;
|
|
71
70
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
72
71
|
return;
|
|
73
72
|
const newForm = Object.assign(form, { email: emailState.email });
|
|
74
73
|
setForm(newForm);
|
|
75
|
-
(
|
|
74
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
76
75
|
validateForm();
|
|
77
76
|
}
|
|
78
77
|
}));
|
|
79
78
|
function validateForm() {
|
|
80
|
-
var
|
|
81
|
-
(
|
|
79
|
+
var _a;
|
|
80
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
82
81
|
setValidated(true);
|
|
83
82
|
}).catch(() => {
|
|
84
83
|
setValidated(false);
|
|
@@ -101,13 +100,13 @@ const AliPay = w((props, ref) => {
|
|
|
101
100
|
validateForm();
|
|
102
101
|
}, [form]);
|
|
103
102
|
const processOnSuccess = (res) => {
|
|
104
|
-
var
|
|
103
|
+
var _a, _b;
|
|
105
104
|
setSubmitButtonStatus("success");
|
|
106
|
-
(
|
|
105
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(
|
|
107
106
|
props,
|
|
108
107
|
formatPaymentResult({
|
|
109
108
|
...res,
|
|
110
|
-
returnUrl: (
|
|
109
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
111
110
|
})
|
|
112
111
|
);
|
|
113
112
|
};
|
|
@@ -127,10 +126,10 @@ const AliPay = w((props, ref) => {
|
|
|
127
126
|
}, [sessionReady]);
|
|
128
127
|
const onTimeout = q(
|
|
129
128
|
(message) => {
|
|
130
|
-
var
|
|
129
|
+
var _a;
|
|
131
130
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
132
131
|
setSubmitButtonStatus("unSubmit");
|
|
133
|
-
(
|
|
132
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props, "retry");
|
|
134
133
|
},
|
|
135
134
|
[i18n, props.onTimeout]
|
|
136
135
|
);
|
|
@@ -163,12 +162,12 @@ const AliPay = w((props, ref) => {
|
|
|
163
162
|
};
|
|
164
163
|
};
|
|
165
164
|
async function pay(search = false, timeout) {
|
|
166
|
-
var
|
|
165
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
167
166
|
try {
|
|
168
167
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
169
168
|
let res = null;
|
|
170
169
|
if (search) {
|
|
171
|
-
const extraParams = (
|
|
170
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.ALI_PAY);
|
|
172
171
|
res = await getAliPayInfo(
|
|
173
172
|
{
|
|
174
173
|
sessionId: session.sessionId,
|
|
@@ -179,12 +178,12 @@ const AliPay = w((props, ref) => {
|
|
|
179
178
|
requestOptions
|
|
180
179
|
);
|
|
181
180
|
} else {
|
|
182
|
-
const extraParams = (
|
|
181
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.ALI_PAY);
|
|
183
182
|
res = await aliPay(await getPaymentParams(), extraParams, requestOptions);
|
|
184
183
|
}
|
|
185
184
|
const { status, orderStatus, errorMessage, errorCode, sessionId } = res;
|
|
186
185
|
sessionId && (session.sessionId = sessionId);
|
|
187
|
-
!search && ((
|
|
186
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
188
187
|
if (status === "PROCESSING") {
|
|
189
188
|
if (!orderStatus) {
|
|
190
189
|
setSubmitButtonStatus("unSubmit");
|
|
@@ -195,7 +194,7 @@ const AliPay = w((props, ref) => {
|
|
|
195
194
|
} else if (orderStatus === "FAILURE") {
|
|
196
195
|
errorMessage && setErrorMsg(errorMessage);
|
|
197
196
|
setSubmitButtonStatus("unSubmit");
|
|
198
|
-
(
|
|
197
|
+
(_f = props.onError) == null ? void 0 : _f.call(props, new PayKKaError("API_ERROR", errorMessage, { code: errorCode }));
|
|
199
198
|
return { end: true };
|
|
200
199
|
} else if (orderStatus === "PROCESSING") {
|
|
201
200
|
!search && startReFetchPayInfo();
|
|
@@ -233,12 +232,12 @@ const AliPay = w((props, ref) => {
|
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
async function onSubmit() {
|
|
236
|
-
var
|
|
235
|
+
var _a;
|
|
237
236
|
setErrorMsg("");
|
|
238
|
-
(
|
|
239
|
-
var
|
|
237
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
238
|
+
var _a2;
|
|
240
239
|
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
241
|
-
(
|
|
240
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
242
241
|
if (errors) {
|
|
243
242
|
setSubmitButtonStatus("unSubmit");
|
|
244
243
|
return;
|
|
@@ -271,13 +270,6 @@ const AliPay = w((props, ref) => {
|
|
|
271
270
|
formRef.current = dom;
|
|
272
271
|
dom && validateForm();
|
|
273
272
|
};
|
|
274
|
-
const formStyle = {
|
|
275
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
276
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
277
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
278
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
279
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
280
|
-
};
|
|
281
273
|
const Email = () => {
|
|
282
274
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.email.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
283
275
|
EmailField,
|
|
@@ -289,13 +281,13 @@ const AliPay = w((props, ref) => {
|
|
|
289
281
|
) }) });
|
|
290
282
|
};
|
|
291
283
|
const Address = () => {
|
|
292
|
-
var
|
|
284
|
+
var _a, _b;
|
|
293
285
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
294
286
|
AddressField,
|
|
295
287
|
{
|
|
296
288
|
ref: addressFieldRef,
|
|
297
289
|
value: form.address,
|
|
298
|
-
country: ((
|
|
290
|
+
country: ((_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
|
|
299
291
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
300
292
|
}
|
|
301
293
|
) }) });
|
|
@@ -308,13 +300,15 @@ const AliPay = w((props, ref) => {
|
|
|
308
300
|
session,
|
|
309
301
|
core
|
|
310
302
|
},
|
|
311
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
303
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: /* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
312
304
|
Email(),
|
|
313
305
|
Address(),
|
|
314
306
|
(session == null ? void 0 : session.checkout.paymentType) === PaymentType.RECURRING && RecurringTip(),
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
307
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
308
|
+
!!errorMsg && /* @__PURE__ */ u(Info, { className: bem("error"), content: errorMsg }),
|
|
309
|
+
Button()
|
|
310
|
+
] })
|
|
311
|
+
] }) }) })
|
|
318
312
|
}
|
|
319
313
|
);
|
|
320
314
|
});
|
|
@@ -3,7 +3,7 @@ import { useBEM } from "../../hooks/useBEM.js";
|
|
|
3
3
|
import { CoreContext } from "../../core/context.js";
|
|
4
4
|
import "../../utils/card-brand/brands.js";
|
|
5
5
|
import "../../utils/system-info/get-browser-info.js";
|
|
6
|
-
import {
|
|
6
|
+
import { normalizedClass, formatAmount } from "../../utils/format.js";
|
|
7
7
|
import { redirectToPayment } from "../../utils/redirect.js";
|
|
8
8
|
import { formatPaymentResult } from "../../utils/payment.js";
|
|
9
9
|
import { isTimeoutError } from "../../api/http.js";
|
|
@@ -25,7 +25,6 @@ import { GuideCard } from "../GuideCard/index.js";
|
|
|
25
25
|
const { bem } = useBEM("boost");
|
|
26
26
|
const fieldClassNames = bem("field");
|
|
27
27
|
const Boost = w((props, ref) => {
|
|
28
|
-
var _a, _b, _c, _d, _e, _f;
|
|
29
28
|
const {
|
|
30
29
|
session,
|
|
31
30
|
showEmail = false,
|
|
@@ -46,21 +45,21 @@ const Boost = w((props, ref) => {
|
|
|
46
45
|
startReFetchPayInfo({ timeout });
|
|
47
46
|
},
|
|
48
47
|
updateAddress: () => {
|
|
49
|
-
var
|
|
48
|
+
var _a;
|
|
50
49
|
if (!(fieldStatus == null ? void 0 : fieldStatus.address.show))
|
|
51
50
|
return;
|
|
52
51
|
const newForm = Object.assign(form, { address: addressCore.getAddressState() });
|
|
53
52
|
setForm(newForm);
|
|
54
|
-
(
|
|
53
|
+
(_a = addressFieldRef.current) == null ? void 0 : _a.update(addressCore.getAddressState());
|
|
55
54
|
validateForm();
|
|
56
55
|
},
|
|
57
56
|
updateEmail: () => {
|
|
58
|
-
var
|
|
57
|
+
var _a;
|
|
59
58
|
if (!(fieldStatus == null ? void 0 : fieldStatus.email.show))
|
|
60
59
|
return;
|
|
61
60
|
const newForm = Object.assign(form, { email: emailState.email });
|
|
62
61
|
setForm(newForm);
|
|
63
|
-
(
|
|
62
|
+
(_a = emailFieldRef.current) == null ? void 0 : _a.update(emailState.email);
|
|
64
63
|
validateForm();
|
|
65
64
|
},
|
|
66
65
|
payment: () => {
|
|
@@ -103,11 +102,11 @@ const Boost = w((props, ref) => {
|
|
|
103
102
|
setFieldStatus({ ...field });
|
|
104
103
|
};
|
|
105
104
|
const processOnSuccess = (res) => {
|
|
106
|
-
var
|
|
105
|
+
var _a, _b;
|
|
107
106
|
setSubmitButtonStatus("success");
|
|
108
|
-
(
|
|
107
|
+
(_b = props.onSuccess) == null ? void 0 : _b.call(props, formatPaymentResult({
|
|
109
108
|
...res,
|
|
110
|
-
returnUrl: (
|
|
109
|
+
returnUrl: (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.returnUrl
|
|
111
110
|
}));
|
|
112
111
|
};
|
|
113
112
|
y(() => {
|
|
@@ -129,16 +128,16 @@ const Boost = w((props, ref) => {
|
|
|
129
128
|
}
|
|
130
129
|
}, [sessionReady]);
|
|
131
130
|
const processOnError = (error) => {
|
|
132
|
-
var
|
|
133
|
-
(
|
|
131
|
+
var _a;
|
|
132
|
+
(_a = props.onError) == null ? void 0 : _a.call(props, error);
|
|
134
133
|
core.resetEnablePaymentMethod();
|
|
135
134
|
};
|
|
136
135
|
const onTimeout = q(
|
|
137
136
|
(message) => {
|
|
138
|
-
var
|
|
137
|
+
var _a;
|
|
139
138
|
setErrorMsg(message || i18n.get("common.payTimeout"));
|
|
140
139
|
setSubmitButtonStatus("unSubmit");
|
|
141
|
-
(
|
|
140
|
+
(_a = props.onTimeout) == null ? void 0 : _a.call(props);
|
|
142
141
|
core.resetEnablePaymentMethod();
|
|
143
142
|
},
|
|
144
143
|
[i18n, props.onTimeout]
|
|
@@ -168,12 +167,12 @@ const Boost = w((props, ref) => {
|
|
|
168
167
|
};
|
|
169
168
|
};
|
|
170
169
|
const pay = async (search = false, timeout) => {
|
|
171
|
-
var
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
172
171
|
try {
|
|
173
172
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
174
173
|
let res = null;
|
|
175
174
|
if (search) {
|
|
176
|
-
const extraParams = (
|
|
175
|
+
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", PaymentMethod.BOOST);
|
|
177
176
|
res = await getBoostPayInfo(
|
|
178
177
|
{
|
|
179
178
|
sessionId: session.sessionId,
|
|
@@ -184,10 +183,10 @@ const Boost = w((props, ref) => {
|
|
|
184
183
|
requestOptions
|
|
185
184
|
);
|
|
186
185
|
} else {
|
|
187
|
-
const extraParams = (
|
|
186
|
+
const extraParams = (_d = (_c = core.config)._getExtraParams) == null ? void 0 : _d.call(_c, "payment", PaymentMethod.BOOST);
|
|
188
187
|
res = await boostPay(await getPaymentParams(), extraParams, requestOptions);
|
|
189
188
|
}
|
|
190
|
-
!search && ((
|
|
189
|
+
!search && ((_e = props.onSubmitResponse) == null ? void 0 : _e.call(props, res));
|
|
191
190
|
const { status, orderStatus, errorMessage, errorCode, payInfo, sessionId } = res;
|
|
192
191
|
sessionId && (session.sessionId = sessionId);
|
|
193
192
|
if (status === "PROCESSING") {
|
|
@@ -214,7 +213,7 @@ const Boost = w((props, ref) => {
|
|
|
214
213
|
return { end: false };
|
|
215
214
|
} else if (orderStatus === "CANCELED") {
|
|
216
215
|
setSubmitButtonStatus("unSubmit");
|
|
217
|
-
(
|
|
216
|
+
(_f = props.onTimeout) == null ? void 0 : _f.call(props);
|
|
218
217
|
core.resetEnablePaymentMethod();
|
|
219
218
|
return { end: true };
|
|
220
219
|
}
|
|
@@ -246,8 +245,8 @@ const Boost = w((props, ref) => {
|
|
|
246
245
|
}
|
|
247
246
|
};
|
|
248
247
|
const validateForm = () => {
|
|
249
|
-
var
|
|
250
|
-
(
|
|
248
|
+
var _a;
|
|
249
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(void 0, false).then(() => {
|
|
251
250
|
setValidated(true);
|
|
252
251
|
}).catch(() => {
|
|
253
252
|
setValidated(false);
|
|
@@ -257,12 +256,12 @@ const Boost = w((props, ref) => {
|
|
|
257
256
|
validateForm();
|
|
258
257
|
}, [form]);
|
|
259
258
|
const onSubmit = async () => {
|
|
260
|
-
var
|
|
259
|
+
var _a;
|
|
261
260
|
setErrorMsg("");
|
|
262
|
-
(
|
|
263
|
-
var
|
|
261
|
+
(_a = formRef.current) == null ? void 0 : _a.validate(async (errors) => {
|
|
262
|
+
var _a2;
|
|
264
263
|
(fieldStatus == null ? void 0 : fieldStatus.address.show) && addressCore.setValidateAllFields(true);
|
|
265
|
-
(
|
|
264
|
+
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, errors);
|
|
266
265
|
if (errors) {
|
|
267
266
|
setSubmitButtonStatus("unSubmit");
|
|
268
267
|
return;
|
|
@@ -277,8 +276,8 @@ const Boost = w((props, ref) => {
|
|
|
277
276
|
dom && validateForm();
|
|
278
277
|
};
|
|
279
278
|
const Button = () => {
|
|
280
|
-
var
|
|
281
|
-
const transAmount = (
|
|
279
|
+
var _a;
|
|
280
|
+
const transAmount = (_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.transAmount;
|
|
282
281
|
const amountText = (transAmount == null ? void 0 : transAmount.amount) ? formatAmount(transAmount).jointSymbol() : "";
|
|
283
282
|
const text = i18n.get("common.pay") + (amountText ? ` ${amountText}` : "");
|
|
284
283
|
return /* @__PURE__ */ u(
|
|
@@ -304,24 +303,17 @@ const Boost = w((props, ref) => {
|
|
|
304
303
|
}
|
|
305
304
|
) }) });
|
|
306
305
|
};
|
|
307
|
-
const formStyle = {
|
|
308
|
-
[cssVarPrefix("button-bg-color")]: (_a = session == null ? void 0 : session.colors) == null ? void 0 : _a.primary,
|
|
309
|
-
[cssVarPrefix("button-bg-color-hover")]: (_b = session == null ? void 0 : session.colors) == null ? void 0 : _b.primaryHover,
|
|
310
|
-
[cssVarPrefix("button-bg-color-active")]: (_c = session == null ? void 0 : session.colors) == null ? void 0 : _c.primaryActive,
|
|
311
|
-
[cssVarPrefix("button-text-color")]: (_e = (_d = session == null ? void 0 : session.checkout) == null ? void 0 : _d.theme) == null ? void 0 : _e.payButtonTextColor,
|
|
312
|
-
[cssVarPrefix("input-color")]: (_f = session == null ? void 0 : session.colors) == null ? void 0 : _f.primary
|
|
313
|
-
};
|
|
314
306
|
const ErrorMessage = () => {
|
|
315
|
-
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg
|
|
307
|
+
return /* @__PURE__ */ u(b, { children: !!errorMsg && /* @__PURE__ */ u(Info, { content: errorMsg }) });
|
|
316
308
|
};
|
|
317
309
|
const Address = () => {
|
|
318
|
-
var
|
|
310
|
+
var _a, _b;
|
|
319
311
|
return /* @__PURE__ */ u(b, { children: (fieldStatus == null ? void 0 : fieldStatus.address.show) && /* @__PURE__ */ u("div", { className: fieldClassNames, children: /* @__PURE__ */ u(
|
|
320
312
|
AddressField,
|
|
321
313
|
{
|
|
322
314
|
ref: addressFieldRef,
|
|
323
315
|
value: form.address,
|
|
324
|
-
country: ((
|
|
316
|
+
country: ((_a = session == null ? void 0 : session.checkout) == null ? void 0 : _a.country) || ((_b = session == null ? void 0 : session.checkout) == null ? void 0 : _b.bill.country),
|
|
325
317
|
onAddressChange: (value) => setForm(Object.assign(form, { address: value }))
|
|
326
318
|
}
|
|
327
319
|
) }) });
|
|
@@ -334,13 +326,15 @@ const Boost = w((props, ref) => {
|
|
|
334
326
|
session,
|
|
335
327
|
core
|
|
336
328
|
},
|
|
337
|
-
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u(
|
|
329
|
+
children: isCheckoutEnabled && i18n.ready.value && /* @__PURE__ */ u("div", { className: core.theme.className, children: [
|
|
338
330
|
showGuideCard && /* @__PURE__ */ u(GuideCard, { type: PaymentCategory.BOOST }),
|
|
339
|
-
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()),
|
|
331
|
+
/* @__PURE__ */ u(Form, { form, ref: setFormRef, onFormChange: (form2) => setForm(form2), children: /* @__PURE__ */ u("div", { className: normalizedClass(COMMON_CLASS_NAME, bem()), children: [
|
|
340
332
|
Email(),
|
|
341
333
|
Address(),
|
|
342
|
-
|
|
343
|
-
|
|
334
|
+
/* @__PURE__ */ u("div", { className: bem("footer-wrapper"), children: [
|
|
335
|
+
ErrorMessage(),
|
|
336
|
+
!hidePaymentButton && Button()
|
|
337
|
+
] })
|
|
344
338
|
] }) })
|
|
345
339
|
] })
|
|
346
340
|
}
|