@alipay/ams-checkout 0.0.1781004142-dev.1 → 0.0.1781004142-dev.11

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.
@@ -60,7 +60,7 @@ var ElementController = /*#__PURE__*/function () {
60
60
  _defineProperty(this, "submitPayPromise", void 0);
61
61
  _defineProperty(this, "elementEventCenter", void 0);
62
62
  /** Current selected payment method type (e.g. 'APPLEPAY', 'CARD'), updated via paymentMethodChanged event */
63
- _defineProperty(this, "currentPaymentMethodType", void 0);
63
+ _defineProperty(this, "currentPaymentMethodType", '');
64
64
  _defineProperty(this, "onValidateFunc", function (event, target) {
65
65
  return new Promise(function (resolve) {
66
66
  event.emitAndListen({
@@ -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, timerId, timeoutPromise, 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,73 +402,118 @@ 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.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
- });
405
+ paymentMethodType = this.currentPaymentMethodType || 'UNKNOWN';
414
406
  if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm && !isApplePay)) {
415
- _context4.next = 27;
407
+ _context4.next = 38;
416
408
  break;
417
409
  }
418
410
  BEFORE_CONFIRM_TIMEOUT_MS = 15000;
419
- _context4.prev = 11;
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
- return setTimeout(function () {
419
+ timerId = setTimeout(function () {
422
420
  return reject(new Error('onBeforeConfirm timed out'));
423
421
  }, BEFORE_CONFIRM_TIMEOUT_MS);
424
422
  });
425
- _context4.next = 15;
423
+ _context4.prev = 14;
424
+ _context4.next = 17;
426
425
  return Promise.race([submitParams.onBeforeConfirm(), timeoutPromise]);
427
- case 15:
426
+ case 17:
428
427
  shouldContinue = _context4.sent;
428
+ case 18:
429
+ _context4.prev = 18;
430
+ clearTimeout(timerId);
431
+ return _context4.finish(18);
432
+ case 21:
429
433
  if (!(shouldContinue === false)) {
430
- _context4.next = 19;
434
+ _context4.next = 26;
431
435
  break;
432
436
  }
437
+ this.serviceMap.Log.logInfo({
438
+ title: 'sdk_before_confirm_abort'
439
+ }, {
440
+ paymentMethodType: paymentMethodType,
441
+ path: 'nonApplePay_sync'
442
+ });
433
443
  this.changeLoading(false);
444
+ this.elementEventCenter.endEvent(startEventId, {
445
+ eventCode: PaymentStatus.FAIL,
446
+ errorName: 'MERCHANT_CONFIRM_ABORT'
447
+ });
434
448
  return _context4.abrupt("return", {
435
449
  status: PaymentStatus.FAIL,
436
450
  error: {
437
451
  code: 'MERCHANT_CONFIRM_ABORT',
438
- message: 'Payment was cancelled by merchant before confirmation.',
452
+ message: 'Merchant canceled payment.',
439
453
  needChangeSessionForRetry: false
440
454
  }
441
455
  });
442
- case 19:
443
- _context4.next = 27;
456
+ case 26:
457
+ this.serviceMap.Log.logInfo({
458
+ title: 'sdk_before_confirm_success'
459
+ }, {
460
+ paymentMethodType: paymentMethodType,
461
+ path: 'nonApplePay_sync'
462
+ });
463
+ _context4.next = 36;
444
464
  break;
445
- case 21:
446
- _context4.prev = 21;
447
- _context4.t0 = _context4["catch"](11);
448
- this.changeLoading(false);
465
+ case 29:
466
+ _context4.prev = 29;
467
+ _context4.t0 = _context4["catch"](12);
449
468
  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
- })
469
+ if (isTimeout) {
470
+ this.serviceMap.Log.logError({
471
+ title: 'sdk_before_confirm_timeout'
472
+ }, {
473
+ paymentMethodType: paymentMethodType,
474
+ path: 'nonApplePay_sync'
475
+ });
476
+ } else {
477
+ this.serviceMap.Log.logError({
478
+ title: 'sdk_before_confirm_error'
479
+ }, {
480
+ paymentMethodType: paymentMethodType,
481
+ errorMessage: String((_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message) || _context4.t0).slice(0, 200),
482
+ path: 'nonApplePay_sync'
483
+ });
484
+ }
485
+ this.changeLoading(false);
486
+ this.elementEventCenter.endEvent(startEventId, {
487
+ eventCode: PaymentStatus.FAIL,
488
+ errorName: 'MERCHANT_CONFIRM_ABORT'
456
489
  });
457
490
  return _context4.abrupt("return", {
458
491
  status: PaymentStatus.FAIL,
459
492
  error: {
460
493
  code: 'MERCHANT_CONFIRM_ABORT',
461
- message: isTimeout ? 'onBeforeConfirm timed out after 15 seconds.' : 'An error occurred during the before-confirm callback.',
494
+ message: 'Merchant canceled payment.',
462
495
  needChangeSessionForRetry: false
463
496
  }
464
497
  });
465
- case 27:
498
+ case 36:
499
+ _context4.next = 39;
500
+ break;
501
+ case 38:
502
+ if (!(submitParams !== null && submitParams !== void 0 && submitParams.onBeforeConfirm)) {
503
+ this.serviceMap.Log.logInfo({
504
+ title: 'sdk_before_confirm_skip'
505
+ }, {
506
+ paymentMethodType: paymentMethodType,
507
+ path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
508
+ });
509
+ }
510
+ case 39:
466
511
  recordResult = null;
467
- _context4.prev = 28;
468
- _context4.next = 31;
512
+ _context4.prev = 40;
513
+ _context4.next = 43;
469
514
  return new Promise( /*#__PURE__*/function () {
470
515
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
471
- var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, _yield$_this3$onValid2, _data, errorString, errorResult;
516
+ var that, recordResultCallback, params, processStep, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, _yield$_this3$onValid2, _data, errorString, errorResult;
472
517
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
473
518
  while (1) switch (_context3.prev = _context3.next) {
474
519
  case 0:
@@ -544,7 +589,7 @@ var ElementController = /*#__PURE__*/function () {
544
589
  return _context3.abrupt("return");
545
590
  case 14:
546
591
  if (!_this3.elementProcessors[ElementType.payment]) {
547
- _context3.next = 24;
592
+ _context3.next = 28;
548
593
  break;
549
594
  }
550
595
  // Apple Pay: set onBeforeConfirm on paymentProcessor for event bridge callback after iframe authorization
@@ -558,21 +603,22 @@ var ElementController = /*#__PURE__*/function () {
558
603
  })
559
604
  });
560
605
  _this3.elementProcessors[ElementType.payment].setOnBeforeConfirm(hasBeforeConfirmForApplePay ? submitParams.onBeforeConfirm : null);
561
- _context3.next = 20;
606
+ hasAmount = !!(submitParams !== null && submitParams !== void 0 && submitParams.amount);
607
+ hasCurrency = !!(submitParams !== null && submitParams !== void 0 && submitParams.currency);
608
+ if ((hasAmount || hasCurrency) && !(hasAmount && hasCurrency)) {
609
+ _this3.serviceMap.Log.logError({
610
+ title: 'sdk_element_submitPayment_amountCurrencyMismatch'
611
+ }, {
612
+ msg: safeStringify({
613
+ amount: submitParams === null || submitParams === void 0 ? void 0 : submitParams.amount,
614
+ currency: submitParams === null || submitParams === void 0 ? void 0 : submitParams.currency,
615
+ reason: 'amount and currency must be provided together, both ignored'
616
+ })
617
+ });
618
+ }
619
+ _this3.elementProcessors[ElementType.payment].setMerchantAmountOverride(hasAmount && hasCurrency ? submitParams.amount : null, hasAmount && hasCurrency ? submitParams.currency : null);
620
+ _context3.next = 24;
562
621
  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
622
  return _objectSpread(_objectSpread(_objectSpread({}, params), {}, {
577
623
  handleActions: (_submitParams$handleA = submitParams === null || submitParams === void 0 ? void 0 : submitParams.handleActions) !== null && _submitParams$handleA !== void 0 ? _submitParams$handleA : true,
578
624
  shipping: submitParams === null || submitParams === void 0 ? void 0 : submitParams.shippingInfo
@@ -583,18 +629,18 @@ var ElementController = /*#__PURE__*/function () {
583
629
  hasBeforeConfirm: hasBeforeConfirmForApplePay
584
630
  });
585
631
  }());
586
- case 20:
632
+ case 24:
587
633
  _yield$_this3$onValid2 = _context3.sent;
588
634
  _data = _yield$_this3$onValid2.data;
589
635
  // TODO 先快速修复类型, 这里结构和标准返回不一致 @马杰
590
636
  // TODO checkout 返回的错误未包含 status 和 message @马杰 @薛浩
591
637
  recordResult = _data;
592
638
  recordResultCallback(recordResult);
593
- case 24:
594
- _context3.next = 33;
639
+ case 28:
640
+ _context3.next = 37;
595
641
  break;
596
- case 26:
597
- _context3.prev = 26;
642
+ case 30:
643
+ _context3.prev = 30;
598
644
  _context3.t0 = _context3["catch"](2);
599
645
  // 修复error为{}空对象的问题,上报stack&message
600
646
  errorString = JSON.stringify(_context3.t0, Object.getOwnPropertyNames(_context3.t0));
@@ -611,20 +657,20 @@ var ElementController = /*#__PURE__*/function () {
611
657
  });
612
658
  recordResult = errorResult;
613
659
  recordResultCallback(errorResult);
614
- case 33:
660
+ case 37:
615
661
  case "end":
616
662
  return _context3.stop();
617
663
  }
618
- }, _callee3, null, [[2, 26]]);
664
+ }, _callee3, null, [[2, 30]]);
619
665
  }));
620
666
  return function (_x2) {
621
667
  return _ref3.apply(this, arguments);
622
668
  };
623
669
  }());
624
- case 31:
670
+ case 43:
625
671
  return _context4.abrupt("return", _context4.sent);
626
- case 32:
627
- _context4.prev = 32;
672
+ case 44:
673
+ _context4.prev = 44;
628
674
  _logParams = {
629
675
  eventCode: (_recordResult = recordResult) === null || _recordResult === void 0 ? void 0 : _recordResult.status,
630
676
  errorName: (_recordResult2 = recordResult) === null || _recordResult2 === void 0 || (_recordResult2 = _recordResult2.error) === null || _recordResult2 === void 0 ? void 0 : _recordResult2.code,
@@ -635,12 +681,12 @@ var ElementController = /*#__PURE__*/function () {
635
681
  };
636
682
  this.elementEventCenter.endEvent(startEventId, _logParams);
637
683
  this.changeLoading(false);
638
- return _context4.finish(32);
639
- case 37:
684
+ return _context4.finish(44);
685
+ case 49:
640
686
  case "end":
641
687
  return _context4.stop();
642
688
  }
643
- }, _callee4, this, [[11, 21], [28,, 32, 37]]);
689
+ }, _callee4, this, [[12, 29], [14,, 18, 21], [40,, 44, 49]]);
644
690
  }));
645
691
  function submitPayment(_x) {
646
692
  return _submitPayment.apply(this, arguments);
@@ -8,7 +8,10 @@ declare class PaymentProcessor extends BaseElementProcessor {
8
8
  * triggered via beforeConfirm event after Apple Pay authorization in iframe.
9
9
  */
10
10
  private _onBeforeConfirm;
11
+ private _merchantAmount;
12
+ private _merchantCurrency;
11
13
  setOnBeforeConfirm(callback: (() => Promise<boolean>) | null): void;
14
+ setMerchantAmountOverride(amount: string | null, currency: string | null): void;
12
15
  onReady(extraParam: any): void;
13
16
  getLogger(): LogService;
14
17
  private addEventListener;
@@ -62,6 +62,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
62
62
  * triggered via beforeConfirm event after Apple Pay authorization in iframe.
63
63
  */
64
64
  _defineProperty(_assertThisInitialized(_this), "_onBeforeConfirm", null);
65
+ _defineProperty(_assertThisInitialized(_this), "_merchantAmount", null);
66
+ _defineProperty(_assertThisInitialized(_this), "_merchantCurrency", null);
65
67
  return _this;
66
68
  }
67
69
  _createClass(PaymentProcessor, [{
@@ -69,6 +71,12 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
69
71
  value: function setOnBeforeConfirm(callback) {
70
72
  this._onBeforeConfirm = callback;
71
73
  }
74
+ }, {
75
+ key: "setMerchantAmountOverride",
76
+ value: function setMerchantAmountOverride(amount, currency) {
77
+ this._merchantAmount = amount;
78
+ this._merchantCurrency = currency;
79
+ }
72
80
  }, {
73
81
  key: "onReady",
74
82
  value: function onReady(extraParam) {
@@ -154,7 +162,9 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
154
162
  parseData: paymentSessionObj,
155
163
  logger: logger,
156
164
  env: _this2.options.env.environment,
157
- shipping: shipping
165
+ shipping: shipping,
166
+ merchantAmount: _this2._merchantAmount,
167
+ merchantCurrency: _this2._merchantCurrency
158
168
  });
159
169
  applePayService.startPay().then(function (res) {
160
170
  _this2.eventCenter.dispatchToApp({
@@ -178,19 +188,21 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
178
188
  // requests SDK layer to execute merchant's onBeforeConfirm callback via beforeConfirm event,
179
189
  // and returns the result (continue/abort) to iframe via dispatchToApp.
180
190
  this.eventCenter.listen(EVENT.beforeConfirm.name, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
181
- var BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, shouldContinue, isTimeout;
191
+ var paymentMethodType, BEFORE_CONFIRM_TIMEOUT_MS, timeoutPromise, startTime, shouldContinue, isTimeout;
182
192
  return _regeneratorRuntime().wrap(function _callee$(_context) {
183
193
  while (1) switch (_context.prev = _context.next) {
184
194
  case 0:
185
- logger.logInfo({
186
- title: 'sdk_element_beforeConfirm_event_received'
187
- }, {
188
- hasCallback: !!_this2._onBeforeConfirm
189
- });
195
+ paymentMethodType = 'APPLEPAY';
190
196
  if (_this2._onBeforeConfirm) {
191
- _context.next = 4;
197
+ _context.next = 5;
192
198
  break;
193
199
  }
200
+ logger.logInfo({
201
+ title: 'sdk_before_confirm_skip'
202
+ }, {
203
+ paymentMethodType: paymentMethodType,
204
+ path: 'applePay_eventBridge'
205
+ });
194
206
  _this2.eventCenter.dispatchToApp({
195
207
  event: EVENT.beforeConfirm.name,
196
208
  data: {
@@ -199,18 +211,31 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
199
211
  }
200
212
  });
201
213
  return _context.abrupt("return");
202
- case 4:
214
+ case 5:
203
215
  BEFORE_CONFIRM_TIMEOUT_MS = 15000;
204
- _context.prev = 5;
216
+ logger.logInfo({
217
+ title: 'sdk_before_confirm_start'
218
+ }, {
219
+ paymentMethodType: paymentMethodType,
220
+ path: 'applePay_eventBridge'
221
+ });
222
+ _context.prev = 7;
205
223
  timeoutPromise = new Promise(function (_, reject) {
206
224
  return setTimeout(function () {
207
225
  return reject(new Error('onBeforeConfirm timed out'));
208
226
  }, BEFORE_CONFIRM_TIMEOUT_MS);
209
227
  });
210
- _context.next = 9;
228
+ startTime = Date.now();
229
+ _context.next = 12;
211
230
  return Promise.race([_this2._onBeforeConfirm(), timeoutPromise]);
212
- case 9:
231
+ case 12:
213
232
  shouldContinue = _context.sent;
233
+ if (Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
234
+ logger.logError({
235
+ title: 'sdk_before_confirm_timeout'
236
+ });
237
+ shouldContinue = false;
238
+ }
214
239
  logger.logInfo({
215
240
  title: 'sdk_element_beforeConfirm_callback_result'
216
241
  }, {
@@ -223,17 +248,28 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
223
248
  result: shouldContinue !== false
224
249
  }
225
250
  });
226
- _context.next = 19;
251
+ _context.next = 23;
227
252
  break;
228
- case 14:
229
- _context.prev = 14;
230
- _context.t0 = _context["catch"](5);
253
+ case 18:
254
+ _context.prev = 18;
255
+ _context.t0 = _context["catch"](7);
231
256
  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
- });
257
+ if (isTimeout) {
258
+ logger.logError({
259
+ title: 'sdk_before_confirm_timeout'
260
+ }, {
261
+ paymentMethodType: paymentMethodType,
262
+ path: 'applePay_eventBridge'
263
+ });
264
+ } else {
265
+ logger.logError({
266
+ title: 'sdk_before_confirm_error'
267
+ }, {
268
+ paymentMethodType: paymentMethodType,
269
+ errorMessage: String((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0).slice(0, 200),
270
+ path: 'applePay_eventBridge'
271
+ });
272
+ }
237
273
  _this2.eventCenter.dispatchToApp({
238
274
  event: EVENT.beforeConfirm.name,
239
275
  data: {
@@ -241,11 +277,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
241
277
  result: false
242
278
  }
243
279
  });
244
- case 19:
280
+ case 23:
245
281
  case "end":
246
282
  return _context.stop();
247
283
  }
248
- }, _callee, null, [[5, 14]]);
284
+ }, _callee, null, [[7, 18]]);
249
285
  })));
250
286
  }
251
287
  }, {
@@ -34,12 +34,16 @@ export declare class ApplePaySdk {
34
34
  private logger;
35
35
  private env;
36
36
  private shipping?;
37
- constructor({ paymentSessionData, parseData, logger, env, shipping, }: {
37
+ private merchantAmount;
38
+ private merchantCurrency;
39
+ constructor({ paymentSessionData, parseData, logger, env, shipping, merchantAmount, merchantCurrency, }: {
38
40
  paymentSessionData: string;
39
41
  parseData: IPaymentSessionMetaData;
40
42
  logger: Logger;
41
43
  env?: string;
42
44
  shipping?: CKPShipping;
45
+ merchantAmount?: string | null;
46
+ merchantCurrency?: string | null;
43
47
  });
44
48
  startPay(): Promise<unknown>;
45
49
  begin(): Promise<unknown>;
@@ -137,7 +137,11 @@ export var ApplePaySdk = /*#__PURE__*/function () {
137
137
  logger = _ref.logger,
138
138
  _ref$env = _ref.env,
139
139
  env = _ref$env === void 0 ? EnvironmentEnum.prod : _ref$env,
140
- shipping = _ref.shipping;
140
+ shipping = _ref.shipping,
141
+ _ref$merchantAmount = _ref.merchantAmount,
142
+ merchantAmount = _ref$merchantAmount === void 0 ? null : _ref$merchantAmount,
143
+ _ref$merchantCurrency = _ref.merchantCurrency,
144
+ merchantCurrency = _ref$merchantCurrency === void 0 ? null : _ref$merchantCurrency;
141
145
  _classCallCheck(this, ApplePaySdk);
142
146
  _defineProperty(this, "APPLESDKURL", 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js');
143
147
  _defineProperty(this, "session", null);
@@ -150,11 +154,15 @@ export var ApplePaySdk = /*#__PURE__*/function () {
150
154
  _defineProperty(this, "logger", void 0);
151
155
  _defineProperty(this, "env", void 0);
152
156
  _defineProperty(this, "shipping", void 0);
157
+ _defineProperty(this, "merchantAmount", void 0);
158
+ _defineProperty(this, "merchantCurrency", void 0);
153
159
  this.paymentSessionData = paymentSessionData;
154
160
  this.parseData = parseData;
155
161
  this.env = env;
156
162
  this.logger = logger;
157
163
  this.shipping = shipping;
164
+ this.merchantAmount = merchantAmount;
165
+ this.merchantCurrency = merchantCurrency;
158
166
  }
159
167
  _createClass(ApplePaySdk, [{
160
168
  key: "startPay",
@@ -337,7 +345,7 @@ export var ApplePaySdk = /*#__PURE__*/function () {
337
345
  key: "submitPay",
338
346
  value: function () {
339
347
  var _submitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
340
- var _this$parseData2;
348
+ var _this$parseData2, _this$parseData3, _this$parseData4;
341
349
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
342
350
  while (1) switch (_context4.prev = _context4.next) {
343
351
  case 0:
@@ -350,7 +358,11 @@ export var ApplePaySdk = /*#__PURE__*/function () {
350
358
  paymentMethod: {
351
359
  paymentMethodType: 'APPLEPAY'
352
360
  },
353
- shipping: this.shipping
361
+ shipping: this.shipping,
362
+ paymentAmount: {
363
+ value: this.merchantAmount || ((_this$parseData3 = this.parseData) === null || _this$parseData3 === void 0 || (_this$parseData3 = _this$parseData3.paymentSessionFactor) === null || _this$parseData3 === void 0 || (_this$parseData3 = _this$parseData3.paymentAmount) === null || _this$parseData3 === void 0 ? void 0 : _this$parseData3.value),
364
+ currency: this.merchantCurrency || ((_this$parseData4 = this.parseData) === null || _this$parseData4 === void 0 || (_this$parseData4 = _this$parseData4.paymentSessionFactor) === null || _this$parseData4 === void 0 || (_this$parseData4 = _this$parseData4.paymentAmount) === null || _this$parseData4 === void 0 ? void 0 : _this$parseData4.currency)
365
+ }
354
366
  };
355
367
  _context4.t2 = this.env;
356
368
  _context4.next = 6;
@@ -405,7 +417,7 @@ export var ApplePaySdk = /*#__PURE__*/function () {
405
417
  key: "initApplePaySession",
406
418
  value: function () {
407
419
  var _initApplePaySession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
408
- var _this$logger7, _this$parseData3, _this$logger6, _ref4, recurringInfo, version, _this$logger8;
420
+ var _this$logger7, _this$parseData5, _this$logger6, _ref4, recurringInfo, version, _this$logger8;
409
421
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
410
422
  while (1) switch (_context5.prev = _context5.next) {
411
423
  case 0:
@@ -440,7 +452,7 @@ export var ApplePaySdk = /*#__PURE__*/function () {
440
452
  }
441
453
  throw new Error('Apple Pay not supported');
442
454
  case 12:
443
- _ref4 = ((_this$parseData3 = this.parseData) === null || _this$parseData3 === void 0 ? void 0 : _this$parseData3.paymentSessionFactor) || {}, recurringInfo = _ref4.recurringInfo;
455
+ _ref4 = ((_this$parseData5 = this.parseData) === null || _this$parseData5 === void 0 ? void 0 : _this$parseData5.paymentSessionFactor) || {}, recurringInfo = _ref4.recurringInfo;
444
456
  version = recurringInfo ? APPLE_PAY_RECURRING_VERSION : APPLE_PAY_VERSION;
445
457
  if (this.isCanMakePayments(version)) {
446
458
  _context5.next = 16;
@@ -487,8 +499,8 @@ export var ApplePaySdk = /*#__PURE__*/function () {
487
499
  }, {
488
500
  key: "initSessionParams",
489
501
  get: function get() {
490
- var _this$parseData4;
491
- var _ref5 = ((_this$parseData4 = this.parseData) === null || _this$parseData4 === void 0 ? void 0 : _this$parseData4.paymentSessionFactor) || {},
502
+ var _this$parseData6;
503
+ var _ref5 = ((_this$parseData6 = this.parseData) === null || _this$parseData6 === void 0 ? void 0 : _this$parseData6.paymentSessionFactor) || {},
492
504
  merchantInfo = _ref5.merchantInfo,
493
505
  order = _ref5.order,
494
506
  paymentAmount = _ref5.paymentAmount,
@@ -496,13 +508,13 @@ export var ApplePaySdk = /*#__PURE__*/function () {
496
508
  extendInfo = _ref5.extendInfo;
497
509
  var request = {
498
510
  countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
499
- currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
511
+ currencyCode: this.merchantCurrency || (paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency),
500
512
  merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
501
513
  supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
502
514
  total: {
503
515
  label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
504
516
  type: 'final',
505
- amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
517
+ amount: this.merchantAmount || (paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value)
506
518
  },
507
519
  requiredBillingContactFields: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.requiredBillingContactFields,
508
520
  requiredShippingContactFields: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.requiredShippingContactFields
@@ -538,8 +550,8 @@ export var ApplePaySdk = /*#__PURE__*/function () {
538
550
  }, {
539
551
  key: "isRequiredParameters",
540
552
  get: function get() {
541
- var _this$parseData5;
542
- var _ref6 = ((_this$parseData5 = this.parseData) === null || _this$parseData5 === void 0 ? void 0 : _this$parseData5.paymentSessionFactor) || {},
553
+ var _this$parseData7;
554
+ var _ref6 = ((_this$parseData7 = this.parseData) === null || _this$parseData7 === void 0 ? void 0 : _this$parseData7.paymentSessionFactor) || {},
543
555
  merchantInfo = _ref6.merchantInfo,
544
556
  extendInfo = _ref6.extendInfo,
545
557
  paymentAmount = _ref6.paymentAmount;
@@ -612,14 +624,14 @@ export var ApplePaySdk = /*#__PURE__*/function () {
612
624
  key: "getDeviceId",
613
625
  value: function () {
614
626
  var _getDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
615
- var _yield$BusManager$pub, _this$parseData6;
627
+ var _yield$BusManager$pub, _this$parseData8;
616
628
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
617
629
  while (1) switch (_context6.prev = _context6.next) {
618
630
  case 0:
619
631
  _context6.next = 2;
620
632
  return BusManager.publishForResult(new BusMessage(SecuritySDKActionEnum.getSecurityDeviceId, JSON.stringify({
621
633
  deviceIdParameter: {
622
- productScene: (_this$parseData6 = this.parseData) === null || _this$parseData6 === void 0 || (_this$parseData6 = _this$parseData6.paymentSessionConfig) === null || _this$parseData6 === void 0 ? void 0 : _this$parseData6.productScene
634
+ productScene: (_this$parseData8 = this.parseData) === null || _this$parseData8 === void 0 || (_this$parseData8 = _this$parseData8.paymentSessionConfig) === null || _this$parseData8 === void 0 ? void 0 : _this$parseData8.productScene
623
635
  }
624
636
  })), {
625
637
  fallback: ''
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.8"
8
+ "packageVersion": "7.58.9"
9
9
  }
10
10
  ]
11
11
  }
@@ -573,14 +573,9 @@ export interface CashierSubmitPayRequest {
573
573
  category?: string;
574
574
  };
575
575
  shipping?: import('../core/component/element/type').CKPShipping;
576
- }
577
- export interface CashierSubmitPayRequest {
578
- paymentMethodType?: string;
579
- paymentFactors?: Record<string, string>;
580
- verifyFactors?: Record<string, string>;
581
- paymentSessionData: string;
582
- paymentSessionConfig?: any;
583
576
  extParams?: any;
577
+ /** 支付金额 */
578
+ paymentAmount?: Pick<IAmount, 'value' | 'currency'>;
584
579
  }
585
580
  export interface CashierSdkActionQueryResult {
586
581
  supportedLanguages?: any[];
@@ -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
  };
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1781004142-dev.1",
3
+ "version": "0.0.1781004142-dev.11",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "exports": {