@paykka/card-checkout-ui 0.13.13 → 0.13.15
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 +14 -14
- package/dist/es/api/modules/get-browser-params.js +1 -1
- package/dist/es/components/GooglePay/index.js +20 -7
- package/dist/es/components/ThreeDS/index.js +19 -3
- package/dist/es/components/internal/Select/Select.js +8 -2
- package/dist/es/config.js +4 -4
- package/dist/es/core/environment.js +13 -14
- package/dist/es/core.js +34 -34
- package/dist/es/hooks/usePayState.js +5 -2
- package/dist/es/index.js +3 -1
- package/dist/es/types/event.js +19 -1
- package/dist/es/types/message.js +1 -0
- package/dist/es/utils/index.js +8 -8
- package/dist/types/api/modules/threeDS/index.d.ts +5 -0
- package/dist/types/components/GooglePay/createGooglePay.d.ts +2 -1
- package/dist/types/components/ThreeDS/components/ThreeDSIframe/output.d.ts +3 -0
- package/dist/types/config.d.ts +2 -2
- package/dist/types/core/environment.d.ts +11 -2
- package/dist/types/types/event.d.ts +37 -3
- package/dist/types/types/message.d.ts +3 -0
- package/dist/types/utils/app-payment.d.ts +10 -0
- package/dist/types/utils/index.d.ts +30 -7
- package/dist/types/utils/logger.d.ts +14 -0
- package/package.json +5 -1
|
@@ -39,7 +39,7 @@ const getBaseBrowserParams = async (params = {}) => {
|
|
|
39
39
|
terminal_type: terminalType,
|
|
40
40
|
fraud_detection_id: fraudDetectionId,
|
|
41
41
|
// 当前组件库版本(构建时由 define 注入)
|
|
42
|
-
app_version: "0.13.
|
|
42
|
+
app_version: "0.13.15"
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
const getBrowserParams = async (params = {}) => {
|
|
@@ -3,6 +3,7 @@ import { isTimeoutError } from "../../api/http.js";
|
|
|
3
3
|
import "../../utils/card-brand/brands.js";
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { extractAreaCodeAndPhoneNumber } from "../../utils/format.js";
|
|
6
|
+
import { GooglePayEventType } from "../../types/event.js";
|
|
6
7
|
import { deepMerge } from "../../utils/object.js";
|
|
7
8
|
import { formatPaymentResult } from "../../utils/payment.js";
|
|
8
9
|
import { getBrowserParams } from "../../api/modules/get-browser-params.js";
|
|
@@ -17,7 +18,7 @@ import { useRetry } from "../../hooks/useRetry.js";
|
|
|
17
18
|
import { Info } from "../internal/Info/Info.js";
|
|
18
19
|
import { loadScript } from "../../utils/load.js";
|
|
19
20
|
import { ThreeDSAuth } from "../ThreeDS/index.js";
|
|
20
|
-
function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
21
|
+
function createGooglePay(core, checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
21
22
|
const {
|
|
22
23
|
transAmount,
|
|
23
24
|
theme: { merchantName }
|
|
@@ -96,9 +97,10 @@ function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
|
96
97
|
}
|
|
97
98
|
function onPaymentAuthorized(paymentData) {
|
|
98
99
|
return new Promise(function(resolve) {
|
|
99
|
-
var _a, _b;
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
|
+
(_b = (_a = core.config).onEvent) == null ? void 0 : _b.call(_a, GooglePayEventType.GOOGLE_PAY_AUTHORIZED);
|
|
100
102
|
console.log("google pay token", paymentData.paymentMethodData.tokenizationData.token);
|
|
101
|
-
console.log("google pay billingAddress", (
|
|
103
|
+
console.log("google pay billingAddress", (_c = paymentData.paymentMethodData.info) == null ? void 0 : _c.billingAddress);
|
|
102
104
|
const {
|
|
103
105
|
name,
|
|
104
106
|
address1,
|
|
@@ -109,7 +111,7 @@ function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
|
109
111
|
locality,
|
|
110
112
|
postalCode,
|
|
111
113
|
phoneNumber
|
|
112
|
-
} = ((
|
|
114
|
+
} = ((_d = paymentData.paymentMethodData.info) == null ? void 0 : _d.billingAddress) ?? {};
|
|
113
115
|
console.warn("GooglePay Res", paymentData.paymentMethodData);
|
|
114
116
|
pay(paymentData.paymentMethodData.tokenizationData.token, {
|
|
115
117
|
email: paymentData.email,
|
|
@@ -130,11 +132,13 @@ function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
|
130
132
|
function onGooglePayLoaded(container) {
|
|
131
133
|
const paymentsClient2 = getGooglePaymentsClient();
|
|
132
134
|
paymentsClient2.isReadyToPay(getGoogleIsReadyToPayRequest()).then(function(response) {
|
|
135
|
+
var _a, _b;
|
|
133
136
|
if (response.result) {
|
|
134
137
|
addGooglePayButton(container);
|
|
135
138
|
onCanUse == null ? void 0 : onCanUse(true);
|
|
136
139
|
} else {
|
|
137
140
|
onCanUse == null ? void 0 : onCanUse(false);
|
|
141
|
+
(_b = (_a = core.config).onEvent) == null ? void 0 : _b.call(_a, GooglePayEventType.GOOGLE_PAY_CAN_NOT_USE);
|
|
138
142
|
}
|
|
139
143
|
}).catch(function(err) {
|
|
140
144
|
console.error(err);
|
|
@@ -150,12 +154,19 @@ function createGooglePay(checkout, googlePayConfig, pay, onClick, onCanUse) {
|
|
|
150
154
|
container == null ? void 0 : container.appendChild(button);
|
|
151
155
|
}
|
|
152
156
|
function onGooglePaymentButtonClicked() {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
(_b = (_a = core.config).onEvent) == null ? void 0 : _b.call(_a, GooglePayEventType.GOOGLE_PAY_BUTTON_CLICKED);
|
|
153
159
|
onClick == null ? void 0 : onClick();
|
|
154
160
|
const paymentDataRequest = getGooglePaymentDataRequest();
|
|
155
161
|
paymentDataRequest.transactionInfo = getGoogleTransactionInfo();
|
|
156
162
|
const paymentsClient2 = getGooglePaymentsClient();
|
|
157
163
|
console.log("paymentDataRequest", paymentDataRequest);
|
|
158
|
-
paymentsClient2.loadPaymentData(paymentDataRequest)
|
|
164
|
+
paymentsClient2.loadPaymentData(paymentDataRequest).catch((err) => {
|
|
165
|
+
var _a2, _b2;
|
|
166
|
+
if ((err == null ? void 0 : err.statusCode) === "CANCELED") {
|
|
167
|
+
(_b2 = (_a2 = core.config).onEvent) == null ? void 0 : _b2.call(_a2, GooglePayEventType.GOOGLE_PAY_CANCELLED);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
159
170
|
}
|
|
160
171
|
return {
|
|
161
172
|
onGooglePayLoaded
|
|
@@ -237,9 +248,10 @@ const GooglePay = w((props, ref) => {
|
|
|
237
248
|
(_a3 = props.onLoad) == null ? void 0 : _a3.call(props, true);
|
|
238
249
|
},
|
|
239
250
|
() => {
|
|
240
|
-
var _a3;
|
|
251
|
+
var _a3, _b2, _c;
|
|
241
252
|
setShowGooglePay(false);
|
|
242
|
-
(_a3 =
|
|
253
|
+
(_b2 = (_a3 = core.config).onEvent) == null ? void 0 : _b2.call(_a3, GooglePayEventType.GOOGLE_PAY_LOAD_ERROR);
|
|
254
|
+
(_c = props.onLoad) == null ? void 0 : _c.call(props, false);
|
|
243
255
|
}
|
|
244
256
|
);
|
|
245
257
|
setHosted(sessionMode === SessionMode.HOSTED);
|
|
@@ -508,6 +520,7 @@ const GooglePay = w((props, ref) => {
|
|
|
508
520
|
y(() => {
|
|
509
521
|
if (containRef && (session == null ? void 0 : session.checkout) && showGooglePay) {
|
|
510
522
|
const { onGooglePayLoaded } = createGooglePay(
|
|
523
|
+
core,
|
|
511
524
|
session == null ? void 0 : session.checkout,
|
|
512
525
|
googlePayConfig,
|
|
513
526
|
pay,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h, A, T, y, u } from "../../core.js";
|
|
1
|
+
import { h, A, x, T, y, u } from "../../core.js";
|
|
2
2
|
import "../../utils/card-brand/brands.js";
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
|
-
import "../../core/context.js";
|
|
4
|
+
import { CoreContext } from "../../core/context.js";
|
|
5
5
|
import "../../out/worldpay-jsc-origin.js";
|
|
6
6
|
import { Modal } from "../internal/Modal/Modal.js";
|
|
7
7
|
import "../internal/Button/button2.js";
|
|
@@ -10,6 +10,7 @@ import { useI18n } from "../../hooks/useI18n.js";
|
|
|
10
10
|
import { safeParse } from "../../utils/index.js";
|
|
11
11
|
import { cdnOrigin } from "../../config.js";
|
|
12
12
|
import { MessageAction } from "../../types/message.js";
|
|
13
|
+
import { ThreeDSEventType } from "../../types/event.js";
|
|
13
14
|
import { useBreakpoints } from "../../hooks/useBreakpoints.js";
|
|
14
15
|
import { Icon3DSInfo } from "../internal/icons/Icon3DSInfo.js";
|
|
15
16
|
import { Button } from "../internal/Button/Button.js";
|
|
@@ -32,11 +33,16 @@ const ThreeDSAuth = (props) => {
|
|
|
32
33
|
const iframeRef = A(null);
|
|
33
34
|
const [iframeName] = h(`${THREE_DS_IFRAME_NAME}-${checkoutId}-${Date.now()}`);
|
|
34
35
|
const { i18n } = useI18n();
|
|
36
|
+
const { core } = x(CoreContext) ?? {};
|
|
35
37
|
const handleLastThreeDs = () => {
|
|
36
38
|
setContinueThreeDs(true);
|
|
37
39
|
};
|
|
38
40
|
const onChange = (status) => {
|
|
39
|
-
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (!status) {
|
|
43
|
+
(_b = (_a = core == null ? void 0 : core.config) == null ? void 0 : _a.onEvent) == null ? void 0 : _b.call(_a, ThreeDSEventType.THREE_DS_CANCELLED);
|
|
44
|
+
onClose == null ? void 0 : onClose();
|
|
45
|
+
}
|
|
40
46
|
};
|
|
41
47
|
const modalWidth = T(() => {
|
|
42
48
|
if (!show) {
|
|
@@ -45,11 +51,16 @@ const ThreeDSAuth = (props) => {
|
|
|
45
51
|
return width || (breakpoints.smaller("sm") ? "90vw" : "600px");
|
|
46
52
|
}, [show, width, breakpoints.matches]);
|
|
47
53
|
y(() => {
|
|
54
|
+
var _a, _b;
|
|
48
55
|
if (show) {
|
|
56
|
+
if (incomplete) {
|
|
57
|
+
(_b = (_a = core == null ? void 0 : core.config) == null ? void 0 : _a.onEvent) == null ? void 0 : _b.call(_a, ThreeDSEventType.THREE_DS_CONTINUE);
|
|
58
|
+
}
|
|
49
59
|
if (messageHandler.current) {
|
|
50
60
|
window.removeEventListener("message", messageHandler.current);
|
|
51
61
|
}
|
|
52
62
|
messageHandler.current = (event) => {
|
|
63
|
+
var _a2, _b2, _c, _d;
|
|
53
64
|
const { data, origin } = event;
|
|
54
65
|
if (origin !== cdnOrigin) {
|
|
55
66
|
return;
|
|
@@ -62,6 +73,11 @@ const ThreeDSAuth = (props) => {
|
|
|
62
73
|
switch (feedbackData.action) {
|
|
63
74
|
case MessageAction.CHECK_THREE_DS: {
|
|
64
75
|
onChange(false);
|
|
76
|
+
(_b2 = (_a2 = core == null ? void 0 : core.config) == null ? void 0 : _a2.onEvent) == null ? void 0 : _b2.call(_a2, ThreeDSEventType.THREE_DS_END);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case MessageAction.THREE_DS_AUTH_LOADED: {
|
|
80
|
+
(_d = (_c = core == null ? void 0 : core.config) == null ? void 0 : _c.onEvent) == null ? void 0 : _d.call(_c, ThreeDSEventType.THREE_DS_AUTH);
|
|
65
81
|
break;
|
|
66
82
|
}
|
|
67
83
|
}
|
|
@@ -34,7 +34,13 @@ const Select = w((props, ref) => {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
setSelectOptions(props.options ?? []);
|
|
37
|
-
if (
|
|
37
|
+
if (isNil(props.value) || props.value === "") {
|
|
38
|
+
setValue(void 0);
|
|
39
|
+
setDisplay(void 0);
|
|
40
|
+
setInputValue("");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (props.options.length) {
|
|
38
44
|
const item = findItemByValue(props.value, props.options);
|
|
39
45
|
item && onSelect(item, false);
|
|
40
46
|
}
|
|
@@ -185,7 +191,7 @@ const Select = w((props, ref) => {
|
|
|
185
191
|
display: dropMenuVisible ? "block" : "none"
|
|
186
192
|
},
|
|
187
193
|
children: [
|
|
188
|
-
doFilter && selectOptions.length
|
|
194
|
+
doFilter && !selectOptions.length ? /* @__PURE__ */ u("div", { class: bem("menu-no-data"), children: props.noDataTip }) : selectOptions.map((item) => /* @__PURE__ */ u(
|
|
189
195
|
SelectMenuItem,
|
|
190
196
|
{
|
|
191
197
|
onSelect,
|
package/dist/es/config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "./utils/card-brand/brands.js";
|
|
2
2
|
import "./utils/system-info/get-browser-info.js";
|
|
3
3
|
import "./core.js";
|
|
4
|
-
let apiUrl = "
|
|
5
|
-
let cdnOrigin = "
|
|
6
|
-
let cdnDir = "
|
|
7
|
-
let cdnUrl =
|
|
4
|
+
let apiUrl = "";
|
|
5
|
+
let cdnOrigin = "";
|
|
6
|
+
let cdnDir = "";
|
|
7
|
+
let cdnUrl = "";
|
|
8
8
|
let fraudDetectionEnv = void 0;
|
|
9
9
|
let customReqHeaders = {};
|
|
10
10
|
let customLocale = void 0;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
+
const SANDBOX_ORIGIN = "https://checkout-sandbox.aq.paykka.com";
|
|
2
|
+
const HK_ORIGIN = "https://checkout.aq.paykka.com";
|
|
3
|
+
const EU_ORIGIN = "https://checkout.eu.paykka.com";
|
|
1
4
|
const apiEnv = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
sandbox:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
dev: ""
|
|
8
|
-
}
|
|
5
|
+
dev: "",
|
|
6
|
+
fat: "",
|
|
7
|
+
sandbox: SANDBOX_ORIGIN,
|
|
8
|
+
hk: HK_ORIGIN,
|
|
9
|
+
eu: EU_ORIGIN
|
|
9
10
|
};
|
|
10
11
|
const cdnEnv = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
sandbox:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
dev: ""
|
|
17
|
-
}
|
|
12
|
+
dev: "",
|
|
13
|
+
fat: "",
|
|
14
|
+
sandbox: `${SANDBOX_ORIGIN}/cp`,
|
|
15
|
+
hk: `${HK_ORIGIN}/cp`,
|
|
16
|
+
eu: `${EU_ORIGIN}/cp`
|
|
18
17
|
};
|
|
19
18
|
export {
|
|
20
19
|
apiEnv,
|
package/dist/es/core.js
CHANGED
|
@@ -701,36 +701,6 @@ l$3.diffed = function(n2) {
|
|
|
701
701
|
var t2 = n2.props, e2 = n2.__e;
|
|
702
702
|
null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value);
|
|
703
703
|
};
|
|
704
|
-
function e$1(e2, n2) {
|
|
705
|
-
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
706
|
-
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
707
|
-
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
708
|
-
return Promise.resolve(s2.responseText);
|
|
709
|
-
}, json: function() {
|
|
710
|
-
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
711
|
-
}, blob: function() {
|
|
712
|
-
return Promise.resolve(new Blob([s2.response]));
|
|
713
|
-
}, clone: e3, headers: { keys: function() {
|
|
714
|
-
return o2;
|
|
715
|
-
}, entries: function() {
|
|
716
|
-
return o2.map(function(e4) {
|
|
717
|
-
return [e4, s2.getResponseHeader(e4)];
|
|
718
|
-
});
|
|
719
|
-
}, get: function(e4) {
|
|
720
|
-
return s2.getResponseHeader(e4);
|
|
721
|
-
}, has: function(e4) {
|
|
722
|
-
return null != s2.getResponseHeader(e4);
|
|
723
|
-
} } };
|
|
724
|
-
};
|
|
725
|
-
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
726
|
-
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
727
|
-
u2[n3] || o2.push(u2[n3] = n3);
|
|
728
|
-
}), t2(a2());
|
|
729
|
-
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
730
|
-
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
731
|
-
s2.send(n2.body || null);
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
704
|
var __assign = function() {
|
|
735
705
|
__assign = Object.assign || function __assign2(t2) {
|
|
736
706
|
for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
|
|
@@ -3943,7 +3913,7 @@ function t() {
|
|
|
3943
3913
|
}
|
|
3944
3914
|
var o = void 0;
|
|
3945
3915
|
var h = void 0, s$1 = 0, f = 0, v = 0;
|
|
3946
|
-
function e(i2) {
|
|
3916
|
+
function e$1(i2) {
|
|
3947
3917
|
if (void 0 !== o) {
|
|
3948
3918
|
var t2 = i2.n;
|
|
3949
3919
|
if (void 0 === t2 || t2.t !== o) {
|
|
@@ -4034,7 +4004,7 @@ u.prototype.peek = function() {
|
|
|
4034
4004
|
}
|
|
4035
4005
|
};
|
|
4036
4006
|
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
4037
|
-
var i2 = e(this);
|
|
4007
|
+
var i2 = e$1(this);
|
|
4038
4008
|
if (void 0 !== i2)
|
|
4039
4009
|
i2.i = this.i;
|
|
4040
4010
|
return this.v;
|
|
@@ -4165,7 +4135,7 @@ y.prototype.N = function() {
|
|
|
4165
4135
|
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
4166
4136
|
if (1 & this.f)
|
|
4167
4137
|
throw new Error("Cycle detected");
|
|
4168
|
-
var i2 = e(this);
|
|
4138
|
+
var i2 = e$1(this);
|
|
4169
4139
|
this.h();
|
|
4170
4140
|
if (void 0 !== i2)
|
|
4171
4141
|
i2.i = this.i;
|
|
@@ -4448,6 +4418,36 @@ function useSignal(n2) {
|
|
|
4448
4418
|
return d$1(n2);
|
|
4449
4419
|
}, []);
|
|
4450
4420
|
}
|
|
4421
|
+
function e(e2, n2) {
|
|
4422
|
+
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
4423
|
+
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
4424
|
+
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
4425
|
+
return Promise.resolve(s2.responseText);
|
|
4426
|
+
}, json: function() {
|
|
4427
|
+
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
4428
|
+
}, blob: function() {
|
|
4429
|
+
return Promise.resolve(new Blob([s2.response]));
|
|
4430
|
+
}, clone: e3, headers: { keys: function() {
|
|
4431
|
+
return o2;
|
|
4432
|
+
}, entries: function() {
|
|
4433
|
+
return o2.map(function(e4) {
|
|
4434
|
+
return [e4, s2.getResponseHeader(e4)];
|
|
4435
|
+
});
|
|
4436
|
+
}, get: function(e4) {
|
|
4437
|
+
return s2.getResponseHeader(e4);
|
|
4438
|
+
}, has: function(e4) {
|
|
4439
|
+
return null != s2.getResponseHeader(e4);
|
|
4440
|
+
} } };
|
|
4441
|
+
};
|
|
4442
|
+
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
4443
|
+
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
4444
|
+
u2[n3] || o2.push(u2[n3] = n3);
|
|
4445
|
+
}), t2(a2());
|
|
4446
|
+
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
4447
|
+
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
4448
|
+
s2.send(n2.body || null);
|
|
4449
|
+
});
|
|
4450
|
+
}
|
|
4451
4451
|
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
4452
4452
|
function isBytes(a2) {
|
|
4453
4453
|
return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array";
|
|
@@ -7019,7 +7019,7 @@ export {
|
|
|
7019
7019
|
b$1 as b,
|
|
7020
7020
|
browser,
|
|
7021
7021
|
d$1 as d,
|
|
7022
|
-
e
|
|
7022
|
+
e,
|
|
7023
7023
|
gcm,
|
|
7024
7024
|
h$1 as h,
|
|
7025
7025
|
index,
|
|
@@ -13,19 +13,22 @@ function usePayState(session, core) {
|
|
|
13
13
|
const { i18n } = useI18n();
|
|
14
14
|
y(() => {
|
|
15
15
|
session.ready().then(() => {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c, _d;
|
|
17
17
|
setSessionReady(true);
|
|
18
18
|
const locale = getRealLocale(
|
|
19
19
|
customLocale || ((_a = session.checkout) == null ? void 0 : _a.locale) || getBrowserInfo().language
|
|
20
20
|
);
|
|
21
21
|
i18n.load(locale);
|
|
22
|
+
if (!((_c = (_b = session.checkout) == null ? void 0 : _b.supportMethods) == null ? void 0 : _c.length)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
22
25
|
const fraudDetection2 = getFraudDetectionInstance(
|
|
23
26
|
{
|
|
24
27
|
clientKey: session.paykkaDetectionKey,
|
|
25
28
|
env: fraudDetectionEnv
|
|
26
29
|
},
|
|
27
30
|
{
|
|
28
|
-
sessionMode: (
|
|
31
|
+
sessionMode: (_d = session.checkout) == null ? void 0 : _d.sessionMode,
|
|
29
32
|
onEvent: (type, data) => {
|
|
30
33
|
var _a2, _b2;
|
|
31
34
|
(_b2 = core == null ? void 0 : (_a2 = core.config).onEvent) == null ? void 0 : _b2.call(_a2, type, data);
|
package/dist/es/index.js
CHANGED
|
@@ -49,7 +49,7 @@ import "./core.js";
|
|
|
49
49
|
import { I18n } from "./i18n/I18n.js";
|
|
50
50
|
import { LocaleKey } from "./i18n/locales/index.js";
|
|
51
51
|
import { setApiUrl, setCDNUrl, setCustomLocale, setCustomReqHeaders, setFraudDetectionEnv } from "./config.js";
|
|
52
|
-
import { ApplePayEventType, FraudDetectionEventType, GooglePayEventType, PaymentEventType } from "./types/event.js";
|
|
52
|
+
import { ApplePayEventType, FraudDetectionEventType, GooglePayEventType, PaymentEventType, SecurityIframeEventType, ThreeDSEventType } from "./types/event.js";
|
|
53
53
|
import "./out/worldpay-jsc-origin.js";
|
|
54
54
|
import { ECollMode } from "./types/fraud-detection.js";
|
|
55
55
|
import { MessageAction } from "./types/message.js";
|
|
@@ -100,11 +100,13 @@ export {
|
|
|
100
100
|
PicPay,
|
|
101
101
|
Pix,
|
|
102
102
|
SecuredIframe,
|
|
103
|
+
SecurityIframeEventType,
|
|
103
104
|
Sepa,
|
|
104
105
|
Session,
|
|
105
106
|
ShopeePay,
|
|
106
107
|
SubmitButton,
|
|
107
108
|
TNGWallet,
|
|
109
|
+
ThreeDSEventType,
|
|
108
110
|
Vietqr,
|
|
109
111
|
WechatPay,
|
|
110
112
|
Zalopay,
|
package/dist/es/types/event.js
CHANGED
|
@@ -22,18 +22,36 @@ var GooglePayEventType = /* @__PURE__ */ ((GooglePayEventType2) => {
|
|
|
22
22
|
GooglePayEventType2["GOOGLE_PAY_LOAD_ERROR"] = "googlePay:loadError";
|
|
23
23
|
GooglePayEventType2["GOOGLE_PAY_CAN_NOT_USE"] = "googlePay:canNotUse";
|
|
24
24
|
GooglePayEventType2["GOOGLE_PAY_BUTTON_CLICKED"] = "googlePay:buttonClicked";
|
|
25
|
+
GooglePayEventType2["GOOGLE_PAY_AUTHORIZED"] = "googlePay:authorized";
|
|
26
|
+
GooglePayEventType2["GOOGLE_PAY_CANCELLED"] = "googlePay:cancelled";
|
|
25
27
|
return GooglePayEventType2;
|
|
26
28
|
})(GooglePayEventType || {});
|
|
27
29
|
var PaymentEventType = /* @__PURE__ */ ((PaymentEventType2) => {
|
|
30
|
+
PaymentEventType2["PAYMENT_START"] = "payment:start";
|
|
28
31
|
PaymentEventType2["PAYMENT_SUCCESS"] = "payment:success";
|
|
29
32
|
PaymentEventType2["PAYMENT_FAILURE"] = "payment:failure";
|
|
30
33
|
PaymentEventType2["PAYMENT_TIMEOUT"] = "payment:timeout";
|
|
31
34
|
PaymentEventType2["PAYMENT_EXPIRED"] = "payment:expired";
|
|
32
35
|
return PaymentEventType2;
|
|
33
36
|
})(PaymentEventType || {});
|
|
37
|
+
var ThreeDSEventType = /* @__PURE__ */ ((ThreeDSEventType2) => {
|
|
38
|
+
ThreeDSEventType2["THREE_DS_CANCELLED"] = "threeDS:cancelled";
|
|
39
|
+
ThreeDSEventType2["THREE_DS_CONTINUE"] = "threeDS:continue";
|
|
40
|
+
ThreeDSEventType2["THREE_DS_END"] = "threeDS:end";
|
|
41
|
+
ThreeDSEventType2["THREE_DS_AUTH"] = "threeDS:auth";
|
|
42
|
+
return ThreeDSEventType2;
|
|
43
|
+
})(ThreeDSEventType || {});
|
|
44
|
+
var SecurityIframeEventType = /* @__PURE__ */ ((SecurityIframeEventType2) => {
|
|
45
|
+
SecurityIframeEventType2["SECURITY_IFRAME_INIT"] = "securityIframe:init";
|
|
46
|
+
SecurityIframeEventType2["SECURITY_IFRAME_INIT_SUCCESS"] = "securityIframe:initSuccess";
|
|
47
|
+
SecurityIframeEventType2["SECURITY_IFRAME_INIT_ERROR"] = "securityIframe:initError";
|
|
48
|
+
return SecurityIframeEventType2;
|
|
49
|
+
})(SecurityIframeEventType || {});
|
|
34
50
|
export {
|
|
35
51
|
ApplePayEventType,
|
|
36
52
|
FraudDetectionEventType,
|
|
37
53
|
GooglePayEventType,
|
|
38
|
-
PaymentEventType
|
|
54
|
+
PaymentEventType,
|
|
55
|
+
SecurityIframeEventType,
|
|
56
|
+
ThreeDSEventType
|
|
39
57
|
};
|
package/dist/es/types/message.js
CHANGED
|
@@ -21,6 +21,7 @@ var MessageAction = /* @__PURE__ */ ((MessageAction2) => {
|
|
|
21
21
|
MessageAction2["CHECK_THREE_DS"] = "checkThreeDS";
|
|
22
22
|
MessageAction2["THREE_DS_STATUS_INIT"] = "threeDSStatusInit";
|
|
23
23
|
MessageAction2["THREE_DS_STATUS_CONFIG"] = "threeDSStatusConfig";
|
|
24
|
+
MessageAction2["THREE_DS_AUTH_LOADED"] = "threeDSAuthLoaded";
|
|
24
25
|
MessageAction2["DEBUG_MODE"] = "debugMode";
|
|
25
26
|
MessageAction2["DDC_RESULT"] = "ddcResult";
|
|
26
27
|
MessageAction2["DDC_JWT_BIN"] = "ddcJwtBin";
|
package/dist/es/utils/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isUndefined } from "./is.js";
|
|
2
2
|
import "./card-brand/brands.js";
|
|
3
3
|
import "./system-info/get-browser-info.js";
|
|
4
|
-
|
|
4
|
+
const getIf = (value, condition) => {
|
|
5
5
|
return condition ? value : void 0;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
};
|
|
7
|
+
const clamp = (value, min, max) => {
|
|
8
8
|
if (!isUndefined(min)) {
|
|
9
9
|
value = Math.max(value, min);
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ function clamp(value, min, max) {
|
|
|
12
12
|
value = Math.min(value, max);
|
|
13
13
|
}
|
|
14
14
|
return value;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
const safeParse = (dataStr, defaultValue = {}) => {
|
|
17
17
|
try {
|
|
18
18
|
return JSON.parse(dataStr);
|
|
@@ -27,14 +27,14 @@ const safeStringify = (data, defaultValue = "") => {
|
|
|
27
27
|
return defaultValue;
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
const isExpired = (expireDate) => {
|
|
31
31
|
const [month, year] = expireDate.split("/").map(Number);
|
|
32
|
-
const expiryDate = new Date(+`20${year}`, month
|
|
32
|
+
const expiryDate = new Date(+`20${year}`, month);
|
|
33
33
|
const currentDate = /* @__PURE__ */ new Date();
|
|
34
34
|
return expiryDate < currentDate;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
const intersection = (...arrays) => {
|
|
37
|
-
if (arrays.length
|
|
37
|
+
if (!arrays.length)
|
|
38
38
|
return [];
|
|
39
39
|
let result = arrays[0];
|
|
40
40
|
for (let i = 1; i < arrays.length; i++) {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type RequestOptions } from '../../http';
|
|
2
2
|
/** 通知后端服务商 3ds 页面已加载 */
|
|
3
3
|
export declare const noticeThreeDSLoaded: (sessionId: string, options?: RequestOptions) => Promise<any>;
|
|
4
|
+
/** 获取 3ds 渠道参数 */
|
|
5
|
+
export declare const getThreeDSChannelParams: (orderId: string) => Promise<{
|
|
6
|
+
actionUrl: any;
|
|
7
|
+
channelParams: any;
|
|
8
|
+
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CheckoutRes } from '../../api';
|
|
2
|
+
import type { PayKKaCheckout } from '../../core';
|
|
2
3
|
import type { GooglePayProps } from './type';
|
|
3
|
-
export declare function createGooglePay(checkout: CheckoutRes, googlePayConfig: GooglePayProps['config'], pay: (token?: string, billAddress?: {
|
|
4
|
+
export declare function createGooglePay(core: PayKKaCheckout, checkout: CheckoutRes, googlePayConfig: GooglePayProps['config'], pay: (token?: string, billAddress?: {
|
|
4
5
|
email?: string;
|
|
5
6
|
} & google.payments.api.Address, search?: boolean, timeout?: number) => Promise<{
|
|
6
7
|
res?: google.payments.api.PaymentAuthorizationResult;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type LocaleKeyType } from './i18n';
|
|
2
2
|
import { type FraudDetectionEnv } from './types';
|
|
3
3
|
export declare let apiUrl: string;
|
|
4
|
-
export declare let cdnOrigin:
|
|
5
|
-
export declare let cdnDir:
|
|
4
|
+
export declare let cdnOrigin: string;
|
|
5
|
+
export declare let cdnDir: string;
|
|
6
6
|
export declare let cdnUrl: string;
|
|
7
7
|
export declare let fraudDetectionEnv: FraudDetectionEnv | undefined;
|
|
8
8
|
export declare let customReqHeaders: Recordable;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 环境配置
|
|
3
|
-
* 打正式包时,fat/dev
|
|
3
|
+
* 打正式包时,fat/dev 环境的配置会被剔除
|
|
4
|
+
* 为什么不用环境变量?因为需要打包成 NPM 包,环境由用户传入
|
|
4
5
|
*/
|
|
5
6
|
import type { PayKKaEnvType } from '../types';
|
|
7
|
+
export declare const origin2Env: Record<string, PayKKaEnvType>;
|
|
6
8
|
export declare const apiEnv: Record<PayKKaEnvType, string>;
|
|
7
9
|
export declare const cdnEnv: Record<PayKKaEnvType, string>;
|
|
8
10
|
/**
|
|
@@ -12,4 +14,11 @@ export declare const cdnEnv: Record<PayKKaEnvType, string>;
|
|
|
12
14
|
* 2. 之所以直接用域名映射,是因为一些特殊的 CDN 文件,如 3DS iframe 需要进行一些请求,但是又没法拿到商户传给 SDK 的 env,所以直接用域名映射
|
|
13
15
|
* 3. 一定要保证映射正确,如果之后新增了域名,一定要在这里添加映射
|
|
14
16
|
*/
|
|
15
|
-
export declare const cdn2ApiMap: Record<
|
|
17
|
+
export declare const cdn2ApiMap: Record<PayKKaEnvType, string>;
|
|
18
|
+
interface LoggerEnvInfo {
|
|
19
|
+
env?: string;
|
|
20
|
+
imgUrl?: string;
|
|
21
|
+
postUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const loggerEnvInfoMap: Record<PayKKaEnvType, LoggerEnvInfo>;
|
|
24
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import type { PaymentMethod } from '../constant';
|
|
|
4
4
|
* 事件类型
|
|
5
5
|
* 适用于埋点上报
|
|
6
6
|
*/
|
|
7
|
-
export type EventType = FraudDetectionEventType | ApplePayEventType | GooglePayEventType | PaymentEventType;
|
|
7
|
+
export type EventType = FraudDetectionEventType | ApplePayEventType | GooglePayEventType | PaymentEventType | ThreeDSEventType;
|
|
8
8
|
export type EventData<T extends EventType> = EventDataMapping[T];
|
|
9
9
|
/** fraud detection 事件类型 */
|
|
10
10
|
export declare enum FraudDetectionEventType {
|
|
@@ -45,18 +45,42 @@ export declare enum GooglePayEventType {
|
|
|
45
45
|
/** 当前环境不支持 Google Pay */
|
|
46
46
|
GOOGLE_PAY_CAN_NOT_USE = "googlePay:canNotUse",
|
|
47
47
|
/** 点击 Google Pay 按钮 */
|
|
48
|
-
GOOGLE_PAY_BUTTON_CLICKED = "googlePay:buttonClicked"
|
|
48
|
+
GOOGLE_PAY_BUTTON_CLICKED = "googlePay:buttonClicked",
|
|
49
|
+
/** Google Pay 支付授权成功 */
|
|
50
|
+
GOOGLE_PAY_AUTHORIZED = "googlePay:authorized",
|
|
51
|
+
/** Google Pay 取消支付 */
|
|
52
|
+
GOOGLE_PAY_CANCELLED = "googlePay:cancelled"
|
|
49
53
|
}
|
|
50
54
|
export declare enum PaymentEventType {
|
|
55
|
+
/** 支付 */
|
|
56
|
+
PAYMENT_START = "payment:start",
|
|
51
57
|
/** 支付成功 */
|
|
52
58
|
PAYMENT_SUCCESS = "payment:success",
|
|
53
59
|
/** 支付失败 */
|
|
54
60
|
PAYMENT_FAILURE = "payment:failure",
|
|
55
|
-
/**
|
|
61
|
+
/** 支付超时,超时并不代表支付失败,只是没有及时获取到结果 */
|
|
56
62
|
PAYMENT_TIMEOUT = "payment:timeout",
|
|
57
63
|
/** 支付过期 */
|
|
58
64
|
PAYMENT_EXPIRED = "payment:expired"
|
|
59
65
|
}
|
|
66
|
+
export declare enum ThreeDSEventType {
|
|
67
|
+
/** 3DS 取消(一般由用户主动关闭弹窗触发,但并不代表 3DS 流程没走完) */
|
|
68
|
+
THREE_DS_CANCELLED = "threeDS:cancelled",
|
|
69
|
+
/** 3DS 继续认证(展示继续认证页面时触发) */
|
|
70
|
+
THREE_DS_CONTINUE = "threeDS:continue",
|
|
71
|
+
/** 3DS 结束(并不代表成功) */
|
|
72
|
+
THREE_DS_END = "threeDS:end",
|
|
73
|
+
/** 3DS 认证(认证页面加载,可能是渠道的,也可能是我们自己的,依赖设计) */
|
|
74
|
+
THREE_DS_AUTH = "threeDS:auth"
|
|
75
|
+
}
|
|
76
|
+
export declare enum SecurityIframeEventType {
|
|
77
|
+
/** 安全 iframe 初始化 */
|
|
78
|
+
SECURITY_IFRAME_INIT = "securityIframe:init",
|
|
79
|
+
/** 安全 iframe 初始化成功 */
|
|
80
|
+
SECURITY_IFRAME_INIT_SUCCESS = "securityIframe:initSuccess",
|
|
81
|
+
/** 安全 iframe 初始化失败 */
|
|
82
|
+
SECURITY_IFRAME_INIT_ERROR = "securityIframe:initError"
|
|
83
|
+
}
|
|
60
84
|
export interface EventDataMapping {
|
|
61
85
|
[FraudDetectionEventType.FRAUD_DETECTION_TRANSFORM_ERROR]: undefined;
|
|
62
86
|
[FraudDetectionEventType.FRAUD_DETECTION_CHANNEL_CONFIG_ERROR]: FraudDetectionBaseData;
|
|
@@ -75,10 +99,20 @@ export interface EventDataMapping {
|
|
|
75
99
|
[GooglePayEventType.GOOGLE_PAY_LOAD_ERROR]: undefined;
|
|
76
100
|
[GooglePayEventType.GOOGLE_PAY_CAN_NOT_USE]: undefined;
|
|
77
101
|
[GooglePayEventType.GOOGLE_PAY_BUTTON_CLICKED]: undefined;
|
|
102
|
+
[GooglePayEventType.GOOGLE_PAY_AUTHORIZED]: undefined;
|
|
103
|
+
[GooglePayEventType.GOOGLE_PAY_CANCELLED]: undefined;
|
|
104
|
+
[PaymentEventType.PAYMENT_START]: PaymentBaseData;
|
|
78
105
|
[PaymentEventType.PAYMENT_SUCCESS]: PaymentBaseData;
|
|
79
106
|
[PaymentEventType.PAYMENT_FAILURE]: PaymentFailureEventData;
|
|
80
107
|
[PaymentEventType.PAYMENT_TIMEOUT]: PaymentBaseData;
|
|
81
108
|
[PaymentEventType.PAYMENT_EXPIRED]: PaymentBaseData;
|
|
109
|
+
[ThreeDSEventType.THREE_DS_CANCELLED]: undefined;
|
|
110
|
+
[ThreeDSEventType.THREE_DS_CONTINUE]: undefined;
|
|
111
|
+
[ThreeDSEventType.THREE_DS_END]: undefined;
|
|
112
|
+
[ThreeDSEventType.THREE_DS_AUTH]: undefined;
|
|
113
|
+
[SecurityIframeEventType.SECURITY_IFRAME_INIT]: undefined;
|
|
114
|
+
[SecurityIframeEventType.SECURITY_IFRAME_INIT_SUCCESS]: undefined;
|
|
115
|
+
[SecurityIframeEventType.SECURITY_IFRAME_INIT_ERROR]: undefined;
|
|
82
116
|
}
|
|
83
117
|
export interface CommonEventData {
|
|
84
118
|
message?: string;
|
|
@@ -55,6 +55,8 @@ export declare const enum MessageAction {
|
|
|
55
55
|
THREE_DS_STATUS_INIT = "threeDSStatusInit",
|
|
56
56
|
/** 向 3DS 状态页传递配置 */
|
|
57
57
|
THREE_DS_STATUS_CONFIG = "threeDSStatusConfig",
|
|
58
|
+
/** 通知 3DS 认证页面加载 */
|
|
59
|
+
THREE_DS_AUTH_LOADED = "threeDSAuthLoaded",
|
|
58
60
|
/** 开启测试模式 */
|
|
59
61
|
DEBUG_MODE = "debugMode",
|
|
60
62
|
/**
|
|
@@ -91,6 +93,7 @@ type MessageMapping = {
|
|
|
91
93
|
[MessageAction.CHECK_THREE_DS]: CheckThreeDSMessage;
|
|
92
94
|
[MessageAction.THREE_DS_STATUS_INIT]: {};
|
|
93
95
|
[MessageAction.THREE_DS_STATUS_CONFIG]: ThreeDSStatusConfigMessage;
|
|
96
|
+
[MessageAction.THREE_DS_AUTH_LOADED]: BaseMessage;
|
|
94
97
|
[MessageAction.DEBUG_MODE]: {};
|
|
95
98
|
[MessageAction.DDC_RESULT]: DDCResultMessage;
|
|
96
99
|
[MessageAction.DDC_JWT_BIN]: DDCJwtBinMessage;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 封装与 app 交互相关的工具函数
|
|
3
|
+
*/
|
|
4
|
+
/** 是否为 app 3ds webview 环境 */
|
|
1
5
|
export declare const isApp3DSWebView: boolean;
|
|
6
|
+
/** 通知 app 3ds 完成 */
|
|
2
7
|
export declare const report3DSFinished2App: () => void;
|
|
8
|
+
/** 获取 app 日志 id */
|
|
9
|
+
export declare const getAppLoggerId: () => {
|
|
10
|
+
sid: string | undefined;
|
|
11
|
+
pid: string | undefined;
|
|
12
|
+
};
|