@alipay/ams-checkout 0.0.1781004142-dev.0 → 0.0.1781004142-dev.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.
- 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 +21 -79
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -7
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +35 -102
- package/esm/core/component/element/type.d.ts +0 -25
- package/esm/core/component/element/type.js +0 -4
- 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,60 +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
|
-
if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
|
|
406
|
-
_context4.next = 23;
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
_context4.prev = 9;
|
|
410
|
-
_context4.next = 12;
|
|
411
|
-
return submitParams.onBeforeConfirm();
|
|
412
|
-
case 12:
|
|
413
|
-
shouldContinue = _context4.sent;
|
|
414
|
-
if (!(shouldContinue === false)) {
|
|
415
|
-
_context4.next = 16;
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
this.changeLoading(false);
|
|
419
|
-
return _context4.abrupt("return", {
|
|
420
|
-
status: PaymentStatus.FAIL,
|
|
421
|
-
error: {
|
|
422
|
-
code: 'MERCHANT_ABORT',
|
|
423
|
-
message: 'Payment was cancelled by merchant before confirmation.',
|
|
424
|
-
needChangeSessionForRetry: false
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
case 16:
|
|
428
|
-
_context4.next = 23;
|
|
429
|
-
break;
|
|
430
|
-
case 18:
|
|
431
|
-
_context4.prev = 18;
|
|
432
|
-
_context4.t0 = _context4["catch"](9);
|
|
433
|
-
this.changeLoading(false);
|
|
434
|
-
this.serviceMap.Log.logError({
|
|
435
|
-
title: ELEMENT_SPM_MAP.sdk_element_missKeyData
|
|
436
|
-
}, {
|
|
437
|
-
msg: safeStringify({
|
|
438
|
-
error: 'onBeforeConfirm callback error'
|
|
439
|
-
})
|
|
440
|
-
});
|
|
441
|
-
return _context4.abrupt("return", {
|
|
442
|
-
status: PaymentStatus.FAIL,
|
|
443
|
-
error: {
|
|
444
|
-
code: 'BEFORE_CONFIRM_ERROR',
|
|
445
|
-
message: 'An error occurred during the before-confirm callback.',
|
|
446
|
-
needChangeSessionForRetry: false
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
case 23:
|
|
450
400
|
recordResult = null;
|
|
451
|
-
_context4.prev =
|
|
452
|
-
_context4.next =
|
|
401
|
+
_context4.prev = 8;
|
|
402
|
+
_context4.next = 11;
|
|
453
403
|
return new Promise( /*#__PURE__*/function () {
|
|
454
404
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
|
455
|
-
var that, recordResultCallback, params, processStep, _submitParams$handleA,
|
|
405
|
+
var that, recordResultCallback, params, processStep, _submitParams$handleA, _yield$_this3$onValid2, _data, errorString, errorResult;
|
|
456
406
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
457
407
|
while (1) switch (_context3.prev = _context3.next) {
|
|
458
408
|
case 0:
|
|
@@ -528,31 +478,26 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
528
478
|
return _context3.abrupt("return");
|
|
529
479
|
case 14:
|
|
530
480
|
if (!_this3.elementProcessors[ElementType.payment]) {
|
|
531
|
-
_context3.next =
|
|
481
|
+
_context3.next = 21;
|
|
532
482
|
break;
|
|
533
483
|
}
|
|
534
|
-
|
|
535
|
-
hasBeforeConfirmForApplePay = isApplePay && !!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm);
|
|
536
|
-
_this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
|
|
537
|
-
_context3.next = 19;
|
|
484
|
+
_context3.next = 17;
|
|
538
485
|
return _this3.onValidateAndSubmitPay(_this3.elementProcessors[ElementType.payment].eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, _objectSpread(_objectSpread({}, params), {}, {
|
|
539
486
|
handleActions: (_submitParams$handleA = submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleActions) !== null && _submitParams$handleA !== void 0 ? _submitParams$handleA : true,
|
|
540
|
-
shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
|
|
541
|
-
applePayAmount: submitParams === null || submitParams === void 0 ? void 0 : submitParams.applePayAmount,
|
|
542
|
-
hasBeforeConfirm: hasBeforeConfirmForApplePay
|
|
487
|
+
shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
|
|
543
488
|
}));
|
|
544
|
-
case
|
|
489
|
+
case 17:
|
|
545
490
|
_yield$_this3$onValid2 = _context3.sent;
|
|
546
491
|
_data = _yield$_this3$onValid2.data;
|
|
547
492
|
// TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
|
|
548
493
|
// TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
|
|
549
494
|
recordResult = _data;
|
|
550
495
|
recordResultCallback(recordResult);
|
|
551
|
-
case
|
|
552
|
-
_context3.next =
|
|
496
|
+
case 21:
|
|
497
|
+
_context3.next = 30;
|
|
553
498
|
break;
|
|
554
|
-
case
|
|
555
|
-
_context3.prev =
|
|
499
|
+
case 23:
|
|
500
|
+
_context3.prev = 23;
|
|
556
501
|
_context3.t0 = _context3["catch"](2);
|
|
557
502
|
// 修复error为{}空对象的问题,上报stack&message
|
|
558
503
|
errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
|
|
@@ -569,20 +514,20 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
569
514
|
});
|
|
570
515
|
recordResult = errorResult;
|
|
571
516
|
recordResultCallback(errorResult);
|
|
572
|
-
case
|
|
517
|
+
case 30:
|
|
573
518
|
case "end":
|
|
574
519
|
return _context3.stop();
|
|
575
520
|
}
|
|
576
|
-
}, _callee3, null, [[2,
|
|
521
|
+
}, _callee3, null, [[2, 23]]);
|
|
577
522
|
}));
|
|
578
523
|
return function (_x2) {
|
|
579
524
|
return _ref3.apply(this, arguments);
|
|
580
525
|
};
|
|
581
526
|
}());
|
|
582
|
-
case
|
|
527
|
+
case 11:
|
|
583
528
|
return _context4.abrupt("return", _context4.sent);
|
|
584
|
-
case
|
|
585
|
-
_context4.prev =
|
|
529
|
+
case 12:
|
|
530
|
+
_context4.prev = 12;
|
|
586
531
|
_logParams = {
|
|
587
532
|
eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
|
|
588
533
|
errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
|
|
@@ -593,12 +538,12 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
593
538
|
};
|
|
594
539
|
this.elementEventCenter.endEvent(startEventId, _logParams);
|
|
595
540
|
this.changeLoading(false);
|
|
596
|
-
return _context4.finish(
|
|
597
|
-
case
|
|
541
|
+
return _context4.finish(12);
|
|
542
|
+
case 17:
|
|
598
543
|
case "end":
|
|
599
544
|
return _context4.stop();
|
|
600
545
|
}
|
|
601
|
-
}, _callee4, this, [[
|
|
546
|
+
}, _callee4, this, [[8,, 12, 17]]);
|
|
602
547
|
}));
|
|
603
548
|
function submitPayment(_x) {
|
|
604
549
|
return _submitPayment.apply(this, arguments);
|
|
@@ -683,9 +628,6 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
683
628
|
var _this4$submitPayPromi;
|
|
684
629
|
(_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
|
|
685
630
|
});
|
|
686
|
-
this.serviceMap.EventCenter.listen(EVENTNAME.PAYMENTMETHODCHANGED, function (data) {
|
|
687
|
-
_this4.currentPaymentMethodType = (data === null || data === void 0 ? void 0 : data.type) || '';
|
|
688
|
-
});
|
|
689
631
|
}
|
|
690
632
|
}, {
|
|
691
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,75 +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 shouldContinue;
|
|
182
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
183
|
-
while (1) switch (_context.prev = _context.next) {
|
|
184
|
-
case 0:
|
|
185
|
-
if (_this2._onBeforeConfirm) {
|
|
186
|
-
_context.next = 3;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
_this2.eventCenter.dispatchToApp({
|
|
190
|
-
event: EVENT.beforeConfirm.name,
|
|
191
|
-
data: {
|
|
192
|
-
success: true,
|
|
193
|
-
result: true
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
return _context.abrupt("return");
|
|
197
|
-
case 3:
|
|
198
|
-
_context.prev = 3;
|
|
199
|
-
_context.next = 6;
|
|
200
|
-
return _this2._onBeforeConfirm();
|
|
201
|
-
case 6:
|
|
202
|
-
shouldContinue = _context.sent;
|
|
203
|
-
_this2.eventCenter.dispatchToApp({
|
|
204
|
-
event: EVENT.beforeConfirm.name,
|
|
205
|
-
data: {
|
|
206
|
-
success: true,
|
|
207
|
-
result: shouldContinue !== false
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
_context.next = 14;
|
|
211
|
-
break;
|
|
212
|
-
case 10:
|
|
213
|
-
_context.prev = 10;
|
|
214
|
-
_context.t0 = _context["catch"](3);
|
|
215
|
-
logger.logError({
|
|
216
|
-
title: 'sdk_element_onBeforeConfirm_error'
|
|
217
|
-
}, {
|
|
218
|
-
error: safeStringify(_context.t0)
|
|
219
|
-
});
|
|
220
|
-
_this2.eventCenter.dispatchToApp({
|
|
221
|
-
event: EVENT.beforeConfirm.name,
|
|
222
|
-
data: {
|
|
223
|
-
success: false,
|
|
224
|
-
result: false
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
case 14:
|
|
228
|
-
case "end":
|
|
229
|
-
return _context.stop();
|
|
230
|
-
}
|
|
231
|
-
}, _callee, null, [[3, 10]]);
|
|
232
|
-
})));
|
|
233
166
|
}
|
|
234
167
|
}, {
|
|
235
168
|
key: "initApplePaySdk",
|
|
236
169
|
value: function () {
|
|
237
|
-
var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
170
|
+
var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
238
171
|
var _this$elementContaine6;
|
|
239
|
-
var
|
|
240
|
-
return _regeneratorRuntime().wrap(function
|
|
241
|
-
while (1) switch (
|
|
172
|
+
var _ref, paymentSessionObj, paymentSession;
|
|
173
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
174
|
+
while (1) switch (_context.prev = _context.next) {
|
|
242
175
|
case 0:
|
|
243
|
-
|
|
176
|
+
_ref = ((_this$elementContaine6 = this.elementContainer) === null || _this$elementContaine6 === void 0 ? void 0 : _this$elementContaine6.getPaymentContext()) || {}, paymentSessionObj = _ref.paymentSessionObj, paymentSession = _ref.paymentSession;
|
|
244
177
|
if (!isSkipRenderPaymentMethod(paymentSessionObj)) {
|
|
245
|
-
|
|
178
|
+
_context.next = 13;
|
|
246
179
|
break;
|
|
247
180
|
}
|
|
248
181
|
this.ApplePayService = new ApplePaySdk({
|
|
@@ -251,29 +184,29 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
251
184
|
logger: logger,
|
|
252
185
|
env: this.options.env.environment
|
|
253
186
|
});
|
|
254
|
-
|
|
187
|
+
_context.prev = 3;
|
|
255
188
|
logger.logInfo({
|
|
256
189
|
title: 'a3753.b107385.c398110'
|
|
257
190
|
});
|
|
258
|
-
|
|
191
|
+
_context.next = 7;
|
|
259
192
|
return this.ApplePayService.initApplePaySession();
|
|
260
193
|
case 7:
|
|
261
194
|
logger.logInfo({
|
|
262
195
|
title: 'a3753.b107385.c398112'
|
|
263
196
|
});
|
|
264
|
-
|
|
197
|
+
_context.next = 13;
|
|
265
198
|
break;
|
|
266
199
|
case 10:
|
|
267
|
-
|
|
268
|
-
|
|
200
|
+
_context.prev = 10;
|
|
201
|
+
_context.t0 = _context["catch"](3);
|
|
269
202
|
logger.logError({
|
|
270
203
|
title: 'a3753.b107385.c398111'
|
|
271
204
|
});
|
|
272
205
|
case 13:
|
|
273
206
|
case "end":
|
|
274
|
-
return
|
|
207
|
+
return _context.stop();
|
|
275
208
|
}
|
|
276
|
-
},
|
|
209
|
+
}, _callee, this, [[3, 10]]);
|
|
277
210
|
}));
|
|
278
211
|
function initApplePaySdk() {
|
|
279
212
|
return _initApplePaySdk.apply(this, arguments);
|
|
@@ -294,20 +227,20 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
294
227
|
}
|
|
295
228
|
}, {
|
|
296
229
|
key: "generateIframeSrc",
|
|
297
|
-
value: function generateIframeSrc(
|
|
298
|
-
var link =
|
|
299
|
-
instanceId =
|
|
230
|
+
value: function generateIframeSrc(_ref2) {
|
|
231
|
+
var link = _ref2.link,
|
|
232
|
+
instanceId = _ref2.instanceId;
|
|
300
233
|
this.instanceId = instanceId;
|
|
301
|
-
var
|
|
302
|
-
paymentSession =
|
|
303
|
-
paymentSessionObj =
|
|
304
|
-
sdkMetaData =
|
|
234
|
+
var _ref3 = this.elementContainer.getPaymentContext() || {},
|
|
235
|
+
paymentSession = _ref3.paymentSession,
|
|
236
|
+
paymentSessionObj = _ref3.paymentSessionObj,
|
|
237
|
+
sdkMetaData = _ref3.sdkMetaData;
|
|
305
238
|
var _this$options = this.options,
|
|
306
239
|
environment = _this$options.env.environment,
|
|
307
240
|
analytics = _this$options.analytics,
|
|
308
241
|
locale = _this$options.locale;
|
|
309
|
-
var
|
|
310
|
-
extendInfo =
|
|
242
|
+
var _ref4 = paymentSessionObj || {},
|
|
243
|
+
extendInfo = _ref4.extendInfo;
|
|
311
244
|
var url = _generateIframeSrc({
|
|
312
245
|
paymentSession: paymentSession,
|
|
313
246
|
paymentSessionObj: paymentSessionObj,
|
|
@@ -325,19 +258,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
325
258
|
}, {
|
|
326
259
|
key: "obtainData",
|
|
327
260
|
value: function () {
|
|
328
|
-
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
261
|
+
var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
329
262
|
var _paymentSessionObj$co,
|
|
330
263
|
_this3 = this;
|
|
331
|
-
var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale,
|
|
332
|
-
return _regeneratorRuntime().wrap(function
|
|
333
|
-
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) {
|
|
334
267
|
case 0:
|
|
335
268
|
requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
|
336
269
|
_this$elementContaine7 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine7.paymentSession, paymentSessionObj = _this$elementContaine7.paymentSessionObj, displayInfo = _this$elementContaine7.displayInfo;
|
|
337
270
|
_displayInfo = displayInfo;
|
|
338
271
|
debugProps = _displayInfo.debugProps;
|
|
339
272
|
_this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
|
|
340
|
-
|
|
273
|
+
_ref5 = paymentSessionObj || {}, paymentSessionConfig = _ref5.paymentSessionConfig;
|
|
341
274
|
hostSign = paymentSession.split('&&')[1] || '';
|
|
342
275
|
isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
|
|
343
276
|
LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
|
|
@@ -474,10 +407,10 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
474
407
|
});
|
|
475
408
|
});
|
|
476
409
|
};
|
|
477
|
-
|
|
410
|
+
_context2.next = 15;
|
|
478
411
|
return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
|
|
479
412
|
case 15:
|
|
480
|
-
_yield$Promise$all =
|
|
413
|
+
_yield$Promise$all = _context2.sent;
|
|
481
414
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
482
415
|
originActionQueryResult = _yield$Promise$all2[0];
|
|
483
416
|
originOneAccountQueryResult = _yield$Promise$all2[1];
|
|
@@ -485,15 +418,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
485
418
|
originActionQueryResult: originActionQueryResult,
|
|
486
419
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
487
420
|
};
|
|
488
|
-
return
|
|
421
|
+
return _context2.abrupt("return", {
|
|
489
422
|
originActionQueryResult: originActionQueryResult,
|
|
490
423
|
originOneAccountQueryResult: originOneAccountQueryResult
|
|
491
424
|
});
|
|
492
425
|
case 21:
|
|
493
426
|
case "end":
|
|
494
|
-
return
|
|
427
|
+
return _context2.stop();
|
|
495
428
|
}
|
|
496
|
-
},
|
|
429
|
+
}, _callee2, this);
|
|
497
430
|
}));
|
|
498
431
|
function obtainData() {
|
|
499
432
|
return _obtainData.apply(this, arguments);
|
|
@@ -508,9 +441,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
508
441
|
}
|
|
509
442
|
}, {
|
|
510
443
|
key: "update",
|
|
511
|
-
value: function update(
|
|
512
|
-
var data =
|
|
513
|
-
paymentSessionData =
|
|
444
|
+
value: function update(_ref6) {
|
|
445
|
+
var data = _ref6.data,
|
|
446
|
+
paymentSessionData = _ref6.paymentSessionData;
|
|
514
447
|
var _parseSessionData = parseSessionData(paymentSessionData),
|
|
515
448
|
_parseSessionData2 = _slicedToArray(_parseSessionData, 2),
|
|
516
449
|
parseData = _parseSessionData2[0],
|
|
@@ -284,34 +284,9 @@ export interface AddressSubmitData {
|
|
|
284
284
|
shippingId: string;
|
|
285
285
|
actionFlag?: 'I' | 'U' | 'D';
|
|
286
286
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Amount info displayed on Apple Pay sheet (display only; actual charge amount is controlled by server)
|
|
289
|
-
*/
|
|
290
|
-
export interface SubmitAmount {
|
|
291
|
-
/** Amount value, e.g. '10.99' */
|
|
292
|
-
value: string;
|
|
293
|
-
/** Currency code, e.g. 'USD' */
|
|
294
|
-
currency: string;
|
|
295
|
-
}
|
|
296
287
|
export interface SubmitFuncParams {
|
|
297
288
|
handleActions?: boolean;
|
|
298
289
|
shippingInfo?: ShippingInfo;
|
|
299
|
-
/**
|
|
300
|
-
* Amount displayed on Apple Pay sheet. Only effective in Apple Pay scenario,
|
|
301
|
-
* used to show amount when launching the sheet first. Actual charge amount
|
|
302
|
-
* is determined by server. Ignored in non-Apple Pay scenarios.
|
|
303
|
-
*/
|
|
304
|
-
applePayAmount?: SubmitAmount;
|
|
305
|
-
/**
|
|
306
|
-
* Pre-confirmation callback. Executed after user authorization but before actual charge,
|
|
307
|
-
* allowing merchant to create order at this point.
|
|
308
|
-
* - Apple Pay: invoked via event bridge after user FaceID/TouchID authorization on the sheet
|
|
309
|
-
* - Non-Apple Pay: invoked synchronously at SDK layer
|
|
310
|
-
* - Return true: proceed with charge
|
|
311
|
-
* - Return false: abort payment, returns MERCHANT_ABORT error code
|
|
312
|
-
* - Throw error: abort payment, returns BEFORE_CONFIRM_ERROR error code
|
|
313
|
-
*/
|
|
314
|
-
onBeforeConfirm?: () => Promise<boolean>;
|
|
315
290
|
}
|
|
316
291
|
export interface SubmitServiceParams extends PaymentSubmitData {
|
|
317
292
|
accountInfo: AuthSubmitData['accountInfo'];
|
|
@@ -119,10 +119,6 @@ export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbac
|
|
|
119
119
|
*/
|
|
120
120
|
|
|
121
121
|
// export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Amount info displayed on Apple Pay sheet (display only; actual charge amount is controlled by server)
|
|
125
|
-
*/
|
|
126
122
|
var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
|
|
127
123
|
AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
|
|
128
124
|
AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
|
|
@@ -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({
|