@alipay/ams-checkout 0.0.1781004142-dev.3 → 0.0.1781004142-dev.4

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.
@@ -283,6 +283,9 @@ export declare const EVENT: {
283
283
  submitPromiseCallback: {
284
284
  name: string;
285
285
  };
286
+ beforeConfirm: {
287
+ name: string;
288
+ };
286
289
  validateFieldsResult: {
287
290
  name: string;
288
291
  forwardName: string;
@@ -289,6 +289,10 @@ 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
+ },
292
296
  validateFieldsResult: {
293
297
  name: 'validateFieldsResult',
294
298
  forwardName: 'validateFieldsResultForward',
@@ -10,6 +10,8 @@ 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;
13
15
  constructor(options: IElementOptions);
14
16
  private initService;
15
17
  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, EXPOSURE_API_EVENT, MountElementType, PaymentStatus } from "../type";
44
+ import { ElementPaymentEvent, ElementPaymentMethod, ElementType, EventCallbackCode, EVENTNAME, 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,6 +59,8 @@ 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);
62
64
  _defineProperty(this, "onValidateFunc", function (event, target) {
63
65
  return new Promise(function (resolve) {
64
66
  event.emitAndListen({
@@ -372,7 +374,7 @@ var ElementController = /*#__PURE__*/function () {
372
374
  value: function () {
373
375
  var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(submitParams) {
374
376
  var _this3 = this;
375
- var startEventId, res, logParams, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
377
+ var startEventId, res, logParams, isApplePay, BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, shouldContinue, isTimeout, recordResult, _recordResult, _recordResult2, _recordResult3, _recordResult4, _recordResult5, _logParams;
376
378
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
377
379
  while (1) switch (_context4.prev = _context4.next) {
378
380
  case 0:
@@ -397,12 +399,76 @@ var ElementController = /*#__PURE__*/function () {
397
399
  return _context4.abrupt("return", Promise.resolve(res));
398
400
  case 6:
399
401
  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:
400
466
  recordResult = null;
401
- _context4.prev = 8;
402
- _context4.next = 11;
467
+ _context4.prev = 28;
468
+ _context4.next = 31;
403
469
  return new Promise( /*#__PURE__*/function () {
404
470
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
405
- var that, recordResultCallback, params, processStep, _submitParams$handleA, _yield$_this3$onValid2, _data, errorString, errorResult;
471
+ var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, _yield$_this3$onValid2, _data, errorString, errorResult;
406
472
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
407
473
  while (1) switch (_context3.prev = _context3.next) {
408
474
  case 0:
@@ -478,26 +544,57 @@ var ElementController = /*#__PURE__*/function () {
478
544
  return _context3.abrupt("return");
479
545
  case 14:
480
546
  if (!_this3.elementProcessors[ElementType.payment]) {
481
- _context3.next = 21;
547
+ _context3.next = 24;
482
548
  break;
483
549
  }
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:
550
+ // Apple Pay: set onBeforeConfirm on paymentProcessor for event bridge callback after iframe authorization
551
+ hasBeforeConfirmForApplePay = isApplePay && !!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm);
552
+ _this3.serviceMap.Log.logInfo({
553
+ title: 'sdk_element_submitPayment_setBeforeConfirm'
554
+ }, {
555
+ msg: safeStringify({
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:
490
587
  _yield$_this3$onValid2 = _context3.sent;
491
588
  _data = _yield$_this3$onValid2.data;
492
589
  // TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
493
590
  // TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
494
591
  recordResult = _data;
495
592
  recordResultCallback(recordResult);
496
- case 21:
497
- _context3.next = 30;
593
+ case 24:
594
+ _context3.next = 33;
498
595
  break;
499
- case 23:
500
- _context3.prev = 23;
596
+ case 26:
597
+ _context3.prev = 26;
501
598
  _context3.t0 = _context3["catch"](2);
502
599
  // 修复error为{}空对象的问题,上报stack&message
503
600
  errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
@@ -514,20 +611,20 @@ var ElementController = /*#__PURE__*/function () {
514
611
  });
515
612
  recordResult = errorResult;
516
613
  recordResultCallback(errorResult);
517
- case 30:
614
+ case 33:
518
615
  case "end":
519
616
  return _context3.stop();
520
617
  }
521
- }, _callee3, null, [[2, 23]]);
618
+ }, _callee3, null, [[2, 26]]);
522
619
  }));
523
620
  return function (_x2) {
524
621
  return _ref3.apply(this, arguments);
525
622
  };
526
623
  }());
527
- case 11:
624
+ case 31:
528
625
  return _context4.abrupt("return", _context4.sent);
529
- case 12:
530
- _context4.prev = 12;
626
+ case 32:
627
+ _context4.prev = 32;
531
628
  _logParams = {
532
629
  eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
533
630
  errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
@@ -538,12 +635,12 @@ var ElementController = /*#__PURE__*/function () {
538
635
  };
539
636
  this.elementEventCenter.endEvent(startEventId, _logParams);
540
637
  this.changeLoading(false);
541
- return _context4.finish(12);
542
- case 17:
638
+ return _context4.finish(32);
639
+ case 37:
543
640
  case "end":
544
641
  return _context4.stop();
545
642
  }
546
- }, _callee4, this, [[8,, 12, 17]]);
643
+ }, _callee4, this, [[11, 21], [28,, 32, 37]]);
547
644
  }));
548
645
  function submitPayment(_x) {
549
646
  return _submitPayment.apply(this, arguments);
@@ -628,6 +725,9 @@ var ElementController = /*#__PURE__*/function () {
628
725
  var _this4$submitPayPromi;
629
726
  (_this4$submitPayPromi = _this4.submitPayPromise) === null || _this4$submitPayPromi === void 0 || _this4$submitPayPromi.call(_this4, data);
630
727
  });
728
+ this.serviceMap.EventCenter.listen(EVENTNAME.PAYMENTMETHODCHANGED, function (data) {
729
+ _this4.currentPaymentMethodType = (data === null || data === void 0 ? void 0 : data.type) || '';
730
+ });
631
731
  }
632
732
  }, {
633
733
  key: "sendRequestAndWaitWebLaunch",
@@ -2,6 +2,13 @@ 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;
5
12
  onReady(extraParam: any): void;
6
13
  getLogger(): LogService;
7
14
  private addEventListener;
@@ -56,9 +56,20 @@ 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);
59
65
  return _this;
60
66
  }
61
67
  _createClass(PaymentProcessor, [{
68
+ key: "setOnBeforeConfirm",
69
+ value: function setOnBeforeConfirm(callback) {
70
+ this._onBeforeConfirm = callback;
71
+ }
72
+ }, {
62
73
  key: "onReady",
63
74
  value: function onReady(extraParam) {
64
75
  var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
@@ -163,19 +174,92 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
163
174
  });
164
175
  });
165
176
  });
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
+ })));
166
250
  }
167
251
  }, {
168
252
  key: "initApplePaySdk",
169
253
  value: function () {
170
- var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
254
+ var _initApplePaySdk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
171
255
  var _this$elementContaine6;
172
- var _ref, paymentSessionObj, paymentSession;
173
- return _regeneratorRuntime().wrap(function _callee$(_context) {
174
- while (1) switch (_context.prev = _context.next) {
256
+ var _ref2, paymentSessionObj, paymentSession;
257
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
258
+ while (1) switch (_context2.prev = _context2.next) {
175
259
  case 0:
176
- _ref = ((_this$elementContaine6 = this.elementContainer) === null || _this$elementContaine6 === void 0 ? void 0 : _this$elementContaine6.getPaymentContext()) || {}, paymentSessionObj = _ref.paymentSessionObj, paymentSession = _ref.paymentSession;
260
+ _ref2 = ((_this$elementContaine6 = this.elementContainer) === null || _this$elementContaine6 === void 0 ? void 0 : _this$elementContaine6.getPaymentContext()) || {}, paymentSessionObj = _ref2.paymentSessionObj, paymentSession = _ref2.paymentSession;
177
261
  if (!isSkipRenderPaymentMethod(paymentSessionObj)) {
178
- _context.next = 13;
262
+ _context2.next = 13;
179
263
  break;
180
264
  }
181
265
  this.ApplePayService = new ApplePaySdk({
@@ -184,29 +268,29 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
184
268
  logger: logger,
185
269
  env: this.options.env.environment
186
270
  });
187
- _context.prev = 3;
271
+ _context2.prev = 3;
188
272
  logger.logInfo({
189
273
  title: 'a3753.b107385.c398110'
190
274
  });
191
- _context.next = 7;
275
+ _context2.next = 7;
192
276
  return this.ApplePayService.initApplePaySession();
193
277
  case 7:
194
278
  logger.logInfo({
195
279
  title: 'a3753.b107385.c398112'
196
280
  });
197
- _context.next = 13;
281
+ _context2.next = 13;
198
282
  break;
199
283
  case 10:
200
- _context.prev = 10;
201
- _context.t0 = _context["catch"](3);
284
+ _context2.prev = 10;
285
+ _context2.t0 = _context2["catch"](3);
202
286
  logger.logError({
203
287
  title: 'a3753.b107385.c398111'
204
288
  });
205
289
  case 13:
206
290
  case "end":
207
- return _context.stop();
291
+ return _context2.stop();
208
292
  }
209
- }, _callee, this, [[3, 10]]);
293
+ }, _callee2, this, [[3, 10]]);
210
294
  }));
211
295
  function initApplePaySdk() {
212
296
  return _initApplePaySdk.apply(this, arguments);
@@ -227,20 +311,20 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
227
311
  }
228
312
  }, {
229
313
  key: "generateIframeSrc",
230
- value: function generateIframeSrc(_ref2) {
231
- var link = _ref2.link,
232
- instanceId = _ref2.instanceId;
314
+ value: function generateIframeSrc(_ref3) {
315
+ var link = _ref3.link,
316
+ instanceId = _ref3.instanceId;
233
317
  this.instanceId = instanceId;
234
- var _ref3 = this.elementContainer.getPaymentContext() || {},
235
- paymentSession = _ref3.paymentSession,
236
- paymentSessionObj = _ref3.paymentSessionObj,
237
- sdkMetaData = _ref3.sdkMetaData;
318
+ var _ref4 = this.elementContainer.getPaymentContext() || {},
319
+ paymentSession = _ref4.paymentSession,
320
+ paymentSessionObj = _ref4.paymentSessionObj,
321
+ sdkMetaData = _ref4.sdkMetaData;
238
322
  var _this$options = this.options,
239
323
  environment = _this$options.env.environment,
240
324
  analytics = _this$options.analytics,
241
325
  locale = _this$options.locale;
242
- var _ref4 = paymentSessionObj || {},
243
- extendInfo = _ref4.extendInfo;
326
+ var _ref5 = paymentSessionObj || {},
327
+ extendInfo = _ref5.extendInfo;
244
328
  var url = _generateIframeSrc({
245
329
  paymentSession: paymentSession,
246
330
  paymentSessionObj: paymentSessionObj,
@@ -258,19 +342,19 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
258
342
  }, {
259
343
  key: "obtainData",
260
344
  value: function () {
261
- var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
345
+ var _obtainData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
262
346
  var _paymentSessionObj$co,
263
347
  _this3 = this;
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) {
348
+ var requestService, _this$elementContaine7, paymentSession, paymentSessionObj, displayInfo, _displayInfo, debugProps, _this$options2, environment, locale, _ref6, paymentSessionConfig, hostSign, isConnect, LOCAL_MOCK, _queryParse, appType, terminalType, generateActionQueryPromise, generateOneAccountQueryPromise, _yield$Promise$all, _yield$Promise$all2, originActionQueryResult, originOneAccountQueryResult;
349
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
350
+ while (1) switch (_context3.prev = _context3.next) {
267
351
  case 0:
268
352
  requestService = ServiceProvider.getInstance(this.instanceId).getService('Requester');
269
353
  _this$elementContaine7 = this.elementContainer.getPaymentContext(), paymentSession = _this$elementContaine7.paymentSession, paymentSessionObj = _this$elementContaine7.paymentSessionObj, displayInfo = _this$elementContaine7.displayInfo;
270
354
  _displayInfo = displayInfo;
271
355
  debugProps = _displayInfo.debugProps;
272
356
  _this$options2 = this.options, environment = _this$options2.env.environment, locale = _this$options2.locale;
273
- _ref5 = paymentSessionObj || {}, paymentSessionConfig = _ref5.paymentSessionConfig;
357
+ _ref6 = paymentSessionObj || {}, paymentSessionConfig = _ref6.paymentSessionConfig;
274
358
  hostSign = paymentSession.split('&&')[1] || '';
275
359
  isConnect = paymentSessionObj === null || paymentSessionObj === void 0 || (_paymentSessionObj$co = paymentSessionObj.connectFactor) === null || _paymentSessionObj$co === void 0 ? void 0 : _paymentSessionObj$co.enableConnect;
276
360
  LOCAL_MOCK = (debugProps === null || debugProps === void 0 ? void 0 : debugProps.isDebug) && (debugProps === null || debugProps === void 0 ? void 0 : debugProps.local_mock);
@@ -407,10 +491,10 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
407
491
  });
408
492
  });
409
493
  };
410
- _context2.next = 15;
494
+ _context3.next = 15;
411
495
  return Promise.all(isConnect ? [generateActionQueryPromise(), generateOneAccountQueryPromise()] : [generateActionQueryPromise()]);
412
496
  case 15:
413
- _yield$Promise$all = _context2.sent;
497
+ _yield$Promise$all = _context3.sent;
414
498
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
415
499
  originActionQueryResult = _yield$Promise$all2[0];
416
500
  originOneAccountQueryResult = _yield$Promise$all2[1];
@@ -418,15 +502,15 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
418
502
  originActionQueryResult: originActionQueryResult,
419
503
  originOneAccountQueryResult: originOneAccountQueryResult
420
504
  };
421
- return _context2.abrupt("return", {
505
+ return _context3.abrupt("return", {
422
506
  originActionQueryResult: originActionQueryResult,
423
507
  originOneAccountQueryResult: originOneAccountQueryResult
424
508
  });
425
509
  case 21:
426
510
  case "end":
427
- return _context2.stop();
511
+ return _context3.stop();
428
512
  }
429
- }, _callee2, this);
513
+ }, _callee3, this);
430
514
  }));
431
515
  function obtainData() {
432
516
  return _obtainData.apply(this, arguments);
@@ -441,9 +525,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
441
525
  }
442
526
  }, {
443
527
  key: "update",
444
- value: function update(_ref6) {
445
- var data = _ref6.data,
446
- paymentSessionData = _ref6.paymentSessionData;
528
+ value: function update(_ref7) {
529
+ var data = _ref7.data,
530
+ paymentSessionData = _ref7.paymentSessionData;
447
531
  var _parseSessionData = parseSessionData(paymentSessionData),
448
532
  _parseSessionData2 = _slicedToArray(_parseSessionData, 2),
449
533
  parseData = _parseSessionData2[0],
@@ -287,6 +287,26 @@ 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>;
290
310
  }
291
311
  export interface SubmitServiceParams extends PaymentSubmitData {
292
312
  accountInfo: AuthSubmitData['accountInfo'];
@@ -1,5 +1,5 @@
1
- import type { CKPShipping } from '../../core/component/element/type';
2
1
  import { type EventPayload, type IPaymentSessionMetaData } from '../../types';
2
+ import type { CKPShipping } from '../../core/component/element/type';
3
3
  import { Logger } from '../../util/logger';
4
4
  export type IChannelBehavior = {
5
5
  usePaymentSessionAsQueryResult: boolean;
@@ -89,9 +89,7 @@ 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
- // 使用原生 appendChild 避免微前端沙箱(如 qiankun)将动态 <script> 劫持为 fetch 加载,
93
- // 导致不支持 CORS 的第三方脚本(如 pay.google.com)加载失败
94
- Node.prototype.appendChild.call(document.body, script);
92
+ document.body.appendChild(script);
95
93
  // 执行googlePay sdk
96
94
  script.onload = function () {
97
95
  var paymentsClient = new window.google.payments.api.PaymentsClient({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1781004142-dev.3",
3
+ "version": "0.0.1781004142-dev.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "exports": {