@alipay/ams-checkout 0.0.1781004142-dev.1 → 0.0.1781004142-dev.3
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/constant/index.d.ts +0 -3
- package/esm/constant/index.js +0 -4
- package/esm/core/component/element/elementController/index.d.ts +0 -2
- package/esm/core/component/element/elementController/index.js +24 -124
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -7
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +35 -119
- package/esm/core/component/element/type.d.ts +0 -20
- package/esm/plugin/component/channel.d.ts +1 -1
- package/esm/plugin/component/channel.js +3 -1
- package/package.json +1 -1
package/esm/constant/index.d.ts
CHANGED
package/esm/constant/index.js
CHANGED
|
@@ -289,10 +289,6 @@ export var EVENT = {
|
|
|
289
289
|
submitPromiseCallback: {
|
|
290
290
|
name: 'onSubmitPayCallback'
|
|
291
291
|
},
|
|
292
|
-
// After Apple Pay authorization, before charge: notify SDK layer to execute merchant's onBeforeConfirm callback
|
|
293
|
-
beforeConfirm: {
|
|
294
|
-
name: 'onBeforeConfirm'
|
|
295
|
-
},
|
|
296
292
|
validateFieldsResult: {
|
|
297
293
|
name: 'validateFieldsResult',
|
|
298
294
|
forwardName: 'validateFieldsResultForward',
|
|
@@ -10,8 +10,6 @@ declare class ElementController {
|
|
|
10
10
|
private onStatusChangeCallback;
|
|
11
11
|
private submitPayPromise;
|
|
12
12
|
private elementEventCenter;
|
|
13
|
-
/** Current selected payment method type (e.g. 'APPLEPAY', 'CARD'), updated via paymentMethodChanged event */
|
|
14
|
-
private currentPaymentMethodType;
|
|
15
13
|
constructor(options: IElementOptions);
|
|
16
14
|
private initService;
|
|
17
15
|
private initElementProcessors;
|
|
@@ -41,7 +41,7 @@ import { ElementContainerService } from "../elementContainerService"; // 引入
|
|
|
41
41
|
import { IContainerStatus } from "../elementContainerService/containerService";
|
|
42
42
|
import { EventCenter as ElementEventCenter } from "../EventCenter/index";
|
|
43
43
|
import { oneAccountUpdate, sdkActionUpdate } from "../mock";
|
|
44
|
-
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode,
|
|
44
|
+
import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
|
|
45
45
|
import { checkCanMount, checkCanUpdate, handleRedirect, isLoadErrorPage, safeParse, safeStringify, showToast } from "../util";
|
|
46
46
|
var TIMEOUT_DURATION = 16000;
|
|
47
47
|
var ElementController = /*#__PURE__*/function () {
|
|
@@ -59,8 +59,6 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
59
59
|
// 新增变量
|
|
60
60
|
_defineProperty(this, "submitPayPromise", void 0);
|
|
61
61
|
_defineProperty(this, "elementEventCenter", void 0);
|
|
62
|
-
/** Current selected payment method type (e.g. 'APPLEPAY', 'CARD'), updated via paymentMethodChanged event */
|
|
63
|
-
_defineProperty(this, "currentPaymentMethodType", void 0);
|
|
64
62
|
_defineProperty(this, "onValidateFunc", function (event, target) {
|
|
65
63
|
return new Promise(function (resolve) {
|
|
66
64
|
event.emitAndListen({
|
|
@@ -374,7 +372,7 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
374
372
|
value: function () {
|
|
375
373
|
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
|
|
376
374
|
var _this3 = this;
|
|
377
|
-
var startEventId, res, logParams,
|
|
375
|
+
var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
|
|
378
376
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
379
377
|
while (1) switch (_context4.prev = _context4.next) {
|
|
380
378
|
case 0:
|
|
@@ -399,76 +397,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
399
397
|
return _context4.abrupt("return", Promise.resolve(res));
|
|
400
398
|
case 6:
|
|
401
399
|
this.changeLoading(true);
|
|
402
|
-
|
|
403
|
-
// Non-Apple Pay: execute onBeforeConfirm at SDK layer directly, abort on failure
|
|
404
|
-
isApplePay = this.currentPaymentMethodType === 'APPLEPAY';
|
|
405
|
-
this.serviceMap.Log.logInfo({
|
|
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
|
-
});
|
|
414
|
-
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
|
|
415
|
-
_context4.next = 27;
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
BEFORE_CONFIRM_TIMEOUT_MS = 15000;
|
|
419
|
-
_context4.prev = 11;
|
|
420
|
-
timeoutPromise = new Promise(function (_, reject) {
|
|
421
|
-
return setTimeout(function () {
|
|
422
|
-
return reject(new Error('onBeforeConfirm timed out'));
|
|
423
|
-
}, BEFORE_CONFIRM_TIMEOUT_MS);
|
|
424
|
-
});
|
|
425
|
-
_context4.next = 15;
|
|
426
|
-
return Promise.race([submitParams.onBeforeConfirm(), timeoutPromise]);
|
|
427
|
-
case 15:
|
|
428
|
-
shouldContinue = _context4.sent;
|
|
429
|
-
if (!(shouldContinue === false)) {
|
|
430
|
-
_context4.next = 19;
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
this.changeLoading(false);
|
|
434
|
-
return _context4.abrupt("return", {
|
|
435
|
-
status: PaymentStatus.FAIL,
|
|
436
|
-
error: {
|
|
437
|
-
code: 'MERCHANT_CONFIRM_ABORT',
|
|
438
|
-
message: 'Payment was cancelled by merchant before confirmation.',
|
|
439
|
-
needChangeSessionForRetry: false
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
case 19:
|
|
443
|
-
_context4.next = 27;
|
|
444
|
-
break;
|
|
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
|
|
452
|
-
}, {
|
|
453
|
-
msg: safeStringify({
|
|
454
|
-
error: isTimeout ? 'onBeforeConfirm timed out after 15s' : 'onBeforeConfirm callback error'
|
|
455
|
-
})
|
|
456
|
-
});
|
|
457
|
-
return _context4.abrupt("return", {
|
|
458
|
-
status: PaymentStatus.FAIL,
|
|
459
|
-
error: {
|
|
460
|
-
code: 'MERCHANT_CONFIRM_ABORT',
|
|
461
|
-
message: isTimeout ? 'onBeforeConfirm timed out after 15 seconds.' : 'An error occurred during the before-confirm callback.',
|
|
462
|
-
needChangeSessionForRetry: false
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
case 27:
|
|
466
400
|
recordResult = null;
|
|
467
|
-
_context4.prev =
|
|
468
|
-
_context4.next =
|
|
401
|
+
_context4.prev = 8;
|
|
402
|
+
_context4.next = 11;
|
|
469
403
|
return new Promise( /*#__PURE__*/function () {
|
|
470
404
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
471
|
-
var that, recordResultCallback, params, processStep,
|
|
405
|
+
var that, recordResultCallback, params, processStep, _submitParams$handleA, _yield$_this3$onValid2, _data, errorString, errorResult;
|
|
472
406
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
473
407
|
while (1) switch (_context3.prev = _context3.next) {
|
|
474
408
|
case 0:
|
|
@@ -544,57 +478,26 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
544
478
|
return _context3.abrupt("return");
|
|
545
479
|
case 14:
|
|
546
480
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
547
|
-
_context3.next =
|
|
481
|
+
_context3.next = 21;
|
|
548
482
|
break;
|
|
549
483
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
hasBeforeConfirmForApplePay: hasBeforeConfirmForApplePay,
|
|
557
|
-
isApplePay: isApplePay
|
|
558
|
-
})
|
|
559
|
-
});
|
|
560
|
-
_this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
|
|
561
|
-
_context3.next = 20;
|
|
562
|
-
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, function (_submitParams$handleA) {
|
|
563
|
-
var hasAmount = !!(submitParams !== null && submitParams !== void 0 && submitParams.amount);
|
|
564
|
-
var hasCurrency = !!(submitParams !== null && submitParams !== void 0 && submitParams.currency);
|
|
565
|
-
if ((hasAmount || hasCurrency) && !(hasAmount && hasCurrency)) {
|
|
566
|
-
_this3.serviceMap.Log.logError({
|
|
567
|
-
title: 'sdk_element_submitPayment_amountCurrencyMismatch'
|
|
568
|
-
}, {
|
|
569
|
-
msg: safeStringify({
|
|
570
|
-
amount: submitParams === null || submitParams === void 0 ? void 0 : submitParams.amount,
|
|
571
|
-
currency: submitParams === null || submitParams === void 0 ? void 0 : submitParams.currency,
|
|
572
|
-
reason: 'amount and currency must be provided together, both ignored'
|
|
573
|
-
})
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
return _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
|
|
577
|
-
handleActions: (_submitParams$handleA = submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleActions) !== null && _submitParams$handleA !== void 0 ? _submitParams$handleA : true,
|
|
578
|
-
shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
|
|
579
|
-
}, hasAmount && hasCurrency ? {
|
|
580
|
-
amount: submitParams.amount,
|
|
581
|
-
currency: submitParams.currency
|
|
582
|
-
} : {}), {}, {
|
|
583
|
-
hasBeforeConfirm: hasBeforeConfirmForApplePay
|
|
584
|
-
});
|
|
585
|
-
}());
|
|
586
|
-
case 20:
|
|
484
|
+
_context3.next = 17;
|
|
485
|
+
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, _objectSpread(_objectSpread({}, params), {}, {
|
|
486
|
+
handleActions: (_submitParams$handleA = submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleActions) !== null && _submitParams$handleA !== void 0 ? _submitParams$handleA : true,
|
|
487
|
+
shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
|
|
488
|
+
}));
|
|
489
|
+
case 17:
|
|
587
490
|
_yield$_this3$onValid2 = _context3.sent;
|
|
588
491
|
_data = _yield$_this3$onValid2.data;
|
|
589
492
|
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
590
493
|
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
591
494
|
recordResult = _data;
|
|
592
495
|
recordResultCallback(recordResult);
|
|
593
|
-
case
|
|
594
|
-
_context3.next =
|
|
496
|
+
case 21:
|
|
497
|
+
_context3.next = 30;
|
|
595
498
|
break;
|
|
596
|
-
case
|
|
597
|
-
_context3.prev =
|
|
499
|
+
case 23:
|
|
500
|
+
_context3.prev = 23;
|
|
598
501
|
_context3.t0 = _context3["catch"](2);
|
|
599
502
|
// 修复error为{}空对象的问题,上报stack&message
|
|
600
503
|
errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
|
|
@@ -611,20 +514,20 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
611
514
|
});
|
|
612
515
|
recordResult = errorResult;
|
|
613
516
|
recordResultCallback(errorResult);
|
|
614
|
-
case
|
|
517
|
+
case 30:
|
|
615
518
|
case "end":
|
|
616
519
|
return _context3.stop();
|
|
617
520
|
}
|
|
618
|
-
}, _callee3, null, [[2,
|
|
521
|
+
}, _callee3, null, [[2, 23]]);
|
|
619
522
|
}));
|
|
620
523
|
return function (_x2) {
|
|
621
524
|
return _ref3.apply(this, arguments);
|
|
622
525
|
};
|
|
623
526
|
}());
|
|
624
|
-
case
|
|
527
|
+
case 11:
|
|
625
528
|
return _context4.abrupt("return", _context4.sent);
|
|
626
|
-
case
|
|
627
|
-
_context4.prev =
|
|
529
|
+
case 12:
|
|
530
|
+
_context4.prev = 12;
|
|
628
531
|
_logParams = {
|
|
629
532
|
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
630
533
|
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
@@ -635,12 +538,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
635
538
|
};
|
|
636
539
|
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
637
540
|
this.changeLoading(false);
|
|
638
|
-
return _context4.finish(
|
|
639
|
-
case
|
|
541
|
+
return _context4.finish(12);
|
|
542
|
+
case 17:
|
|
640
543
|
case "end":
|
|
641
544
|
return _context4.stop();
|
|
642
545
|
}
|
|
643
|
-
}, _callee4, this, [[
|
|
546
|
+
}, _callee4, this, [[8,, 12, 17]]);
|
|
644
547
|
}));
|
|
645
548
|
function submitPayment(_x) {
|
|
646
549
|
return _submitPayment.apply(this, arguments);
|
|
@@ -725,9 +628,6 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
725
628
|
var _this4$submitPayPromi;
|
|
726
629
|
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
|
727
630
|
});
|
|
728
|
-
this.serviceMap.EventCenter.listen(EVENTNAME.PAYMENTMETHODCHANGED, function (data) {
|
|
729
|
-
_this4.currentPaymentMethodType = (data === null || data === void 0 ? void 0 : data.type) || '';
|
|
730
|
-
});
|
|
731
631
|
}
|
|
732
632
|
}, {
|
|
733
633
|
key: "sendRequestAndWaitWebLaunch",
|
|
@@ -2,13 +2,6 @@ import { LogService } from '../../../../foundation/service/log';
|
|
|
2
2
|
import BaseElementProcessor from './baseElementProcessor';
|
|
3
3
|
declare class PaymentProcessor extends BaseElementProcessor {
|
|
4
4
|
private ApplePayService;
|
|
5
|
-
/**
|
|
6
|
-
* Merchant's onBeforeConfirm callback reference, used in Apple Pay scenario only.
|
|
7
|
-
* Set by elementController.submitPayment before payment,
|
|
8
|
-
* triggered via beforeConfirm event after Apple Pay authorization in iframe.
|
|
9
|
-
*/
|
|
10
|
-
private _onBeforeConfirm;
|
|
11
|
-
setOnBeforeConfirm(callback: (() => Promise<boolean>) | null): void;
|
|
12
5
|
onReady(extraParam: any): void;
|
|
13
6
|
getLogger(): LogService;
|
|
14
7
|
private addEventListener;
|
|
@@ -56,20 +56,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
56
56
|
// parameterInitAndCheck(): void {}
|
|
57
57
|
// apple pay
|
|
58
58
|
_defineProperty(_assertThisInitialized(_this), "ApplePayService", void 0);
|
|
59
|
-
/**
|
|
60
|
-
* Merchant's onBeforeConfirm callback reference, used in Apple Pay scenario only.
|
|
61
|
-
* Set by elementController.submitPayment before payment,
|
|
62
|
-
* triggered via beforeConfirm event after Apple Pay authorization in iframe.
|
|
63
|
-
*/
|
|
64
|
-
_defineProperty(_assertThisInitialized(_this), "_onBeforeConfirm", null);
|
|
65
59
|
return _this;
|
|
66
60
|
}
|
|
67
61
|
_createClass(PaymentProcessor, [{
|
|
68
|
-
key: "setOnBeforeConfirm",
|
|
69
|
-
value: function setOnBeforeConfirm(callback) {
|
|
70
|
-
this._onBeforeConfirm = callback;
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
62
|
key: "onReady",
|
|
74
63
|
value: function onReady(extraParam) {
|
|
75
64
|
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
|
@@ -174,92 +163,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
174
163
|
});
|
|
175
164
|
});
|
|
176
165
|
});
|
|
177
|
-
// Apple Pay event bridge: after user authorization (FaceID/TouchID) in iframe, before actual charge,
|
|
178
|
-
// requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
|
|
179
|
-
// and returns the result (continue/abort) to iframe via dispatchToApp.
|
|
180
|
-
this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
181
|
-
var BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, shouldContinue, isTimeout;
|
|
182
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
183
|
-
while (1) switch (_context.prev = _context.next) {
|
|
184
|
-
case 0:
|
|
185
|
-
logger.logInfo({
|
|
186
|
-
title: 'sdk_element_beforeConfirm_event_received'
|
|
187
|
-
}, {
|
|
188
|
-
hasCallback: !!_this2._onBeforeConfirm
|
|
189
|
-
});
|
|
190
|
-
if (_this2._onBeforeConfirm) {
|
|
191
|
-
_context.next = 4;
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
_this2.eventCenter.dispatchToApp({
|
|
195
|
-
event: EVENT.beforeConfirm.name,
|
|
196
|
-
data: {
|
|
197
|
-
success: true,
|
|
198
|
-
result: true
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
return _context.abrupt("return");
|
|
202
|
-
case 4:
|
|
203
|
-
BEFORE_CONFIRM_TIMEOUT_MS = 15000;
|
|
204
|
-
_context.prev = 5;
|
|
205
|
-
timeoutPromise = new Promise(function (_, reject) {
|
|
206
|
-
return setTimeout(function () {
|
|
207
|
-
return reject(new Error('onBeforeConfirm timed out'));
|
|
208
|
-
}, BEFORE_CONFIRM_TIMEOUT_MS);
|
|
209
|
-
});
|
|
210
|
-
_context.next = 9;
|
|
211
|
-
return Promise.race([_this2._onBeforeConfirm(), timeoutPromise]);
|
|
212
|
-
case 9:
|
|
213
|
-
shouldContinue = _context.sent;
|
|
214
|
-
logger.logInfo({
|
|
215
|
-
title: 'sdk_element_beforeConfirm_callback_result'
|
|
216
|
-
}, {
|
|
217
|
-
shouldContinue: shouldContinue
|
|
218
|
-
});
|
|
219
|
-
_this2.eventCenter.dispatchToApp({
|
|
220
|
-
event: EVENT.beforeConfirm.name,
|
|
221
|
-
data: {
|
|
222
|
-
success: true,
|
|
223
|
-
result: shouldContinue !== false
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
_context.next = 19;
|
|
227
|
-
break;
|
|
228
|
-
case 14:
|
|
229
|
-
_context.prev = 14;
|
|
230
|
-
_context.t0 = _context["catch"](5);
|
|
231
|
-
isTimeout = _context.t0 instanceof Error && _context.t0.message === 'onBeforeConfirm timed out';
|
|
232
|
-
logger.logError({
|
|
233
|
-
title: 'sdk_element_onBeforeConfirm_error'
|
|
234
|
-
}, {
|
|
235
|
-
error: isTimeout ? 'onBeforeConfirm timed out after 15s' : safeStringify(_context.t0)
|
|
236
|
-
});
|
|
237
|
-
_this2.eventCenter.dispatchToApp({
|
|
238
|
-
event: EVENT.beforeConfirm.name,
|
|
239
|
-
data: {
|
|
240
|
-
success: false,
|
|
241
|
-
result: false
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
case 19:
|
|
245
|
-
case "end":
|
|
246
|
-
return _context.stop();
|
|
247
|
-
}
|
|
248
|
-
}, _callee, null, [[5, 14]]);
|
|
249
|
-
})));
|
|
250
166
|
}
|
|
251
167
|
}, {
|
|
252
168
|
key: "initApplePaySdk",
|
|
253
169
|
value: function () {
|
|
254
|
-
var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
170
|
+
var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
255
171
|
var _this$elementContaine6;
|
|
256
|
-
var
|
|
257
|
-
return _regeneratorRuntime().wrap(function
|
|
258
|
-
while (1) switch (
|
|
172
|
+
var _ref, paymentSessionObj, paymentSession;
|
|
173
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
174
|
+
while (1) switch (_context.prev = _context.next) {
|
|
259
175
|
case 0:
|
|
260
|
-
|
|
176
|
+
_ref = ((_this$elementContaine6 = this.elementContainer) === null || _this$elementContaine6 === void 0 ? void 0 : _this$elementContaine6.getPaymentContext()) || {}, paymentSessionObj = _ref.paymentSessionObj, paymentSession = _ref.paymentSession;
|
|
261
177
|
if (!isSkipRenderPaymentMethod(paymentSessionObj)) {
|
|
262
|
-
|
|
178
|
+
_context.next = 13;
|
|
263
179
|
break;
|
|
264
180
|
}
|
|
265
181
|
this.ApplePayService = new ApplePaySdk({
|
|
@@ -268,29 +184,29 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
268
184
|
logger: logger,
|
|
269
185
|
env: this.options.env.environment
|
|
270
186
|
});
|
|
271
|
-
|
|
187
|
+
_context.prev = 3;
|
|
272
188
|
logger.logInfo({
|
|
273
189
|
title: 'a3753.b107385.c398110'
|
|
274
190
|
});
|
|
275
|
-
|
|
191
|
+
_context.next = 7;
|
|
276
192
|
return this.ApplePayService.initApplePaySession();
|
|
277
193
|
case 7:
|
|
278
194
|
logger.logInfo({
|
|
279
195
|
title: 'a3753.b107385.c398112'
|
|
280
196
|
});
|
|
281
|
-
|
|
197
|
+
_context.next = 13;
|
|
282
198
|
break;
|
|
283
199
|
case 10:
|
|
284
|
-
|
|
285
|
-
|
|
200
|
+
_context.prev = 10;
|
|
201
|
+
_context.t0 = _context["catch"](3);
|
|
286
202
|
logger.logError({
|
|
287
203
|
title: 'a3753.b107385.c398111'
|
|
288
204
|
});
|
|
289
205
|
case 13:
|
|
290
206
|
case "end":
|
|
291
|
-
return
|
|
207
|
+
return _context.stop();
|
|
292
208
|
}
|
|
293
|
-
},
|
|
209
|
+
}, _callee, this, [[3, 10]]);
|
|
294
210
|
}));
|
|
295
211
|
function initApplePaySdk() {
|
|
296
212
|
return _initApplePaySdk.apply(this, arguments);
|
|
@@ -311,20 +227,20 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
311
227
|
}
|
|
312
228
|
}, {
|
|
313
229
|
key: "generateIframeSrc",
|
|
314
|
-
value: function generateIframeSrc(
|
|
315
|
-
var link =
|
|
316
|
-
instanceId =
|
|
230
|
+
value: function generateIframeSrc(_ref2) {
|
|
231
|
+
var link = _ref2.link,
|
|
232
|
+
instanceId = _ref2.instanceId;
|
|
317
233
|
this.instanceId = instanceId;
|
|
318
|
-
var
|
|
319
|
-
paymentSession =
|
|
320
|
-
paymentSessionObj =
|
|
321
|
-
sdkMetaData =
|
|
234
|
+
var _ref3 = this.elementContainer.getPaymentContext() || {},
|
|
235
|
+
paymentSession = _ref3.paymentSession,
|
|
236
|
+
paymentSessionObj = _ref3.paymentSessionObj,
|
|
237
|
+
sdkMetaData = _ref3.sdkMetaData;
|
|
322
238
|
var _this$options = this.options,
|
|
323
239
|
environment = _this$options.env.environment,
|
|
324
240
|
analytics = _this$options.analytics,
|
|
325
241
|
locale = _this$options.locale;
|
|
326
|
-
var
|
|
327
|
-
extendInfo =
|
|
242
|
+
var _ref4 = paymentSessionObj || {},
|
|
243
|
+
extendInfo = _ref4.extendInfo;
|
|
328
244
|
var url = _generateIframeSrc({
|
|
329
245
|
paymentSession: paymentSession,
|
|
330
246
|
paymentSessionObj: paymentSessionObj,
|
|
@@ -342,19 +258,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
342
258
|
}, {
|
|
343
259
|
key: "obtainData",
|
|
344
260
|
value: function () {
|
|
345
|
-
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
261
|
+
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
346
262
|
var _paymentSessionObj$co,
|
|
347
263
|
_this3 = this;
|
|
348
|
-
var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale,
|
|
349
|
-
return _regeneratorRuntime().wrap(function
|
|
350
|
-
while (1) switch (
|
|
264
|
+
var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref5, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
|
|
265
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
266
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
351
267
|
case 0:
|
|
352
268
|
requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
|
353
269
|
_this$elementContaine7 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine7.paymentSession, paymentSessionObj = _this$elementContaine7.paymentSessionObj, displayInfo = _this$elementContaine7.displayInfo;
|
|
354
270
|
_displayInfo = displayInfo;
|
|
355
271
|
debugProps = _displayInfo.debugProps;
|
|
356
272
|
_this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
|
|
357
|
-
|
|
273
|
+
_ref5 = paymentSessionObj || {}, paymentSessionConfig = _ref5.paymentSessionConfig;
|
|
358
274
|
hostSign = paymentSession.split('&&')[1] || '';
|
|
359
275
|
isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
|
|
360
276
|
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
|
|
@@ -491,10 +407,10 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
491
407
|
});
|
|
492
408
|
});
|
|
493
409
|
};
|
|
494
|
-
|
|
410
|
+
_context2.next = 15;
|
|
495
411
|
return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
|
|
496
412
|
case 15:
|
|
497
|
-
_yield$Promise$all =
|
|
413
|
+
_yield$Promise$all = _context2.sent;
|
|
498
414
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
499
415
|
originActionQueryResult = _yield$Promise$all2[0];
|
|
500
416
|
originOneAccountQueryResult = _yield$Promise$all2[1];
|
|
@@ -502,15 +418,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
502
418
|
originActionQueryResult: originActionQueryResult,
|
|
503
419
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
504
420
|
};
|
|
505
|
-
return
|
|
421
|
+
return _context2.abrupt("return", {
|
|
506
422
|
originActionQueryResult: originActionQueryResult,
|
|
507
423
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
508
424
|
});
|
|
509
425
|
case 21:
|
|
510
426
|
case "end":
|
|
511
|
-
return
|
|
427
|
+
return _context2.stop();
|
|
512
428
|
}
|
|
513
|
-
},
|
|
429
|
+
}, _callee2, this);
|
|
514
430
|
}));
|
|
515
431
|
function obtainData() {
|
|
516
432
|
return _obtainData.apply(this, arguments);
|
|
@@ -525,9 +441,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
525
441
|
}
|
|
526
442
|
}, {
|
|
527
443
|
key: "update",
|
|
528
|
-
value: function update(
|
|
529
|
-
var data =
|
|
530
|
-
paymentSessionData =
|
|
444
|
+
value: function update(_ref6) {
|
|
445
|
+
var data = _ref6.data,
|
|
446
|
+
paymentSessionData = _ref6.paymentSessionData;
|
|
531
447
|
var _parseSessionData = parseSessionData(paymentSessionData),
|
|
532
448
|
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
|
533
449
|
parseData = _parseSessionData2[0],
|
|
@@ -287,26 +287,6 @@ export interface AddressSubmitData {
|
|
|
287
287
|
export interface SubmitFuncParams {
|
|
288
288
|
handleActions?: boolean;
|
|
289
289
|
shippingInfo?: ShippingInfo;
|
|
290
|
-
/**
|
|
291
|
-
* Amount displayed on the Apple Pay payment sheet, e.g. '10.99'.
|
|
292
|
-
* Display only; actual charge amount is controlled by server.
|
|
293
|
-
* Must be provided together with `currency`. Only effective for Apple Pay.
|
|
294
|
-
*/
|
|
295
|
-
amount?: string;
|
|
296
|
-
/**
|
|
297
|
-
* Currency code displayed on the Apple Pay payment sheet, e.g. 'USD'.
|
|
298
|
-
* Follows ISO 4217 standard. Must be provided together with `amount`. Only effective for Apple Pay.
|
|
299
|
-
*/
|
|
300
|
-
currency?: string;
|
|
301
|
-
/**
|
|
302
|
-
* Pre-confirmation callback. Executed after user authorization but before actual charge,
|
|
303
|
-
* allowing merchant to create order at this point.
|
|
304
|
-
* - Only effective when payment method is Apple Pay
|
|
305
|
-
* - Invoked via event bridge after user FaceID/TouchID authorization on the payment sheet
|
|
306
|
-
* - Return true: proceed with charge
|
|
307
|
-
* - Return false / timeout / throw error: abort payment, returns MERCHANT_CONFIRM_ABORT error code
|
|
308
|
-
*/
|
|
309
|
-
onBeforeConfirm?: () => Promise<boolean>;
|
|
310
290
|
}
|
|
311
291
|
export interface SubmitServiceParams extends PaymentSubmitData {
|
|
312
292
|
accountInfo: AuthSubmitData['accountInfo'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EventPayload, type IPaymentSessionMetaData } from '../../types';
|
|
2
1
|
import type { CKPShipping } from '../../core/component/element/type';
|
|
2
|
+
import { type EventPayload, type IPaymentSessionMetaData } from '../../types';
|
|
3
3
|
import { Logger } from '../../util/logger';
|
|
4
4
|
export type IChannelBehavior = {
|
|
5
5
|
usePaymentSessionAsQueryResult: boolean;
|
|
@@ -89,7 +89,9 @@ export var handleGooglePay = function handleGooglePay(data) {
|
|
|
89
89
|
var script = document.createElement('script');
|
|
90
90
|
script.src = 'https://pay.google.com/gp/p/js/pay.js';
|
|
91
91
|
script.async = true;
|
|
92
|
-
|
|
92
|
+
// 使用原生 appendChild 避免微前端沙箱(如 qiankun)将动态 <script> 劫持为 fetch 加载,
|
|
93
|
+
// 导致不支持 CORS 的第三方脚本(如 pay.google.com)加载失败
|
|
94
|
+
Node.prototype.appendChild.call(document.body, script);
|
|
93
95
|
// 执行googlePay sdk
|
|
94
96
|
script.onload = function () {
|
|
95
97
|
var paymentsClient = new window.google.payments.api.PaymentsClient({
|