@alipay/ams-checkout 0.0.1726046231-dev.2 → 0.0.1726046231-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.
@@ -10,7 +10,7 @@ export declare class ElementAddressComponent {
10
10
  environment: string;
11
11
  locale: string;
12
12
  }): void;
13
- mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement>;
13
+ mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
14
14
  update(): void;
15
15
  unmount(): void;
16
16
  }
@@ -38,6 +38,8 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
38
38
  _this.elementContainer = elementContainer;
39
39
  var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
40
40
  resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
41
+ }, function () {
42
+ resolve(undefined);
41
43
  });
42
44
  });
43
45
  }
@@ -55,7 +57,8 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
55
57
  var _this$elementContaine, _this$elementContaine2;
56
58
  var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
57
59
  if (containers !== null && containers !== void 0 && containers[0]) {
58
- containers[0].remove();
60
+ var _containers$, _containers$$remove;
61
+ (_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
59
62
  }
60
63
  }
61
64
  }]);
@@ -10,7 +10,7 @@ export declare class ElementAuthComponent {
10
10
  environment: string;
11
11
  locale: string;
12
12
  }): void;
13
- mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement>;
13
+ mount(options: ElementAuthMountOptions): Promise<HTMLIFrameElement | undefined>;
14
14
  update(height?: number): void;
15
15
  unmount(): void;
16
16
  }
@@ -20,15 +20,19 @@ export var ElementAuthComponent = /*#__PURE__*/function () {
20
20
  value: function mount(options) {
21
21
  var _this = this;
22
22
  return new Promise(function (resolve) {
23
- var selector = options.selector,
24
- url = options.url;
25
- var containerSelector = "antom-sdk-web-app-".concat(selector);
26
- var container = createInlineBaseElement(selector);
27
- var webApp = createIframe(containerSelector);
28
- webApp.src = url;
29
- container.appendChild(webApp);
30
- _this.elementContainer = container;
31
- resolve(webApp);
23
+ try {
24
+ var selector = options.selector,
25
+ url = options.url;
26
+ var containerSelector = "antom-sdk-web-app-".concat(selector);
27
+ var container = createInlineBaseElement(selector);
28
+ var webApp = createIframe(containerSelector);
29
+ webApp.src = url;
30
+ container.appendChild(webApp);
31
+ _this.elementContainer = container;
32
+ resolve(webApp);
33
+ } catch (error) {
34
+ resolve(undefined);
35
+ }
32
36
  });
33
37
  }
34
38
  }, {
@@ -47,7 +51,8 @@ export var ElementAuthComponent = /*#__PURE__*/function () {
47
51
  }, {
48
52
  key: "unmount",
49
53
  value: function unmount() {
50
- this.elementContainer.remove();
54
+ var _this$elementContaine3, _this$elementContaine4;
55
+ (_this$elementContaine3 = this.elementContainer) === null || _this$elementContaine3 === void 0 || (_this$elementContaine4 = _this$elementContaine3.remove) === null || _this$elementContaine4 === void 0 || _this$elementContaine4.call(_this$elementContaine3);
51
56
  }
52
57
  }]);
53
58
  return ElementAuthComponent;
@@ -10,7 +10,7 @@ export declare class ElementPaymentComponent {
10
10
  environment: string;
11
11
  locale: string;
12
12
  }): void;
13
- mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement>;
13
+ mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
14
14
  update(): void;
15
15
  unmount(): void;
16
16
  }
@@ -42,6 +42,8 @@ export var ElementPaymentComponent = /*#__PURE__*/function () {
42
42
  _this.elementContainer = elementContainer;
43
43
  var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
44
44
  resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
45
+ }, function () {
46
+ resolve(undefined);
45
47
  });
46
48
  });
47
49
  }
@@ -59,7 +61,8 @@ export var ElementPaymentComponent = /*#__PURE__*/function () {
59
61
  var _this$elementContaine, _this$elementContaine2;
60
62
  var containers = (_this$elementContaine = this.elementContainer) === null || _this$elementContaine === void 0 || (_this$elementContaine2 = _this$elementContaine.getElementsByTagName) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.call(_this$elementContaine, 'div');
61
63
  if (containers !== null && containers !== void 0 && containers[0]) {
62
- containers[0].remove();
64
+ var _containers$, _containers$$remove;
65
+ (_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
63
66
  }
64
67
  }
65
68
  }]);
@@ -1,5 +1,5 @@
1
1
  import { IElementOptions } from '../../../types';
2
- import type { AddressMountOptions, AddressMountResult, LinkAuthMountOptions, LinkAuthMountResult, PaymentMountOptions, PaymentMountResult, SubmitFuncResult } from './type';
2
+ import type { AddressMountOptions, AddressMountResult, LinkAuthMountOptions, LinkAuthMountResult, PaymentMountOptions, PaymentMountResult } from './type';
3
3
  export declare class ElementComponent {
4
4
  private parseData;
5
5
  private loading;
@@ -40,5 +40,5 @@ export declare class ElementComponent {
40
40
  private onSubmitRiskFunc;
41
41
  private onSubmit;
42
42
  private validatePromiseFuncs;
43
- submitPayment(): Promise<SubmitFuncResult>;
43
+ submitPayment(): void;
44
44
  }
@@ -105,6 +105,14 @@ export var ElementComponent = /*#__PURE__*/function () {
105
105
  selector: sdkSelector,
106
106
  debugProps: renderOptions.debugProps
107
107
  }).then(function (result) {
108
+ if (!result) {
109
+ var _this$_options$onEven, _this$_options;
110
+ (_this$_options$onEven = (_this$_options = _this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
111
+ code: EventCallbackCode.Failed,
112
+ message: 'Component loading failed'
113
+ });
114
+ return undefined;
115
+ }
108
116
  _this.eventService.addIFrame(result);
109
117
  _this.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
110
118
  });
@@ -121,6 +129,14 @@ export var ElementComponent = /*#__PURE__*/function () {
121
129
  selector: sdkSelector,
122
130
  debugProps: renderOptions.debugProps
123
131
  }).then(function (result) {
132
+ if (!result) {
133
+ var _this$_options$onEven2, _this$_options2;
134
+ (_this$_options$onEven2 = (_this$_options2 = _this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options2, {
135
+ code: EventCallbackCode.Failed,
136
+ message: 'Component loading failed'
137
+ });
138
+ return undefined;
139
+ }
124
140
  _this.eventService.addIFrame(result);
125
141
  _this.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
126
142
  });
@@ -184,6 +200,8 @@ export var ElementComponent = /*#__PURE__*/function () {
184
200
  envInfo: {
185
201
  locale: _this._options.locale
186
202
  },
203
+ timeout: 30000,
204
+ // TODO dev环境submit提交接口超时
187
205
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
188
206
  }).then(function (result) {
189
207
  console.log('element submit result ------', result);
@@ -342,8 +360,8 @@ export var ElementComponent = /*#__PURE__*/function () {
342
360
  locale: this._options.locale
343
361
  });
344
362
  } catch (error) {
345
- var _this$_options$onEven, _this$_options;
346
- (_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
363
+ var _this$_options$onEven3, _this$_options3;
364
+ (_this$_options$onEven3 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven3 === void 0 || _this$_options$onEven3.call(_this$_options3, {
347
365
  code: EventCallbackCode.Failed,
348
366
  message: 'create sdk fail'
349
367
  });
@@ -539,6 +557,14 @@ export var ElementComponent = /*#__PURE__*/function () {
539
557
  selector: _selector,
540
558
  url: renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP = renderOptions.debugProps) === null || _renderOptions$debugP === void 0 ? void 0 : _renderOptions$debugP.localLink
541
559
  }).then(function (result) {
560
+ if (!result) {
561
+ var _this6$_options$onEve, _this6$_options;
562
+ (_this6$_options$onEve = (_this6$_options = _this6._options).onEventCallback) === null || _this6$_options$onEve === void 0 || _this6$_options$onEve.call(_this6$_options, {
563
+ code: EventCallbackCode.Failed,
564
+ message: 'Component loading failed'
565
+ });
566
+ return undefined;
567
+ }
542
568
  _this6.eventService.addIFrame(result);
543
569
  _this6.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
544
570
  });
@@ -556,8 +582,8 @@ export var ElementComponent = /*#__PURE__*/function () {
556
582
  var _this$_options$loadin4;
557
583
  var element = document.querySelector(sdkSelector);
558
584
  if (!element) {
559
- var _this$_options$onEven2, _this$_options2;
560
- (_this$_options$onEven2 = (_this$_options2 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options2, {
585
+ var _this$_options$onEven4, _this$_options4;
586
+ (_this$_options$onEven4 = (_this$_options4 = this._options).onEventCallback) === null || _this$_options$onEven4 === void 0 || _this$_options$onEven4.call(_this$_options4, {
561
587
  code: EventCallbackCode.Failed,
562
588
  message: 'Unable to obtain selector'
563
589
  });
@@ -614,7 +640,20 @@ export var ElementComponent = /*#__PURE__*/function () {
614
640
  }, {
615
641
  key: "submitPayment",
616
642
  value: function submitPayment() {
617
- return this.validatePromiseFuncs();
643
+ var _this$_options$loadin7,
644
+ _this7 = this;
645
+ if ((_this$_options$loadin7 = this._options.loading) !== null && _this$_options$loadin7 !== void 0 && _this$_options$loadin7.onStartLoading) {
646
+ var _this$_options$loadin8, _this$_options$loadin9;
647
+ (_this$_options$loadin8 = this._options.loading) === null || _this$_options$loadin8 === void 0 || (_this$_options$loadin9 = _this$_options$loadin8.onStartLoading) === null || _this$_options$loadin9 === void 0 || _this$_options$loadin9.call(_this$_options$loadin8);
648
+ }
649
+ this.validatePromiseFuncs().then(function () {
650
+ var _this7$_options$loadi;
651
+ if ((_this7$_options$loadi = _this7._options.loading) !== null && _this7$_options$loadi !== void 0 && _this7$_options$loadi.onEndLoading) {
652
+ var _this7$_options$loadi2, _this7$_options$loadi3;
653
+ (_this7$_options$loadi2 = _this7._options.loading) === null || _this7$_options$loadi2 === void 0 || (_this7$_options$loadi3 = _this7$_options$loadi2.onEndLoading) === null || _this7$_options$loadi3 === void 0 || _this7$_options$loadi3.call(_this7$_options$loadi2);
654
+ }
655
+ });
656
+ return;
618
657
  }
619
658
  }]);
620
659
  return ElementComponent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1726046231-dev.2",
3
+ "version": "0.0.1726046231-dev.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",