@alipay/ams-checkout 0.0.1701393225-dev.14 → 0.0.1701393225-dev.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.
@@ -44,9 +44,7 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
44
44
|
merchantIdentifier: _this.merchantIdentifier,
|
45
45
|
validationUrl: event.validationURL
|
46
46
|
}).then(function (merchantSessionObjectString) {
|
47
|
-
console.log('merchantSessionObjectString', merchantSessionObjectString);
|
48
47
|
var merchantSessionObject = JSON.parse(merchantSessionObjectString);
|
49
|
-
console.log('merchantSessionObject', merchantSessionObject);
|
50
48
|
_this.session.completeMerchantValidation(merchantSessionObject);
|
51
49
|
_this.applePayTrace('completeMerchantValidation');
|
52
50
|
}).catch(function (error) {
|
@@ -56,7 +54,6 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
56
54
|
});
|
57
55
|
_defineProperty(this, "onpaymentauthorized", function (event) {
|
58
56
|
var _event$payment;
|
59
|
-
console.log('onpaymentauthorized', event);
|
60
57
|
_this.applePayTrace('onpaymentauthorized');
|
61
58
|
var _window = window,
|
62
59
|
ApplePaySession = _window.ApplePaySession;
|
@@ -70,7 +67,6 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
70
67
|
_this.completePaymentAuthorized({
|
71
68
|
paymentToken: JSON.stringify(event.payment.token)
|
72
69
|
}).then(function (data) {
|
73
|
-
console.log('onpaymentauthorized then', data);
|
74
70
|
_this.applePayTrace('completeApplePay');
|
75
71
|
_this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
|
76
72
|
_this.completeApplePay(data);
|
@@ -97,14 +93,12 @@ var ApplePayService = /*#__PURE__*/function () {
|
|
97
93
|
paymentAmount = paymentSessionFactor.paymentAmount,
|
98
94
|
order = paymentSessionFactor.order;
|
99
95
|
_this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
|
100
|
-
// TODO 参数判空处理
|
101
96
|
var request = {
|
102
97
|
merchantCapabilities: applePay === null || applePay === void 0 ? void 0 : applePay.merchantCapabilities,
|
103
98
|
supportedNetworks: applePay === null || applePay === void 0 ? void 0 : applePay.supportedNetworks,
|
104
99
|
countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
|
105
100
|
currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
|
106
101
|
total: {
|
107
|
-
// todo 待确认
|
108
102
|
type: 'final',
|
109
103
|
label: order === null || order === void 0 ? void 0 : order.orderDescription,
|
110
104
|
amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
|
@@ -28,12 +28,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
28
28
|
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
29
29
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
30
30
|
*/
|
31
|
-
import { componentSignEnum, eventCodeEnum, productSceneEnum } from "../../types";
|
31
|
+
import { componentSignEnum, environmentEnum, eventCodeEnum, productSceneEnum } from "../../types";
|
32
32
|
import ApplePayService from "../../common/applepay";
|
33
33
|
import { getComponentSign, parseSessionData } from "../component";
|
34
34
|
import { getApplePayPaymentSession, submitPayInfo } from "../../service";
|
35
35
|
import CoreInstance from "../instance";
|
36
|
-
import {
|
36
|
+
import { EVENT } from "../../constant";
|
37
|
+
|
37
38
|
/**
|
38
39
|
* Apple pay Component
|
39
40
|
*/
|
@@ -43,7 +44,9 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
43
44
|
function ApplePayComponent(options) {
|
44
45
|
var _this;
|
45
46
|
_classCallCheck(this, ApplePayComponent);
|
46
|
-
var _options = Object.assign({
|
47
|
+
var _options = Object.assign({
|
48
|
+
environment: environmentEnum.prod
|
49
|
+
}, options, {
|
47
50
|
product: productSceneEnum.CARD_APPLE_PAY
|
48
51
|
});
|
49
52
|
_this = _super.call(this, _options);
|
@@ -150,14 +153,43 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
150
153
|
sessionData = _parseSessionData2[1];
|
151
154
|
this._parseData = parseData;
|
152
155
|
this._sessionData = sessionData;
|
156
|
+
// parse data is null
|
157
|
+
if (Object.keys(parseData).length === 0) {
|
158
|
+
this._eventCenter.emit(EVENT.eventCallback.name, {
|
159
|
+
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
160
|
+
result: {
|
161
|
+
errorMsg: 'Abnormal response data is null'
|
162
|
+
}
|
163
|
+
});
|
164
|
+
this.logger.logError({
|
165
|
+
name: 'APPLE_PAY',
|
166
|
+
title: 'sessionDataNull',
|
167
|
+
msg: 'Abnormal response data is null'
|
168
|
+
}, {
|
169
|
+
type: 'error',
|
170
|
+
biz: 'sdk'
|
171
|
+
}).send();
|
172
|
+
return;
|
173
|
+
}
|
153
174
|
// validate parse data
|
154
175
|
var componentSign = getComponentSign(parseData);
|
155
176
|
if (componentSign === componentSignEnum.NONE) {
|
156
177
|
// eslint-disable-next-line prefer-promise-reject-errors
|
157
|
-
|
158
|
-
code:
|
159
|
-
|
178
|
+
this._eventCenter.emit(EVENT.eventCallback.name, {
|
179
|
+
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
180
|
+
result: {
|
181
|
+
errorMsg: "Abnormal response data, interface failure, or unsupported payment method"
|
182
|
+
}
|
160
183
|
});
|
184
|
+
this.logger.logError({
|
185
|
+
name: 'APPLE_PAY',
|
186
|
+
title: 'paymentMethodUnknown',
|
187
|
+
msg: 'Abnormal response data, interface failure, or unsupported payment method'
|
188
|
+
}, {
|
189
|
+
type: 'error',
|
190
|
+
biz: 'sdk'
|
191
|
+
}).send();
|
192
|
+
return;
|
161
193
|
}
|
162
194
|
/**
|
163
195
|
* Get MerchantSession spi
|
@@ -174,18 +206,14 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
174
206
|
requestParams = {
|
175
207
|
validateUrl: validationUrl,
|
176
208
|
paymentSessionData: _this3._sessionData
|
177
|
-
};
|
178
|
-
console.log('getMerchantSession validationUrl', validationUrl);
|
179
|
-
console.log('getMerchantSession _sessionData', _this3._sessionData);
|
180
|
-
|
181
|
-
// get deviceId
|
209
|
+
}; // get deviceId
|
182
210
|
_context2.t0 = getApplePayPaymentSession;
|
183
211
|
_context2.t1 = _this3._sessionData;
|
184
212
|
_context2.t2 = requestParams;
|
185
213
|
_context2.t3 = _this3.options.env.environment;
|
186
|
-
_context2.next =
|
214
|
+
_context2.next = 8;
|
187
215
|
return _this3.getDeviceIdAndLog();
|
188
|
-
case
|
216
|
+
case 8:
|
189
217
|
_context2.t4 = _context2.sent;
|
190
218
|
_context2.t5 = {
|
191
219
|
deviceId: _context2.t4
|
@@ -196,9 +224,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
196
224
|
};
|
197
225
|
_context2.t7 = _this3.logger;
|
198
226
|
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1, _context2.t2, _context2.t6, _context2.t7).then(function (res) {
|
199
|
-
console.log('res', res);
|
200
227
|
if (res !== null && res !== void 0 && res.success && res.merchantSessionObject) {
|
201
|
-
console.log('res.merchantSessionObject', res.merchantSessionObject);
|
202
228
|
return Promise.resolve(res.merchantSessionObject);
|
203
229
|
}
|
204
230
|
return Promise.reject({
|
@@ -208,7 +234,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
208
234
|
}).catch(function (error) {
|
209
235
|
return Promise.reject(error);
|
210
236
|
}));
|
211
|
-
case
|
237
|
+
case 13:
|
212
238
|
case "end":
|
213
239
|
return _context2.stop();
|
214
240
|
}
|
@@ -252,7 +278,13 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
252
278
|
};
|
253
279
|
_context3.t6 = _this3.logger;
|
254
280
|
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
|
255
|
-
|
281
|
+
_this3.logger.logInfo({
|
282
|
+
name: 'APPLE_PAY',
|
283
|
+
title: 'submitPayStatus',
|
284
|
+
msg: res === null || res === void 0 ? void 0 : res.errorStatus
|
285
|
+
}, {
|
286
|
+
biz: 'sdk'
|
287
|
+
}).send();
|
256
288
|
if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
|
257
289
|
return Promise.resolve(res);
|
258
290
|
}
|
@@ -261,7 +293,6 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
261
293
|
errorMessage: res.errorMessage
|
262
294
|
});
|
263
295
|
}).catch(function (error) {
|
264
|
-
console.log('completePaymentAuthorized catch', error);
|
265
296
|
return Promise.reject(error);
|
266
297
|
}));
|
267
298
|
case 12:
|
@@ -276,7 +307,6 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
276
307
|
}();
|
277
308
|
var completeApplePay = function completeApplePay(data) {
|
278
309
|
var _data$actionForm;
|
279
|
-
// TODO 处理redirectUrl
|
280
310
|
_this3._eventCenter.emit(EVENT.eventCallback.name, {
|
281
311
|
code: eventCodeEnum.SDK_PAYMENT_FINISH,
|
282
312
|
result: {
|
@@ -285,14 +315,21 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
285
315
|
});
|
286
316
|
};
|
287
317
|
var logError = function logError(msg, error) {
|
288
|
-
//
|
289
|
-
|
318
|
+
// log error
|
319
|
+
_this3.logger.logError({
|
320
|
+
name: 'APPLE_PAY',
|
321
|
+
title: msg,
|
322
|
+
label: msg,
|
323
|
+
msg: error
|
324
|
+
}, {
|
325
|
+
type: 'error',
|
326
|
+
biz: 'sdk'
|
327
|
+
}).send();
|
290
328
|
if (msg === 'UserCancel') {
|
291
329
|
_this3._eventCenter.emit(EVENT.eventCallback.name, {
|
292
330
|
code: eventCodeEnum.SDK_PAYMENT_CANCEL
|
293
331
|
});
|
294
332
|
} else {
|
295
|
-
// this._eventCenter.emit(EVENT.error.name, error);
|
296
333
|
_this3._eventCenter.emit(EVENT.eventCallback.name, {
|
297
334
|
code: eventCodeEnum.SDK_PAYMENT_FAIL,
|
298
335
|
result: {
|
@@ -302,12 +339,14 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
302
339
|
}
|
303
340
|
};
|
304
341
|
var applePayTrace = function applePayTrace(msg) {
|
305
|
-
//
|
306
|
-
console.log('applePayTrace', msg);
|
342
|
+
// set log funnel
|
307
343
|
_this3.logger.logInfo({
|
308
|
-
|
344
|
+
name: 'APPLE_PAY',
|
345
|
+
title: msg,
|
346
|
+
label: msg
|
309
347
|
}, {
|
310
|
-
|
348
|
+
type: 'funnel',
|
349
|
+
biz: 'sdk'
|
311
350
|
}).send();
|
312
351
|
};
|
313
352
|
|