@alipay/ams-checkout 0.0.1732700846-dev.6 → 0.0.1732700846-dev.7

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.
@@ -198,6 +198,12 @@ export declare const EVENT: {
198
198
  initSecuritySDK: {
199
199
  name: string;
200
200
  };
201
+ closePaymentPolling: {
202
+ name: string;
203
+ };
204
+ onPollingEnd: {
205
+ name: string;
206
+ };
201
207
  };
202
208
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
203
209
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -200,6 +200,12 @@ export var EVENT = {
200
200
  },
201
201
  initSecuritySDK: {
202
202
  name: 'initSecuritySDK'
203
+ },
204
+ closePaymentPolling: {
205
+ name: 'closePaymentPolling'
206
+ },
207
+ onPollingEnd: {
208
+ name: 'onPollingEnd'
203
209
  }
204
210
  };
205
211
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -212,8 +212,9 @@ export var ElementComponent = /*#__PURE__*/function () {
212
212
  if (!result) {
213
213
  var _this4$_options$onEve, _this4$_options2;
214
214
  (_this4$_options$onEve = (_this4$_options2 = _this4._options).onEventCallback) === null || _this4$_options$onEve === void 0 || _this4$_options$onEve.call(_this4$_options2, {
215
- code: EventCallbackCode.Failed,
216
- message: 'Address Component loading failed'
215
+ code: EventCallbackCode.FAILED,
216
+ message: 'INTERNAL_FAILED'
217
+ // message: 'Address Component loading failed',
217
218
  });
218
219
  return undefined;
219
220
  }
@@ -242,8 +243,9 @@ export var ElementComponent = /*#__PURE__*/function () {
242
243
  if (!result) {
243
244
  var _this4$_options$onEve2, _this4$_options4;
244
245
  (_this4$_options$onEve2 = (_this4$_options4 = _this4._options).onEventCallback) === null || _this4$_options$onEve2 === void 0 || _this4$_options$onEve2.call(_this4$_options4, {
245
- code: EventCallbackCode.Failed,
246
- message: 'Payment Component loading failed'
246
+ code: EventCallbackCode.FAILED,
247
+ message: 'INTERNAL_FAILED'
248
+ // message: 'Payment Component loading failed',
247
249
  });
248
250
  return undefined;
249
251
  }
@@ -341,7 +343,7 @@ export var ElementComponent = /*#__PURE__*/function () {
341
343
  _defineProperty(this, "validatePromiseFuncs", function () {
342
344
  return new Promise( /*#__PURE__*/function () {
343
345
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
344
- var params, _result$data, _result$data2, result, _result$data3, _result$data4, _result, _result2$data, _result2$data2, _result2$data3, _result2;
346
+ var params, _result$data, _result$data2, result, _result$data3, _result$data4, _result, _result2$data, _result2;
345
347
  return _regeneratorRuntime().wrap(function _callee$(_context) {
346
348
  while (1) switch (_context.prev = _context.next) {
347
349
  case 0:
@@ -379,7 +381,7 @@ export var ElementComponent = /*#__PURE__*/function () {
379
381
  return _context.abrupt("return", resolve(undefined));
380
382
  case 17:
381
383
  if (!(_this4.launchSource.includes(ElementPaymentMethod.PAYMENT_ELEMENT) || !_this4.isConnect)) {
382
- _context.next = 32;
384
+ _context.next = 30;
383
385
  break;
384
386
  }
385
387
  _context.prev = 18;
@@ -388,29 +390,29 @@ export var ElementComponent = /*#__PURE__*/function () {
388
390
  case 21:
389
391
  _result2 = _context.sent;
390
392
  console.log('element submit validate payment---------', _result2, _this4.isConnect);
391
- params.paymentFactors = (_result2$data = _result2.data) === null || _result2$data === void 0 || (_result2$data = _result2$data.data) === null || _result2$data === void 0 ? void 0 : _result2$data.paymentFactors;
392
- params.paymentMethod = (_result2$data2 = _result2.data) === null || _result2$data2 === void 0 || (_result2$data2 = _result2$data2.data) === null || _result2$data2 === void 0 ? void 0 : _result2$data2.paymentMethod;
393
- if (_result2 !== null && _result2 !== void 0 && (_result2$data3 = _result2.data) !== null && _result2$data3 !== void 0 && _result2$data3.success) {
394
- _context.next = 27;
393
+ // params.paymentFactors = result.data?.data?.paymentFactors;
394
+ // params.paymentMethod = result.data?.data?.paymentMethod;
395
+ if (_result2 !== null && _result2 !== void 0 && (_result2$data = _result2.data) !== null && _result2$data !== void 0 && _result2$data.success) {
396
+ _context.next = 25;
395
397
  break;
396
398
  }
397
399
  return _context.abrupt("return", resolve(undefined));
398
- case 27:
399
- _context.next = 32;
400
+ case 25:
401
+ _context.next = 30;
400
402
  break;
401
- case 29:
402
- _context.prev = 29;
403
+ case 27:
404
+ _context.prev = 27;
403
405
  _context.t0 = _context["catch"](18);
404
406
  return _context.abrupt("return", resolve(undefined));
405
- case 32:
407
+ case 30:
406
408
  // params.paymentFactors = paymentResult.data?.data.paymentFactors;
407
409
  // params.paymentMethod = paymentResult.data?.data.paymentMethod;
408
410
  resolve(params);
409
- case 33:
411
+ case 31:
410
412
  case "end":
411
413
  return _context.stop();
412
414
  }
413
- }, _callee, null, [[18, 29]]);
415
+ }, _callee, null, [[18, 27]]);
414
416
  }));
415
417
  return function (_x) {
416
418
  return _ref.apply(this, arguments);
@@ -442,10 +444,10 @@ export var ElementComponent = /*#__PURE__*/function () {
442
444
  sessionData = _parseSessionData2[1];
443
445
  this.parseData = parseData;
444
446
  this.sessionData = sessionData;
445
- this.isConnect = ((_parseData$connectFac = parseData.connectFactor) === null || _parseData$connectFac === void 0 ? void 0 : _parseData$connectFac.enableConnect) && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
447
+ this.isConnect = (parseData === null || parseData === void 0 || (_parseData$connectFac = parseData.connectFactor) === null || _parseData$connectFac === void 0 ? void 0 : _parseData$connectFac.enableConnect) && (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) === ProductSceneEnum.ELEMENT_PAYMENT;
446
448
  this.elementContainer = new AntomSDKCore();
447
449
  this.elementContainer.registerProcessor(ProductSceneEnum.ELEMENT_PAYMENT, '', new ElementProcessor({
448
- paymentSessionConfig: parseData.paymentSessionConfig,
450
+ paymentSessionConfig: parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig,
449
451
  sessionData: sessionData,
450
452
  environment: this._options.environment,
451
453
  locale: this._options.locale,
@@ -459,15 +461,16 @@ export var ElementComponent = /*#__PURE__*/function () {
459
461
  if (!_this5.isConnect) return;
460
462
  var bizFlowBehavior = _this5.elementContainer.getBizFlowBehavior();
461
463
  if (!(bizFlowBehavior !== null && bizFlowBehavior !== void 0 && (_bizFlowBehavior$data = bizFlowBehavior.data) !== null && _bizFlowBehavior$data !== void 0 && _bizFlowBehavior$data.success)) {
462
- var _this5$_options, _this5$_options$onEve, _bizFlowBehavior$data2;
464
+ var _this5$_options, _this5$_options$onEve;
463
465
  _this5 === null || _this5 === void 0 || (_this5$_options = _this5._options) === null || _this5$_options === void 0 || (_this5$_options$onEve = _this5$_options.onEventCallback) === null || _this5$_options$onEve === void 0 || _this5$_options$onEve.call(_this5$_options, {
464
- code: EventCallbackCode.Failed,
465
- message: (bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data2 = bizFlowBehavior.data) === null || _bizFlowBehavior$data2 === void 0 ? void 0 : _bizFlowBehavior$data2.errorMsg) || 'start biz flow fail, please retry.'
466
+ code: EventCallbackCode.FAILED,
467
+ message: 'INTERNAL_FAILED'
468
+ // message: bizFlowBehavior?.data?.errorMsg || 'start biz flow fail, please retry.',
466
469
  });
467
470
  } else {
468
- var _bizFlowBehavior$data3, _bizFlowBehavior$data4;
469
- _this5.oneAccountRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data3 = bizFlowBehavior.data) === null || _bizFlowBehavior$data3 === void 0 ? void 0 : _bizFlowBehavior$data3.oneAccountRes;
470
- _this5.sdkActionRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data4 = bizFlowBehavior.data) === null || _bizFlowBehavior$data4 === void 0 ? void 0 : _bizFlowBehavior$data4.sdkActionRes;
471
+ var _bizFlowBehavior$data2, _bizFlowBehavior$data3;
472
+ _this5.oneAccountRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data2 = bizFlowBehavior.data) === null || _bizFlowBehavior$data2 === void 0 ? void 0 : _bizFlowBehavior$data2.oneAccountRes;
473
+ _this5.sdkActionRes = bizFlowBehavior === null || bizFlowBehavior === void 0 || (_bizFlowBehavior$data3 = bizFlowBehavior.data) === null || _bizFlowBehavior$data3 === void 0 ? void 0 : _bizFlowBehavior$data3.sdkActionRes;
471
474
  _this5.afterInit();
472
475
  }
473
476
  });
@@ -500,8 +503,9 @@ export var ElementComponent = /*#__PURE__*/function () {
500
503
  } catch (error) {
501
504
  var _this$_options$onEven, _this$_options;
502
505
  (_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
503
- code: EventCallbackCode.Failed,
504
- message: 'create sdk fail'
506
+ code: EventCallbackCode.FAILED,
507
+ message: 'INTERNAL_FAILED'
508
+ // message: 'create sdk fail',
505
509
  });
506
510
  }
507
511
 
@@ -562,6 +566,10 @@ export var ElementComponent = /*#__PURE__*/function () {
562
566
  (_this6 === null || _this6 === void 0 ? void 0 : _this6.authBase) && (_this6 === null || _this6 === void 0 || (_this6$authBase = _this6.authBase) === null || _this6$authBase === void 0 ? void 0 : _this6$authBase.update(result.data.height));
563
567
  }
564
568
  });
569
+ this.eventService.listen(ElementPaymentEvent.SEND_MUITI_APP_EVENT_TO_SDK, function (result) {
570
+ var _this6$_options$onEve, _this6$_options;
571
+ (_this6$_options$onEve = (_this6$_options = _this6._options).onEventCallback) === null || _this6$_options$onEve === void 0 || _this6$_options$onEve.call(_this6$_options, result.data);
572
+ });
565
573
  this.eventService.listen(ElementPaymentEvent.CALLBACK, function (result) {
566
574
  var _this6$eventCallback;
567
575
  console.log('antom sdk 组件事件回调');
@@ -691,8 +699,9 @@ export var ElementComponent = /*#__PURE__*/function () {
691
699
  if (!result) {
692
700
  var _this8$_options$onEve, _this8$_options;
693
701
  (_this8$_options$onEve = (_this8$_options = _this8._options).onEventCallback) === null || _this8$_options$onEve === void 0 || _this8$_options$onEve.call(_this8$_options, {
694
- code: EventCallbackCode.Failed,
695
- message: 'Auth Component loading failed'
702
+ code: EventCallbackCode.FAILED,
703
+ message: 'INTERNAL_FAILED'
704
+ // message: 'Auth Component loading failed',
696
705
  });
697
706
  return undefined;
698
707
  }
@@ -710,8 +719,9 @@ export var ElementComponent = /*#__PURE__*/function () {
710
719
  if (!element) {
711
720
  var _this$_options$onEven2, _this$_options3;
712
721
  (_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
713
- code: EventCallbackCode.Failed,
714
- message: 'Unable to obtain selector'
722
+ code: EventCallbackCode.FAILED,
723
+ message: 'INTERNAL_FAILED'
724
+ // message: 'Unable to obtain selector',
715
725
  });
716
726
  return undefined;
717
727
  }
@@ -736,8 +746,9 @@ export var ElementComponent = /*#__PURE__*/function () {
736
746
  }
737
747
  } else {
738
748
  this._options.onEventCallback({
739
- code: EventCallbackCode.Failed,
740
- message: 'Invalid argument for mount method'
749
+ code: EventCallbackCode.FAILED,
750
+ message: 'INTERNAL_FAILED'
751
+ // message: 'Invalid argument for mount method',
741
752
  });
742
753
  return undefined;
743
754
  }
@@ -777,7 +788,7 @@ export var ElementComponent = /*#__PURE__*/function () {
777
788
  function () {
778
789
  var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
779
790
  var _this$_options$loadin7, _this$_options$loadin10;
780
- var _this$_options$loadin8, _this$_options$loadin9, validateRes, _this$_options$loadin11, _this$_options$loadin12;
791
+ var _this$_options$loadin8, _this$_options$loadin9, _this$_options$loadin11, _this$_options$loadin12;
781
792
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
782
793
  while (1) switch (_context2.prev = _context2.next) {
783
794
  case 0:
@@ -789,19 +800,11 @@ export var ElementComponent = /*#__PURE__*/function () {
789
800
  _context2.next = 3;
790
801
  return this.validatePromiseFuncs();
791
802
  case 3:
792
- validateRes = _context2.sent;
793
- if (!validateRes) {
794
- _context2.next = 7;
795
- break;
796
- }
797
- _context2.next = 7;
798
- return this.onSubmit(validateRes);
799
- case 7:
800
803
  if ((_this$_options$loadin10 = this._options.loading) !== null && _this$_options$loadin10 !== void 0 && _this$_options$loadin10.onEndLoading) {
801
804
  (_this$_options$loadin11 = this._options.loading) === null || _this$_options$loadin11 === void 0 || (_this$_options$loadin12 = _this$_options$loadin11.onEndLoading) === null || _this$_options$loadin12 === void 0 || _this$_options$loadin12.call(_this$_options$loadin11);
802
805
  }
803
806
  return _context2.abrupt("return");
804
- case 9:
807
+ case 5:
805
808
  case "end":
806
809
  return _context2.stop();
807
810
  }
@@ -12,8 +12,8 @@ export declare const addressTheme: {
12
12
  night: string;
13
13
  };
14
14
  export declare enum EventCallbackCode {
15
- Failed = "Failed",
16
- Completed = "Completed"
15
+ FAILED = "FAILED",
16
+ SUCCESS = "SUCCESS"
17
17
  }
18
18
  export declare enum ELEMENT_ENVIRONMENT {
19
19
  DEV = "DEV",
@@ -13,8 +13,8 @@ export var ThemeType = /*#__PURE__*/function (ThemeType) {
13
13
  }({});
14
14
  export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
15
15
  export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
16
- EventCallbackCode["Failed"] = "Failed";
17
- EventCallbackCode["Completed"] = "Completed";
16
+ EventCallbackCode["FAILED"] = "FAILED";
17
+ EventCallbackCode["SUCCESS"] = "SUCCESS";
18
18
  return EventCallbackCode;
19
19
  }({});
20
20
  export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
@@ -178,7 +178,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
178
178
  key: "startBizFlow",
179
179
  value: function () {
180
180
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
181
- var _this$paymentContext$, _this$paymentContext$2;
181
+ var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
182
182
  var paymentSession, displayInfo, _convertPaymentSessio, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
183
183
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
184
184
  while (1) switch (_context3.prev = _context3.next) {
@@ -201,7 +201,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
201
201
  sdkMetaData: this.sdkMetaData
202
202
  };
203
203
  // upgrade WebApp version
204
- mid = this.paymentContext.paymentSessionObj.clientId;
204
+ mid = (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.clientId;
205
205
  webAppMatchConfig = parseWebAppMatchConfig(this.paymentContext.paymentSessionObj.extendInfo);
206
206
  webAppVersion = getWebAppVersion(this.sdkMetaData, mid, webAppMatchConfig);
207
207
  this.sdkMetaData.webAppVersion = webAppVersion;
@@ -211,8 +211,8 @@ export var AntomSDKCore = /*#__PURE__*/function () {
211
211
  ServiceProvider.getInstance(this.instanceId).update(this.paymentContext);
212
212
 
213
213
  // Invoke processor
214
- productScene = (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 || (_this$paymentContext$ = _this$paymentContext$.paymentSessionConfig) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.productScene;
215
- paymentMethod = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType;
214
+ productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
215
+ paymentMethod = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentMethodInfoView) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.paymentMethodType;
216
216
  _context3.prev = 13;
217
217
  if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
218
218
  _context3.next = 20;
@@ -1324,6 +1324,22 @@ var ComponentApp = /*#__PURE__*/function () {
1324
1324
  });
1325
1325
  return;
1326
1326
  }
1327
+ if (data.context.event === EVENT.onPollingEnd.name) {
1328
+ this.dispatchToApp({
1329
+ context: {
1330
+ event: 'onPollingEnd',
1331
+ data: data.context.data
1332
+ }
1333
+ });
1334
+ }
1335
+ if (data.context.event === EVENT.closePaymentPolling.name) {
1336
+ this.dispatchToApp({
1337
+ context: {
1338
+ event: EVENT.closePaymentPolling.name,
1339
+ data: {}
1340
+ }
1341
+ });
1342
+ }
1327
1343
 
1328
1344
  // log event before sending the callback
1329
1345
  this.logEventCallback(data, 'sdk_event_event_callback');
@@ -849,6 +849,7 @@ export declare enum ElementPaymentEvent {
849
849
  SIZE_CHANGE = "onSizeChange",
850
850
  LAUNCH = "onLaunch",
851
851
  CALLBACK = "callback",
852
+ SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
852
853
  LOG = "log"
853
854
  }
854
855
  export declare enum ConnectErrorCode {
@@ -245,6 +245,7 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
245
245
  ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
246
246
  ElementPaymentEvent["LAUNCH"] = "onLaunch";
247
247
  ElementPaymentEvent["CALLBACK"] = "callback";
248
+ ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
248
249
  ElementPaymentEvent["LOG"] = "log";
249
250
  return ElementPaymentEvent;
250
251
  }({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1732700846-dev.6",
3
+ "version": "0.0.1732700846-dev.7",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",