@paykka/card-checkout-ui 0.15.2 → 0.16.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 +15 -15
- package/dist/card-checkout-ui.umd.cjs +15 -15
- package/dist/es/api/http.js +12 -1
- package/dist/es/api/modules/apple-pay/index.js +0 -12
- package/dist/es/api/modules/common/index.js +29 -0
- package/dist/es/api/modules/get-browser-params.js +1 -1
- package/dist/es/api/modules/index.js +1 -1
- package/dist/es/api/modules/threeDS/index.js +1 -1
- package/dist/es/api/utils/index.js +3 -0
- package/dist/es/components/AccountNameField/index.js +2 -2
- package/dist/es/components/AddressField/index.js +2 -2
- package/dist/es/components/ApplePay/index.js +26 -10
- package/dist/es/components/CPFField/index.js +2 -2
- package/dist/es/components/Card/index.js +20 -6
- package/dist/es/components/CardHolderNameField/index.js +2 -2
- package/dist/es/components/CardSecurityCodeField/index.js +2 -2
- package/dist/es/components/CombinedCardInfo/index.js +3 -3
- package/dist/es/components/EmailField/EmailField.js +2 -2
- package/dist/es/components/EncryptedCard/index.js +1 -1
- package/dist/es/components/GooglePay/index.js +35 -21
- package/dist/es/components/SecuredFieldsProvider/index.js +2 -0
- package/dist/es/components/SecuredIframe/index.js +19 -10
- package/dist/es/components/Sepa/index.js +21 -6
- package/dist/es/components/business/BlikConfirmModal/BlikConfirmModal.js +1 -1
- package/dist/es/components/business/NameField/NameField.js +2 -2
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +1 -1
- package/dist/es/components/business/SegmentedDigitInput/format.js +3 -0
- package/dist/es/components/business/SegmentedDigitInput/index.js +2 -0
- package/dist/es/components/internal/Accordion/accordionTransition.js +3 -0
- package/dist/es/components/internal/Form/Form.js +2 -0
- package/dist/es/components/internal/Form/FormItem.js +2 -0
- package/dist/es/components/internal/Input/Input.js +2 -0
- package/dist/es/components/internal/icons/Icon3DSFail.js +2 -0
- package/dist/es/components/internal/icons/Icon3DSInfo.js +2 -0
- package/dist/es/components/internal/icons/Icon3DSSuccess.js +2 -0
- package/dist/es/components/internal/icons/IconAdd.js +2 -0
- package/dist/es/components/internal/icons/IconAlipayPlus.js +2 -0
- package/dist/es/components/internal/icons/IconAmex.js +2 -0
- package/dist/es/components/internal/icons/IconArrowDown.js +2 -0
- package/dist/es/components/internal/icons/IconBancontact.js +2 -0
- package/dist/es/components/internal/icons/IconBlik.js +2 -0
- package/dist/es/components/internal/icons/IconBoost.js +2 -0
- package/dist/es/components/internal/icons/IconCard.js +2 -0
- package/dist/es/components/internal/icons/IconCard2.js +2 -0
- package/dist/es/components/internal/icons/IconCardNo.js +2 -0
- package/dist/es/components/internal/icons/IconDinnersClub.js +2 -0
- package/dist/es/components/internal/icons/IconDiscover.js +2 -0
- package/dist/es/components/internal/icons/IconError.js +2 -0
- package/dist/es/components/internal/icons/IconGCash.js +2 -0
- package/dist/es/components/internal/icons/IconGcashComplete.js +2 -0
- package/dist/es/components/internal/icons/IconGrabPay.js +2 -0
- package/dist/es/components/internal/icons/IconIdeal.js +2 -0
- package/dist/es/components/internal/icons/IconInfo.js +2 -0
- package/dist/es/components/internal/icons/IconJcb.js +2 -0
- package/dist/es/components/internal/icons/IconLinePay.js +2 -0
- package/dist/es/components/internal/icons/IconMasterCard.js +2 -0
- package/dist/es/components/internal/icons/IconMayBankQRPay.js +2 -0
- package/dist/es/components/internal/icons/IconNinePay.js +2 -0
- package/dist/es/components/internal/icons/IconOpayWallet.js +2 -0
- package/dist/es/components/internal/icons/IconOvo.js +2 -0
- package/dist/es/components/internal/icons/IconP24.js +2 -0
- package/dist/es/components/internal/icons/IconPagaWallet.js +2 -0
- package/dist/es/components/internal/icons/IconPaymaya.js +2 -0
- package/dist/es/components/internal/icons/IconPhone.js +2 -0
- package/dist/es/components/internal/icons/IconPicPay.js +2 -0
- package/dist/es/components/internal/icons/IconPix.js +2 -0
- package/dist/es/components/internal/icons/IconRedirect.js +2 -0
- package/dist/es/components/internal/icons/IconSafe.js +2 -0
- package/dist/es/components/internal/icons/IconScan.js +2 -0
- package/dist/es/components/internal/icons/IconShopeePay.js +2 -0
- package/dist/es/components/internal/icons/IconSkrill.js +2 -0
- package/dist/es/components/internal/icons/IconSuccess.js +2 -0
- package/dist/es/components/internal/icons/IconSwitch.js +2 -0
- package/dist/es/components/internal/icons/IconTNGWallet.js +2 -0
- package/dist/es/components/internal/icons/IconTick.js +2 -0
- package/dist/es/components/internal/icons/IconTrustly.js +2 -0
- package/dist/es/components/internal/icons/IconUnionPay.js +2 -0
- package/dist/es/components/internal/icons/IconVietqr.js +2 -0
- package/dist/es/components/internal/icons/IconVietqrComplete.js +2 -0
- package/dist/es/components/internal/icons/IconVisa.js +2 -0
- package/dist/es/components/internal/icons/IconWechatPayGlobal.js +2 -0
- package/dist/es/components/internal/icons/IconWechatPayGlobalComplete.js +2 -0
- package/dist/es/components/internal/icons/IconZalopay.js +2 -0
- package/dist/es/components/internal/icons/IconZalopayComplete.js +2 -0
- package/dist/es/components/internal/icons/iconChecked.js +2 -0
- package/dist/es/components/internal/icons/index.js +2 -0
- package/dist/es/components/wallets/WechatPay/WechatPay.js +5 -10
- package/dist/es/config.js +2 -0
- package/dist/es/core/address.js +3 -0
- package/dist/es/core/checkout.js +3 -2
- package/dist/es/core/create.js +2 -0
- package/dist/es/core/logger.js +4 -1
- package/dist/es/core/payment.js +2 -0
- package/dist/es/core/query.js +1 -1
- package/dist/es/core.js +36 -36
- package/dist/es/hooks/useBEM.js +3 -0
- package/dist/es/hooks/useBaseWallet.js +45 -9
- package/dist/es/hooks/usePayState.js +1 -0
- package/dist/es/i18n/I18n.js +2 -0
- package/dist/es/i18n/index.js +2 -0
- package/dist/es/i18n/locales/de-DE.js +1 -1
- package/dist/es/i18n/locales/en-GB.js +1 -1
- package/dist/es/i18n/locales/es-ES.js +1 -1
- package/dist/es/i18n/locales/fr-FR.js +1 -1
- package/dist/es/i18n/locales/ja-JP.js +1 -1
- package/dist/es/i18n/locales/ko-KR.js +1 -1
- package/dist/es/i18n/locales/nl-NL.js +1 -1
- package/dist/es/i18n/locales/pt-PT.js +1 -1
- package/dist/es/i18n/locales/ru-RU.js +1 -1
- package/dist/es/i18n/locales/zh-CN.js +1 -1
- package/dist/es/i18n/locales/zh-HK.js +1 -1
- package/dist/es/i18n/locales/zh-TW.js +1 -1
- package/dist/es/i18n/util.js +3 -0
- package/dist/es/index.js +1 -1
- package/dist/es/utils/bem.js +3 -0
- package/dist/es/utils/card-brand/brands.js +2 -0
- package/dist/es/utils/index.js +3 -0
- package/dist/es/utils/payment.js +76 -1
- package/dist/types/api/http.d.ts +6 -1
- package/dist/types/api/modules/apple-pay/index.d.ts +0 -3
- package/dist/types/api/modules/common/index.d.ts +39 -0
- package/dist/types/api/modules/index.d.ts +1 -4
- package/dist/types/hooks/useBaseWallet.d.ts +16 -4
- package/dist/types/utils/payment.d.ts +13 -2
- package/package.json +1 -1
- package/dist/es/api/modules/card/index.js +0 -16
- package/dist/es/api/modules/google-pay/index.js +0 -16
- package/dist/es/api/modules/sepa/index.js +0 -16
- package/dist/es/api/modules/wallet/index.js +0 -16
- package/dist/types/api/modules/card/index.d.ts +0 -4
- package/dist/types/api/modules/google-pay/index.d.ts +0 -4
- package/dist/types/api/modules/sepa/index.d.ts +0 -4
- package/dist/types/api/modules/wallet/index.d.ts +0 -18
package/dist/es/api/http.js
CHANGED
|
@@ -6,8 +6,19 @@ import { getFetch } from "./fetch.js";
|
|
|
6
6
|
import { PayKKaError, EPayKKaError } from "../core/error.js";
|
|
7
7
|
import "../out/fraud-detection.js";
|
|
8
8
|
import { getBrowserInfo } from "../utils/system-info/get-browser-info.js";
|
|
9
|
-
const request = async (method, url, params, { timeout = 2e4, headers, locale } = {}) => {
|
|
9
|
+
const request = async (method, url, params, { timeout = 2e4, headers, locale, signal } = {}) => {
|
|
10
10
|
const abortController = new AbortController();
|
|
11
|
+
if (signal) {
|
|
12
|
+
if (signal.aborted) {
|
|
13
|
+
abortController.abort(signal.reason);
|
|
14
|
+
} else {
|
|
15
|
+
signal.addEventListener(
|
|
16
|
+
"abort",
|
|
17
|
+
() => abortController.abort(signal.reason),
|
|
18
|
+
{ once: true }
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
11
22
|
const timer = setTimeout(() => {
|
|
12
23
|
abortController.abort();
|
|
13
24
|
}, timeout);
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import { apiPrefix } from "../../../config.js";
|
|
2
2
|
import { http } from "../../http.js";
|
|
3
|
-
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
4
|
-
import { payResMap } from "../map.js";
|
|
5
3
|
const getMerchantSession = async (options) => {
|
|
6
4
|
return http.post(`${apiPrefix}/apple-pay/create-session`, options);
|
|
7
5
|
};
|
|
8
|
-
const applePay = async (params, extraParams, options) => {
|
|
9
|
-
const paymentParams = buildPaymentParams(params, extraParams);
|
|
10
|
-
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
11
|
-
};
|
|
12
|
-
const getApplePayInfo = async (params, extraParams, options) => {
|
|
13
|
-
const queryParams = buildQueryParams(params, extraParams);
|
|
14
|
-
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
15
|
-
};
|
|
16
6
|
export {
|
|
17
|
-
applePay,
|
|
18
|
-
getApplePayInfo,
|
|
19
7
|
getMerchantSession
|
|
20
8
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
|
+
import "../../../utils/card-brand/brands.js";
|
|
3
|
+
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
+
import { payWithCheckpoints } from "../../../utils/payment.js";
|
|
5
|
+
import { http } from "../../http.js";
|
|
6
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
7
|
+
import { payResMap } from "../map.js";
|
|
8
|
+
const commonPayment = async (config) => {
|
|
9
|
+
const { params, extraParams, options: { request, query } = {} } = config;
|
|
10
|
+
if (query == null ? void 0 : query.enable) {
|
|
11
|
+
return payWithCheckpoints(
|
|
12
|
+
(signal) => doCommonPayment(params, extraParams, { ...request, signal }),
|
|
13
|
+
(timeout, signal) => commonPaymentQuery(query.params, query.extraParams, { ...request, timeout, signal })
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return doCommonPayment(params, extraParams, request);
|
|
17
|
+
};
|
|
18
|
+
const doCommonPayment = async (params, extraParams, options) => {
|
|
19
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
20
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
21
|
+
};
|
|
22
|
+
const commonPaymentQuery = async (params, extraParams, options) => {
|
|
23
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
24
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
commonPayment,
|
|
28
|
+
commonPaymentQuery
|
|
29
|
+
};
|
|
@@ -35,7 +35,7 @@ const getBaseBrowserParams = async (params = {}) => {
|
|
|
35
35
|
terminal_type: terminalType,
|
|
36
36
|
fraud_detection_id: fraudDetectionId,
|
|
37
37
|
// 当前组件库版本(构建时由 define 注入)
|
|
38
|
-
app_version: "0.
|
|
38
|
+
app_version: "0.16.0"
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
const getBrowserParams = async (params = {}) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../../../utils/card-brand/brands.js";
|
|
2
2
|
import "../../../utils/system-info/get-browser-info.js";
|
|
3
|
-
import "../../../core.js";
|
|
4
3
|
import { http } from "../../http.js";
|
|
4
|
+
import "../../../core.js";
|
|
5
5
|
var ThreeDSAuthOperate = /* @__PURE__ */ ((ThreeDSAuthOperate2) => {
|
|
6
6
|
ThreeDSAuthOperate2["OPEN"] = "OPEN";
|
|
7
7
|
ThreeDSAuthOperate2["CANCEL"] = "CANCEL";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import "../../utils/card-brand/brands.js";
|
|
2
2
|
import "../../utils/system-info/get-browser-info.js";
|
|
3
3
|
import { deepMerge } from "../../utils/object.js";
|
|
4
|
+
import "../../core.js";
|
|
5
|
+
import "../../core/context.js";
|
|
6
|
+
import "../../out/fraud-detection.js";
|
|
4
7
|
const buildPaymentParams = (params, extraParams = {}) => {
|
|
5
8
|
const { bill, payment, customer } = params;
|
|
6
9
|
const mergedParams = deepMerge(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { u } from "../../core.js";
|
|
2
2
|
import "../../utils/card-brand/brands.js";
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { useI18n } from "../../hooks/useI18n.js";
|
|
5
|
-
import "../../out/fraud-detection.js";
|
|
6
4
|
import "../../core/context.js";
|
|
5
|
+
import "../../out/fraud-detection.js";
|
|
6
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
7
|
import "../internal/Form/type.js";
|
|
8
8
|
import "../internal/Form/context.js";
|
|
9
9
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -4,10 +4,10 @@ import { EAddressType } from "../../constant.js";
|
|
|
4
4
|
import { isArray, 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 { CoreContext } from "../../core/context.js";
|
|
8
|
+
import "../../out/fraud-detection.js";
|
|
7
9
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
8
10
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
9
|
-
import "../../out/fraud-detection.js";
|
|
10
|
-
import { CoreContext } from "../../core/context.js";
|
|
11
11
|
import "../internal/Form/type.js";
|
|
12
12
|
import "../internal/Form/context.js";
|
|
13
13
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -7,9 +7,10 @@ import { ApplePayEventType } from "../../types/event.js";
|
|
|
7
7
|
import { PaymentMethod, SessionMode } from "../../constant.js";
|
|
8
8
|
import { deepMerge } from "../../utils/object.js";
|
|
9
9
|
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { getMerchantSession } from "../../api/modules/apple-pay/index.js";
|
|
11
|
+
import { commonPaymentQuery, commonPayment } from "../../api/modules/common/index.js";
|
|
12
12
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
13
|
+
import { buildPaymentParams } from "../../api/utils/index.js";
|
|
13
14
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
15
|
import "../../core/context.js";
|
|
15
16
|
import { PayKKaError } from "../../core/error.js";
|
|
@@ -222,7 +223,7 @@ const ApplePay = w((props) => {
|
|
|
222
223
|
};
|
|
223
224
|
};
|
|
224
225
|
async function pay(search = false, timeout, token, billingContact, shippingContact) {
|
|
225
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
226
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
226
227
|
setErrorMsg("");
|
|
227
228
|
try {
|
|
228
229
|
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
@@ -230,7 +231,7 @@ const ApplePay = w((props) => {
|
|
|
230
231
|
let res = null;
|
|
231
232
|
if (search) {
|
|
232
233
|
const extraParams = (_b = (_a = core.config)._getExtraParams) == null ? void 0 : _b.call(_a, "query", CURR_PAYMENT_METHOD);
|
|
233
|
-
res = await
|
|
234
|
+
res = await commonPaymentQuery(
|
|
234
235
|
{
|
|
235
236
|
sessionId: session.sessionId,
|
|
236
237
|
clientKey: session.clientKey,
|
|
@@ -246,11 +247,26 @@ const ApplePay = w((props) => {
|
|
|
246
247
|
await core.updateSessionId(buildPaymentParams(paymentParams, extraParams));
|
|
247
248
|
session.sessionId && (paymentParams.sessionId = session.sessionId);
|
|
248
249
|
}
|
|
249
|
-
res = await
|
|
250
|
+
res = await commonPayment({
|
|
251
|
+
params: paymentParams,
|
|
252
|
+
extraParams,
|
|
253
|
+
options: {
|
|
254
|
+
request: requestOptions,
|
|
255
|
+
query: {
|
|
256
|
+
enable: true,
|
|
257
|
+
params: {
|
|
258
|
+
sessionId: session.sessionId,
|
|
259
|
+
clientKey: session.clientKey,
|
|
260
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
261
|
+
},
|
|
262
|
+
extraParams: (_g = (_f = core.config)._getExtraParams) == null ? void 0 : _g.call(_f, "query", CURR_PAYMENT_METHOD)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
});
|
|
250
266
|
}
|
|
251
267
|
const { errorMessage, errorCode, sessionId } = res;
|
|
252
268
|
sessionId && (session.sessionId = sessionId);
|
|
253
|
-
!search && ((
|
|
269
|
+
!search && ((_h = props.onSubmitResponse) == null ? void 0 : _h.call(props, res, getPaymentMethodContext()));
|
|
254
270
|
let end = true;
|
|
255
271
|
await processPaymentStatus(res, {
|
|
256
272
|
onProcessing: async () => {
|
|
@@ -299,7 +315,7 @@ const ApplePay = w((props) => {
|
|
|
299
315
|
} else {
|
|
300
316
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
301
317
|
message && setErrorMsg(message);
|
|
302
|
-
(
|
|
318
|
+
(_i = props.onError) == null ? void 0 : _i.call(
|
|
303
319
|
props,
|
|
304
320
|
new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
|
|
305
321
|
getPaymentMethodContext()
|
|
@@ -313,7 +329,7 @@ const ApplePay = w((props) => {
|
|
|
313
329
|
const genApplePayRequest = () => {
|
|
314
330
|
var _a, _b, _c, _d, _e, _f;
|
|
315
331
|
const checkout = session == null ? void 0 : session.checkout;
|
|
316
|
-
const { applePay
|
|
332
|
+
const { applePay } = (checkout == null ? void 0 : checkout.channelParams) ?? {};
|
|
317
333
|
const requiredBillingContactFields = [
|
|
318
334
|
...((_a = applePayConfig.request) == null ? void 0 : _a.requiredBillingContactFields) || []
|
|
319
335
|
];
|
|
@@ -323,11 +339,11 @@ const ApplePay = w((props) => {
|
|
|
323
339
|
const amount = (_c = core.payment) == null ? void 0 : _c.amount.value;
|
|
324
340
|
return {
|
|
325
341
|
merchantCapabilities: ["supports3DS"],
|
|
326
|
-
countryCode: (
|
|
342
|
+
countryCode: (applePay == null ? void 0 : applePay.countryCode) ?? "",
|
|
327
343
|
requiredBillingContactFields,
|
|
328
344
|
requiredShippingContactFields: (_d = applePayConfig.request) == null ? void 0 : _d.requiredShippingContactFields,
|
|
329
345
|
currencyCode: (amount == null ? void 0 : amount.currency) ?? "",
|
|
330
|
-
supportedNetworks: ((_f = (_e =
|
|
346
|
+
supportedNetworks: ((_f = (_e = applePay == null ? void 0 : applePay.supportedNetworks) == null ? void 0 : _e.map) == null ? void 0 : _f.call(_e, (item) => underscoreToUpperCamelCase(item))) ?? [],
|
|
331
347
|
total: {
|
|
332
348
|
label: (checkout == null ? void 0 : checkout.theme.merchantName) ?? "",
|
|
333
349
|
type: "final",
|
|
@@ -3,9 +3,9 @@ import { isUndefined } from "../../utils/is.js";
|
|
|
3
3
|
import "../../utils/card-brand/brands.js";
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { EInternalFieldType } from "../SecuredFieldsProvider/index.js";
|
|
6
|
-
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
|
-
import "../../out/fraud-detection.js";
|
|
8
6
|
import "../../core/context.js";
|
|
7
|
+
import "../../out/fraud-detection.js";
|
|
8
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
9
9
|
import "../internal/Form/type.js";
|
|
10
10
|
import "../internal/Form/context.js";
|
|
11
11
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { w, A, h, F, y, q, T, u, b } from "../../core.js";
|
|
2
2
|
import { isTimeoutError } from "../../api/http.js";
|
|
3
|
-
import { getCardPayInfo, cardPay } from "../../api/modules/card/index.js";
|
|
4
3
|
import { safeParse, safeStringify } from "../../utils/index.js";
|
|
5
4
|
import { defaultInputStyleConfig } from "../../types/index.js";
|
|
6
5
|
import { PaymentMethod, PaymentType, SessionMode, COMMON_CLASS_NAME, CardPaymentMethods } from "../../constant.js";
|
|
7
|
-
import {
|
|
6
|
+
import { commonPaymentQuery, commonPayment } from "../../api/modules/common/index.js";
|
|
8
7
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
9
8
|
import { CoreContext } from "../../core/context.js";
|
|
10
9
|
import { PayKKaError } from "../../core/error.js";
|
|
@@ -13,6 +12,7 @@ import { createPromise } from "../../utils/create-promise.js";
|
|
|
13
12
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
13
|
import { usePayState } from "../../hooks/usePayState.js";
|
|
15
14
|
import { useRetry } from "../../hooks/useRetry.js";
|
|
15
|
+
import { buildPaymentParams } from "../../api/utils/index.js";
|
|
16
16
|
import { DEFAULT_ADDRESS, AddressField } from "../AddressField/index.js";
|
|
17
17
|
import { CardBrands } from "../CardBrands/index.js";
|
|
18
18
|
import { CardExpireDateField } from "../CardExpireDateField/index.js";
|
|
@@ -315,14 +315,14 @@ const Card = w((props, ref) => {
|
|
|
315
315
|
};
|
|
316
316
|
};
|
|
317
317
|
async function pay(search = false, timeout) {
|
|
318
|
-
var _a2, _b2, _c, _d, _e, _f;
|
|
318
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
319
319
|
try {
|
|
320
320
|
core.payment.currPaymentMethod.value = CURR_PAYMENT_METHOD;
|
|
321
321
|
const requestOptions = { locale: i18n.locale, timeout };
|
|
322
322
|
let res = null;
|
|
323
323
|
if (search) {
|
|
324
324
|
const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", CURR_PAYMENT_METHOD);
|
|
325
|
-
res = await
|
|
325
|
+
res = await commonPaymentQuery(
|
|
326
326
|
{
|
|
327
327
|
sessionId: session.sessionId,
|
|
328
328
|
clientKey: session.clientKey
|
|
@@ -341,7 +341,21 @@ const Card = w((props, ref) => {
|
|
|
341
341
|
(_f = SFPRef.current) == null ? void 0 : _f.payment(paymentParams, extraParams);
|
|
342
342
|
return { end: true };
|
|
343
343
|
} else {
|
|
344
|
-
res = await
|
|
344
|
+
res = await commonPayment({
|
|
345
|
+
params: paymentParams,
|
|
346
|
+
extraParams,
|
|
347
|
+
options: {
|
|
348
|
+
request: requestOptions,
|
|
349
|
+
query: {
|
|
350
|
+
enable: false,
|
|
351
|
+
params: {
|
|
352
|
+
sessionId: session.sessionId,
|
|
353
|
+
clientKey: session.clientKey
|
|
354
|
+
},
|
|
355
|
+
extraParams: (_h = (_g = core.config)._getExtraParams) == null ? void 0 : _h.call(_g, "query", CURR_PAYMENT_METHOD)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
return processAfterPayment(res, search);
|
|
@@ -473,7 +487,7 @@ const Card = w((props, ref) => {
|
|
|
473
487
|
return { end: true };
|
|
474
488
|
try {
|
|
475
489
|
const extraParams = (_b2 = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b2.call(_a2, "query", CURR_PAYMENT_METHOD);
|
|
476
|
-
const res = await
|
|
490
|
+
const res = await commonPaymentQuery(
|
|
477
491
|
{
|
|
478
492
|
sessionId: session.sessionId,
|
|
479
493
|
clientKey: session.clientKey
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { u } from "../../core.js";
|
|
2
2
|
import "../../utils/card-brand/brands.js";
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { useI18n } from "../../hooks/useI18n.js";
|
|
5
|
-
import "../../out/fraud-detection.js";
|
|
6
4
|
import "../../core/context.js";
|
|
5
|
+
import "../../out/fraud-detection.js";
|
|
6
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
7
|
import "../internal/Form/type.js";
|
|
8
8
|
import "../internal/Form/context.js";
|
|
9
9
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -4,9 +4,9 @@ import "../../utils/card-brand/brands.js";
|
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { limitedToNumber } from "../../utils/format.js";
|
|
6
6
|
import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
7
|
-
import { useI18n } from "../../hooks/useI18n.js";
|
|
8
|
-
import "../../out/fraud-detection.js";
|
|
9
7
|
import "../../core/context.js";
|
|
8
|
+
import "../../out/fraud-detection.js";
|
|
9
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
10
10
|
import "../internal/Form/type.js";
|
|
11
11
|
import "../internal/Form/context.js";
|
|
12
12
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -9,11 +9,11 @@ import { EFieldType } from "../SecuredFieldsProvider/index.js";
|
|
|
9
9
|
import { finCardBrandInfoByCode, findCardBrandInfo, getSupportedCardBrands } from "../../utils/card-brand/index.js";
|
|
10
10
|
import "../../utils/system-info/get-browser-info.js";
|
|
11
11
|
import { trimAll } from "../../utils/format.js";
|
|
12
|
-
import
|
|
12
|
+
import "../../core/context.js";
|
|
13
|
+
import "../../out/fraud-detection.js";
|
|
13
14
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
14
15
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
15
|
-
import "
|
|
16
|
-
import "../../core/context.js";
|
|
16
|
+
import { IconCardNo } from "../internal/icons/IconCardNo.js";
|
|
17
17
|
const { bem } = useBEM("combined-card-info");
|
|
18
18
|
const CombinedCardInfo = w(
|
|
19
19
|
(props, ref) => {
|
|
@@ -9,9 +9,9 @@ import { isValuable } from "../../utils/is.js";
|
|
|
9
9
|
import "../../utils/card-brand/brands.js";
|
|
10
10
|
import "../../utils/system-info/get-browser-info.js";
|
|
11
11
|
import { EMAIL_REG } from "../../utils/reg-exp.js";
|
|
12
|
-
import { useI18n } from "../../hooks/useI18n.js";
|
|
13
|
-
import "../../out/fraud-detection.js";
|
|
14
12
|
import "../../core/context.js";
|
|
13
|
+
import "../../out/fraud-detection.js";
|
|
14
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
15
15
|
import "../internal/Form/type.js";
|
|
16
16
|
import "../internal/Form/context.js";
|
|
17
17
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
@@ -11,8 +11,8 @@ import { createPromise } from "../../utils/create-promise.js";
|
|
|
11
11
|
import { separateInputStyle, genComponentStyle, loadStyle } from "../../utils/style.js";
|
|
12
12
|
import { EFieldType, SecuredFieldsProvider } from "../SecuredFieldsProvider/index.js";
|
|
13
13
|
import { intersection } from "../../utils/array.js";
|
|
14
|
-
import { genShortId } from "../../utils/string.js";
|
|
15
14
|
import { defaultInputStyleConfig } from "../../types/index.js";
|
|
15
|
+
import { genShortId } from "../../utils/string.js";
|
|
16
16
|
import { CardNumberField } from "../CardNumberField/index.js";
|
|
17
17
|
import { CardExpireDateField } from "../CardExpireDateField/index.js";
|
|
18
18
|
import { CardSecurityCodeField } from "../CardSecurityCodeField/index.js";
|
|
@@ -8,9 +8,9 @@ import { createUrlWithParams } from "../../utils/location.js";
|
|
|
8
8
|
import { PaymentMethod, SessionMode } from "../../constant.js";
|
|
9
9
|
import { deepMerge } from "../../utils/object.js";
|
|
10
10
|
import { processPaymentStatus, formatPaymentResult } from "../../utils/payment.js";
|
|
11
|
-
import {
|
|
12
|
-
import { getGooglePayInfo, googlePay } from "../../api/modules/google-pay/index.js";
|
|
11
|
+
import { commonPaymentQuery, commonPayment } from "../../api/modules/common/index.js";
|
|
13
12
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
13
|
+
import { buildPaymentParams } from "../../api/utils/index.js";
|
|
14
14
|
import { useBEM } from "../../hooks/useBEM.js";
|
|
15
15
|
import "../../core/context.js";
|
|
16
16
|
import { PayKKaError } from "../../core/error.js";
|
|
@@ -22,7 +22,7 @@ import { loadScript } from "../../utils/load.js";
|
|
|
22
22
|
import { ThreeDSAuth } from "../ThreeDS/index.js";
|
|
23
23
|
const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse, onCancel) => {
|
|
24
24
|
const { theme: { merchantName } } = checkout;
|
|
25
|
-
const { googlePay
|
|
25
|
+
const { googlePay } = (checkout == null ? void 0 : checkout.channelParams) || {};
|
|
26
26
|
let paymentsClient;
|
|
27
27
|
const baseRequest = {
|
|
28
28
|
apiVersion: 2,
|
|
@@ -32,12 +32,12 @@ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse
|
|
|
32
32
|
type: "PAYMENT_GATEWAY",
|
|
33
33
|
// 固定
|
|
34
34
|
parameters: {
|
|
35
|
-
gateway:
|
|
36
|
-
gatewayMerchantId:
|
|
35
|
+
gateway: googlePay == null ? void 0 : googlePay.providerGatewayId,
|
|
36
|
+
gatewayMerchantId: googlePay == null ? void 0 : googlePay.merchantGatewayId
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
const allowedCardNetworks = (
|
|
40
|
-
const allowedCardAuthMethods = (
|
|
39
|
+
const allowedCardNetworks = (googlePay == null ? void 0 : googlePay.allowedCardNetworks) || [];
|
|
40
|
+
const allowedCardAuthMethods = (googlePay == null ? void 0 : googlePay.allowedAuthMethods) || [];
|
|
41
41
|
const baseCardPaymentMethod = {
|
|
42
42
|
type: "CARD",
|
|
43
43
|
parameters: {
|
|
@@ -62,7 +62,7 @@ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse
|
|
|
62
62
|
const getGoogleTransactionInfo = () => {
|
|
63
63
|
var _a, _b, _c, _d;
|
|
64
64
|
return {
|
|
65
|
-
countryCode:
|
|
65
|
+
countryCode: googlePay == null ? void 0 : googlePay.countryCode,
|
|
66
66
|
currencyCode: ((_b = (_a = core.payment) == null ? void 0 : _a.amount.value) == null ? void 0 : _b.currency) || "",
|
|
67
67
|
totalPriceStatus: "FINAL",
|
|
68
68
|
totalPrice: String(((_d = (_c = core.payment) == null ? void 0 : _c.amount.value) == null ? void 0 : _d.amount) || 0),
|
|
@@ -76,7 +76,7 @@ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse
|
|
|
76
76
|
allowedPaymentMethods: [cardPaymentMethod],
|
|
77
77
|
transactionInfo: getGoogleTransactionInfo(),
|
|
78
78
|
merchantInfo: {
|
|
79
|
-
merchantId:
|
|
79
|
+
merchantId: googlePay == null ? void 0 : googlePay.googlePayMerchantId,
|
|
80
80
|
merchantName
|
|
81
81
|
},
|
|
82
82
|
callbackIntents: ["PAYMENT_AUTHORIZATION"]
|
|
@@ -85,7 +85,7 @@ const createGooglePay = (core, checkout, googlePayConfig, pay, onClick, onCanUse
|
|
|
85
85
|
const getGooglePaymentsClient = () => {
|
|
86
86
|
if (!paymentsClient) {
|
|
87
87
|
paymentsClient = new google.payments.api.PaymentsClient({
|
|
88
|
-
environment:
|
|
88
|
+
environment: googlePay == null ? void 0 : googlePay.environment,
|
|
89
89
|
paymentDataCallbacks: { onPaymentAuthorized }
|
|
90
90
|
});
|
|
91
91
|
}
|
|
@@ -331,7 +331,7 @@ const GooglePay = w((props, ref) => {
|
|
|
331
331
|
};
|
|
332
332
|
};
|
|
333
333
|
async function pay(token, billAddress, search = false, timeout) {
|
|
334
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
334
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
335
335
|
setErrorMsg("");
|
|
336
336
|
if (!search) {
|
|
337
337
|
(_a2 = props.onSubmit) == null ? void 0 : _a2.call(props, void 0, getPaymentMethodContext());
|
|
@@ -342,7 +342,7 @@ const GooglePay = w((props, ref) => {
|
|
|
342
342
|
let res = null;
|
|
343
343
|
if (search) {
|
|
344
344
|
const extraParams = (_c = (_b = core.config)._getExtraParams) == null ? void 0 : _c.call(_b, "query", CURR_PAYMENT_METHOD);
|
|
345
|
-
res = await
|
|
345
|
+
res = await commonPaymentQuery(
|
|
346
346
|
{
|
|
347
347
|
sessionId: session.sessionId,
|
|
348
348
|
clientKey: session.clientKey,
|
|
@@ -358,12 +358,27 @@ const GooglePay = w((props, ref) => {
|
|
|
358
358
|
await core.updateSessionId(buildPaymentParams(paymentParams, extraParams));
|
|
359
359
|
session.sessionId && (paymentParams.sessionId = session.sessionId);
|
|
360
360
|
}
|
|
361
|
-
res = await
|
|
361
|
+
res = await commonPayment({
|
|
362
|
+
params: paymentParams,
|
|
363
|
+
extraParams,
|
|
364
|
+
options: {
|
|
365
|
+
request: requestOptions,
|
|
366
|
+
query: {
|
|
367
|
+
enable: false,
|
|
368
|
+
params: {
|
|
369
|
+
sessionId: session.sessionId,
|
|
370
|
+
clientKey: session.clientKey,
|
|
371
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
372
|
+
},
|
|
373
|
+
extraParams: (_h = (_g = core.config)._getExtraParams) == null ? void 0 : _h.call(_g, "query", CURR_PAYMENT_METHOD)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
});
|
|
362
377
|
}
|
|
363
378
|
const { errorMessage, payInfo = {}, errorCode, sessionId } = res;
|
|
364
379
|
const { threeDSUrl } = payInfo;
|
|
365
380
|
sessionId && (session.sessionId = sessionId);
|
|
366
|
-
!search && ((
|
|
381
|
+
!search && ((_i = props.onSubmitResponse) == null ? void 0 : _i.call(props, res, getPaymentMethodContext()));
|
|
367
382
|
let result = {
|
|
368
383
|
end: true,
|
|
369
384
|
res: { transactionState: "SUCCESS" }
|
|
@@ -444,10 +459,10 @@ const GooglePay = w((props, ref) => {
|
|
|
444
459
|
};
|
|
445
460
|
}
|
|
446
461
|
} else {
|
|
447
|
-
(
|
|
462
|
+
(_j = core.payment) == null ? void 0 : _j.resetCurrPaymentMethod();
|
|
448
463
|
const message = error.i18nKey ? i18n.get(error.i18nKey) : error.message;
|
|
449
464
|
setErrorMsg(message);
|
|
450
|
-
(
|
|
465
|
+
(_k = props.onError) == null ? void 0 : _k.call(
|
|
451
466
|
props,
|
|
452
467
|
new PayKKaError("API_ERROR", message, { code: error.code, cause: error }),
|
|
453
468
|
getPaymentMethodContext()
|
|
@@ -479,15 +494,14 @@ const GooglePay = w((props, ref) => {
|
|
|
479
494
|
return { end: true };
|
|
480
495
|
try {
|
|
481
496
|
const extraParams = (_b = (_a2 = core.config)._getExtraParams) == null ? void 0 : _b.call(_a2, "query", CURR_PAYMENT_METHOD);
|
|
482
|
-
const res = await
|
|
497
|
+
const res = await commonPaymentQuery(
|
|
483
498
|
{
|
|
484
499
|
sessionId: session.sessionId,
|
|
485
|
-
clientKey: session.clientKey
|
|
500
|
+
clientKey: session.clientKey,
|
|
501
|
+
paymentMethod: CURR_PAYMENT_METHOD
|
|
486
502
|
},
|
|
487
503
|
extraParams,
|
|
488
|
-
{
|
|
489
|
-
locale: i18n.locale
|
|
490
|
-
}
|
|
504
|
+
{ locale: i18n.locale }
|
|
491
505
|
);
|
|
492
506
|
const { errorMessage } = res;
|
|
493
507
|
let end = true;
|
|
@@ -6,7 +6,9 @@ var __publicField = (obj, key, value) => {
|
|
|
6
6
|
};
|
|
7
7
|
import "../../utils/card-brand/brands.js";
|
|
8
8
|
import "../../utils/system-info/get-browser-info.js";
|
|
9
|
+
import "../../core/context.js";
|
|
9
10
|
import { w, A, y, F, q, u } from "../../core.js";
|
|
11
|
+
import "../../out/fraud-detection.js";
|
|
10
12
|
import { SessionMode } from "../../constant.js";
|
|
11
13
|
import { cdnUrl, cdnOrigin, apiUrl, apiPrefix } from "../../config.js";
|
|
12
14
|
import { MessageAction } from "../../types/message.js";
|
|
@@ -11,9 +11,8 @@ import { MessageAction } from "../../types/message.js";
|
|
|
11
11
|
import { generateClassNameMap, style2String, createPlaceholderStyle, loadStyle } from "../../utils/style.js";
|
|
12
12
|
import { postMessageToIframe } from "../../utils/iframe.js";
|
|
13
13
|
import { isTimeoutError } from "../../api/http.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { walletPay } from "../../api/modules/wallet/index.js";
|
|
14
|
+
import { CardPaymentMethods } from "../../constant.js";
|
|
15
|
+
import { commonPayment } from "../../api/modules/common/index.js";
|
|
17
16
|
import { encryptCard } from "../../api/modules/encrypted-card/index.js";
|
|
18
17
|
const useSecuredInput = () => {
|
|
19
18
|
let fieldType;
|
|
@@ -478,12 +477,6 @@ const HiddenIframe = ({ checkoutId }) => {
|
|
|
478
477
|
api: bkApi(`${apiPrefix}/payments`),
|
|
479
478
|
startTime: performance.now()
|
|
480
479
|
};
|
|
481
|
-
const paymentMethod = params.payment.paymentMethod;
|
|
482
|
-
const payMap = {
|
|
483
|
-
[PaymentMethod.PIX]: walletPay,
|
|
484
|
-
[PaymentMethod.PIC_PAY]: walletPay
|
|
485
|
-
};
|
|
486
|
-
const payFn = payMap[paymentMethod] || cardPay;
|
|
487
480
|
const data = {
|
|
488
481
|
...params,
|
|
489
482
|
payment: {
|
|
@@ -497,7 +490,23 @@ const HiddenIframe = ({ checkoutId }) => {
|
|
|
497
490
|
document: formData.cpf
|
|
498
491
|
}
|
|
499
492
|
};
|
|
500
|
-
|
|
493
|
+
commonPayment({
|
|
494
|
+
params: data,
|
|
495
|
+
extraParams,
|
|
496
|
+
options: {
|
|
497
|
+
request: { locale },
|
|
498
|
+
query: {
|
|
499
|
+
enable: true,
|
|
500
|
+
params: {
|
|
501
|
+
sessionId: params.sessionId,
|
|
502
|
+
clientKey: params.clientKey,
|
|
503
|
+
// 卡支付不需要 paymentMethod
|
|
504
|
+
paymentMethod: CardPaymentMethods.includes(params.payment.paymentMethod) ? void 0 : params.payment.paymentMethod
|
|
505
|
+
},
|
|
506
|
+
extraParams
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}).then((res) => {
|
|
501
510
|
sendAfterPaymentMessage(res, requestInfo);
|
|
502
511
|
}).catch((error) => {
|
|
503
512
|
if (isTimeoutError(error)) {
|