@alipay/ams-checkout 0.0.1726046231-dev.1 → 0.0.1726046231-dev.10
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/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/element/components/address.d.ts +2 -1
- package/esm/core/component/element/components/address.js +6 -7
- package/esm/core/component/element/components/auth.d.ts +1 -1
- package/esm/core/component/element/components/auth.js +15 -10
- package/esm/core/component/element/components/payment.d.ts +2 -1
- package/esm/core/component/element/components/payment.js +8 -5
- package/esm/core/component/element/index.d.ts +4 -2
- package/esm/core/component/element/index.js +98 -21
- package/esm/core/component/element/type.d.ts +21 -18
- package/esm/core/component/element/type.js +13 -5
- package/package.json +1 -1
@@ -9,8 +9,9 @@ export declare class ElementAddressComponent {
|
|
9
9
|
create(options: {
|
10
10
|
environment: string;
|
11
11
|
locale: string;
|
12
|
+
appVersion: string;
|
12
13
|
}): void;
|
13
|
-
mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement>;
|
14
|
+
mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
|
14
15
|
update(): void;
|
15
16
|
unmount(): void;
|
16
17
|
}
|
@@ -15,11 +15,7 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
|
|
15
15
|
_createClass(ElementAddressComponent, [{
|
16
16
|
key: "create",
|
17
17
|
value: function create(options) {
|
18
|
-
this.sdk = new AddressComponent(
|
19
|
-
environment: options.environment,
|
20
|
-
locale: options.locale,
|
21
|
-
appVersion: ''
|
22
|
-
});
|
18
|
+
this.sdk = new AddressComponent(options);
|
23
19
|
}
|
24
20
|
}, {
|
25
21
|
key: "mount",
|
@@ -38,6 +34,8 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
|
|
38
34
|
_this.elementContainer = elementContainer;
|
39
35
|
var iframes = elementContainer === null || elementContainer === void 0 || (_elementContainer$get = elementContainer.getElementsByTagName) === null || _elementContainer$get === void 0 ? void 0 : _elementContainer$get.call(elementContainer, 'iframe');
|
40
36
|
resolve(iframes === null || iframes === void 0 ? void 0 : iframes[0]);
|
37
|
+
}, function () {
|
38
|
+
resolve(undefined);
|
41
39
|
});
|
42
40
|
});
|
43
41
|
}
|
@@ -45,7 +43,7 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
|
|
45
43
|
key: "update",
|
46
44
|
value: function update() {
|
47
45
|
if (this.elementContainer) {
|
48
|
-
this.elementContainer.style.display = '
|
46
|
+
this.elementContainer.style.display = '';
|
49
47
|
}
|
50
48
|
// 下发数据
|
51
49
|
}
|
@@ -55,7 +53,8 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
|
|
55
53
|
var _this$elementContaine, _this$elementContaine2;
|
56
54
|
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
55
|
if (containers !== null && containers !== void 0 && containers[0]) {
|
58
|
-
|
56
|
+
var _containers$, _containers$$remove;
|
57
|
+
(_containers$ = containers[0]) === null || _containers$ === void 0 || (_containers$$remove = _containers$.remove) === null || _containers$$remove === void 0 || _containers$$remove.call(_containers$);
|
59
58
|
}
|
60
59
|
}
|
61
60
|
}]);
|
@@ -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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
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;
|
@@ -9,8 +9,9 @@ export declare class ElementPaymentComponent {
|
|
9
9
|
create(options: {
|
10
10
|
environment: string;
|
11
11
|
locale: string;
|
12
|
+
appVersion: string;
|
12
13
|
}): void;
|
13
|
-
mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement>;
|
14
|
+
mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
|
14
15
|
update(): void;
|
15
16
|
unmount(): void;
|
16
17
|
}
|
@@ -1,4 +1,6 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
2
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
3
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
4
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
@@ -15,14 +17,12 @@ export var ElementPaymentComponent = /*#__PURE__*/function () {
|
|
15
17
|
_createClass(ElementPaymentComponent, [{
|
16
18
|
key: "create",
|
17
19
|
value: function create(options) {
|
18
|
-
this.sdk = new AMSPaymentElement({
|
19
|
-
environment: options.environment,
|
20
|
-
locale: options.locale,
|
20
|
+
this.sdk = new AMSPaymentElement(_objectSpread(_objectSpread({}, options), {}, {
|
21
21
|
analytics: {
|
22
22
|
enabled: true
|
23
23
|
},
|
24
24
|
onEventCallback: function onEventCallback(state) {}
|
25
|
-
});
|
25
|
+
}));
|
26
26
|
}
|
27
27
|
}, {
|
28
28
|
key: "mount",
|
@@ -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
|
-
|
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
|
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;
|
@@ -14,12 +14,14 @@ export declare class ElementComponent {
|
|
14
14
|
private sdkActionRes;
|
15
15
|
private oneAccountRes;
|
16
16
|
private launchSource;
|
17
|
+
private iframeSrc;
|
17
18
|
private mountOptions;
|
18
19
|
private iframes;
|
19
20
|
private componentsCount;
|
20
21
|
private eventCallback;
|
21
22
|
constructor(options: IElementOptions);
|
22
23
|
private createElement;
|
24
|
+
private createIframeSrc;
|
23
25
|
private sdkActionQuery;
|
24
26
|
private oneAccountQuery;
|
25
27
|
private addListener;
|
@@ -40,5 +42,5 @@ export declare class ElementComponent {
|
|
40
42
|
private onSubmitRiskFunc;
|
41
43
|
private onSubmit;
|
42
44
|
private validatePromiseFuncs;
|
43
|
-
submitPayment():
|
45
|
+
submitPayment(): void;
|
44
46
|
}
|
@@ -22,7 +22,7 @@ import { parseSessionData } from "../index";
|
|
22
22
|
import { ElementAddressComponent } from "./components/address";
|
23
23
|
import { ElementAuthComponent } from "./components/auth";
|
24
24
|
import { ElementPaymentComponent } from "./components/payment";
|
25
|
-
import { addressTheme } from "./type";
|
25
|
+
import { addressTheme, ThemeType, ELEMENT_ENVIRONMENT } from "./type";
|
26
26
|
var ElementProcessor = /*#__PURE__*/function () {
|
27
27
|
function ElementProcessor() {
|
28
28
|
_classCallCheck(this, ElementProcessor);
|
@@ -76,6 +76,8 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
76
76
|
// one account接口返回
|
77
77
|
_defineProperty(this, "launchSource", void 0);
|
78
78
|
// launch 来源记录
|
79
|
+
_defineProperty(this, "iframeSrc", void 0);
|
80
|
+
// iframe src记录
|
79
81
|
_defineProperty(this, "mountOptions", void 0);
|
80
82
|
// 组件mount配置记录
|
81
83
|
_defineProperty(this, "iframes", void 0);
|
@@ -105,6 +107,14 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
105
107
|
selector: sdkSelector,
|
106
108
|
debugProps: renderOptions.debugProps
|
107
109
|
}).then(function (result) {
|
110
|
+
if (!result) {
|
111
|
+
var _this$_options$onEven, _this$_options;
|
112
|
+
(_this$_options$onEven = (_this$_options = _this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
|
113
|
+
code: EventCallbackCode.Failed,
|
114
|
+
message: 'Component loading failed'
|
115
|
+
});
|
116
|
+
return undefined;
|
117
|
+
}
|
108
118
|
_this.eventService.addIFrame(result);
|
109
119
|
_this.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
|
110
120
|
});
|
@@ -121,6 +131,14 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
121
131
|
selector: sdkSelector,
|
122
132
|
debugProps: renderOptions.debugProps
|
123
133
|
}).then(function (result) {
|
134
|
+
if (!result) {
|
135
|
+
var _this$_options$onEven2, _this$_options2;
|
136
|
+
(_this$_options$onEven2 = (_this$_options2 = _this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options2, {
|
137
|
+
code: EventCallbackCode.Failed,
|
138
|
+
message: 'Component loading failed'
|
139
|
+
});
|
140
|
+
return undefined;
|
141
|
+
}
|
124
142
|
_this.eventService.addIFrame(result);
|
125
143
|
_this.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
|
126
144
|
});
|
@@ -184,6 +202,8 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
184
202
|
envInfo: {
|
185
203
|
locale: _this._options.locale
|
186
204
|
},
|
205
|
+
timeout: 300000,
|
206
|
+
// TODO dev环境submit提交接口超时
|
187
207
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
188
208
|
}).then(function (result) {
|
189
209
|
console.log('element submit result ------', result);
|
@@ -317,6 +337,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
317
337
|
// this.sendRenderData();
|
318
338
|
// }, 500);
|
319
339
|
});
|
340
|
+
this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
|
320
341
|
|
321
342
|
// 注册 auth 邮箱模块
|
322
343
|
try {
|
@@ -332,18 +353,20 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
332
353
|
this.paymentBase = new ElementPaymentComponent();
|
333
354
|
this.paymentBase.create({
|
334
355
|
environment: this._options.environment,
|
335
|
-
locale: this._options.locale
|
356
|
+
locale: this._options.locale,
|
357
|
+
appVersion: this._options.version || ''
|
336
358
|
});
|
337
359
|
|
338
360
|
// 注册 address 地址模块
|
339
361
|
this.addressBase = new ElementAddressComponent();
|
340
362
|
this.addressBase.create({
|
341
363
|
environment: this._options.environment,
|
342
|
-
locale: this._options.locale
|
364
|
+
locale: this._options.locale,
|
365
|
+
appVersion: this._options.version || ''
|
343
366
|
});
|
344
367
|
} catch (error) {
|
345
|
-
var _this$_options$
|
346
|
-
(_this$_options$
|
368
|
+
var _this$_options$onEven3, _this$_options3;
|
369
|
+
(_this$_options$onEven3 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven3 === void 0 || _this$_options$onEven3.call(_this$_options3, {
|
347
370
|
code: EventCallbackCode.Failed,
|
348
371
|
message: 'create sdk fail'
|
349
372
|
});
|
@@ -352,6 +375,19 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
352
375
|
// 注册监听消息
|
353
376
|
this.addListener();
|
354
377
|
}
|
378
|
+
}, {
|
379
|
+
key: "createIframeSrc",
|
380
|
+
value: function createIframeSrc() {
|
381
|
+
var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ELEMENT_ENVIRONMENT.DEV;
|
382
|
+
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.23.0';
|
383
|
+
var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'http://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://cdn-pre.marmot-cloud.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
|
384
|
+
var _env = (env === null || env === void 0 ? void 0 : env.toLocaleUpperCase()) || ELEMENT_ENVIRONMENT.DEV;
|
385
|
+
return {
|
386
|
+
auth: "".concat(baseUrl[_env], "/auth-element/").concat(version, "/pages/element_auth/index.html"),
|
387
|
+
address: "".concat(baseUrl[_env], "/element-address/").concat(version, "/pages/address/index.html"),
|
388
|
+
payment: "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/element_payment/index.html")
|
389
|
+
};
|
390
|
+
}
|
355
391
|
}, {
|
356
392
|
key: "sdkActionQuery",
|
357
393
|
value: function sdkActionQuery() {
|
@@ -368,8 +404,17 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
368
404
|
locale: _this3._options.locale
|
369
405
|
},
|
370
406
|
hostSign: hostSign,
|
407
|
+
timeout: 300000,
|
408
|
+
// TODO dev环境接口超时
|
371
409
|
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
372
410
|
}).then(function (result) {
|
411
|
+
if (!result.success) {
|
412
|
+
var _this3$_options$onEve, _this3$_options;
|
413
|
+
(_this3$_options$onEve = (_this3$_options = _this3._options).onEventCallback) === null || _this3$_options$onEve === void 0 || _this3$_options$onEve.call(_this3$_options, {
|
414
|
+
code: EventCallbackCode.Failed,
|
415
|
+
message: 'sdkAction.query Request Error'
|
416
|
+
});
|
417
|
+
}
|
373
418
|
resolve(result);
|
374
419
|
});
|
375
420
|
});
|
@@ -392,6 +437,8 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
392
437
|
envInfo: {
|
393
438
|
locale: _this4._options.locale
|
394
439
|
},
|
440
|
+
timeout: 300000,
|
441
|
+
// TODO dev环境接口超时
|
395
442
|
'Operation-Type': 'com.ipay.iexpfront.one.account.query'
|
396
443
|
}).then(function (result) {
|
397
444
|
resolve(result);
|
@@ -457,7 +504,7 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
457
504
|
// 发送初始化数据
|
458
505
|
function sendRenderData() {
|
459
506
|
if (this.launchSource.length === this.componentsCount && this.sdkActionRes && this.oneAccountRes) {
|
460
|
-
var _this$_options$loadin, _this$mountOptions, _this$mountOptions2, _this$mountOptions3, _this$mountOptions4, _this$paymentBase, _this$addressBase, _this$authBase;
|
507
|
+
var _this$_options$loadin, _this$mountOptions, _this$_options4, _this$mountOptions2, _this$_options5, _this$mountOptions3, _this$mountOptions4, _this$_options6, _this$paymentBase, _this$addressBase, _this$authBase;
|
461
508
|
var baseData = {
|
462
509
|
originActionQueryResult: this.sdkActionRes,
|
463
510
|
originOneAccountQueryResult: this.oneAccountRes,
|
@@ -476,7 +523,9 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
476
523
|
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
477
524
|
params: _objectSpread({
|
478
525
|
queryResult: this.sdkActionRes,
|
479
|
-
appearance: ((_this$mountOptions = this.mountOptions) === null || _this$mountOptions === void 0 || (_this$mountOptions = _this$mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT]) === null || _this$mountOptions === void 0 ? void 0 : _this$mountOptions.appearance) || this._options.appearance
|
526
|
+
appearance: ((_this$mountOptions = this.mountOptions) === null || _this$mountOptions === void 0 || (_this$mountOptions = _this$mountOptions[ElementPaymentMethod.PAYMENT_ELEMENT]) === null || _this$mountOptions === void 0 ? void 0 : _this$mountOptions.appearance) || ((_this$_options4 = this._options) === null || _this$_options4 === void 0 ? void 0 : _this$_options4.appearance) || {
|
527
|
+
theme: ThemeType.Default
|
528
|
+
}
|
480
529
|
}, baseData)
|
481
530
|
}
|
482
531
|
}, function () {});
|
@@ -486,18 +535,15 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
486
535
|
target: ElementPaymentMethod.ADDRESS_ELEMENT,
|
487
536
|
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
488
537
|
params: _objectSpread({
|
489
|
-
prefillValue: this.oneAccountRes.shippings || [
|
490
|
-
shippingAddress: {
|
491
|
-
region: ''
|
492
|
-
}
|
493
|
-
}],
|
538
|
+
prefillValue: this.oneAccountRes.shippings || [],
|
494
539
|
appearance: {
|
495
|
-
themeType: addressTheme[((_this$mountOptions2 = this.mountOptions) === null || _this$mountOptions2 === void 0 || (_this$mountOptions2 = _this$mountOptions2[ElementPaymentMethod.ADDRESS_ELEMENT]) === null || _this$mountOptions2 === void 0 || (_this$mountOptions2 = _this$mountOptions2.appearance) === null || _this$mountOptions2 === void 0 ? void 0 : _this$mountOptions2.theme) || this._options.appearance.theme ||
|
540
|
+
themeType: addressTheme[((_this$mountOptions2 = this.mountOptions) === null || _this$mountOptions2 === void 0 || (_this$mountOptions2 = _this$mountOptions2[ElementPaymentMethod.ADDRESS_ELEMENT]) === null || _this$mountOptions2 === void 0 || (_this$mountOptions2 = _this$mountOptions2.appearance) === null || _this$mountOptions2 === void 0 ? void 0 : _this$mountOptions2.theme) || ((_this$_options5 = this._options) === null || _this$_options5 === void 0 || (_this$_options5 = _this$_options5.appearance) === null || _this$_options5 === void 0 ? void 0 : _this$_options5.theme) || ThemeType.Default]
|
496
541
|
},
|
497
542
|
configParams: _objectSpread({
|
498
543
|
needEditBackBtn: true,
|
499
544
|
autoSaveAsDefaultAddress: true,
|
500
|
-
editingNeedShippingQuery: true
|
545
|
+
editingNeedShippingQuery: true,
|
546
|
+
showTitle: true
|
501
547
|
}, (_this$mountOptions3 = this.mountOptions) === null || _this$mountOptions3 === void 0 ? void 0 : _this$mountOptions3[ElementPaymentMethod.ADDRESS_ELEMENT])
|
502
548
|
}, baseData)
|
503
549
|
}
|
@@ -508,7 +554,9 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
508
554
|
target: ElementPaymentMethod.AUTH_ELEMENT,
|
509
555
|
source: ElementPaymentMethod.CONTAINER_ELEMENT,
|
510
556
|
params: _objectSpread(_objectSpread({}, baseData), {}, {
|
511
|
-
appearance: ((_this$mountOptions4 = this.mountOptions) === null || _this$mountOptions4 === void 0 || (_this$mountOptions4 = _this$mountOptions4[ElementPaymentMethod.AUTH_ELEMENT]) === null || _this$mountOptions4 === void 0 ? void 0 : _this$mountOptions4.appearance) || this._options.appearance
|
557
|
+
appearance: ((_this$mountOptions4 = this.mountOptions) === null || _this$mountOptions4 === void 0 || (_this$mountOptions4 = _this$mountOptions4[ElementPaymentMethod.AUTH_ELEMENT]) === null || _this$mountOptions4 === void 0 ? void 0 : _this$mountOptions4.appearance) || ((_this$_options6 = this._options) === null || _this$_options6 === void 0 ? void 0 : _this$_options6.appearance) || {
|
558
|
+
theme: ThemeType.Default
|
559
|
+
}
|
512
560
|
})
|
513
561
|
}
|
514
562
|
}, function () {});
|
@@ -539,10 +587,21 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
539
587
|
_this6 = this;
|
540
588
|
this.mountOptions[ElementPaymentMethod.AUTH_ELEMENT] = renderOptions;
|
541
589
|
var _selector = sdkSelector.indexOf('#') === 0 ? sdkSelector.slice(1) : sdkSelector;
|
590
|
+
var link = renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP = renderOptions.debugProps) === null || _renderOptions$debugP === void 0 ? void 0 : _renderOptions$debugP.localLink;
|
591
|
+
var params = window.location.href.split('?')[1];
|
592
|
+
var url = link.indexOf('?') === -1 ? "".concat(link, "?").concat(params) : link;
|
542
593
|
this.authBase.mount({
|
543
594
|
selector: _selector,
|
544
|
-
url:
|
595
|
+
url: url
|
545
596
|
}).then(function (result) {
|
597
|
+
if (!result) {
|
598
|
+
var _this6$_options$onEve, _this6$_options;
|
599
|
+
(_this6$_options$onEve = (_this6$_options = _this6._options).onEventCallback) === null || _this6$_options$onEve === void 0 || _this6$_options$onEve.call(_this6$_options, {
|
600
|
+
code: EventCallbackCode.Failed,
|
601
|
+
message: 'Component loading failed'
|
602
|
+
});
|
603
|
+
return undefined;
|
604
|
+
}
|
546
605
|
_this6.eventService.addIFrame(result);
|
547
606
|
_this6.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
|
548
607
|
});
|
@@ -557,11 +616,11 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
557
616
|
key: "mount",
|
558
617
|
value: function mount(renderOptions, sdkSelector) {
|
559
618
|
if (typeof sdkSelector === 'string') {
|
560
|
-
var _this$_options$loadin4;
|
619
|
+
var _this$_options$loadin4, _renderOptions$debugP2;
|
561
620
|
var element = document.querySelector(sdkSelector);
|
562
621
|
if (!element) {
|
563
|
-
var _this$_options$
|
564
|
-
(_this$_options$
|
622
|
+
var _this$_options$onEven4, _this$_options7;
|
623
|
+
(_this$_options$onEven4 = (_this$_options7 = this._options).onEventCallback) === null || _this$_options$onEven4 === void 0 || _this$_options$onEven4.call(_this$_options7, {
|
565
624
|
code: EventCallbackCode.Failed,
|
566
625
|
message: 'Unable to obtain selector'
|
567
626
|
});
|
@@ -572,8 +631,13 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
572
631
|
var _this$_options$loadin5, _this$_options$loadin6;
|
573
632
|
(_this$_options$loadin5 = this._options.loading) === null || _this$_options$loadin5 === void 0 || (_this$_options$loadin6 = _this$_options$loadin5.onStartLoading) === null || _this$_options$loadin6 === void 0 || _this$_options$loadin6.call(_this$_options$loadin5);
|
574
633
|
}
|
634
|
+
if (!(renderOptions !== null && renderOptions !== void 0 && (_renderOptions$debugP2 = renderOptions.debugProps) !== null && _renderOptions$debugP2 !== void 0 && _renderOptions$debugP2.localLink)) {
|
635
|
+
renderOptions.debugProps = {
|
636
|
+
localLink: this.iframeSrc[renderOptions.type]
|
637
|
+
};
|
638
|
+
}
|
575
639
|
this.loading = true;
|
576
|
-
if (renderOptions.type === '
|
640
|
+
if (renderOptions.type === 'auth') {
|
577
641
|
return this.mountAuth(renderOptions, sdkSelector);
|
578
642
|
}
|
579
643
|
if (renderOptions.type === 'address') {
|
@@ -618,7 +682,20 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
618
682
|
}, {
|
619
683
|
key: "submitPayment",
|
620
684
|
value: function submitPayment() {
|
621
|
-
|
685
|
+
var _this$_options$loadin7,
|
686
|
+
_this7 = this;
|
687
|
+
if ((_this$_options$loadin7 = this._options.loading) !== null && _this$_options$loadin7 !== void 0 && _this$_options$loadin7.onStartLoading) {
|
688
|
+
var _this$_options$loadin8, _this$_options$loadin9;
|
689
|
+
(_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);
|
690
|
+
}
|
691
|
+
this.validatePromiseFuncs().then(function () {
|
692
|
+
var _this7$_options$loadi;
|
693
|
+
if ((_this7$_options$loadi = _this7._options.loading) !== null && _this7$_options$loadi !== void 0 && _this7$_options$loadi.onEndLoading) {
|
694
|
+
var _this7$_options$loadi2, _this7$_options$loadi3;
|
695
|
+
(_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);
|
696
|
+
}
|
697
|
+
});
|
698
|
+
return;
|
622
699
|
}
|
623
700
|
}]);
|
624
701
|
return ElementComponent;
|
@@ -1,30 +1,35 @@
|
|
1
1
|
import { ConnectErrorCode, ElementPaymentMethod } from '../../../types';
|
2
|
-
interface BaseMountOptions<T = void> {
|
3
|
-
config?: {};
|
4
|
-
}
|
5
2
|
export declare enum ThemeType {
|
6
3
|
NostalgicGray = "nostalgicGray",
|
7
|
-
|
4
|
+
Default = "default",
|
8
5
|
Night = "night",
|
9
6
|
CherryBlossomPink = "cherryBlossomPink",
|
10
7
|
GamingPurple = "gamingPurple",
|
11
8
|
AgateGreen = "agateGreen"
|
12
9
|
}
|
13
10
|
export declare const addressTheme: {
|
11
|
+
default: string;
|
14
12
|
night: string;
|
15
|
-
light: string;
|
16
13
|
};
|
17
14
|
export declare enum EventCallbackCode {
|
18
15
|
Failed = "Failed",
|
19
16
|
Completed = "Completed"
|
20
17
|
}
|
18
|
+
export declare enum ELEMENT_ENVIRONMENT {
|
19
|
+
DEV = "DEV",
|
20
|
+
TEST = "TEST",
|
21
|
+
PRE = "PRE",
|
22
|
+
PROD = "PROD"
|
23
|
+
}
|
24
|
+
export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
|
21
25
|
export interface IElementOptions {
|
22
26
|
sessionData: string;
|
23
|
-
environment?:
|
27
|
+
environment?: ELEMENT_ENVIRONMENT_TYPE;
|
24
28
|
locale?: string;
|
25
29
|
mode?: string;
|
30
|
+
version?: string;
|
26
31
|
appearance?: {
|
27
|
-
theme: ThemeType.
|
32
|
+
theme: ThemeType.Default | ThemeType.Night;
|
28
33
|
};
|
29
34
|
onEventCallback?: ({ code, message }: {
|
30
35
|
code: EventCallbackCode;
|
@@ -35,6 +40,12 @@ export interface IElementOptions {
|
|
35
40
|
onEndLoading: () => void;
|
36
41
|
};
|
37
42
|
}
|
43
|
+
interface BaseMountOptions<T = void> {
|
44
|
+
config?: {};
|
45
|
+
debugProps?: {
|
46
|
+
localLink: string;
|
47
|
+
};
|
48
|
+
}
|
38
49
|
type HideField = 'shippingCountry' | 'shippingName' | 'shippingPhoneNo' | 'shippingRegion' | 'shippingAddress1' | 'shippingZipCode' | 'shippingAddress2';
|
39
50
|
export interface AddressMountOptions extends BaseMountOptions<{
|
40
51
|
/**
|
@@ -50,29 +61,20 @@ export interface AddressMountOptions extends BaseMountOptions<{
|
|
50
61
|
}> {
|
51
62
|
type: 'address';
|
52
63
|
appearance?: {
|
53
|
-
theme: ThemeType.
|
54
|
-
};
|
55
|
-
debugProps?: {
|
56
|
-
localLink: string;
|
64
|
+
theme: ThemeType.Default | ThemeType.Night;
|
57
65
|
};
|
58
66
|
}
|
59
67
|
export interface LinkAuthMountOptions extends BaseMountOptions {
|
60
|
-
type: '
|
68
|
+
type: 'auth';
|
61
69
|
appearance?: {
|
62
70
|
theme: ThemeType;
|
63
71
|
};
|
64
|
-
debugProps?: {
|
65
|
-
localLink?: string;
|
66
|
-
};
|
67
72
|
}
|
68
73
|
export interface PaymentMountOptions extends BaseMountOptions {
|
69
74
|
type: 'payment';
|
70
75
|
appearance?: {
|
71
76
|
theme: ThemeType;
|
72
77
|
};
|
73
|
-
debugProps?: {
|
74
|
-
localLink: string;
|
75
|
-
};
|
76
78
|
}
|
77
79
|
export declare enum AddressEventCallbackName {
|
78
80
|
SHIPPING_CHANGE = "SHIPPING_CHANGE"
|
@@ -142,6 +144,7 @@ export interface AddressSubmitData {
|
|
142
144
|
notes: string;
|
143
145
|
prefer: '1' | '0';
|
144
146
|
shippingId: string;
|
147
|
+
actionFlag: 'I' | 'U' | 'D';
|
145
148
|
}
|
146
149
|
export interface SubmitServiceParams extends PaymentSubmitData {
|
147
150
|
accountInfo: AuthSubmitData['accountInfo'];
|
@@ -1,21 +1,29 @@
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
4
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
1
5
|
export var ThemeType = /*#__PURE__*/function (ThemeType) {
|
2
6
|
ThemeType["NostalgicGray"] = "nostalgicGray";
|
3
|
-
ThemeType["
|
7
|
+
ThemeType["Default"] = "default";
|
4
8
|
ThemeType["Night"] = "night";
|
5
9
|
ThemeType["CherryBlossomPink"] = "cherryBlossomPink";
|
6
10
|
ThemeType["GamingPurple"] = "gamingPurple";
|
7
11
|
ThemeType["AgateGreen"] = "agateGreen";
|
8
12
|
return ThemeType;
|
9
13
|
}({});
|
10
|
-
export var addressTheme = {
|
11
|
-
night: 'NIGHT',
|
12
|
-
light: 'LIGHT'
|
13
|
-
};
|
14
|
+
export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
|
14
15
|
export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
|
15
16
|
EventCallbackCode["Failed"] = "Failed";
|
16
17
|
EventCallbackCode["Completed"] = "Completed";
|
17
18
|
return EventCallbackCode;
|
18
19
|
}({});
|
20
|
+
export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
|
21
|
+
ELEMENT_ENVIRONMENT["DEV"] = "DEV";
|
22
|
+
ELEMENT_ENVIRONMENT["TEST"] = "TEST";
|
23
|
+
ELEMENT_ENVIRONMENT["PRE"] = "PRE";
|
24
|
+
ELEMENT_ENVIRONMENT["PROD"] = "PROD";
|
25
|
+
return ELEMENT_ENVIRONMENT;
|
26
|
+
}({});
|
19
27
|
// export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
|
20
28
|
|
21
29
|
export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
|