@alipay/ams-checkout 0.0.1690894389-dev.0 → 0.0.1691379784-dev.0
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/esm/config/index.d.ts +2 -22
- package/dist/esm/config/index.js +9 -61
- package/dist/esm/config/request.d.ts +21 -0
- package/dist/esm/config/request.js +67 -0
- package/dist/esm/constant/index.d.ts +1 -0
- package/dist/esm/constant/index.js +1 -0
- package/dist/esm/core/component/index.d.ts +3 -3
- package/dist/esm/core/component/index.js +61 -88
- package/dist/esm/core/instance/index.d.ts +2 -10
- package/dist/esm/core/instance/index.js +0 -22
- package/dist/esm/plugin/component/cashierApp.d.ts +23 -0
- package/dist/esm/plugin/component/cashierApp.js +122 -0
- package/dist/esm/plugin/component/component.style.js +1 -1
- package/dist/esm/plugin/component/index.d.ts +9 -15
- package/dist/esm/plugin/component/index.js +116 -144
- package/dist/esm/request/index.d.ts +1 -1
- package/dist/esm/request/index.js +5 -5
- package/dist/esm/service/index.d.ts +2 -2
- package/dist/esm/types/index.d.ts +42 -13
- package/dist/esm/types/index.js +8 -5
- package/dist/esm/util/index.js +1 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/plugin/component/appPath.d.ts +0 -2
- package/dist/esm/plugin/component/appPath.js +0 -75
@@ -17,18 +17,20 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
18
18
|
*/
|
19
19
|
/* eslint-disable no-console */
|
20
|
-
import
|
21
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
20
|
+
import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
22
21
|
import { queryPaymentInfo } from "../../service";
|
23
|
-
import {
|
24
|
-
import { getDesignFontSize,
|
22
|
+
import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
|
23
|
+
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
|
25
24
|
import { isLocalMock } from "../../util/mock";
|
26
|
-
import { getAppDomain,
|
25
|
+
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
27
26
|
import { componentAddCSS } from "./component.style";
|
27
|
+
var _window = window,
|
28
|
+
innerHeight = _window.innerHeight;
|
28
29
|
var amsSetSize = function amsSetSize(event, dom) {
|
29
30
|
try {
|
30
31
|
var _dom = dom || document.getElementById('ams-component-container');
|
31
32
|
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
33
|
+
innerHeight = window.innerHeight;
|
32
34
|
// eslint-disable-next-line no-empty
|
33
35
|
} catch (error) {}
|
34
36
|
};
|
@@ -40,15 +42,13 @@ var addEvent = function addEvent() {
|
|
40
42
|
window.addEventListener('pageShow', amsSetSize);
|
41
43
|
window.addEventListener('DOMContentLoaded', amsSetSize);
|
42
44
|
};
|
43
|
-
var _window = window,
|
44
|
-
innerHeight = _window.innerHeight;
|
45
45
|
var mockupId = 'ams-component-mockup';
|
46
46
|
var loadingId = 'ams-component-loading';
|
47
|
+
var listenerPrefix = '_ams_sdk_component_listener';
|
47
48
|
var ComponentApp = /*#__PURE__*/function () {
|
48
49
|
function ComponentApp() {
|
49
50
|
_classCallCheck(this, ComponentApp);
|
50
51
|
_defineProperty(this, "app", void 0);
|
51
|
-
_defineProperty(this, "paymentMethodsResult", void 0);
|
52
52
|
_defineProperty(this, "appDomain", void 0);
|
53
53
|
_defineProperty(this, "AMSSDK", void 0);
|
54
54
|
_defineProperty(this, "platform", void 0);
|
@@ -58,11 +58,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
58
58
|
_defineProperty(this, "_isRetention", void 0);
|
59
59
|
_defineProperty(this, "_actionQueryPromise", null);
|
60
60
|
_defineProperty(this, "_renderParams", null);
|
61
|
-
_defineProperty(this, "
|
61
|
+
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
62
62
|
_defineProperty(this, "_performanceData", []);
|
63
63
|
_defineProperty(this, "_isInitComponent", void 0);
|
64
64
|
_defineProperty(this, "_clickEventName", void 0);
|
65
|
-
this._appVersion = '1.
|
65
|
+
this._appVersion = '1.4.0';
|
66
66
|
this._isInitComponent = false;
|
67
67
|
this._selector = '#ams-component-section';
|
68
68
|
this.createIframeNode = function () {
|
@@ -112,11 +112,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
112
112
|
*/
|
113
113
|
}, {
|
114
114
|
key: "appendIframeNodes",
|
115
|
-
value: function appendIframeNodes(
|
115
|
+
value: function appendIframeNodes(componentSign, renderParams) {
|
116
116
|
var _renderParams$appeara,
|
117
117
|
_this = this;
|
118
118
|
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
119
119
|
this._isInitComponent = true;
|
120
|
+
this._renderParams = renderParams;
|
121
|
+
this._componentSign = componentSign;
|
120
122
|
this._performanceData.push({
|
121
123
|
key: 'sdk_create_component',
|
122
124
|
value: Date.now()
|
@@ -131,19 +133,20 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
131
133
|
this.showLoading();
|
132
134
|
}
|
133
135
|
this.showCashier();
|
134
|
-
this._renderParams = renderParams;
|
135
|
-
this._componentName = componentName;
|
136
136
|
this.createApp(renderParams);
|
137
|
-
this.
|
137
|
+
this.createActionQueryPromise();
|
138
138
|
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
|
139
139
|
selector: this._selector
|
140
140
|
})), this._actionQueryPromise]).catch(function () {
|
141
141
|
_this._isInitComponent = false;
|
142
142
|
});
|
143
143
|
}
|
144
|
+
/**
|
145
|
+
* @description Interface request
|
146
|
+
*/
|
144
147
|
}, {
|
145
|
-
key: "
|
146
|
-
value: function
|
148
|
+
key: "createActionQueryPromise",
|
149
|
+
value: function createActionQueryPromise() {
|
147
150
|
var _this2 = this;
|
148
151
|
this._performanceData.push({
|
149
152
|
key: 'sdk_action_query_start',
|
@@ -152,59 +155,64 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
152
155
|
this._actionQueryPromise = new Promise(function (resolve, reject) {
|
153
156
|
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
|
154
157
|
var params = {
|
155
|
-
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData),
|
156
|
-
paymentSessionConfig: (
|
158
|
+
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
|
159
|
+
paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
|
157
160
|
};
|
158
|
-
|
159
|
-
|
161
|
+
/**
|
162
|
+
* @description card
|
163
|
+
*/
|
164
|
+
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
|
160
165
|
params.paymentMethodType = 'CARD';
|
161
|
-
params.paymentSessionConfig = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : (_this2$_renderParams5 = _this2$_renderParams4.paymentSessionMetaData) === null || _this2$_renderParams5 === void 0 ? void 0 : _this2$_renderParams5.paymentSessionConfig) || {};
|
162
166
|
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
var
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
productScene =
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
//
|
167
|
+
/**
|
168
|
+
* @description easyPay
|
169
|
+
*/
|
170
|
+
if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
|
171
|
+
var _this2$_renderParams4;
|
172
|
+
var _ref = params.paymentSessionConfig || {},
|
173
|
+
_ref$productSceneVers = _ref.productSceneVersion,
|
174
|
+
productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
|
175
|
+
_ref$productScene = _ref.productScene,
|
176
|
+
productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
|
177
|
+
var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
|
178
|
+
_ref2$action = _ref2.action,
|
179
|
+
_ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
|
180
|
+
_ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
|
181
|
+
autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
|
182
|
+
if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
|
183
|
+
// if EASY_PAY 2.0 , no need to query payment request
|
180
184
|
return resolve({
|
181
|
-
message: 'sdk no need to make query request'
|
185
|
+
message: 'sdk no need to make query request',
|
186
|
+
success: true
|
182
187
|
});
|
183
188
|
}
|
184
189
|
}
|
185
190
|
/**
|
186
191
|
* @author tianqiang
|
187
|
-
* @description
|
192
|
+
* @description autoDebit
|
188
193
|
*/
|
189
|
-
if (
|
190
|
-
var _this2$
|
191
|
-
var action = ((_this2$
|
192
|
-
var signType =
|
194
|
+
if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
|
195
|
+
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
|
196
|
+
var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
|
197
|
+
var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
193
198
|
if (signType === 'SMS') {
|
194
199
|
return resolve({
|
195
|
-
message: 'sdk no need to make query request'
|
200
|
+
message: 'sdk no need to make query request',
|
201
|
+
success: true
|
196
202
|
});
|
197
|
-
}
|
203
|
+
}
|
204
|
+
if (!signType || signType !== 'REDIRECT') {
|
198
205
|
return resolve({
|
199
206
|
success: false
|
200
207
|
});
|
201
208
|
}
|
202
209
|
}
|
203
210
|
|
204
|
-
//
|
211
|
+
// mock
|
205
212
|
if (isLocalMock()) {
|
206
213
|
return resolve({
|
207
|
-
message: 'sdk no need to make query request'
|
214
|
+
message: 'sdk no need to make query request',
|
215
|
+
success: true
|
208
216
|
});
|
209
217
|
}
|
210
218
|
queryPaymentInfo(params, {
|
@@ -215,7 +223,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
215
223
|
key: 'sdk_action_query_end',
|
216
224
|
value: Date.now()
|
217
225
|
});
|
218
|
-
if (res && res.success) {
|
226
|
+
if (res !== null && res !== void 0 && res.success) {
|
219
227
|
resolve(res);
|
220
228
|
} else {
|
221
229
|
resolve(res);
|
@@ -259,9 +267,25 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
259
267
|
var _renderParams$payment, _renderParams$payment2, _renderParams$payment3;
|
260
268
|
var productSceneVersion = (renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$payment = renderParams.paymentSessionMetaData) === null || _renderParams$payment === void 0 ? void 0 : (_renderParams$payment2 = _renderParams$payment.paymentSessionConfig) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.productSceneVersion) || '';
|
261
269
|
var extendInfo = (renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$payment3 = renderParams.paymentSessionMetaData) === null || _renderParams$payment3 === void 0 ? void 0 : _renderParams$payment3.extendInfo) || '';
|
262
|
-
|
263
|
-
this.
|
264
|
-
|
270
|
+
var environment = this.AMSSDK.options.env.environment;
|
271
|
+
this.appDomain = getAppDomain({
|
272
|
+
environment: environment,
|
273
|
+
appVersion: this._appVersion,
|
274
|
+
componentSign: this._componentSign,
|
275
|
+
productSceneVersion: productSceneVersion,
|
276
|
+
extendInfo: extendInfo
|
277
|
+
});
|
278
|
+
this.app = createIframe(this.AMSSDK.options.mode);
|
279
|
+
this.app.src = getIframeUrl({
|
280
|
+
componentSign: this._componentSign,
|
281
|
+
analytics: this.AMSSDK.options.analytics,
|
282
|
+
productSceneVersion: productSceneVersion,
|
283
|
+
environment: environment,
|
284
|
+
appVersion: this._appVersion,
|
285
|
+
extendInfo: extendInfo,
|
286
|
+
locale: this.AMSSDK.options.locale,
|
287
|
+
instanceId: this.AMSSDK._instanceId
|
288
|
+
});
|
265
289
|
|
266
290
|
// Subscribe to messages from iframe
|
267
291
|
this._addEventListener();
|
@@ -272,76 +296,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
272
296
|
}
|
273
297
|
}
|
274
298
|
}, {
|
275
|
-
key: "
|
276
|
-
value: function
|
277
|
-
var _this$_renderParams, _this$_renderParams$p;
|
278
|
-
var analytics = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
279
|
-
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
280
|
-
var path = getAppPath(this.AMSSDK.options.env.environment, this._appVersion, componentName, productSceneVersion, ((_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : (_this$_renderParams$p = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams$p === void 0 ? void 0 : _this$_renderParams$p.extendInfo) || '');
|
281
|
-
var scale = getViewPort('initial-scale') || 1;
|
282
|
-
var _queryParse = queryParse(),
|
283
|
-
_sandbox = _queryParse._sandbox,
|
284
|
-
_light_sandbox = _queryParse._light_sandbox,
|
285
|
-
_queryParse$requestHo = _queryParse.requestHost,
|
286
|
-
requestHost = _queryParse$requestHo === void 0 ? '' : _queryParse$requestHo,
|
287
|
-
_queryParse$groupId = _queryParse.groupId,
|
288
|
-
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
289
|
-
LOCAL_MOCK = _queryParse.LOCAL_MOCK;
|
290
|
-
var urlParams = Object.assign({
|
291
|
-
locale: this.AMSSDK.options.locale,
|
292
|
-
scale: scale,
|
293
|
-
merchantDomain: window.btoa(getOrigin()),
|
294
|
-
instanceId: this.AMSSDK._instanceId,
|
295
|
-
sandbox: this.AMSSDK.options.env.environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
|
296
|
-
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
297
|
-
sdkVersion: json.version,
|
298
|
-
refUrl: window.location.href,
|
299
|
-
shadow: this.AMSSDK.options.env.environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
|
300
|
-
requestHost: requestHost,
|
301
|
-
groupId: groupId,
|
302
|
-
LOCAL_MOCK: LOCAL_MOCK
|
303
|
-
}, appearance);
|
304
|
-
var locationSearch = serialize(urlParams);
|
305
|
-
return "".concat(path, "?").concat(locationSearch);
|
306
|
-
}
|
307
|
-
|
308
|
-
/**
|
309
|
-
* @description Create iframe
|
310
|
-
*/
|
311
|
-
}, {
|
312
|
-
key: "createIframe",
|
313
|
-
value: function createIframe() {
|
314
|
-
var iframe = document.createElement('iframe');
|
315
|
-
var iframeId = this._getIframeId(this.AMSSDK.options.mode);
|
316
|
-
iframe.id = iframeId;
|
317
|
-
iframe.style.height = '0px';
|
318
|
-
iframe.style.width = '100%';
|
319
|
-
iframe.style.border = '0';
|
320
|
-
iframe.style.overflow = 'hidden';
|
321
|
-
return iframe;
|
322
|
-
}
|
323
|
-
|
324
|
-
/**
|
325
|
-
* @description Get iftame id
|
326
|
-
*/
|
327
|
-
}, {
|
328
|
-
key: "_getIframeId",
|
329
|
-
value: function _getIframeId(UIMode) {
|
330
|
-
var id = 'checkout-dropin';
|
331
|
-
// eslint-disable-next-line default-case
|
332
|
-
switch (UIMode) {
|
333
|
-
case 'dropin':
|
334
|
-
id = 'checkout-dropin';
|
335
|
-
break;
|
336
|
-
case 'component':
|
337
|
-
id = 'checkout-component';
|
338
|
-
break;
|
339
|
-
}
|
340
|
-
return id;
|
341
|
-
}
|
342
|
-
}, {
|
343
|
-
key: "_listener",
|
344
|
-
value: function _listener(e) {
|
299
|
+
key: "listener",
|
300
|
+
value: function listener(e) {
|
345
301
|
if (e.origin !== this.appDomain) {
|
346
302
|
return;
|
347
303
|
}
|
@@ -357,6 +313,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
357
313
|
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.NOT_JSON_FORMAT);
|
358
314
|
}
|
359
315
|
}
|
316
|
+
}, {
|
317
|
+
key: "resizeListener",
|
318
|
+
value: function resizeListener() {
|
319
|
+
var cashier = document.getElementById('ams-component-container');
|
320
|
+
cashier.style.transition = 'none';
|
321
|
+
this.dispatchToApp({
|
322
|
+
context: {
|
323
|
+
event: 'renderResize',
|
324
|
+
data: {
|
325
|
+
heightOfVisible: window.innerHeight,
|
326
|
+
widthOfVisible: window.innerWidth
|
327
|
+
}
|
328
|
+
}
|
329
|
+
});
|
330
|
+
}
|
360
331
|
|
361
332
|
/**
|
362
333
|
* @description Initialize subscription iframe message
|
@@ -364,14 +335,17 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
335
|
}, {
|
365
336
|
key: "_addEventListener",
|
366
337
|
value: function _addEventListener() {
|
367
|
-
window["_ams_sdk_component_listener_".concat(this.AMSSDK._instanceId)] = this._listener.bind(this);
|
368
338
|
this._removeEventListener();
|
369
|
-
window.
|
339
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
340
|
+
window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
341
|
+
window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
342
|
+
window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
370
343
|
}
|
371
344
|
}, {
|
372
345
|
key: "_removeEventListener",
|
373
346
|
value: function _removeEventListener() {
|
374
|
-
window.removeEventListener('message', window["
|
347
|
+
window.removeEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
|
348
|
+
window.removeEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
375
349
|
}
|
376
350
|
|
377
351
|
/**
|
@@ -474,7 +448,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
474
448
|
// size变动时动画
|
475
449
|
setTimeout(function () {
|
476
450
|
cashier.style.transition = 'height 0.28s ease-in-out';
|
477
|
-
},
|
451
|
+
}, 500);
|
478
452
|
}
|
479
453
|
this.app.style.height = "".concat(data.context.data.height, "px");
|
480
454
|
this.app.style.width = '100%';
|
@@ -508,10 +482,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
508
482
|
});
|
509
483
|
};
|
510
484
|
|
511
|
-
//
|
485
|
+
// 支持 target: _blank,新开tab页打开
|
512
486
|
if (_data.target === Target.BLANK) {
|
487
|
+
if (!_data.normalUrl) return failCallback();
|
513
488
|
successCallback('normalUrl', _data.normalUrl);
|
514
|
-
if (!_data.normalUrl) return;
|
515
489
|
window.open(_data.normalUrl);
|
516
490
|
return;
|
517
491
|
}
|
@@ -537,9 +511,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
537
511
|
}
|
538
512
|
}, {
|
539
513
|
key: "handleDeclareInfo",
|
540
|
-
value: function handleDeclareInfo(
|
541
|
-
var
|
542
|
-
closeDialogData =
|
514
|
+
value: function handleDeclareInfo(_ref3) {
|
515
|
+
var _ref3$closeDialogData = _ref3.closeDialogData,
|
516
|
+
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
543
517
|
try {
|
544
518
|
if (closeDialogData) {
|
545
519
|
var retentionTitle = document.getElementById('ams-component-retention-title');
|
@@ -610,7 +584,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
610
584
|
*/
|
611
585
|
}, {
|
612
586
|
key: "dispatchToApp",
|
613
|
-
value: function dispatchToApp(
|
587
|
+
value: function dispatchToApp(payload) {
|
588
|
+
var data = Object.assign({}, payload, {
|
589
|
+
name: messageName.SDK_TO_APP,
|
590
|
+
mode: this.AMSSDK.options.mode,
|
591
|
+
appId: COMPONENTPLUGINID,
|
592
|
+
instanceId: this.AMSSDK._instanceId
|
593
|
+
});
|
614
594
|
if (this.app && this.app.contentWindow) {
|
615
595
|
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
|
616
596
|
}
|
@@ -638,7 +618,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
638
618
|
key: "sendRenderEvent",
|
639
619
|
value: function () {
|
640
620
|
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
641
|
-
var _this$
|
621
|
+
var _this$_renderParams, _this$_renderParams2, res;
|
642
622
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
643
623
|
while (1) switch (_context.prev = _context.next) {
|
644
624
|
case 0:
|
@@ -658,16 +638,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
658
638
|
value: Date.now()
|
659
639
|
});
|
660
640
|
this.dispatchToApp({
|
661
|
-
name: messageName.SDK_TO_APP,
|
662
|
-
mode: this.AMSSDK.options.mode,
|
663
|
-
appId: COMPONENTPLUGINID,
|
664
|
-
instanceId: this.AMSSDK._instanceId,
|
665
641
|
context: {
|
666
642
|
event: 'renderComponent',
|
667
643
|
data: {
|
668
644
|
queryResult: res,
|
669
|
-
sessionResult: (_this$
|
670
|
-
paymentSessionData: (_this$
|
645
|
+
sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
|
646
|
+
paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
|
671
647
|
heightOfVisible: Math.max(innerHeight, window.innerHeight),
|
672
648
|
envInfo: {
|
673
649
|
screenHeight: screen.height,
|
@@ -677,10 +653,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
677
653
|
}
|
678
654
|
});
|
679
655
|
this.dispatchToApp({
|
680
|
-
name: messageName.SDK_TO_APP,
|
681
|
-
mode: this.AMSSDK.options.mode,
|
682
|
-
appId: COMPONENTPLUGINID,
|
683
|
-
instanceId: this.AMSSDK._instanceId,
|
684
656
|
context: {
|
685
657
|
event: 'web-sdk-performance',
|
686
658
|
data: {
|
@@ -803,7 +775,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
803
775
|
var _this5 = this;
|
804
776
|
var container = document.getElementById('ams-component-container');
|
805
777
|
// close btn
|
806
|
-
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"
|
778
|
+
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
807
779
|
var closeBlock = document.createElement('div');
|
808
780
|
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
|
809
781
|
closeBlock.id = 'asm-component-section-close-block';
|
@@ -12,4 +12,4 @@ import { RequestConfig } from '../types';
|
|
12
12
|
* @param options 请求配置
|
13
13
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
14
14
|
*/
|
15
|
-
export declare function request(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<
|
15
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<T>;
|
@@ -15,11 +15,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
17
|
|
18
|
-
import {
|
18
|
+
import { sdkVersion } from "../config/index";
|
19
|
+
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
19
20
|
import { ERROR } from "../types";
|
20
21
|
import { get } from "../util/get";
|
21
22
|
import axios from 'axios';
|
22
|
-
import json from "../../package.json";
|
23
23
|
import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
|
24
24
|
var _queryParse = queryParse(),
|
25
25
|
_sandbox = _queryParse._sandbox;
|
@@ -35,7 +35,7 @@ function requestInstance(options) {
|
|
35
35
|
var _headers = _objectSpread((_objectSpread2 = {
|
36
36
|
appId: lightSandboxConfig.appId || appId,
|
37
37
|
workspaceId: options.env === 'pre' ? 'pre' : 'default'
|
38
|
-
}, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version',
|
38
|
+
}, _defineProperty(_objectSpread2, "x-cors-".concat(appId.toLowerCase(), "-default"), '1'), _defineProperty(_objectSpread2, "version", '2.0'), _defineProperty(_objectSpread2, 'sofa-group-name', lightSandboxConfig.sofaId || sofaId), _defineProperty(_objectSpread2, 'Operation-Type', lightSandboxConfig['Operation-Type'] || options['Operation-Type'] || ''), _defineProperty(_objectSpread2, 'Client-Time', utcTimestamp), _defineProperty(_objectSpread2, "tntInstId", tntInstId), _defineProperty(_objectSpread2, 'sdk-version', sdkVersion || ''), _objectSpread2), options.headers);
|
39
39
|
// sandbox 影子链路
|
40
40
|
if (_sandbox === 'true' || env === 'sandbox') {
|
41
41
|
_headers['load-test'] = true;
|
@@ -130,11 +130,11 @@ function _request() {
|
|
130
130
|
});
|
131
131
|
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
|
132
132
|
errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
|
133
|
-
return _context.abrupt("return", {
|
133
|
+
return _context.abrupt("return", Promise.reject({
|
134
134
|
success: false,
|
135
135
|
errorCode: errorCode,
|
136
136
|
errorMessage: ''
|
137
|
-
});
|
137
|
+
}));
|
138
138
|
case 28:
|
139
139
|
case "end":
|
140
140
|
return _context.stop();
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { RequestConfig } from '../types';
|
2
|
-
export declare function queryPaymentInfo(params?:
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
|
2
|
+
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;
|
@@ -11,7 +11,6 @@
|
|
11
11
|
export interface optionsParams {
|
12
12
|
environment?: string;
|
13
13
|
locale?: string;
|
14
|
-
onReady?: any;
|
15
14
|
onError?: callOnError;
|
16
15
|
onSizeChanged?: callOnSizeChanged;
|
17
16
|
onPaymentMethodSelected?: callonPaymentMethodSelected;
|
@@ -33,10 +32,12 @@ export interface createPaymentParams {
|
|
33
32
|
backgroundColor?: string;
|
34
33
|
};
|
35
34
|
}
|
36
|
-
export declare enum
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
35
|
+
export declare enum componentSignEnum {
|
36
|
+
'EASY_PAY_WALLET' = "EASY_PAY_WALLET",
|
37
|
+
'CASHIER_PAYMENT_CARD' = "CASHIER_PAYMENT_CARD",
|
38
|
+
'CASHIER_PAYMENT_BANK' = "CASHIER_PAYMENT_BANK",
|
39
|
+
'AUTO_DEBIT_WALLET' = "AUTO_DEBIT_WALLET",
|
40
|
+
'NONE' = "NONE"
|
40
41
|
}
|
41
42
|
export declare enum productSceneEnum {
|
42
43
|
'EASY_PAY' = "EASY_PAY",
|
@@ -45,7 +46,8 @@ export declare enum productSceneEnum {
|
|
45
46
|
}
|
46
47
|
export declare enum paymentMethodCategoryTypeEnum {
|
47
48
|
'CARD' = "CARD",
|
48
|
-
'WALLET' = "WALLET"
|
49
|
+
'WALLET' = "WALLET",
|
50
|
+
'BANK' = "BANK"
|
49
51
|
}
|
50
52
|
export interface IcreateComponent {
|
51
53
|
paymentSessionData: string;
|
@@ -55,12 +57,13 @@ export interface IcreateComponent {
|
|
55
57
|
export interface IappendIframeNodesParams extends IcreateComponent {
|
56
58
|
paymentSessionMetaData?: IpaymentSessionMetaData;
|
57
59
|
}
|
60
|
+
interface IpaymentSessionConfig {
|
61
|
+
productScene: productSceneEnum;
|
62
|
+
paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
|
63
|
+
productSceneVersion: string;
|
64
|
+
}
|
58
65
|
export interface IpaymentSessionMetaData {
|
59
|
-
paymentSessionConfig?:
|
60
|
-
productScene: productSceneEnum;
|
61
|
-
paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
|
62
|
-
productSceneVersion?: string;
|
63
|
-
};
|
66
|
+
paymentSessionConfig?: IpaymentSessionConfig;
|
64
67
|
moneyView?: any;
|
65
68
|
extendInfo?: string;
|
66
69
|
paymentMethodInfoView?: any;
|
@@ -119,7 +122,10 @@ export type callOnSizeChanged = (state: {
|
|
119
122
|
width: string;
|
120
123
|
height: string;
|
121
124
|
}) => void;
|
122
|
-
export type callOnLog = (
|
125
|
+
export type callOnLog = (state: {
|
126
|
+
code: string;
|
127
|
+
message: string;
|
128
|
+
}) => void;
|
123
129
|
export declare enum messageName {
|
124
130
|
SDK_TO_APP = "SDK_TO_APP",
|
125
131
|
APP_TO_SDK = "APP_TO_SDK",
|
@@ -142,7 +148,7 @@ export interface AMSCheckoutOptions {
|
|
142
148
|
mode: string;
|
143
149
|
analytics?: Ianalytics;
|
144
150
|
}
|
145
|
-
interface Ianalytics {
|
151
|
+
export interface Ianalytics {
|
146
152
|
enabled: boolean;
|
147
153
|
}
|
148
154
|
export declare enum ERROR {
|
@@ -175,6 +181,29 @@ export interface RequestConfig {
|
|
175
181
|
locale?: string;
|
176
182
|
hostSign?: string;
|
177
183
|
}
|
184
|
+
export interface CashierSdkActionQueryRequest {
|
185
|
+
paymentSessionData: string;
|
186
|
+
paymentSessionConfig?: IpaymentSessionConfig;
|
187
|
+
paymentMethodType?: string;
|
188
|
+
extParams?: any;
|
189
|
+
}
|
190
|
+
export interface CashierSdkActionQueryResult {
|
191
|
+
supportedLanguages?: any[];
|
192
|
+
amountConfirmRequired?: boolean;
|
193
|
+
orderAmount?: Record<string, string>;
|
194
|
+
paymentMethodView?: Record<string, string>;
|
195
|
+
autoDebitWithToken?: boolean;
|
196
|
+
success: boolean;
|
197
|
+
errorCode?: string;
|
198
|
+
errorMessage?: string;
|
199
|
+
message?: string;
|
200
|
+
errorStatus?: string;
|
201
|
+
redirectUrl?: string;
|
202
|
+
normalUrl?: string;
|
203
|
+
applinkUrl?: string;
|
204
|
+
schemeUrl?: string;
|
205
|
+
authUrl?: string;
|
206
|
+
}
|
178
207
|
declare global {
|
179
208
|
interface Window {
|
180
209
|
[key: string]: any;
|
package/dist/esm/types/index.js
CHANGED
@@ -10,11 +10,13 @@
|
|
10
10
|
* SDK options
|
11
11
|
*/
|
12
12
|
|
13
|
-
export var
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
|
14
|
+
componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
|
15
|
+
componentSignEnum["CASHIER_PAYMENT_CARD"] = "CASHIER_PAYMENT_CARD";
|
16
|
+
componentSignEnum["CASHIER_PAYMENT_BANK"] = "CASHIER_PAYMENT_BANK";
|
17
|
+
componentSignEnum["AUTO_DEBIT_WALLET"] = "AUTO_DEBIT_WALLET";
|
18
|
+
componentSignEnum["NONE"] = "NONE";
|
19
|
+
return componentSignEnum;
|
18
20
|
}({});
|
19
21
|
export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
20
22
|
productSceneEnum["EASY_PAY"] = "EASY_PAY";
|
@@ -25,6 +27,7 @@ export var productSceneEnum = /*#__PURE__*/function (productSceneEnum) {
|
|
25
27
|
export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodCategoryTypeEnum) {
|
26
28
|
paymentMethodCategoryTypeEnum["CARD"] = "CARD";
|
27
29
|
paymentMethodCategoryTypeEnum["WALLET"] = "WALLET";
|
30
|
+
paymentMethodCategoryTypeEnum["BANK"] = "BANK";
|
28
31
|
return paymentMethodCategoryTypeEnum;
|
29
32
|
}({});
|
30
33
|
export var localeEnum = /*#__PURE__*/function (localeEnum) {
|
package/dist/esm/util/index.js
CHANGED
@@ -230,6 +230,6 @@ var queryParse = function queryParse(url) {
|
|
230
230
|
var getDesignFontSize = function getDesignFontSize() {
|
231
231
|
var screenWidth = document.documentElement.clientWidth;
|
232
232
|
var currentFontSize = isPC() ? 100 : screenWidth * 100 / 390;
|
233
|
-
return currentFontSize;
|
233
|
+
return Math.min(currentFontSize, 100);
|
234
234
|
};
|
235
235
|
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize };
|