@alipay/ams-checkout 0.0.1756987734-dev.2 → 0.0.1757298389-dev.1
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/component/component.popup.style.d.ts +0 -1
- package/esm/component/component.popup.style.js +1 -1
- package/esm/component/popupWindow.style.d.ts +18 -9
- package/esm/component/popupWindow.style.js +21 -11
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +0 -9
- package/esm/constant/index.js +0 -11
- package/esm/core/component/element/elementController/index.d.ts +8 -0
- package/esm/core/component/element/elementController/index.js +156 -90
- package/esm/core/component/element/index.d.ts +3 -0
- package/esm/core/component/element/index.js +5 -0
- package/esm/core/component/element/type.d.ts +2 -1
- package/esm/core/component/element/type.js +2 -1
- package/esm/core/component/index.d.ts +1 -3
- package/esm/core/component/index.js +1 -83
- package/esm/foundation/service/container/popup.d.ts +11 -0
- package/esm/foundation/service/container/popup.js +23 -2
- package/esm/index.d.ts +1 -10
- package/esm/index.js +1 -15
- package/esm/plugin/component/index.d.ts +0 -2
- package/esm/plugin/component/index.js +7 -15
- package/esm/plugin/paypal/index.js +2 -5
- package/esm/types/index.d.ts +0 -3
- package/package.json +2 -2
@@ -49,10 +49,24 @@ var ElementController = /*#__PURE__*/function () {
|
|
49
49
|
_defineProperty(this, "elementContainerService", void 0);
|
50
50
|
// 新增变量
|
51
51
|
_defineProperty(this, "onStatusChangeCallback", void 0);
|
52
|
-
_defineProperty(this, "onValidateFunc", function (event, target
|
52
|
+
_defineProperty(this, "onValidateFunc", function (event, target) {
|
53
53
|
return new Promise(function (resolve) {
|
54
54
|
event.emitAndListen({
|
55
55
|
event: ElementPaymentEvent.VALIDATE,
|
56
|
+
data: {
|
57
|
+
params: {},
|
58
|
+
target: target,
|
59
|
+
source: ElementPaymentMethod.CONTAINER_ELEMENT
|
60
|
+
}
|
61
|
+
}, function (result) {
|
62
|
+
resolve(result);
|
63
|
+
});
|
64
|
+
});
|
65
|
+
});
|
66
|
+
_defineProperty(this, "onValidateAndSubmitPay", function (event, target, params) {
|
67
|
+
return new Promise(function (resolve) {
|
68
|
+
event.emitAndListen({
|
69
|
+
event: ElementPaymentEvent.SUBMIT_PAY,
|
56
70
|
data: {
|
57
71
|
params: _objectSpread({}, params),
|
58
72
|
target: target,
|
@@ -188,75 +202,127 @@ var ElementController = /*#__PURE__*/function () {
|
|
188
202
|
});
|
189
203
|
}
|
190
204
|
}, {
|
191
|
-
key: "
|
192
|
-
value:
|
205
|
+
key: "validateFields",
|
206
|
+
value:
|
207
|
+
/**
|
208
|
+
* 25/09/08 新增商户主动校验api
|
209
|
+
* @returns {Promise<{isValid: boolean}>}
|
210
|
+
*/
|
211
|
+
function validateFields() {
|
193
212
|
var _this3 = this;
|
194
|
-
|
195
|
-
new Promise( /*#__PURE__*/function () {
|
213
|
+
return new Promise( /*#__PURE__*/function () {
|
196
214
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resolve) {
|
197
|
-
var
|
215
|
+
var _this3$elementProcess;
|
216
|
+
var _this3$elementProcess2, validateResult;
|
198
217
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
199
218
|
while (1) switch (_context.prev = _context.next) {
|
200
219
|
case 0:
|
201
|
-
|
202
|
-
|
203
|
-
_context.next = 8;
|
220
|
+
if (!((_this3$elementProcess = _this3.elementProcessors) !== null && _this3$elementProcess !== void 0 && _this3$elementProcess[ElementType.payment])) {
|
221
|
+
_context.next = 13;
|
204
222
|
break;
|
205
223
|
}
|
224
|
+
_context.prev = 1;
|
206
225
|
_context.next = 4;
|
207
|
-
return _this3.onValidateFunc((_this3$
|
226
|
+
return _this3.onValidateFunc((_this3$elementProcess2 = _this3.elementProcessors[ElementType.payment]) === null || _this3$elementProcess2 === void 0 ? void 0 : _this3$elementProcess2.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT);
|
227
|
+
case 4:
|
228
|
+
validateResult = _context.sent;
|
229
|
+
return _context.abrupt("return", resolve({
|
230
|
+
isValid: validateResult.data.success
|
231
|
+
}));
|
232
|
+
case 8:
|
233
|
+
_context.prev = 8;
|
234
|
+
_context.t0 = _context["catch"](1);
|
235
|
+
return _context.abrupt("return", resolve({
|
236
|
+
isValid: false
|
237
|
+
}));
|
238
|
+
case 11:
|
239
|
+
_context.next = 14;
|
240
|
+
break;
|
241
|
+
case 13:
|
242
|
+
return _context.abrupt("return", resolve({
|
243
|
+
isValid: false
|
244
|
+
}));
|
245
|
+
case 14:
|
246
|
+
case "end":
|
247
|
+
return _context.stop();
|
248
|
+
}
|
249
|
+
}, _callee, null, [[1, 8]]);
|
250
|
+
}));
|
251
|
+
return function (_x) {
|
252
|
+
return _ref2.apply(this, arguments);
|
253
|
+
};
|
254
|
+
}());
|
255
|
+
}
|
256
|
+
}, {
|
257
|
+
key: "submitPayment",
|
258
|
+
value: function submitPayment() {
|
259
|
+
var _this4 = this;
|
260
|
+
this.changeLoading(true);
|
261
|
+
new Promise( /*#__PURE__*/function () {
|
262
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve) {
|
263
|
+
var params, _this4$elementProcess, _result$data, _result$data2, result, _this4$elementProcess2, _result$data3, _result$data4, _result, _this4$elementProcess3;
|
264
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
265
|
+
while (1) switch (_context2.prev = _context2.next) {
|
266
|
+
case 0:
|
267
|
+
params = {};
|
268
|
+
if (!_this4.elementProcessors[ElementType.auth]) {
|
269
|
+
_context2.next = 8;
|
270
|
+
break;
|
271
|
+
}
|
272
|
+
_context2.next = 4;
|
273
|
+
return _this4.onValidateAndSubmitPay((_this4$elementProcess = _this4.elementProcessors[ElementType.auth]) === null || _this4$elementProcess === void 0 ? void 0 : _this4$elementProcess.eventCenter, ElementPaymentMethod.AUTH_ELEMENT);
|
208
274
|
case 4:
|
209
|
-
result =
|
275
|
+
result = _context2.sent;
|
210
276
|
params.accountInfo = (_result$data = result.data) === null || _result$data === void 0 || (_result$data = _result$data.data) === null || _result$data === void 0 ? void 0 : _result$data.accountInfo;
|
211
277
|
if (result !== null && result !== void 0 && (_result$data2 = result.data) !== null && _result$data2 !== void 0 && _result$data2.success) {
|
212
|
-
|
278
|
+
_context2.next = 8;
|
213
279
|
break;
|
214
280
|
}
|
215
|
-
return
|
281
|
+
return _context2.abrupt("return", resolve(undefined));
|
216
282
|
case 8:
|
217
|
-
if (!
|
218
|
-
|
283
|
+
if (!_this4.elementProcessors[ElementType.address]) {
|
284
|
+
_context2.next = 15;
|
219
285
|
break;
|
220
286
|
}
|
221
|
-
|
222
|
-
return
|
287
|
+
_context2.next = 11;
|
288
|
+
return _this4.onValidateAndSubmitPay((_this4$elementProcess2 = _this4.elementProcessors[ElementType.address]) === null || _this4$elementProcess2 === void 0 ? void 0 : _this4$elementProcess2.eventCenter, ElementPaymentMethod.ADDRESS_ELEMENT);
|
223
289
|
case 11:
|
224
|
-
_result =
|
290
|
+
_result = _context2.sent;
|
225
291
|
params.shipping = (_result$data3 = _result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
226
292
|
if (_result !== null && _result !== void 0 && (_result$data4 = _result.data) !== null && _result$data4 !== void 0 && _result$data4.success) {
|
227
|
-
|
293
|
+
_context2.next = 15;
|
228
294
|
break;
|
229
295
|
}
|
230
|
-
return
|
296
|
+
return _context2.abrupt("return", resolve(undefined));
|
231
297
|
case 15:
|
232
|
-
if (!
|
233
|
-
|
298
|
+
if (!_this4.elementProcessors[ElementType.payment]) {
|
299
|
+
_context2.next = 25;
|
234
300
|
break;
|
235
301
|
}
|
236
|
-
|
237
|
-
|
238
|
-
return
|
302
|
+
_context2.prev = 16;
|
303
|
+
_context2.next = 19;
|
304
|
+
return _this4.onValidateAndSubmitPay((_this4$elementProcess3 = _this4.elementProcessors[ElementType.payment]) === null || _this4$elementProcess3 === void 0 ? void 0 : _this4$elementProcess3.eventCenter, ElementPaymentMethod.PAYMENT_ELEMENT, params);
|
239
305
|
case 19:
|
240
|
-
return
|
306
|
+
return _context2.abrupt("return", resolve(undefined));
|
241
307
|
case 22:
|
242
|
-
|
243
|
-
|
244
|
-
return
|
308
|
+
_context2.prev = 22;
|
309
|
+
_context2.t0 = _context2["catch"](16);
|
310
|
+
return _context2.abrupt("return", resolve(undefined));
|
245
311
|
case 25:
|
246
312
|
resolve(params);
|
247
313
|
case 26:
|
248
314
|
case "end":
|
249
|
-
return
|
315
|
+
return _context2.stop();
|
250
316
|
}
|
251
|
-
},
|
317
|
+
}, _callee2, null, [[16, 22]]);
|
252
318
|
}));
|
253
|
-
return function (
|
254
|
-
return
|
319
|
+
return function (_x2) {
|
320
|
+
return _ref3.apply(this, arguments);
|
255
321
|
};
|
256
322
|
}()).then(function () {
|
257
|
-
|
323
|
+
_this4.changeLoading(false);
|
258
324
|
}, function () {
|
259
|
-
|
325
|
+
_this4.changeLoading(false);
|
260
326
|
});
|
261
327
|
}
|
262
328
|
}, {
|
@@ -281,21 +347,21 @@ var ElementController = /*#__PURE__*/function () {
|
|
281
347
|
}, {
|
282
348
|
key: "addEventListener",
|
283
349
|
value: function addEventListener(renderCallback) {
|
284
|
-
var
|
350
|
+
var _this5 = this;
|
285
351
|
this.serviceMap.EventCenter.listen(ElementPaymentEvent.ON_EVENT_CALLBACK, function (data) {
|
286
|
-
var
|
287
|
-
(
|
352
|
+
var _this5$onEventCallbac;
|
353
|
+
(_this5$onEventCallbac = _this5.onEventCallback) === null || _this5$onEventCallbac === void 0 || _this5$onEventCallbac.call(_this5, data);
|
288
354
|
});
|
289
355
|
this.serviceMap.EventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
290
|
-
clearTimeout(
|
291
|
-
|
292
|
-
if (
|
356
|
+
clearTimeout(_this5.initTimeout);
|
357
|
+
_this5.initTimeout = null;
|
358
|
+
if (_this5.elementContainerService.getContainerService(data.source)) {
|
293
359
|
renderCallback({
|
294
360
|
success: true
|
295
361
|
});
|
296
|
-
|
362
|
+
_this5.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
297
363
|
}
|
298
|
-
|
364
|
+
_this5.changeLoading(false);
|
299
365
|
// 遍历containerService中的所有container查看是否所有状态都是IN_BIZ_FLOW
|
300
366
|
// const allContainersInBizFlow = Object.values(this.elementContainerService.getContainerServices()).every(
|
301
367
|
// (containerService) => containerService.getContainerStatus() === IContainerStatus.IN_BIZ_FLOW,
|
@@ -305,22 +371,22 @@ var ElementController = /*#__PURE__*/function () {
|
|
305
371
|
// }
|
306
372
|
});
|
307
373
|
this.serviceMap.EventCenter.listen(EVENT.redirect.name, function (data) {
|
308
|
-
var onEventCallback =
|
374
|
+
var onEventCallback = _this5.onEventCallback.bind(_this5);
|
309
375
|
handleRedirect(data, false, onEventCallback);
|
310
376
|
});
|
311
377
|
this.serviceMap.EventCenter.listen(EVENT.destroy.name, function () {
|
312
|
-
|
313
|
-
|
378
|
+
_this5.setControllerStatusOrView(IElementStatus.READY);
|
379
|
+
_this5.destroyHandle();
|
314
380
|
});
|
315
381
|
this.serviceMap.EventCenter.listen(EVENT.webAppReady.name, function (data) {
|
316
|
-
clearTimeout(
|
317
|
-
if (
|
382
|
+
clearTimeout(_this5.initTimeout);
|
383
|
+
if (_this5.elementContainerService.getContainerService(data.source)) {
|
318
384
|
renderCallback({
|
319
385
|
success: true
|
320
386
|
});
|
321
|
-
|
387
|
+
_this5.elementContainerService.getContainerService(data.source).switchContainerStatus(IContainerStatus.IN_BIZ_FLOW);
|
322
388
|
}
|
323
|
-
|
389
|
+
_this5.changeLoading(false);
|
324
390
|
});
|
325
391
|
this.serviceMap.EventCenter.listen(EVENT.showToast.name, function (data) {
|
326
392
|
showToast(data);
|
@@ -328,8 +394,8 @@ var ElementController = /*#__PURE__*/function () {
|
|
328
394
|
this.serviceMap.EventCenter.listen(EVENT.messageForward.name, function (data) {
|
329
395
|
var source = MountElementType[data.source];
|
330
396
|
var target = MountElementType[data.target];
|
331
|
-
if (
|
332
|
-
|
397
|
+
if (_this5.elementProcessors[source] && _this5.elementProcessors[target]) {
|
398
|
+
_this5.elementProcessors[target].eventCenter.dispatchToApp({
|
333
399
|
event: data.event,
|
334
400
|
data: data
|
335
401
|
});
|
@@ -339,24 +405,24 @@ var ElementController = /*#__PURE__*/function () {
|
|
339
405
|
}, {
|
340
406
|
key: "sendRequestAndWaitWebLaunch",
|
341
407
|
value: function sendRequestAndWaitWebLaunch(renderOptions) {
|
342
|
-
var
|
408
|
+
var _this6 = this;
|
343
409
|
var type = renderOptions.type,
|
344
410
|
options = _objectWithoutProperties(renderOptions, _excluded);
|
345
411
|
var webLaunchPromise = this.elementContainerService.getContainerService(type).createWebLaunchPromise();
|
346
|
-
Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (
|
347
|
-
var
|
348
|
-
var
|
349
|
-
_webLaunchRes =
|
350
|
-
_obtainDataRes =
|
351
|
-
(
|
412
|
+
Promise.all([webLaunchPromise, this.elementProcessors[type].obtainData()]).then(function (_ref4) {
|
413
|
+
var _this6$elementContain;
|
414
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
415
|
+
_webLaunchRes = _ref5[0],
|
416
|
+
_obtainDataRes = _ref5[1];
|
417
|
+
(_this6$elementContain = _this6.elementContainerService.getContainerService(type)) === null || _this6$elementContain === void 0 || _this6$elementContain.switchContainerStatus(IContainerStatus.READY);
|
352
418
|
var allReady = true;
|
353
|
-
|
419
|
+
_this6.elementContainerService.getContainerServices().forEach(function (item) {
|
354
420
|
if (!allReady) return;
|
355
421
|
allReady = item.getContainerStatus() === IContainerStatus.READY;
|
356
422
|
});
|
357
423
|
if (allReady) {
|
358
|
-
|
359
|
-
|
424
|
+
_this6.elementContainerService.getContainerServices().forEach(function (value, key) {
|
425
|
+
_this6.sendReady(key, options);
|
360
426
|
});
|
361
427
|
}
|
362
428
|
});
|
@@ -392,37 +458,37 @@ var ElementController = /*#__PURE__*/function () {
|
|
392
458
|
}, {
|
393
459
|
key: "updatePayment",
|
394
460
|
value: function () {
|
395
|
-
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
396
|
-
var
|
397
|
-
return _regeneratorRuntime().wrap(function
|
398
|
-
while (1) switch (
|
461
|
+
var _updatePayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(paymentSessionData) {
|
462
|
+
var _this7 = this;
|
463
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
464
|
+
while (1) switch (_context4.prev = _context4.next) {
|
399
465
|
case 0:
|
400
|
-
return
|
401
|
-
var
|
466
|
+
return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
|
467
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
402
468
|
var prePaymentSessionData, data, LOCAL_MOCK;
|
403
|
-
return _regeneratorRuntime().wrap(function
|
404
|
-
while (1) switch (
|
469
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
470
|
+
while (1) switch (_context3.prev = _context3.next) {
|
405
471
|
case 0:
|
406
472
|
if (checkCanUpdate({
|
407
|
-
status:
|
408
|
-
paymentContainerService:
|
473
|
+
status: _this7.elementContainer.getStatus(),
|
474
|
+
paymentContainerService: _this7.elementContainerService.getContainerService(ElementType.payment),
|
409
475
|
newPaymentSessionData: paymentSessionData,
|
410
|
-
oldPaymentSessionData:
|
476
|
+
oldPaymentSessionData: _this7.options.sessionData
|
411
477
|
})) {
|
412
|
-
|
478
|
+
_context3.next = 2;
|
413
479
|
break;
|
414
480
|
}
|
415
|
-
return
|
481
|
+
return _context3.abrupt("return", resolve(false));
|
416
482
|
case 2:
|
417
|
-
prePaymentSessionData =
|
418
|
-
|
483
|
+
prePaymentSessionData = _this7.elementContainer.getPaymentContext().paymentSession;
|
484
|
+
_this7.elementContainer.updatePaymentSessionData(paymentSessionData);
|
419
485
|
// 1、数据获取
|
420
|
-
|
421
|
-
return
|
486
|
+
_context3.next = 6;
|
487
|
+
return _this7.elementProcessors[ElementType.payment].obtainData();
|
422
488
|
case 6:
|
423
|
-
data =
|
489
|
+
data = _context3.sent;
|
424
490
|
LOCAL_MOCK = window.location.href.indexOf('LOCAL_MOCK=1') !== -1; // 2、发送update消息
|
425
|
-
Object.values(
|
491
|
+
Object.values(_this7.elementProcessors).forEach(function (processor) {
|
426
492
|
processor.update({
|
427
493
|
data: {
|
428
494
|
originActionQueryResult: LOCAL_MOCK ? sdkActionUpdate : data.originActionQueryResult,
|
@@ -432,30 +498,30 @@ var ElementController = /*#__PURE__*/function () {
|
|
432
498
|
});
|
433
499
|
});
|
434
500
|
// 3、返回更新结果
|
435
|
-
|
501
|
+
_this7.serviceMap.EventCenter.listen(EVENT.updated.name, function (data) {
|
436
502
|
// 若更新不成功,还原core.paymentContext信息
|
437
503
|
if (!data.success) {
|
438
|
-
|
504
|
+
_this7.elementContainer.updatePaymentSessionData(prePaymentSessionData);
|
439
505
|
}
|
440
506
|
return resolve(data.success || false);
|
441
507
|
});
|
442
508
|
case 10:
|
443
509
|
case "end":
|
444
|
-
return
|
510
|
+
return _context3.stop();
|
445
511
|
}
|
446
|
-
},
|
512
|
+
}, _callee3);
|
447
513
|
}));
|
448
|
-
return function (
|
449
|
-
return
|
514
|
+
return function (_x4) {
|
515
|
+
return _ref6.apply(this, arguments);
|
450
516
|
};
|
451
517
|
}()));
|
452
518
|
case 1:
|
453
519
|
case "end":
|
454
|
-
return
|
520
|
+
return _context4.stop();
|
455
521
|
}
|
456
|
-
},
|
522
|
+
}, _callee4);
|
457
523
|
}));
|
458
|
-
function updatePayment(
|
524
|
+
function updatePayment(_x3) {
|
459
525
|
return _updatePayment.apply(this, arguments);
|
460
526
|
}
|
461
527
|
return updatePayment;
|
@@ -7,6 +7,9 @@ export declare class ElementComponent {
|
|
7
7
|
mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
|
8
8
|
mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
|
9
9
|
mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
|
10
|
+
validateFields(): Promise<{
|
11
|
+
isValid: boolean;
|
12
|
+
}>;
|
10
13
|
submitPayment(): void;
|
11
14
|
destroy(): void;
|
12
15
|
}
|
@@ -49,6 +49,11 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
49
49
|
appearance: this === null || this === void 0 || (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.appearance
|
50
50
|
}, renderOptions), sdkSelector);
|
51
51
|
}
|
52
|
+
}, {
|
53
|
+
key: "validateFields",
|
54
|
+
value: function validateFields() {
|
55
|
+
return this.controller.validateFields();
|
56
|
+
}
|
52
57
|
}, {
|
53
58
|
key: "submitPayment",
|
54
59
|
value: function submitPayment() {
|
@@ -10,7 +10,8 @@ export declare enum ElementPaymentEvent {
|
|
10
10
|
CAPTURE_ASSET = "onCaptureAsset",
|
11
11
|
SIGN_OUT = "onSignout",
|
12
12
|
BLUR = "onBlur",
|
13
|
-
|
13
|
+
SUBMIT_PAY = "submitPay",
|
14
|
+
VALIDATE = "onValidate",
|
14
15
|
SUBMIT_RISK = "onSubmitRisk",
|
15
16
|
AFTER_SUBMIT = "onAfterSubmit",
|
16
17
|
SIZE_CHANGE = "onSizeChange",
|
@@ -10,7 +10,8 @@ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
|
|
10
10
|
ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
|
11
11
|
ElementPaymentEvent["SIGN_OUT"] = "onSignout";
|
12
12
|
ElementPaymentEvent["BLUR"] = "onBlur";
|
13
|
-
ElementPaymentEvent["
|
13
|
+
ElementPaymentEvent["SUBMIT_PAY"] = "submitPay";
|
14
|
+
ElementPaymentEvent["VALIDATE"] = "onValidate";
|
14
15
|
ElementPaymentEvent["SUBMIT_RISK"] = "onSubmitRisk";
|
15
16
|
ElementPaymentEvent["AFTER_SUBMIT"] = "onAfterSubmit";
|
16
17
|
ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import ComponentApp from '../../plugin/component';
|
2
|
-
import { ComponentSignEnum,
|
2
|
+
import { ComponentSignEnum, IappendIframeNodesParams, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
|
3
3
|
import CoreInstance from '../instance/index';
|
4
4
|
export declare const getComponentSign: (params: IPaymentSessionMetaData) => ComponentSignEnum;
|
5
5
|
export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
|
@@ -52,6 +52,4 @@ export declare class AMSComponent extends CoreInstance {
|
|
52
52
|
* @param data - Transfer information in the submission interface according to your requirements (optional)
|
53
53
|
*/
|
54
54
|
submit(data?: Isubmit): Promise<unknown>;
|
55
|
-
protected _validateFields(): Promise<ValidationResult>;
|
56
|
-
protected _sendMessageToAPP(eventContext: EventPayloadContext): void;
|
57
55
|
}
|
@@ -35,7 +35,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
35
35
|
* 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.
|
36
36
|
*/
|
37
37
|
import { v4 as uuid } from 'uuid';
|
38
|
-
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT
|
38
|
+
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
39
39
|
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
40
40
|
import ComponentApp from "../../plugin/component";
|
41
41
|
import { ExtendPlugin } from "../../plugin/const";
|
@@ -526,88 +526,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
526
526
|
}
|
527
527
|
});
|
528
528
|
}
|
529
|
-
|
530
|
-
// 预留给AMSVaulting复用
|
531
|
-
}, {
|
532
|
-
key: "_validateFields",
|
533
|
-
value: function _validateFields() {
|
534
|
-
var _this9 = this;
|
535
|
-
return new Promise(function (resolve) {
|
536
|
-
// 收银台应用渲染表单后,才允许发送校验消息,三端约定一致
|
537
|
-
if (!_this9._componentApp.shouldValidateFields()) {
|
538
|
-
resolve({
|
539
|
-
isValid: false
|
540
|
-
});
|
541
|
-
_this9.logger.logInfo({
|
542
|
-
title: 'sdk_event_validateFields'
|
543
|
-
}, {
|
544
|
-
processResult: 'notRenderComponent'
|
545
|
-
});
|
546
|
-
return;
|
547
|
-
}
|
548
|
-
var timeoutId;
|
549
|
-
var validationPromise = new Promise(function (validationResolve) {
|
550
|
-
// 发送validateFields消息
|
551
|
-
_this9._sendMessageToAPP({
|
552
|
-
event: SENDEVENT.validateFields.name,
|
553
|
-
data: {}
|
554
|
-
});
|
555
|
-
// 接收收银台应用的返回validateFieldsResult消息
|
556
|
-
_this9._overrideSubscription(EVENT.validateFieldsResult.name, /*#__PURE__*/function () {
|
557
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
|
558
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
559
|
-
while (1) switch (_context2.prev = _context2.next) {
|
560
|
-
case 0:
|
561
|
-
_this9.logger.logInfo({
|
562
|
-
title: 'sdk_event_validateFields'
|
563
|
-
}, {
|
564
|
-
processResult: payload.isValid ? 'true' : 'false'
|
565
|
-
});
|
566
|
-
// 收银台应用保证数据格式,三端SDK负责透传
|
567
|
-
validationResolve(payload);
|
568
|
-
case 2:
|
569
|
-
case "end":
|
570
|
-
return _context2.stop();
|
571
|
-
}
|
572
|
-
}, _callee2);
|
573
|
-
}));
|
574
|
-
return function (_x2) {
|
575
|
-
return _ref5.apply(this, arguments);
|
576
|
-
};
|
577
|
-
}(), EVENT.validateFieldsResult.uniqueKey);
|
578
|
-
});
|
579
|
-
|
580
|
-
// 兜底场景,三端约定超时时间15秒,兼容cpf网络校验超时场景
|
581
|
-
var timeoutPromise = new Promise(function (timeoutResolve) {
|
582
|
-
timeoutId = setTimeout(function () {
|
583
|
-
_this9.logger.logInfo({
|
584
|
-
title: 'sdk_event_validateFields'
|
585
|
-
}, {
|
586
|
-
processResult: 'timeout'
|
587
|
-
});
|
588
|
-
timeoutResolve({
|
589
|
-
isValid: false
|
590
|
-
});
|
591
|
-
}, 15000);
|
592
|
-
});
|
593
|
-
Promise.race([validationPromise, timeoutPromise]).then(function (result) {
|
594
|
-
clearTimeout(timeoutId);
|
595
|
-
resolve(result);
|
596
|
-
}).catch(function () {
|
597
|
-
clearTimeout(timeoutId);
|
598
|
-
resolve({
|
599
|
-
isValid: false
|
600
|
-
});
|
601
|
-
});
|
602
|
-
});
|
603
|
-
}
|
604
|
-
}, {
|
605
|
-
key: "_sendMessageToAPP",
|
606
|
-
value: function _sendMessageToAPP(eventContext) {
|
607
|
-
this._componentApp.dispatchToApp({
|
608
|
-
context: eventContext
|
609
|
-
});
|
610
|
-
}
|
611
529
|
}]);
|
612
530
|
return AMSComponent;
|
613
531
|
}(CoreInstance);
|
@@ -6,6 +6,11 @@ export type IPopUpParams = {
|
|
6
6
|
platform: PlatformEnum;
|
7
7
|
showCloseOnLoading: boolean;
|
8
8
|
onCloseOnLoading: () => void;
|
9
|
+
textDirection?: 'ltr' | 'rtl';
|
10
|
+
loadingConfig?: {
|
11
|
+
theme?: string;
|
12
|
+
backgroundPrimary?: string;
|
13
|
+
};
|
9
14
|
};
|
10
15
|
/**
|
11
16
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
@@ -15,6 +20,12 @@ export declare class PopupManager {
|
|
15
20
|
private popupUrlQuery;
|
16
21
|
popupApp: HTMLIFrameElement;
|
17
22
|
setPopupUrlQuery(queryParams: string): void;
|
23
|
+
/**
|
24
|
+
* 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
|
25
|
+
* @param baseUrl 基础URL
|
26
|
+
* @returns 合并后的URL
|
27
|
+
*/
|
28
|
+
private mergeUrlParams;
|
18
29
|
popup(data: IPopUpParams): Promise<void>;
|
19
30
|
pop(): void;
|
20
31
|
}
|
@@ -25,6 +25,26 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
25
25
|
value: function setPopupUrlQuery(queryParams) {
|
26
26
|
this.popupUrlQuery = queryParams;
|
27
27
|
}
|
28
|
+
/**
|
29
|
+
* 合并URL参数, 优先加载弹窗参数作为基准, 用baseUrl参数覆盖弹窗参数
|
30
|
+
* @param baseUrl 基础URL
|
31
|
+
* @returns 合并后的URL
|
32
|
+
*/
|
33
|
+
}, {
|
34
|
+
key: "mergeUrlParams",
|
35
|
+
value: function mergeUrlParams(baseUrl) {
|
36
|
+
var urlObj = new URL(baseUrl);
|
37
|
+
// 优先加载弹窗参数作为基准
|
38
|
+
var mergedParams = new URLSearchParams(this.popupUrlQuery.replace(/^(?:\?|%3F)/i, ''));
|
39
|
+
// 用baseUrl参数覆盖弹窗参数(set方法自动覆盖)
|
40
|
+
urlObj.searchParams.forEach(function (value, key) {
|
41
|
+
mergedParams.set(key, value);
|
42
|
+
});
|
43
|
+
// 将合并后的参数设置到URL对象中
|
44
|
+
urlObj.search = mergedParams.toString();
|
45
|
+
// 返回合并后的URL
|
46
|
+
return urlObj.toString();
|
47
|
+
}
|
28
48
|
}, {
|
29
49
|
key: "popup",
|
30
50
|
value: function () {
|
@@ -45,7 +65,7 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
45
65
|
pageUrl = data.url;
|
46
66
|
_context.prev = 6;
|
47
67
|
if (this.popupUrlQuery) {
|
48
|
-
pageUrl =
|
68
|
+
pageUrl = this.mergeUrlParams(data.url);
|
49
69
|
}
|
50
70
|
isLoad = false;
|
51
71
|
_context.next = 11;
|
@@ -55,7 +75,8 @@ export var PopupManager = /*#__PURE__*/function () {
|
|
55
75
|
url: pageUrl,
|
56
76
|
loadingConfig: undefined,
|
57
77
|
showCloseOnLoading: data.showCloseOnLoading,
|
58
|
-
onCloseOnLoading: data.onCloseOnLoading
|
78
|
+
onCloseOnLoading: data.onCloseOnLoading,
|
79
|
+
textDirection: data === null || data === void 0 ? void 0 : data.textDirection
|
59
80
|
});
|
60
81
|
case 11:
|
61
82
|
this.popupApp = _context.sent;
|
package/esm/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AddressComponent } from './core/component/address';
|
2
2
|
import { ElementComponent } from './core/component/element';
|
3
3
|
import { AMSComponent } from './core/component/index';
|
4
|
-
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions
|
4
|
+
import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
|
5
5
|
export { AMSCheckoutPage } from './core/component/ckp';
|
6
6
|
export * from './types';
|
7
7
|
export declare class AMSCheckout extends AMSComponent {
|
@@ -14,15 +14,6 @@ export declare class AMSAutoDebitPay extends AMSCheckout {
|
|
14
14
|
export declare class AMSCashierPayment extends AMSCheckout {
|
15
15
|
constructor(options: IoptionsParams);
|
16
16
|
static preload(options?: IPreloadOptions): void;
|
17
|
-
/**
|
18
|
-
* Form validation function
|
19
|
-
* If the form is currently displayed:
|
20
|
-
* - Successful validation: isValid is true
|
21
|
-
* - Failed validation: isValid is false, and error messages are displayed on the form page
|
22
|
-
* If not on the form display page, isValid returns false
|
23
|
-
* @returns {Promise<ValidationResult>} Returns a Promise containing the validation result
|
24
|
-
*/
|
25
|
-
validateFields(): Promise<ValidationResult>;
|
26
17
|
}
|
27
18
|
export declare class AMSVaulting extends AMSCheckout {
|
28
19
|
constructor(options: IoptionsParams);
|