@alipay/ams-checkout 0.0.1781004142-dev.4 → 0.0.1781004142-dev.6
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/ams-checkout.js +3 -3
- package/dist/ams-checkout.min.js +1 -1
- package/esm/core/component/element/elementController/index.js +75 -37
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +48 -22
- package/esm/util/spm-map.d.ts +6 -0
- package/esm/util/spm-map.js +7 -1
- package/package.json +1 -1
|
@@ -374,7 +374,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
374
374
|
value: function () {
|
|
375
375
|
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
|
|
376
376
|
var _this3 = this;
|
|
377
|
-
var startEventId, res, logParams, isApplePay, BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, shouldContinue, isTimeout, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
377
|
+
var startEventId, res, logParams, isApplePay, paymentMethodType, BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, startTime, shouldContinue, isTimeout, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
378
378
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
379
379
|
while (1) switch (_context4.prev = _context4.next) {
|
|
380
380
|
case 0:
|
|
@@ -402,34 +402,45 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
402
402
|
|
|
403
403
|
// Non-Apple Pay: execute onBeforeConfirm at SDK layer directly, abort on failure
|
|
404
404
|
isApplePay = this.currentPaymentMethodType === 'APPLEPAY';
|
|
405
|
-
this.
|
|
406
|
-
title: 'sdk_element_submitPayment_beforeConfirm'
|
|
407
|
-
}, {
|
|
408
|
-
msg: safeStringify({
|
|
409
|
-
isApplePay: isApplePay,
|
|
410
|
-
hasOnBeforeConfirm: !!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm),
|
|
411
|
-
currentPaymentMethodType: this.currentPaymentMethodType
|
|
412
|
-
})
|
|
413
|
-
});
|
|
405
|
+
paymentMethodType = this.currentPaymentMethodType || 'UNKNOWN';
|
|
414
406
|
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
|
|
415
|
-
_context4.next =
|
|
407
|
+
_context4.next = 34;
|
|
416
408
|
break;
|
|
417
409
|
}
|
|
418
410
|
BEFORE_CONFIRM_TIMEOUT_MS = 15000;
|
|
419
|
-
|
|
411
|
+
this.serviceMap.Log.logInfo({
|
|
412
|
+
title: 'sdk_before_confirm_start'
|
|
413
|
+
}, {
|
|
414
|
+
paymentMethodType: paymentMethodType,
|
|
415
|
+
path: 'nonApplePay_sync'
|
|
416
|
+
});
|
|
417
|
+
_context4.prev = 12;
|
|
420
418
|
timeoutPromise = new Promise(function (_, reject) {
|
|
421
419
|
return setTimeout(function () {
|
|
422
420
|
return reject(new Error('onBeforeConfirm timed out'));
|
|
423
421
|
}, BEFORE_CONFIRM_TIMEOUT_MS);
|
|
424
422
|
});
|
|
425
|
-
|
|
423
|
+
startTime = Date.now();
|
|
424
|
+
_context4.next = 17;
|
|
426
425
|
return Promise.race([submitParams.onBeforeConfirm(), timeoutPromise]);
|
|
427
|
-
case
|
|
426
|
+
case 17:
|
|
428
427
|
shouldContinue = _context4.sent;
|
|
428
|
+
if (Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
|
|
429
|
+
this.serviceMap.Log.logError({
|
|
430
|
+
title: 'sdk_before_confirm_timeout'
|
|
431
|
+
});
|
|
432
|
+
shouldContinue = false;
|
|
433
|
+
}
|
|
429
434
|
if (!(shouldContinue === false)) {
|
|
430
|
-
_context4.next =
|
|
435
|
+
_context4.next = 23;
|
|
431
436
|
break;
|
|
432
437
|
}
|
|
438
|
+
this.serviceMap.Log.logInfo({
|
|
439
|
+
title: 'sdk_before_confirm_abort'
|
|
440
|
+
}, {
|
|
441
|
+
paymentMethodType: paymentMethodType,
|
|
442
|
+
path: 'nonApplePay_sync'
|
|
443
|
+
});
|
|
433
444
|
this.changeLoading(false);
|
|
434
445
|
return _context4.abrupt("return", {
|
|
435
446
|
status: PaymentStatus.FAIL,
|
|
@@ -439,21 +450,36 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
439
450
|
needChangeSessionForRetry: false
|
|
440
451
|
}
|
|
441
452
|
});
|
|
442
|
-
case
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
case 21:
|
|
446
|
-
_context4.prev = 21;
|
|
447
|
-
_context4.t0 = _context4["catch"](11);
|
|
448
|
-
this.changeLoading(false);
|
|
449
|
-
isTimeout = _context4.t0 instanceof Error && _context4.t0.message === 'onBeforeConfirm timed out';
|
|
450
|
-
this.serviceMap.Log.logError({
|
|
451
|
-
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
453
|
+
case 23:
|
|
454
|
+
this.serviceMap.Log.logInfo({
|
|
455
|
+
title: 'sdk_before_confirm_success'
|
|
452
456
|
}, {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
})
|
|
457
|
+
paymentMethodType: paymentMethodType,
|
|
458
|
+
path: 'nonApplePay_sync'
|
|
456
459
|
});
|
|
460
|
+
_context4.next = 32;
|
|
461
|
+
break;
|
|
462
|
+
case 26:
|
|
463
|
+
_context4.prev = 26;
|
|
464
|
+
_context4.t0 = _context4["catch"](12);
|
|
465
|
+
isTimeout = _context4.t0 instanceof Error && _context4.t0.message === 'onBeforeConfirm timed out';
|
|
466
|
+
if (isTimeout) {
|
|
467
|
+
this.serviceMap.Log.logError({
|
|
468
|
+
title: 'sdk_before_confirm_timeout'
|
|
469
|
+
}, {
|
|
470
|
+
paymentMethodType: paymentMethodType,
|
|
471
|
+
path: 'nonApplePay_sync'
|
|
472
|
+
});
|
|
473
|
+
} else {
|
|
474
|
+
this.serviceMap.Log.logError({
|
|
475
|
+
title: 'sdk_before_confirm_error'
|
|
476
|
+
}, {
|
|
477
|
+
paymentMethodType: paymentMethodType,
|
|
478
|
+
errorMessage: String((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message) || _context4.t0).slice(0, 200),
|
|
479
|
+
path: 'nonApplePay_sync'
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
this.changeLoading(false);
|
|
457
483
|
return _context4.abrupt("return", {
|
|
458
484
|
status: PaymentStatus.FAIL,
|
|
459
485
|
error: {
|
|
@@ -462,10 +488,22 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
462
488
|
needChangeSessionForRetry: false
|
|
463
489
|
}
|
|
464
490
|
});
|
|
465
|
-
case
|
|
491
|
+
case 32:
|
|
492
|
+
_context4.next = 35;
|
|
493
|
+
break;
|
|
494
|
+
case 34:
|
|
495
|
+
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm)) {
|
|
496
|
+
this.serviceMap.Log.logInfo({
|
|
497
|
+
title: 'sdk_before_confirm_skip'
|
|
498
|
+
}, {
|
|
499
|
+
paymentMethodType: paymentMethodType,
|
|
500
|
+
path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
case 35:
|
|
466
504
|
recordResult = null;
|
|
467
|
-
_context4.prev =
|
|
468
|
-
_context4.next =
|
|
505
|
+
_context4.prev = 36;
|
|
506
|
+
_context4.next = 39;
|
|
469
507
|
return new Promise( /*#__PURE__*/function () {
|
|
470
508
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
471
509
|
var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, _yield$_this3$onValid2, _data, errorString, errorResult;
|
|
@@ -621,10 +659,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
621
659
|
return _ref3.apply(this, arguments);
|
|
622
660
|
};
|
|
623
661
|
}());
|
|
624
|
-
case
|
|
662
|
+
case 39:
|
|
625
663
|
return _context4.abrupt("return", _context4.sent);
|
|
626
|
-
case
|
|
627
|
-
_context4.prev =
|
|
664
|
+
case 40:
|
|
665
|
+
_context4.prev = 40;
|
|
628
666
|
_logParams = {
|
|
629
667
|
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
630
668
|
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
@@ -635,12 +673,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
635
673
|
};
|
|
636
674
|
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
637
675
|
this.changeLoading(false);
|
|
638
|
-
return _context4.finish(
|
|
639
|
-
case
|
|
676
|
+
return _context4.finish(40);
|
|
677
|
+
case 45:
|
|
640
678
|
case "end":
|
|
641
679
|
return _context4.stop();
|
|
642
680
|
}
|
|
643
|
-
}, _callee4, this, [[
|
|
681
|
+
}, _callee4, this, [[12, 26], [36,, 40, 45]]);
|
|
644
682
|
}));
|
|
645
683
|
function submitPayment(_x) {
|
|
646
684
|
return _submitPayment.apply(this, arguments);
|
|
@@ -178,19 +178,21 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
178
178
|
// requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
|
|
179
179
|
// and returns the result (continue/abort) to iframe via dispatchToApp.
|
|
180
180
|
this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
181
|
-
var BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, shouldContinue, isTimeout;
|
|
181
|
+
var paymentMethodType, BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, startTime, shouldContinue, isTimeout;
|
|
182
182
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
183
183
|
while (1) switch (_context.prev = _context.next) {
|
|
184
184
|
case 0:
|
|
185
|
-
|
|
186
|
-
title: 'sdk_element_beforeConfirm_event_received'
|
|
187
|
-
}, {
|
|
188
|
-
hasCallback: !!_this2._onBeforeConfirm
|
|
189
|
-
});
|
|
185
|
+
paymentMethodType = 'APPLEPAY';
|
|
190
186
|
if (_this2._onBeforeConfirm) {
|
|
191
|
-
_context.next =
|
|
187
|
+
_context.next = 5;
|
|
192
188
|
break;
|
|
193
189
|
}
|
|
190
|
+
logger.logInfo({
|
|
191
|
+
title: 'sdk_before_confirm_skip'
|
|
192
|
+
}, {
|
|
193
|
+
paymentMethodType: paymentMethodType,
|
|
194
|
+
path: 'applePay_eventBridge'
|
|
195
|
+
});
|
|
194
196
|
_this2.eventCenter.dispatchToApp({
|
|
195
197
|
event: EVENT.beforeConfirm.name,
|
|
196
198
|
data: {
|
|
@@ -199,18 +201,31 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
199
201
|
}
|
|
200
202
|
});
|
|
201
203
|
return _context.abrupt("return");
|
|
202
|
-
case
|
|
204
|
+
case 5:
|
|
203
205
|
BEFORE_CONFIRM_TIMEOUT_MS = 15000;
|
|
204
|
-
|
|
206
|
+
logger.logInfo({
|
|
207
|
+
title: 'sdk_before_confirm_start'
|
|
208
|
+
}, {
|
|
209
|
+
paymentMethodType: paymentMethodType,
|
|
210
|
+
path: 'applePay_eventBridge'
|
|
211
|
+
});
|
|
212
|
+
_context.prev = 7;
|
|
205
213
|
timeoutPromise = new Promise(function (_, reject) {
|
|
206
214
|
return setTimeout(function () {
|
|
207
215
|
return reject(new Error('onBeforeConfirm timed out'));
|
|
208
216
|
}, BEFORE_CONFIRM_TIMEOUT_MS);
|
|
209
217
|
});
|
|
210
|
-
|
|
218
|
+
startTime = Date.now();
|
|
219
|
+
_context.next = 12;
|
|
211
220
|
return Promise.race([_this2._onBeforeConfirm(), timeoutPromise]);
|
|
212
|
-
case
|
|
221
|
+
case 12:
|
|
213
222
|
shouldContinue = _context.sent;
|
|
223
|
+
if (Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
|
|
224
|
+
logger.logError({
|
|
225
|
+
title: 'sdk_before_confirm_timeout'
|
|
226
|
+
});
|
|
227
|
+
shouldContinue = false;
|
|
228
|
+
}
|
|
214
229
|
logger.logInfo({
|
|
215
230
|
title: 'sdk_element_beforeConfirm_callback_result'
|
|
216
231
|
}, {
|
|
@@ -223,17 +238,28 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
223
238
|
result: shouldContinue !== false
|
|
224
239
|
}
|
|
225
240
|
});
|
|
226
|
-
_context.next =
|
|
241
|
+
_context.next = 23;
|
|
227
242
|
break;
|
|
228
|
-
case
|
|
229
|
-
_context.prev =
|
|
230
|
-
_context.t0 = _context["catch"](
|
|
243
|
+
case 18:
|
|
244
|
+
_context.prev = 18;
|
|
245
|
+
_context.t0 = _context["catch"](7);
|
|
231
246
|
isTimeout = _context.t0 instanceof Error && _context.t0.message === 'onBeforeConfirm timed out';
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
247
|
+
if (isTimeout) {
|
|
248
|
+
logger.logError({
|
|
249
|
+
title: 'sdk_before_confirm_timeout'
|
|
250
|
+
}, {
|
|
251
|
+
paymentMethodType: paymentMethodType,
|
|
252
|
+
path: 'applePay_eventBridge'
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
logger.logError({
|
|
256
|
+
title: 'sdk_before_confirm_error'
|
|
257
|
+
}, {
|
|
258
|
+
paymentMethodType: paymentMethodType,
|
|
259
|
+
errorMessage: String((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0).slice(0, 200),
|
|
260
|
+
path: 'applePay_eventBridge'
|
|
261
|
+
});
|
|
262
|
+
}
|
|
237
263
|
_this2.eventCenter.dispatchToApp({
|
|
238
264
|
event: EVENT.beforeConfirm.name,
|
|
239
265
|
data: {
|
|
@@ -241,11 +267,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
241
267
|
result: false
|
|
242
268
|
}
|
|
243
269
|
});
|
|
244
|
-
case
|
|
270
|
+
case 23:
|
|
245
271
|
case "end":
|
|
246
272
|
return _context.stop();
|
|
247
273
|
}
|
|
248
|
-
}, _callee, null, [[
|
|
274
|
+
}, _callee, null, [[7, 18]]);
|
|
249
275
|
})));
|
|
250
276
|
}
|
|
251
277
|
}, {
|
package/esm/util/spm-map.d.ts
CHANGED
|
@@ -208,4 +208,10 @@ export declare const SPM_MAP: {
|
|
|
208
208
|
'Abnormal params recurringInfo': string;
|
|
209
209
|
'Payment processing but user dismissed the sheet': string;
|
|
210
210
|
'User dismissed the sheet': string;
|
|
211
|
+
sdk_before_confirm_start: string;
|
|
212
|
+
sdk_before_confirm_success: string;
|
|
213
|
+
sdk_before_confirm_abort: string;
|
|
214
|
+
sdk_before_confirm_error: string;
|
|
215
|
+
sdk_before_confirm_timeout: string;
|
|
216
|
+
sdk_before_confirm_skip: string;
|
|
211
217
|
};
|
package/esm/util/spm-map.js
CHANGED
|
@@ -198,5 +198,11 @@ export var SPM_MAP = _objectSpread({
|
|
|
198
198
|
'Abnormal params paymentSessionFactor': 'a3753.b101271.c388189.d518377',
|
|
199
199
|
'Abnormal params recurringInfo': 'a3753.b101271.c388189.d518377',
|
|
200
200
|
'Payment processing but user dismissed the sheet': 'a3753.b101271.c388189.d518377',
|
|
201
|
-
'User dismissed the sheet': 'a3753.b101271.c388189.d518377'
|
|
201
|
+
'User dismissed the sheet': 'a3753.b101271.c388189.d518377',
|
|
202
|
+
sdk_before_confirm_start: 'a3753.b204577.c480929',
|
|
203
|
+
sdk_before_confirm_success: 'a3753.b204577.c480930',
|
|
204
|
+
sdk_before_confirm_abort: 'a3753.b204577.c480931',
|
|
205
|
+
sdk_before_confirm_error: 'a3753.b204577.c480932',
|
|
206
|
+
sdk_before_confirm_timeout: 'a3753.b204577.c480933',
|
|
207
|
+
sdk_before_confirm_skip: 'a3753.b204577.c480934'
|
|
202
208
|
}, ELEMENT_SPM_MAP);
|