@paykka/card-checkout-ui 0.21.0 → 0.21.2

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.
@@ -1,7 +1,11 @@
1
1
  import { apiPrefix } from "../../../config.js";
2
2
  import { http } from "../../http.js";
3
- const getMerchantSession = async (options) => {
4
- return http.post(`${apiPrefix}/apple-pay/create-session`, options);
3
+ const getMerchantSession = async (params, options) => {
4
+ return http.post(
5
+ `${apiPrefix}/apple-pay/create-session`,
6
+ { merchant_id: params.merchantId },
7
+ options
8
+ );
5
9
  };
6
10
  export {
7
11
  getMerchantSession
@@ -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.21.0"
38
+ app_version: "0.21.2"
39
39
  };
40
40
  };
41
41
  const getBrowserParams = async (params = {}) => {
@@ -368,10 +368,12 @@ const ApplePay = w((props) => {
368
368
  initApplePaySession({
369
369
  request,
370
370
  onValidate: async () => {
371
- var _a2;
371
+ var _a2, _b2, _c;
372
372
  onEvent == null ? void 0 : onEvent(ApplePayEventType.APPLE_PAY_VALIDATE_MERCHANT);
373
- const merchantSession = await getMerchantSession();
374
- (_a2 = applePaySession.current) == null ? void 0 : _a2.completeMerchantValidation(merchantSession);
373
+ const merchantSession = await getMerchantSession(
374
+ ((_a2 = session == null ? void 0 : session.checkout) == null ? void 0 : _a2.sessionMode) === SessionMode.HOSTED ? {} : { merchantId: (_b2 = session == null ? void 0 : session.checkout) == null ? void 0 : _b2.merchantId }
375
+ );
376
+ (_c = applePaySession.current) == null ? void 0 : _c.completeMerchantValidation(merchantSession);
375
377
  },
376
378
  onAuthorized: async (event) => {
377
379
  var _a2;
@@ -46,7 +46,7 @@ class PayKKaLogger {
46
46
  (_b = window.JlFeLogger) == null ? void 0 : _b.init({
47
47
  pid: options.pid || COMPONENT_PID,
48
48
  env: loggerEnvInfo.env,
49
- release: "0.21.0",
49
+ release: "0.21.2",
50
50
  imgUrl: loggerEnvInfo.imgUrl,
51
51
  postUrl: loggerEnvInfo.postUrl,
52
52
  beforeSend: this.beforeSendEvent
@@ -1,166 +1,166 @@
1
- ;(function (global) {
2
- 'use strict'
3
-
4
- // globalThis
5
- if (typeof global.globalThis === 'undefined') {
6
- global.globalThis = global
7
- }
8
-
9
- // Object.values
10
- if (typeof Object.values !== 'function') {
11
- Object.values = function (obj) {
12
- if (obj == null) {
13
- throw new TypeError('Cannot convert undefined or null to object')
14
- }
15
-
16
- var target = Object(obj)
17
- var keys = Object.keys(target)
18
- var result = new Array(keys.length)
19
-
20
- for (var i = 0; i < keys.length; i++) {
21
- result[i] = target[keys[i]]
22
- }
23
-
24
- return result
25
- }
26
- }
27
-
28
- // Object.entries
29
- if (typeof Object.entries !== 'function') {
30
- Object.entries = function (obj) {
31
- if (obj == null) {
32
- throw new TypeError('Cannot convert undefined or null to object')
33
- }
34
-
35
- var target = Object(obj)
36
- var keys = Object.keys(target)
37
- var result = new Array(keys.length)
38
-
39
- for (var i = 0; i < keys.length; i++) {
40
- result[i] = [keys[i], target[keys[i]]]
41
- }
42
-
43
- return result
44
- }
45
- }
46
-
47
- // Promise.prototype.finally
48
- if (
49
- typeof global.Promise !== 'undefined' &&
50
- global.Promise.prototype &&
51
- typeof global.Promise.prototype.finally !== 'function'
52
- ) {
53
- global.Promise.prototype.finally = function (onFinally) {
54
- var P = this.constructor
55
-
56
- return this.then(
57
- function (value) {
58
- return P.resolve(
59
- typeof onFinally === 'function' ? onFinally() : onFinally
60
- ).then(function () {
61
- return value
62
- })
63
- },
64
- function (reason) {
65
- return P.resolve(
66
- typeof onFinally === 'function' ? onFinally() : onFinally
67
- ).then(function () {
68
- throw reason
69
- })
70
- }
71
- )
72
- }
73
- }
74
-
75
- // AbortController minimal shim
76
- // 说明:
77
- // 1. 只解决 "AbortController is not defined"
78
- // 2. 不保证旧浏览器原生 fetch 一定真正中断请求
79
- // 3. 但足够避免直接 ReferenceError,并让依赖 signal 的逻辑尽量工作
80
- if (typeof global.AbortController === 'undefined') {
81
- function AbortSignal() {
82
- this.aborted = false
83
- this.reason = void 0
84
- this.onabort = null
85
- this._listeners = []
86
- }
87
-
88
- AbortSignal.prototype.addEventListener = function (type, listener) {
89
- if (type !== 'abort' || typeof listener !== 'function') return
90
- this._listeners.push(listener)
91
- }
92
-
93
- AbortSignal.prototype.removeEventListener = function (type, listener) {
94
- if (type !== 'abort') return
95
-
96
- for (var i = 0; i < this._listeners.length; i++) {
97
- if (this._listeners[i] === listener) {
98
- this._listeners.splice(i, 1)
99
- break
100
- }
101
- }
102
- }
103
-
104
- AbortSignal.prototype.dispatchEvent = function (event) {
105
- var listeners = this._listeners.slice()
106
-
107
- for (var i = 0; i < listeners.length; i++) {
108
- try {
109
- listeners[i].call(this, event)
110
- } catch (e) {}
111
- }
112
-
113
- return true
114
- }
115
-
116
- function AbortController() {
117
- this.signal = new AbortSignal()
118
- }
119
-
120
- AbortController.prototype.abort = function (reason) {
121
- if (this.signal.aborted) return
122
-
123
- this.signal.aborted = true
124
- this.signal.reason = reason
125
-
126
- var event = { type: 'abort' }
127
-
128
- if (typeof this.signal.onabort === 'function') {
129
- try {
130
- this.signal.onabort.call(this.signal, event)
131
- } catch (e) {}
132
- }
133
-
134
- this.signal.dispatchEvent(event)
135
- }
136
-
137
- global.AbortController = AbortController
138
- global.AbortSignal = AbortSignal
139
- }
140
-
141
- // postMessage compatibility helper
142
- // 用法:
143
- // window.__postMessageCompat(targetWindow, data, targetOrigin)
144
- //
145
- // 说明:
146
- // 旧 WebView 不支持 postMessage(message, { targetOrigin })
147
- // 必须改成 postMessage(message, targetOrigin)
148
- if (typeof global.__postMessageCompat !== 'function') {
149
- global.__postMessageCompat = function (targetWindow, data, targetOrigin) {
150
- if (!targetWindow || targetWindow === global) return
151
-
152
- var message = typeof data === 'string' ? data : JSON.stringify(data)
153
- var origin = typeof targetOrigin === 'string' ? targetOrigin : '*'
154
-
155
- targetWindow.postMessage(message, origin)
156
- }
157
- }
158
- })(
159
- typeof window !== 'undefined'
160
- ? window
161
- : typeof globalThis !== 'undefined'
162
- ? globalThis
163
- : typeof self !== 'undefined'
164
- ? self
165
- : this
1
+ ;(function (global) {
2
+ 'use strict'
3
+
4
+ // globalThis
5
+ if (typeof global.globalThis === 'undefined') {
6
+ global.globalThis = global
7
+ }
8
+
9
+ // Object.values
10
+ if (typeof Object.values !== 'function') {
11
+ Object.values = function (obj) {
12
+ if (obj == null) {
13
+ throw new TypeError('Cannot convert undefined or null to object')
14
+ }
15
+
16
+ var target = Object(obj)
17
+ var keys = Object.keys(target)
18
+ var result = new Array(keys.length)
19
+
20
+ for (var i = 0; i < keys.length; i++) {
21
+ result[i] = target[keys[i]]
22
+ }
23
+
24
+ return result
25
+ }
26
+ }
27
+
28
+ // Object.entries
29
+ if (typeof Object.entries !== 'function') {
30
+ Object.entries = function (obj) {
31
+ if (obj == null) {
32
+ throw new TypeError('Cannot convert undefined or null to object')
33
+ }
34
+
35
+ var target = Object(obj)
36
+ var keys = Object.keys(target)
37
+ var result = new Array(keys.length)
38
+
39
+ for (var i = 0; i < keys.length; i++) {
40
+ result[i] = [keys[i], target[keys[i]]]
41
+ }
42
+
43
+ return result
44
+ }
45
+ }
46
+
47
+ // Promise.prototype.finally
48
+ if (
49
+ typeof global.Promise !== 'undefined' &&
50
+ global.Promise.prototype &&
51
+ typeof global.Promise.prototype.finally !== 'function'
52
+ ) {
53
+ global.Promise.prototype.finally = function (onFinally) {
54
+ var P = this.constructor
55
+
56
+ return this.then(
57
+ function (value) {
58
+ return P.resolve(
59
+ typeof onFinally === 'function' ? onFinally() : onFinally
60
+ ).then(function () {
61
+ return value
62
+ })
63
+ },
64
+ function (reason) {
65
+ return P.resolve(
66
+ typeof onFinally === 'function' ? onFinally() : onFinally
67
+ ).then(function () {
68
+ throw reason
69
+ })
70
+ }
71
+ )
72
+ }
73
+ }
74
+
75
+ // AbortController minimal shim
76
+ // 说明:
77
+ // 1. 只解决 "AbortController is not defined"
78
+ // 2. 不保证旧浏览器原生 fetch 一定真正中断请求
79
+ // 3. 但足够避免直接 ReferenceError,并让依赖 signal 的逻辑尽量工作
80
+ if (typeof global.AbortController === 'undefined') {
81
+ function AbortSignal() {
82
+ this.aborted = false
83
+ this.reason = void 0
84
+ this.onabort = null
85
+ this._listeners = []
86
+ }
87
+
88
+ AbortSignal.prototype.addEventListener = function (type, listener) {
89
+ if (type !== 'abort' || typeof listener !== 'function') return
90
+ this._listeners.push(listener)
91
+ }
92
+
93
+ AbortSignal.prototype.removeEventListener = function (type, listener) {
94
+ if (type !== 'abort') return
95
+
96
+ for (var i = 0; i < this._listeners.length; i++) {
97
+ if (this._listeners[i] === listener) {
98
+ this._listeners.splice(i, 1)
99
+ break
100
+ }
101
+ }
102
+ }
103
+
104
+ AbortSignal.prototype.dispatchEvent = function (event) {
105
+ var listeners = this._listeners.slice()
106
+
107
+ for (var i = 0; i < listeners.length; i++) {
108
+ try {
109
+ listeners[i].call(this, event)
110
+ } catch (e) {}
111
+ }
112
+
113
+ return true
114
+ }
115
+
116
+ function AbortController() {
117
+ this.signal = new AbortSignal()
118
+ }
119
+
120
+ AbortController.prototype.abort = function (reason) {
121
+ if (this.signal.aborted) return
122
+
123
+ this.signal.aborted = true
124
+ this.signal.reason = reason
125
+
126
+ var event = { type: 'abort' }
127
+
128
+ if (typeof this.signal.onabort === 'function') {
129
+ try {
130
+ this.signal.onabort.call(this.signal, event)
131
+ } catch (e) {}
132
+ }
133
+
134
+ this.signal.dispatchEvent(event)
135
+ }
136
+
137
+ global.AbortController = AbortController
138
+ global.AbortSignal = AbortSignal
139
+ }
140
+
141
+ // postMessage compatibility helper
142
+ // 用法:
143
+ // window.__postMessageCompat(targetWindow, data, targetOrigin)
144
+ //
145
+ // 说明:
146
+ // 旧 WebView 不支持 postMessage(message, { targetOrigin })
147
+ // 必须改成 postMessage(message, targetOrigin)
148
+ if (typeof global.__postMessageCompat !== 'function') {
149
+ global.__postMessageCompat = function (targetWindow, data, targetOrigin) {
150
+ if (!targetWindow || targetWindow === global) return
151
+
152
+ var message = typeof data === 'string' ? data : JSON.stringify(data)
153
+ var origin = typeof targetOrigin === 'string' ? targetOrigin : '*'
154
+
155
+ targetWindow.postMessage(message, origin)
156
+ }
157
+ }
158
+ })(
159
+ typeof window !== 'undefined'
160
+ ? window
161
+ : typeof globalThis !== 'undefined'
162
+ ? globalThis
163
+ : typeof self !== 'undefined'
164
+ ? self
165
+ : this
166
166
  )