@paykka/card-checkout-ui 0.11.6 → 0.13.1
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 +17 -17
- package/dist/card-checkout-ui.umd.cjs +17 -17
- package/dist/es/api/index.js +1 -0
- package/dist/es/api/modules/address/index.js +9 -9
- package/dist/es/api/modules/ali-pay/index.js +10 -49
- package/dist/es/api/modules/apple-pay/index.js +13 -59
- package/dist/es/api/modules/boost/index.js +8 -48
- package/dist/es/api/modules/card/index.js +10 -54
- package/dist/es/api/modules/checkout/index.js +11 -9
- package/dist/es/api/modules/checkout/map.js +25 -18
- package/dist/es/api/modules/encrypted-card/index.js +3 -2
- package/dist/es/api/modules/gcash/index.js +8 -48
- package/dist/es/api/modules/google-pay/index.js +10 -56
- package/dist/es/api/modules/grab-pay/index.js +8 -48
- package/dist/es/api/modules/index.js +1 -0
- package/dist/es/api/modules/line-pay/index.js +8 -48
- package/dist/es/api/modules/map.js +17 -11
- package/dist/es/api/modules/may-bank-qr-pay/index.js +8 -48
- package/dist/es/api/modules/nine-pay/index.js +8 -48
- package/dist/es/api/modules/paymaya/index.js +8 -48
- package/dist/es/api/modules/risk/index.js +2 -1
- package/dist/es/api/modules/sepa/index.js +10 -51
- package/dist/es/api/modules/shopee-pay/index.js +8 -48
- package/dist/es/api/modules/threeDS/index.js +3 -0
- package/dist/es/api/modules/tng-wallet/index.js +8 -48
- package/dist/es/api/modules/wechat-pay/index.js +10 -51
- package/dist/es/api/modules/zalopay/index.js +16 -0
- package/dist/es/api/utils/index.js +59 -0
- package/dist/es/components/AddressField/index.js +37 -37
- package/dist/es/components/AliPay/index.js +143 -90
- package/dist/es/components/ApplePay/index.js +99 -67
- package/dist/es/components/Boost/index.js +66 -39
- package/dist/es/components/Card/index.js +90 -79
- package/dist/es/components/CardSelector/index.js +1 -1
- package/dist/es/components/DropIn/index.js +12 -4
- package/dist/es/components/EncryptedCard/index.js +1 -1
- package/dist/es/components/GooglePay/index.js +93 -60
- package/dist/es/components/GrabPay/index.js +66 -39
- package/dist/es/components/GuideCard/index.js +10 -7
- package/dist/es/components/LinePay/index.js +66 -39
- package/dist/es/components/MayBankQRPay/index.js +306 -273
- package/dist/es/components/NinePay/index.js +66 -39
- package/dist/es/components/SecuredFieldsProvider/index.js +3 -2
- package/dist/es/components/SecuredIframe/index.js +4 -2
- package/dist/es/components/Sepa/index.js +62 -39
- package/dist/es/components/ShopeePay/index.js +66 -39
- package/dist/es/components/SubmitButton/index.js +8 -7
- package/dist/es/components/TNGWallet/index.js +66 -39
- package/dist/es/components/WechatPay/index.js +146 -92
- package/dist/es/components/business/QRCodeModal/QRCodeModal.js +26 -6
- package/dist/es/components/index.js +1 -0
- package/dist/es/components/internal/Modal/Modal.js +1 -1
- package/dist/es/components/internal/Select/Select.js +19 -8
- package/dist/es/components/internal/Select/SelectMenuItem.js +12 -4
- package/dist/es/components/internal/icons/IconZalopay.js +47 -0
- package/dist/es/components/internal/icons/IconZalopayComplete.js +48 -0
- package/dist/es/components/wallets/GCash/GCash.js +68 -39
- package/dist/es/components/wallets/Paymaya/Paymaya.js +66 -39
- package/dist/es/components/wallets/Zalopay/Zalopay.js +386 -0
- package/dist/es/components/wallets/Zalopay/index.js +1 -0
- package/dist/es/components/wallets/Zalopay/type.js +1 -0
- package/dist/es/components/wallets/Zalopay/zalopay2.js +1 -0
- package/dist/es/config.js +5 -5
- package/dist/es/constant.js +8 -2
- package/dist/es/core/{Address.js → address.js} +8 -16
- package/dist/es/core/{PayKKaCheckout.js → checkout.js} +78 -27
- package/dist/es/core/query.js +3 -2
- package/dist/es/core/{Session.js → session.js} +37 -20
- package/dist/es/core.js +0 -4
- package/dist/es/hooks/usePayment.js +14 -0
- package/dist/es/i18n/locales/de-DE.js +3 -1
- package/dist/es/i18n/locales/en-GB.js +3 -1
- package/dist/es/i18n/locales/es-ES.js +3 -1
- package/dist/es/i18n/locales/fr-FR.js +3 -1
- package/dist/es/i18n/locales/ja-JP.js +3 -1
- package/dist/es/i18n/locales/ko-KR.js +3 -1
- package/dist/es/i18n/locales/nl-NL.js +3 -1
- package/dist/es/i18n/locales/pt-PT.js +3 -1
- package/dist/es/i18n/locales/ru-RU.js +3 -1
- package/dist/es/i18n/locales/zh-CN.js +3 -1
- package/dist/es/i18n/locales/zh-HK.js +3 -1
- package/dist/es/i18n/locales/zh-TW.js +3 -1
- package/dist/es/index.js +16 -4
- package/dist/es/style.css +1 -1
- package/dist/es/types/index.js +7 -0
- package/dist/es/utils/colors.js +5 -1
- package/dist/es/utils/payment.js +82 -0
- package/dist/es/utils/redirect.js +4 -4
- package/dist/style.css +1 -1
- package/dist/types/api/modules/address/index.d.ts +15 -6
- package/dist/types/api/modules/ali-pay/index.d.ts +3 -19
- package/dist/types/api/modules/apple-pay/index.d.ts +4 -14
- package/dist/types/api/modules/boost/index.d.ts +3 -23
- package/dist/types/api/modules/card/index.d.ts +3 -30
- package/dist/types/api/modules/checkout/index.d.ts +3 -3
- package/dist/types/api/modules/checkout/map.d.ts +3 -3
- package/dist/types/api/modules/checkout/type.d.ts +33 -4
- package/dist/types/api/modules/gcash/index.d.ts +3 -23
- package/dist/types/api/modules/google-pay/index.d.ts +3 -13
- package/dist/types/api/modules/grab-pay/index.d.ts +3 -23
- package/dist/types/api/modules/index.d.ts +1 -0
- package/dist/types/api/modules/line-pay/index.d.ts +3 -23
- package/dist/types/api/modules/map.d.ts +2 -2
- package/dist/types/api/modules/may-bank-qr-pay/index.d.ts +3 -23
- package/dist/types/api/modules/nine-pay/index.d.ts +3 -23
- package/dist/types/api/modules/paymaya/index.d.ts +3 -23
- package/dist/types/api/modules/sepa/index.d.ts +3 -24
- package/dist/types/api/modules/shopee-pay/index.d.ts +3 -23
- package/dist/types/api/modules/tng-wallet/index.d.ts +3 -23
- package/dist/types/api/modules/type.d.ts +74 -21
- package/dist/types/api/modules/wechat-pay/index.d.ts +3 -20
- package/dist/types/api/modules/zalopay/index.d.ts +4 -0
- package/dist/types/api/utils/index.d.ts +48 -0
- package/dist/types/components/AddressField/type.d.ts +3 -9
- package/dist/types/components/AliPay/AliPay.d.ts +6 -2
- package/dist/types/components/AliPay/type.d.ts +15 -2
- package/dist/types/components/ApplePay/ApplePay.d.ts +6 -2
- package/dist/types/components/ApplePay/type.d.ts +10 -14
- package/dist/types/components/ApplePay/utils.d.ts +1 -1
- package/dist/types/components/Boost/Boost.d.ts +6 -2
- package/dist/types/components/Boost/type.d.ts +2 -24
- package/dist/types/components/Card/Card.d.ts +6 -2
- package/dist/types/components/Card/type.d.ts +3 -43
- package/dist/types/components/DropIn/DropIn.d.ts +6 -2
- package/dist/types/components/DropIn/type.d.ts +4 -10
- package/dist/types/components/GooglePay/GooglePay.d.ts +6 -2
- package/dist/types/components/GooglePay/createGooglePay.d.ts +2 -1
- package/dist/types/components/GooglePay/type.d.ts +10 -26
- package/dist/types/components/GrabPay/GrabPay.d.ts +6 -2
- package/dist/types/components/GrabPay/type.d.ts +3 -25
- package/dist/types/components/LinePay/LinePay.d.ts +6 -2
- package/dist/types/components/LinePay/type.d.ts +3 -25
- package/dist/types/components/MayBankQRPay/MayBankQRPay.d.ts +6 -2
- package/dist/types/components/MayBankQRPay/type.d.ts +3 -25
- package/dist/types/components/NinePay/NinePay.d.ts +6 -2
- package/dist/types/components/NinePay/type.d.ts +3 -25
- package/dist/types/components/Sepa/Sepa.d.ts +6 -2
- package/dist/types/components/Sepa/type.d.ts +3 -2
- package/dist/types/components/ShopeePay/ShopeePay.d.ts +6 -2
- package/dist/types/components/ShopeePay/type.d.ts +3 -25
- package/dist/types/components/TNGWallet/TNGWallet.d.ts +6 -2
- package/dist/types/components/TNGWallet/type.d.ts +3 -25
- package/dist/types/components/WechatPay/WechatPay.d.ts +6 -2
- package/dist/types/components/WechatPay/type.d.ts +15 -2
- package/dist/types/components/business/QRCodeModal/type.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/internal/icons/IconZalopay.d.ts +2 -0
- package/dist/types/components/internal/icons/IconZalopayComplete.d.ts +2 -0
- package/dist/types/components/internal/icons/index.d.ts +3 -0
- package/dist/types/components/wallets/GCash/GCash.d.ts +6 -2
- package/dist/types/components/wallets/GCash/type.d.ts +3 -35
- package/dist/types/components/wallets/Paymaya/Paymaya.d.ts +6 -2
- package/dist/types/components/wallets/Paymaya/type.d.ts +3 -25
- package/dist/types/components/wallets/Zalopay/Zalopay.d.ts +10 -0
- package/dist/types/components/wallets/Zalopay/index.d.ts +2 -0
- package/dist/types/components/wallets/Zalopay/type.d.ts +39 -0
- package/dist/types/config.d.ts +2 -4
- package/dist/types/constant.d.ts +3 -1
- package/dist/types/core/{Address.d.ts → address.d.ts} +23 -24
- package/dist/types/core/{PayKKaCheckout.d.ts → checkout.d.ts} +5 -3
- package/dist/types/core/context.d.ts +3 -2
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/query.d.ts +2 -2
- package/dist/types/core/session.d.ts +33 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/usePayment.d.ts +8 -0
- package/dist/types/i18n/locales/de-DE.d.ts +2 -0
- package/dist/types/i18n/locales/en-GB.d.ts +2 -0
- package/dist/types/i18n/locales/es-ES.d.ts +2 -0
- package/dist/types/i18n/locales/fr-FR.d.ts +2 -0
- package/dist/types/i18n/locales/ja-JP.d.ts +2 -0
- package/dist/types/i18n/locales/ko-KR.d.ts +2 -0
- package/dist/types/i18n/locales/nl-NL.d.ts +2 -0
- package/dist/types/i18n/locales/pt-PT.d.ts +2 -0
- package/dist/types/i18n/locales/ru-RU.d.ts +2 -0
- package/dist/types/i18n/locales/zh-CN.d.ts +2 -0
- package/dist/types/i18n/locales/zh-HK.d.ts +2 -0
- package/dist/types/i18n/locales/zh-TW.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts +70 -32
- package/dist/types/types/message.d.ts +1 -0
- package/dist/types/utils/card-brand/index.d.ts +3 -3
- package/dist/types/utils/colors.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/payment.d.ts +37 -0
- package/package.json +3 -3
- package/dist/types/core/Session.d.ts +0 -16
package/dist/es/api/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeAsyncFn } from "../../../utils/merge-async-fn.js";
|
|
2
2
|
import { http } from "../../http.js";
|
|
3
3
|
import { addressItemMap } from "./map.js";
|
|
4
|
-
async
|
|
4
|
+
const getCountry = async (options) => {
|
|
5
5
|
return http.get("/pub/datadict/get/COUNTRY", void 0, options).then((res) => {
|
|
6
6
|
var _a;
|
|
7
7
|
const { values } = res;
|
|
@@ -10,12 +10,12 @@ async function getCountry(options) {
|
|
|
10
10
|
value: item.value
|
|
11
11
|
}))) ?? [];
|
|
12
12
|
});
|
|
13
|
-
}
|
|
14
|
-
async
|
|
15
|
-
return http.post(`/address/style/${
|
|
13
|
+
};
|
|
14
|
+
const getAddressFormat = async (country, options) => {
|
|
15
|
+
return http.post(`/address/style/${country}`, void 0, options).then(({ address_style_list }) => {
|
|
16
16
|
return address_style_list.map((item) => addressItemMap(item));
|
|
17
17
|
});
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
const mergedGetAddressFormat = mergeAsyncFn(getAddressFormat, {
|
|
20
20
|
argsResolver(items) {
|
|
21
21
|
return items == null ? void 0 : items[0].args;
|
|
@@ -24,7 +24,7 @@ const mergedGetAddressFormat = mergeAsyncFn(getAddressFormat, {
|
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
async
|
|
27
|
+
const getProvince = async (country, options) => {
|
|
28
28
|
return http.post(`/address/province-dict/${country}`, void 0, options).then((res) => {
|
|
29
29
|
var _a;
|
|
30
30
|
return (_a = res == null ? void 0 : res.map) == null ? void 0 : _a.call(res, ({ code, description }) => {
|
|
@@ -34,7 +34,7 @@ async function getProvince(country, options) {
|
|
|
34
34
|
};
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
const mergedGetProvince = mergeAsyncFn(getProvince, {
|
|
39
39
|
argsResolver(items) {
|
|
40
40
|
return items == null ? void 0 : items[0].args;
|
|
@@ -43,7 +43,7 @@ const mergedGetProvince = mergeAsyncFn(getProvince, {
|
|
|
43
43
|
return result;
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
async
|
|
46
|
+
const getCity = async (province) => {
|
|
47
47
|
return http.post(`/address/city-dict/${province}`).then((res) => {
|
|
48
48
|
var _a;
|
|
49
49
|
return (_a = res == null ? void 0 : res.map) == null ? void 0 : _a.call(res, ({ code, description }) => {
|
|
@@ -53,7 +53,7 @@ async function getCity(province) {
|
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
export {
|
|
58
58
|
getCity,
|
|
59
59
|
getCountry,
|
|
@@ -1,54 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../utils/card-brand/brands.js";
|
|
3
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
5
2
|
import { http } from "../../http.js";
|
|
6
|
-
import {
|
|
3
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
7
4
|
import { payResMap } from "../map.js";
|
|
8
|
-
async
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
bill: {
|
|
17
|
-
email: bill.email,
|
|
18
|
-
country: bill.country,
|
|
19
|
-
state: bill.province,
|
|
20
|
-
city: bill.city,
|
|
21
|
-
postal_code: bill.postCode,
|
|
22
|
-
address_line1: bill.address1,
|
|
23
|
-
address_line2: bill.address2,
|
|
24
|
-
county: bill.area
|
|
25
|
-
}
|
|
26
|
-
}, extraParams || {});
|
|
27
|
-
return http.post(
|
|
28
|
-
"/session/payments",
|
|
29
|
-
{
|
|
30
|
-
...params,
|
|
31
|
-
session_id: sessionId,
|
|
32
|
-
client_key: clientKey,
|
|
33
|
-
payment: {
|
|
34
|
-
payment_method: PaymentMethod.ALI_PAY
|
|
35
|
-
},
|
|
36
|
-
browser: await getBrowserParams()
|
|
37
|
-
},
|
|
38
|
-
options
|
|
39
|
-
).then(payResMap);
|
|
40
|
-
}
|
|
41
|
-
async function getAliPayInfo({ sessionId, clientKey }, options) {
|
|
42
|
-
return http.post(
|
|
43
|
-
"/session/payments/query",
|
|
44
|
-
{
|
|
45
|
-
session_id: sessionId,
|
|
46
|
-
client_key: clientKey,
|
|
47
|
-
payment_method: PaymentMethod.ALI_PAY
|
|
48
|
-
},
|
|
49
|
-
options
|
|
50
|
-
).then(payResMap);
|
|
51
|
-
}
|
|
5
|
+
const aliPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getAliPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
52
13
|
export {
|
|
53
14
|
aliPay,
|
|
54
15
|
getAliPayInfo
|
|
@@ -1,64 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../utils/card-brand/brands.js";
|
|
3
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
5
2
|
import { http } from "../../http.js";
|
|
3
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
6
4
|
import { payResMap } from "../map.js";
|
|
7
|
-
async
|
|
8
|
-
return http.post(
|
|
9
|
-
}
|
|
10
|
-
async
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", PaymentMethod.APPLE_PAY);
|
|
19
|
-
const params = deepMerge({
|
|
20
|
-
bill: {
|
|
21
|
-
first_name: bill == null ? void 0 : bill.firstName,
|
|
22
|
-
middle_name: bill == null ? void 0 : bill.middleName,
|
|
23
|
-
last_name: bill == null ? void 0 : bill.lastName,
|
|
24
|
-
address_line1: bill == null ? void 0 : bill.addressLine1,
|
|
25
|
-
address_line2: bill == null ? void 0 : bill.addressLine2,
|
|
26
|
-
country: bill == null ? void 0 : bill.country,
|
|
27
|
-
state: bill == null ? void 0 : bill.state,
|
|
28
|
-
city: bill == null ? void 0 : bill.city,
|
|
29
|
-
email: bill == null ? void 0 : bill.email,
|
|
30
|
-
postal_code: bill == null ? void 0 : bill.postalCode,
|
|
31
|
-
area_code: bill == null ? void 0 : bill.areaCode,
|
|
32
|
-
phone_number: bill == null ? void 0 : bill.phoneNumber,
|
|
33
|
-
descriptor: bill == null ? void 0 : bill.descriptor
|
|
34
|
-
}
|
|
35
|
-
}, extraParams || {});
|
|
36
|
-
return http.post(
|
|
37
|
-
"/session/payments",
|
|
38
|
-
{
|
|
39
|
-
...params,
|
|
40
|
-
session_id: sessionId,
|
|
41
|
-
client_key: clientKey,
|
|
42
|
-
payment: {
|
|
43
|
-
payment_method: PaymentMethod.APPLE_PAY,
|
|
44
|
-
token_data: token
|
|
45
|
-
},
|
|
46
|
-
browser
|
|
47
|
-
},
|
|
48
|
-
options
|
|
49
|
-
).then(payResMap);
|
|
50
|
-
}
|
|
51
|
-
async function getApplePayInfo({ sessionId, clientKey }, options) {
|
|
52
|
-
return http.post(
|
|
53
|
-
"/session/payments/query",
|
|
54
|
-
{
|
|
55
|
-
session_id: sessionId,
|
|
56
|
-
client_key: clientKey,
|
|
57
|
-
payment_method: PaymentMethod.APPLE_PAY
|
|
58
|
-
},
|
|
59
|
-
options
|
|
60
|
-
).then(payResMap);
|
|
61
|
-
}
|
|
5
|
+
const getMerchantSession = async (options) => {
|
|
6
|
+
return http.post(`${apiPrefix}/apple-pay/create-session`, options);
|
|
7
|
+
};
|
|
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
|
+
};
|
|
62
16
|
export {
|
|
63
17
|
applePay,
|
|
64
18
|
getApplePayInfo,
|
|
@@ -1,54 +1,14 @@
|
|
|
1
|
-
import { PaymentMethod } from "../../../constant.js";
|
|
2
|
-
import "../../../utils/card-brand/brands.js";
|
|
3
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
5
1
|
import { http } from "../../http.js";
|
|
6
2
|
import { payResMap } from "../map.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
browser
|
|
13
|
-
}, core, options) => {
|
|
14
|
-
const { _getExtraParams } = core.config;
|
|
15
|
-
const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
|
|
16
|
-
const params = deepMerge({
|
|
17
|
-
bill: {
|
|
18
|
-
email: bill.email,
|
|
19
|
-
country: bill.country,
|
|
20
|
-
state: bill.province,
|
|
21
|
-
city: bill.city,
|
|
22
|
-
postal_code: bill.postCode,
|
|
23
|
-
address_line1: bill.address1,
|
|
24
|
-
address_line2: bill.address2,
|
|
25
|
-
county: bill.area
|
|
26
|
-
}
|
|
27
|
-
}, extraParams || {});
|
|
28
|
-
return http.post(
|
|
29
|
-
"/session/payments",
|
|
30
|
-
{
|
|
31
|
-
...params,
|
|
32
|
-
session_id: sessionId,
|
|
33
|
-
client_key: clientKey,
|
|
34
|
-
payment: {
|
|
35
|
-
payment_method: payment.paymentMethod
|
|
36
|
-
},
|
|
37
|
-
browser
|
|
38
|
-
},
|
|
39
|
-
options
|
|
40
|
-
).then(payResMap);
|
|
3
|
+
import { apiPrefix } from "../../../config.js";
|
|
4
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
5
|
+
const boostPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
41
8
|
};
|
|
42
|
-
const getBoostPayInfo = async (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
session_id: sessionId,
|
|
47
|
-
client_key: clientKey,
|
|
48
|
-
payment_method: PaymentMethod.BOOST
|
|
49
|
-
},
|
|
50
|
-
options
|
|
51
|
-
).then(payResMap);
|
|
9
|
+
const getBoostPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
52
12
|
};
|
|
53
13
|
export {
|
|
54
14
|
boostPay,
|
|
@@ -1,59 +1,15 @@
|
|
|
1
|
-
import "../../../
|
|
2
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
3
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
4
2
|
import { http } from "../../http.js";
|
|
3
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
5
4
|
import { payResMap } from "../map.js";
|
|
6
|
-
async
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
bill: {
|
|
15
|
-
email: bill.email,
|
|
16
|
-
country: bill.country,
|
|
17
|
-
state: bill.province,
|
|
18
|
-
city: bill.city,
|
|
19
|
-
postal_code: bill.postCode,
|
|
20
|
-
address_line1: bill.address1,
|
|
21
|
-
address_line2: bill.address2,
|
|
22
|
-
county: bill.area
|
|
23
|
-
}
|
|
24
|
-
}, extraParams || {});
|
|
25
|
-
return http.post(
|
|
26
|
-
"/session/payments",
|
|
27
|
-
{
|
|
28
|
-
...params,
|
|
29
|
-
session_id: sessionId,
|
|
30
|
-
client_key: clientKey,
|
|
31
|
-
payment: {
|
|
32
|
-
payment_method: payment.paymentMethod,
|
|
33
|
-
card_no: payment.cardNo,
|
|
34
|
-
exp_year: payment.expYear,
|
|
35
|
-
exp_month: payment.expMonth,
|
|
36
|
-
cvv: payment.cvv,
|
|
37
|
-
holder_name: payment.holderName,
|
|
38
|
-
store_payment_method: payment.storePaymentMethod,
|
|
39
|
-
token_usage: payment.tokenUsage,
|
|
40
|
-
token: payment.token
|
|
41
|
-
},
|
|
42
|
-
browser
|
|
43
|
-
},
|
|
44
|
-
options
|
|
45
|
-
).then(payResMap);
|
|
46
|
-
}
|
|
47
|
-
async function getCardPayInfo({ sessionId, clientKey }, options) {
|
|
48
|
-
return http.post(
|
|
49
|
-
"/session/payments/query",
|
|
50
|
-
{
|
|
51
|
-
session_id: sessionId,
|
|
52
|
-
client_key: clientKey
|
|
53
|
-
},
|
|
54
|
-
options
|
|
55
|
-
).then(payResMap);
|
|
56
|
-
}
|
|
5
|
+
const cardPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getCardPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
57
13
|
export {
|
|
58
14
|
cardPay,
|
|
59
15
|
getCardPayInfo
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { RequestCacheManager } from "../../../utils/request-cache-manager.js";
|
|
2
|
+
import { apiPrefix } from "../../../config.js";
|
|
2
3
|
import { http } from "../../http.js";
|
|
3
4
|
import { getBrowserParams } from "../get-browser-params.js";
|
|
4
5
|
import { checkoutMap } from "./map.js";
|
|
5
|
-
const queryCheckout = async (
|
|
6
|
+
const queryCheckout = async (params, extraParams = {}, options) => {
|
|
6
7
|
return http.post(
|
|
7
|
-
|
|
8
|
+
`${apiPrefix}/info`,
|
|
8
9
|
{
|
|
9
|
-
session_id: sessionId,
|
|
10
|
-
client_key: clientKey,
|
|
10
|
+
session_id: params.sessionId,
|
|
11
|
+
client_key: params.clientKey,
|
|
12
|
+
...extraParams,
|
|
11
13
|
browser: await getBrowserParams()
|
|
12
14
|
},
|
|
13
15
|
options
|
|
14
16
|
);
|
|
15
17
|
};
|
|
16
|
-
const getCheckoutInfo = async (
|
|
17
|
-
const checkoutInfo = await queryCheckout(
|
|
18
|
-
return checkoutMap(
|
|
18
|
+
const getCheckoutInfo = async (params, extraParams = {}, options) => {
|
|
19
|
+
const checkoutInfo = await queryCheckout(params, extraParams, options);
|
|
20
|
+
return checkoutMap(checkoutInfo);
|
|
19
21
|
};
|
|
20
22
|
const requestCacheManager = new RequestCacheManager();
|
|
21
|
-
const onceGetCheckoutInfo = async (params, options) => {
|
|
22
|
-
const request = getCheckoutInfo(params, options);
|
|
23
|
+
const onceGetCheckoutInfo = async (params, extraParams = {}, options) => {
|
|
24
|
+
const request = getCheckoutInfo(params, extraParams, options);
|
|
23
25
|
return requestCacheManager.cacheRequest(JSON.stringify(params), request);
|
|
24
26
|
};
|
|
25
27
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PaymentMethod } from "../../../constant.js";
|
|
2
2
|
import { amountMap } from "../map.js";
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
const formatPaymentMethodInfo = (paymentMethods = []) => {
|
|
4
|
+
const supportMethods = [];
|
|
5
5
|
const channelParams = {};
|
|
6
6
|
paymentMethods.forEach(({ value, configuration = {} }) => {
|
|
7
7
|
if (value === PaymentMethod.APPLE_PAY) {
|
|
@@ -38,17 +38,17 @@ function formatPaymentMethodInfo(paymentMethods = []) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
if (value === PaymentMethod.BANKCARD) {
|
|
41
|
-
|
|
41
|
+
supportMethods.push(...configuration.allowed_card_networks || []);
|
|
42
42
|
} else {
|
|
43
|
-
|
|
43
|
+
supportMethods.push(value);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
|
-
|
|
47
|
+
supportMethods,
|
|
48
48
|
channelParams
|
|
49
49
|
};
|
|
50
|
-
}
|
|
51
|
-
|
|
50
|
+
};
|
|
51
|
+
const formatAmountBreakdown = (info = {}) => {
|
|
52
52
|
return {
|
|
53
53
|
goodsTax: amountMap(info.goods_tax),
|
|
54
54
|
shippingAmount: amountMap(info.shipping_amount),
|
|
@@ -56,10 +56,11 @@ function formatAmountBreakdown(info = {}) {
|
|
|
56
56
|
discount: amountMap(info.discount),
|
|
57
57
|
other: amountMap(info.other)
|
|
58
58
|
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
var _a, _b
|
|
62
|
-
const { theme,
|
|
59
|
+
};
|
|
60
|
+
const checkoutMap = (res = {}) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const { theme, field, support_methods = {} } = res;
|
|
63
|
+
const { payment_methods, bill, tokens } = support_methods;
|
|
63
64
|
const paymentMethodsInfo = formatPaymentMethodInfo(payment_methods);
|
|
64
65
|
const sessionMode = res.session_mode === "HOST" ? "HOSTED" : res.session_mode;
|
|
65
66
|
return {
|
|
@@ -69,13 +70,17 @@ function checkoutMap(res = {}) {
|
|
|
69
70
|
status: res.status,
|
|
70
71
|
transAmount: amountMap(res.trans_amount),
|
|
71
72
|
expireTime: res.expire_time,
|
|
72
|
-
|
|
73
|
+
paymentMethod: res.payment_method,
|
|
74
|
+
// 兼容其他收银台,没有 session_mode 字段就默认 HOSTED
|
|
75
|
+
sessionMode: sessionMode || "HOSTED",
|
|
73
76
|
merchantName: (_a = res.theme) == null ? void 0 : _a.merchant_name,
|
|
74
77
|
returnUrl: res.return_url,
|
|
75
78
|
cancelUrl: res.cancel_url,
|
|
76
79
|
locale: res.locale,
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
// 兼容其他收银台,没有 payment_type 字段就默认 PURCHASE
|
|
81
|
+
paymentType: res.payment_type || "PURCHASE",
|
|
82
|
+
orderId: res.order_id,
|
|
83
|
+
goods: res.goods || [],
|
|
79
84
|
theme: {
|
|
80
85
|
merchantName: theme == null ? void 0 : theme.merchant_name,
|
|
81
86
|
logo: theme == null ? void 0 : theme.logo,
|
|
@@ -91,13 +96,13 @@ function checkoutMap(res = {}) {
|
|
|
91
96
|
descriptor: bill == null ? void 0 : bill.descriptor,
|
|
92
97
|
country: bill == null ? void 0 : bill.country
|
|
93
98
|
},
|
|
94
|
-
tokens:
|
|
99
|
+
tokens: tokens == null ? void 0 : tokens.map((card) => ({
|
|
95
100
|
token: card.token,
|
|
96
101
|
last4: card.last4,
|
|
97
102
|
cardBrand: card.card_brand,
|
|
98
103
|
billingAddressFilled: card.billing_address_filled
|
|
99
104
|
})),
|
|
100
|
-
storePaymentMethod: (
|
|
105
|
+
storePaymentMethod: (_b = res.payment) == null ? void 0 : _b.store_payment_method,
|
|
101
106
|
field: {
|
|
102
107
|
holderName: {
|
|
103
108
|
show: !!(field == null ? void 0 : field.holder_name_display),
|
|
@@ -114,9 +119,11 @@ function checkoutMap(res = {}) {
|
|
|
114
119
|
}
|
|
115
120
|
},
|
|
116
121
|
amountBreakdown: formatAmountBreakdown(res.amount_breakdown),
|
|
117
|
-
|
|
122
|
+
finishTime: res.utc_finish_time,
|
|
123
|
+
...paymentMethodsInfo,
|
|
124
|
+
rawResponse: res
|
|
118
125
|
};
|
|
119
|
-
}
|
|
126
|
+
};
|
|
120
127
|
export {
|
|
121
128
|
checkoutMap,
|
|
122
129
|
formatPaymentMethodInfo
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { intersection } from "../../../utils/index.js";
|
|
2
2
|
import { http } from "../../http.js";
|
|
3
|
+
import "../../../core.js";
|
|
3
4
|
import { formatPaymentMethodInfo } from "../checkout/map.js";
|
|
4
5
|
import { cardBrandCodes } from "../../../utils/card-brand/brands.js";
|
|
5
6
|
const verifyClientKey = async (clientKey, merchantId, options) => {
|
|
@@ -12,8 +13,8 @@ const verifyClientKey = async (clientKey, merchantId, options) => {
|
|
|
12
13
|
options
|
|
13
14
|
).then((res) => {
|
|
14
15
|
var _a;
|
|
15
|
-
const {
|
|
16
|
-
const brands = intersection(cardBrandCodes,
|
|
16
|
+
const { supportMethods } = formatPaymentMethodInfo(((_a = res.support_methods) == null ? void 0 : _a.payment_methods) || []);
|
|
17
|
+
const brands = intersection(cardBrandCodes, supportMethods);
|
|
17
18
|
return {
|
|
18
19
|
brands
|
|
19
20
|
};
|
|
@@ -1,54 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../utils/card-brand/brands.js";
|
|
3
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
5
2
|
import { http } from "../../http.js";
|
|
3
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
6
4
|
import { payResMap } from "../map.js";
|
|
7
|
-
const gcashPay = async ({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
payment,
|
|
11
|
-
bill,
|
|
12
|
-
browser
|
|
13
|
-
}, core, options) => {
|
|
14
|
-
const { _getExtraParams } = core.config;
|
|
15
|
-
const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", payment.paymentMethod);
|
|
16
|
-
const params = deepMerge({
|
|
17
|
-
bill: {
|
|
18
|
-
email: bill.email,
|
|
19
|
-
country: bill.country,
|
|
20
|
-
state: bill.province,
|
|
21
|
-
city: bill.city,
|
|
22
|
-
postal_code: bill.postCode,
|
|
23
|
-
address_line1: bill.address1,
|
|
24
|
-
address_line2: bill.address2,
|
|
25
|
-
county: bill.area
|
|
26
|
-
}
|
|
27
|
-
}, extraParams || {});
|
|
28
|
-
return http.post(
|
|
29
|
-
"/session/payments",
|
|
30
|
-
{
|
|
31
|
-
...params,
|
|
32
|
-
session_id: sessionId,
|
|
33
|
-
client_key: clientKey,
|
|
34
|
-
payment: {
|
|
35
|
-
payment_method: payment.paymentMethod
|
|
36
|
-
},
|
|
37
|
-
browser
|
|
38
|
-
},
|
|
39
|
-
options
|
|
40
|
-
).then(payResMap);
|
|
5
|
+
const gcashPay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
41
8
|
};
|
|
42
|
-
const getGcashPayInfo = async (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
session_id: sessionId,
|
|
47
|
-
client_key: clientKey,
|
|
48
|
-
payment_method: PaymentMethod.GCASH
|
|
49
|
-
},
|
|
50
|
-
options
|
|
51
|
-
).then(payResMap);
|
|
9
|
+
const getGcashPayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
52
12
|
};
|
|
53
13
|
export {
|
|
54
14
|
gcashPay,
|
|
@@ -1,61 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../utils/card-brand/brands.js";
|
|
3
|
-
import "../../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import { deepMerge } from "../../../utils/object.js";
|
|
1
|
+
import { apiPrefix } from "../../../config.js";
|
|
5
2
|
import { http } from "../../http.js";
|
|
3
|
+
import { buildPaymentParams, buildQueryParams } from "../../utils/index.js";
|
|
6
4
|
import { payResMap } from "../map.js";
|
|
7
|
-
async
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const extraParams = _getExtraParams == null ? void 0 : _getExtraParams("payment", PaymentMethod.GOOGLE_PAY);
|
|
16
|
-
const params = deepMerge({
|
|
17
|
-
bill: {
|
|
18
|
-
first_name: bill == null ? void 0 : bill.firstName,
|
|
19
|
-
middle_name: bill == null ? void 0 : bill.middleName,
|
|
20
|
-
last_name: bill == null ? void 0 : bill.lastName,
|
|
21
|
-
address_line1: bill == null ? void 0 : bill.addressLine1,
|
|
22
|
-
address_line2: bill == null ? void 0 : bill.addressLine2,
|
|
23
|
-
country: bill == null ? void 0 : bill.country,
|
|
24
|
-
state: bill == null ? void 0 : bill.state,
|
|
25
|
-
city: bill == null ? void 0 : bill.city,
|
|
26
|
-
email: bill == null ? void 0 : bill.email,
|
|
27
|
-
postal_code: bill == null ? void 0 : bill.postalCode,
|
|
28
|
-
area_code: bill == null ? void 0 : bill.areaCode,
|
|
29
|
-
phone_number: bill == null ? void 0 : bill.phoneNumber,
|
|
30
|
-
descriptor: bill == null ? void 0 : bill.descriptor
|
|
31
|
-
}
|
|
32
|
-
}, extraParams || {});
|
|
33
|
-
return http.post(
|
|
34
|
-
"/session/payments",
|
|
35
|
-
{
|
|
36
|
-
...params,
|
|
37
|
-
session_id: sessionId,
|
|
38
|
-
client_key: clientKey,
|
|
39
|
-
payment: {
|
|
40
|
-
payment_method: PaymentMethod.GOOGLE_PAY,
|
|
41
|
-
token_data: token
|
|
42
|
-
},
|
|
43
|
-
browser
|
|
44
|
-
},
|
|
45
|
-
options
|
|
46
|
-
).then(payResMap);
|
|
47
|
-
}
|
|
48
|
-
async function getGooglePayInfo({ sessionId, clientKey }, options) {
|
|
49
|
-
return http.post(
|
|
50
|
-
"/session/payments/query",
|
|
51
|
-
{
|
|
52
|
-
session_id: sessionId,
|
|
53
|
-
client_key: clientKey,
|
|
54
|
-
payment_method: PaymentMethod.GOOGLE_PAY
|
|
55
|
-
},
|
|
56
|
-
options
|
|
57
|
-
).then(payResMap);
|
|
58
|
-
}
|
|
5
|
+
const googlePay = async (params, extraParams, options) => {
|
|
6
|
+
const paymentParams = buildPaymentParams(params, extraParams);
|
|
7
|
+
return http.post(`${apiPrefix}/payments`, paymentParams, options).then(payResMap);
|
|
8
|
+
};
|
|
9
|
+
const getGooglePayInfo = async (params, extraParams, options) => {
|
|
10
|
+
const queryParams = buildQueryParams(params, extraParams);
|
|
11
|
+
return http.post(`${apiPrefix}/payments/query`, queryParams, options).then(payResMap);
|
|
12
|
+
};
|
|
59
13
|
export {
|
|
60
14
|
getGooglePayInfo,
|
|
61
15
|
googlePay
|