@alipay/ams-checkout 0.0.1704337820-dev.0 → 0.0.1704337820-dev.2
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/common/applepay/index.d.ts +48 -0
- package/esm/common/applepay/index.js +171 -0
- package/esm/common/applepay/interface.d.ts +102 -0
- package/esm/common/applepay/interface.js +1 -0
- package/esm/constant/index.d.ts +2 -4
- package/esm/constant/index.js +3 -5
- package/esm/core/applepay/index.d.ts +31 -0
- package/esm/core/applepay/index.js +369 -0
- package/esm/core/component/index.d.ts +3 -1
- package/esm/core/component/index.js +15 -2
- package/esm/core/instance/index.js +1 -1
- package/esm/index.d.ts +3 -0
- package/esm/index.js +18 -8
- package/esm/plugin/component/index.js +129 -67
- package/esm/plugin/component/popupWindow.style.d.ts +1 -1
- package/esm/plugin/component/popupWindow.style.js +32 -23
- package/esm/request/index.js +14 -8
- package/esm/service/index.d.ts +9 -1
- package/esm/service/index.js +31 -0
- package/esm/types/index.d.ts +45 -2
- package/esm/types/index.js +13 -0
- package/esm/util/logger.js +3 -0
- package/esm/util/security.d.ts +1 -0
- package/esm/util/security.js +2 -2
- package/package.json +56 -1
@@ -15,7 +15,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
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
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
|
-
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
18
|
+
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT } from "../../constant";
|
19
19
|
import { queryPaymentInfo, submitPayInfo } from "../../service";
|
20
20
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
21
|
import { getType, isJsonString, isPC } from "../../util";
|
@@ -341,7 +341,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
341
341
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
342
342
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
343
343
|
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
|
344
|
-
var envInfo, params, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
|
344
|
+
var envInfo, params, search, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
|
345
345
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
346
346
|
while (1) switch (_context2.prev = _context2.next) {
|
347
347
|
case 0:
|
@@ -367,7 +367,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
367
367
|
}));
|
368
368
|
case 4:
|
369
369
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
370
|
-
_context2.next =
|
370
|
+
_context2.next = 11;
|
371
371
|
break;
|
372
372
|
}
|
373
373
|
params.paymentMethodType = 'CARD';
|
@@ -375,55 +375,62 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
375
375
|
return _this5.getDeviceIdAndLog();
|
376
376
|
case 8:
|
377
377
|
envInfo.deviceId = _context2.sent;
|
378
|
-
|
378
|
+
// TODO 加一个后门 判断是否为小程序环境
|
379
|
+
search = window.location.search;
|
380
|
+
if (window.navigator.userAgent.indexOf('miniProgram') > -1 || search.indexOf('miniProgram') > -1) {
|
381
|
+
envInfo.extendInfo = {
|
382
|
+
WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
|
383
|
+
};
|
384
|
+
}
|
385
|
+
case 11:
|
379
386
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
380
|
-
_context2.next =
|
387
|
+
_context2.next = 19;
|
381
388
|
break;
|
382
389
|
}
|
383
390
|
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
384
391
|
_ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
385
392
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
386
|
-
_context2.next =
|
393
|
+
_context2.next = 16;
|
387
394
|
break;
|
388
395
|
}
|
389
396
|
return _context2.abrupt("return", resolve({
|
390
397
|
message: 'sdk no need to make query request',
|
391
398
|
success: true
|
392
399
|
}));
|
393
|
-
case 14:
|
394
|
-
_context2.next = 16;
|
395
|
-
return _this5.getDeviceIdAndLog();
|
396
400
|
case 16:
|
401
|
+
_context2.next = 18;
|
402
|
+
return _this5.getDeviceIdAndLog();
|
403
|
+
case 18:
|
397
404
|
envInfo.deviceId = _context2.sent;
|
398
|
-
case
|
405
|
+
case 19:
|
399
406
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
400
|
-
_context2.next =
|
407
|
+
_context2.next = 29;
|
401
408
|
break;
|
402
409
|
}
|
403
410
|
action = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 || (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.action) || {};
|
404
411
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
405
412
|
if (!(signType === 'SMS')) {
|
406
|
-
_context2.next =
|
413
|
+
_context2.next = 24;
|
407
414
|
break;
|
408
415
|
}
|
409
416
|
return _context2.abrupt("return", resolve({
|
410
417
|
message: 'sdk no need to make query request',
|
411
418
|
success: true
|
412
419
|
}));
|
413
|
-
case
|
420
|
+
case 24:
|
414
421
|
if (!(!signType || signType !== 'REDIRECT')) {
|
415
|
-
_context2.next =
|
422
|
+
_context2.next = 26;
|
416
423
|
break;
|
417
424
|
}
|
418
425
|
return _context2.abrupt("return", resolve({
|
419
426
|
success: false
|
420
427
|
}));
|
421
|
-
case 24:
|
422
|
-
_context2.next = 26;
|
423
|
-
return _this5.getDeviceIdAndLog();
|
424
428
|
case 26:
|
429
|
+
_context2.next = 28;
|
430
|
+
return _this5.getDeviceIdAndLog();
|
431
|
+
case 28:
|
425
432
|
envInfo.deviceId = _context2.sent;
|
426
|
-
case
|
433
|
+
case 29:
|
427
434
|
_this5.AMSSDK.logger.logInfo({
|
428
435
|
title: 'sdk_event_sdkQuery'
|
429
436
|
}, {
|
@@ -459,7 +466,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
459
466
|
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
460
467
|
}).send();
|
461
468
|
});
|
462
|
-
case
|
469
|
+
case 31:
|
463
470
|
case "end":
|
464
471
|
return _context2.stop();
|
465
472
|
}
|
@@ -633,6 +640,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
633
640
|
// Subscribe to messages from iframe
|
634
641
|
this.addEventListener();
|
635
642
|
} catch (error) {
|
643
|
+
this.AMSSDK.logger.logError({
|
644
|
+
title: 'sdk_error_created_app_failed'
|
645
|
+
}).send();
|
636
646
|
this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
|
637
647
|
stack: error
|
638
648
|
}));
|
@@ -670,31 +680,80 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
670
680
|
}
|
671
681
|
}, {
|
672
682
|
key: "createDialog",
|
673
|
-
value: function
|
674
|
-
var
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
683
|
+
value: function () {
|
684
|
+
var _createDialog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
|
685
|
+
var pageUrl, isLoad, timeout, logTimeout;
|
686
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
687
|
+
while (1) switch (_context4.prev = _context4.next) {
|
688
|
+
case 0:
|
689
|
+
pageUrl = data.url.includes('?') ? "".concat(data.url, "&").concat(this._appLocationSearch) : "".concat(data.url, "?").concat(this._appLocationSearch);
|
690
|
+
_context4.prev = 1;
|
691
|
+
isLoad = false;
|
692
|
+
_context4.next = 5;
|
693
|
+
return createModal({
|
694
|
+
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
695
|
+
heightPadding: data === null || data === void 0 ? void 0 : data.heightPadding,
|
696
|
+
device: this.platform,
|
697
|
+
url: pageUrl
|
698
|
+
});
|
699
|
+
case 5:
|
700
|
+
this.popupApp = _context4.sent;
|
701
|
+
timeout = setTimeout(function () {
|
702
|
+
if (isLoad) return;
|
703
|
+
throw {
|
704
|
+
title: 'sdk_error_create_pop_up'
|
705
|
+
};
|
706
|
+
}, LOADTIME_LIMIT);
|
707
|
+
logTimeout = setTimeout(function () {
|
708
|
+
if (isLoad) return;
|
709
|
+
throw {
|
710
|
+
title: 'sdk_error_pop_up_time_out'
|
711
|
+
};
|
712
|
+
}, POPUP_LOADTIME_LOG_LIMIT);
|
713
|
+
this.popupApp.onload = function () {
|
714
|
+
isLoad = true;
|
715
|
+
clearTimeout(timeout);
|
716
|
+
clearTimeout(logTimeout);
|
717
|
+
};
|
718
|
+
_context4.next = 15;
|
719
|
+
break;
|
720
|
+
case 11:
|
721
|
+
_context4.prev = 11;
|
722
|
+
_context4.t0 = _context4["catch"](1);
|
723
|
+
this.AMSSDK.logger.logError({
|
724
|
+
title: (_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.title) || 'sdk_error_create_pop_up'
|
725
|
+
}, {
|
726
|
+
message: _context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message,
|
727
|
+
url: pageUrl
|
728
|
+
});
|
729
|
+
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
730
|
+
case 15:
|
731
|
+
case "end":
|
732
|
+
return _context4.stop();
|
733
|
+
}
|
734
|
+
}, _callee4, this, [[1, 11]]);
|
735
|
+
}));
|
736
|
+
function createDialog(_x4) {
|
737
|
+
return _createDialog.apply(this, arguments);
|
738
|
+
}
|
739
|
+
return createDialog;
|
740
|
+
}()
|
682
741
|
}, {
|
683
742
|
key: "getDeviceIdAndCallback",
|
684
743
|
value: function () {
|
685
|
-
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
744
|
+
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
|
686
745
|
var deviceId;
|
687
|
-
return _regeneratorRuntime().wrap(function
|
688
|
-
while (1) switch (
|
746
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
747
|
+
while (1) switch (_context5.prev = _context5.next) {
|
689
748
|
case 0:
|
690
749
|
if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
|
691
|
-
|
750
|
+
_context5.next = 5;
|
692
751
|
break;
|
693
752
|
}
|
694
|
-
|
753
|
+
_context5.next = 3;
|
695
754
|
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
696
755
|
case 3:
|
697
|
-
deviceId =
|
756
|
+
deviceId = _context5.sent;
|
698
757
|
this.dispatchToApp({
|
699
758
|
context: {
|
700
759
|
event: 'appEventCallback',
|
@@ -706,11 +765,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
706
765
|
});
|
707
766
|
case 5:
|
708
767
|
case "end":
|
709
|
-
return
|
768
|
+
return _context5.stop();
|
710
769
|
}
|
711
|
-
},
|
770
|
+
}, _callee5, this);
|
712
771
|
}));
|
713
|
-
function getDeviceIdAndCallback(
|
772
|
+
function getDeviceIdAndCallback(_x5) {
|
714
773
|
return _getDeviceIdAndCallback.apply(this, arguments);
|
715
774
|
}
|
716
775
|
return getDeviceIdAndCallback;
|
@@ -718,9 +777,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
718
777
|
}, {
|
719
778
|
key: "getUserAgentAndCallback",
|
720
779
|
value: function () {
|
721
|
-
var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
722
|
-
return _regeneratorRuntime().wrap(function
|
723
|
-
while (1) switch (
|
780
|
+
var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventContext) {
|
781
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
782
|
+
while (1) switch (_context6.prev = _context6.next) {
|
724
783
|
case 0:
|
725
784
|
if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
|
726
785
|
try {
|
@@ -729,19 +788,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
729
788
|
event: 'appEventCallback',
|
730
789
|
eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
|
731
790
|
data: {
|
732
|
-
|
791
|
+
// TODO 上线前删除链接参数
|
792
|
+
userAgent: window.navigator.userAgent + window.location.search
|
733
793
|
}
|
734
794
|
}
|
735
795
|
});
|
736
|
-
} catch (error) {
|
796
|
+
} catch (error) {
|
797
|
+
/* empty */
|
798
|
+
}
|
737
799
|
}
|
738
800
|
case 1:
|
739
801
|
case "end":
|
740
|
-
return
|
802
|
+
return _context6.stop();
|
741
803
|
}
|
742
|
-
},
|
804
|
+
}, _callee6, this);
|
743
805
|
}));
|
744
|
-
function getUserAgentAndCallback(
|
806
|
+
function getUserAgentAndCallback(_x6) {
|
745
807
|
return _getUserAgentAndCallback.apply(this, arguments);
|
746
808
|
}
|
747
809
|
return getUserAgentAndCallback;
|
@@ -749,10 +811,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
749
811
|
}, {
|
750
812
|
key: "returnDataAndCallback",
|
751
813
|
value: function () {
|
752
|
-
var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
814
|
+
var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventContext) {
|
753
815
|
var _eventContext$data, targetData;
|
754
|
-
return _regeneratorRuntime().wrap(function
|
755
|
-
while (1) switch (
|
816
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
817
|
+
while (1) switch (_context7.prev = _context7.next) {
|
756
818
|
case 0:
|
757
819
|
if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
|
758
820
|
targetData = this._globalData.get((_eventContext$data = eventContext.data) === null || _eventContext$data === void 0 ? void 0 : _eventContext$data.dataKey);
|
@@ -766,11 +828,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
766
828
|
}
|
767
829
|
case 1:
|
768
830
|
case "end":
|
769
|
-
return
|
831
|
+
return _context7.stop();
|
770
832
|
}
|
771
|
-
},
|
833
|
+
}, _callee7, this);
|
772
834
|
}));
|
773
|
-
function returnDataAndCallback(
|
835
|
+
function returnDataAndCallback(_x7) {
|
774
836
|
return _returnDataAndCallback.apply(this, arguments);
|
775
837
|
}
|
776
838
|
return returnDataAndCallback;
|
@@ -827,7 +889,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
827
889
|
this._globalData.set((_data$context$data = data.context.data) === null || _data$context$data === void 0 ? void 0 : _data$context$data.dataKey, (_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.data);
|
828
890
|
return;
|
829
891
|
}
|
830
|
-
if (data.context.event === EVENT.
|
892
|
+
if (data.context.event === EVENT.popupWindow.name) {
|
831
893
|
var _data$context;
|
832
894
|
this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
|
833
895
|
return;
|
@@ -1127,26 +1189,26 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1127
1189
|
}, {
|
1128
1190
|
key: "sendRenderEvent",
|
1129
1191
|
value: (function () {
|
1130
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
1192
|
+
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
1131
1193
|
var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
|
1132
|
-
return _regeneratorRuntime().wrap(function
|
1133
|
-
while (1) switch (
|
1194
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
1195
|
+
while (1) switch (_context8.prev = _context8.next) {
|
1134
1196
|
case 0:
|
1135
|
-
|
1197
|
+
_context8.prev = 0;
|
1136
1198
|
if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
|
1137
|
-
|
1199
|
+
_context8.next = 3;
|
1138
1200
|
break;
|
1139
1201
|
}
|
1140
|
-
return
|
1202
|
+
return _context8.abrupt("return");
|
1141
1203
|
case 3:
|
1142
|
-
|
1204
|
+
_context8.next = 5;
|
1143
1205
|
return this._actionQueryPromise;
|
1144
1206
|
case 5:
|
1145
|
-
res =
|
1146
|
-
|
1207
|
+
res = _context8.sent;
|
1208
|
+
_context8.next = 8;
|
1147
1209
|
return this._actionSubmitPromise;
|
1148
1210
|
case 8:
|
1149
|
-
submitRes =
|
1211
|
+
submitRes = _context8.sent;
|
1150
1212
|
this._performanceData.push({
|
1151
1213
|
key: 'sdk_render_component',
|
1152
1214
|
value: Date.now()
|
@@ -1180,16 +1242,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1180
1242
|
}
|
1181
1243
|
});
|
1182
1244
|
// eslint-disable-next-line no-empty
|
1183
|
-
|
1245
|
+
_context8.next = 16;
|
1184
1246
|
break;
|
1185
1247
|
case 14:
|
1186
|
-
|
1187
|
-
|
1248
|
+
_context8.prev = 14;
|
1249
|
+
_context8.t0 = _context8["catch"](0);
|
1188
1250
|
case 16:
|
1189
1251
|
case "end":
|
1190
|
-
return
|
1252
|
+
return _context8.stop();
|
1191
1253
|
}
|
1192
|
-
},
|
1254
|
+
}, _callee8, this, [[0, 14]]);
|
1193
1255
|
}));
|
1194
1256
|
function sendRenderEvent() {
|
1195
1257
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -16,29 +16,38 @@ export var createModal = function createModal(_ref) {
|
|
16
16
|
url = _ref.url,
|
17
17
|
widthPadding = _ref.widthPadding,
|
18
18
|
heightPadding = _ref.heightPadding;
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
19
|
+
return new Promise(function (resolve, reject) {
|
20
|
+
try {
|
21
|
+
var overlay = document.createElement('div');
|
22
|
+
overlay.classList.add("".concat(AMSPOPUP_PREFIX, "overlay"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
23
|
+
var modal = document.createElement('div');
|
24
|
+
modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
|
25
|
+
if (device === 'desktop') {
|
26
|
+
modal.style.width = '600px';
|
27
|
+
modal.style.height = '464px';
|
28
|
+
modal.style.borderRadius = '12px';
|
29
|
+
} else {
|
30
|
+
modal.style.width = "calc(100% - ".concat(2 * widthPadding, "px)");
|
31
|
+
modal.style.height = "calc(100% - ".concat(2 * heightPadding, "px)");
|
32
|
+
modal.style.borderRadius = '8px';
|
33
|
+
}
|
34
|
+
var iframe = document.createElement('iframe');
|
35
|
+
iframe.src = url; // 替换为实际的 URL 地址
|
36
|
+
iframe.style.border = 'none';
|
37
|
+
iframe.style.width = '100%';
|
38
|
+
iframe.style.height = '100%';
|
39
|
+
modal.appendChild(iframe);
|
40
|
+
var body = document.getElementsByTagName('body')[0];
|
41
|
+
body.appendChild(overlay);
|
42
|
+
body.appendChild(modal);
|
43
|
+
resolve(iframe);
|
44
|
+
} catch (error) {
|
45
|
+
reject({
|
46
|
+
title: 'sdk_error_create_pop_up',
|
47
|
+
message: error === null || error === void 0 ? void 0 : error.toString()
|
48
|
+
});
|
49
|
+
}
|
50
|
+
});
|
42
51
|
};
|
43
52
|
|
44
53
|
// 销毁弹窗
|
package/esm/request/index.js
CHANGED
@@ -50,6 +50,8 @@ function requestInstance(options) {
|
|
50
50
|
withCredentials: (_options$withCredenti = options.withCredentials) !== null && _options$withCredenti !== void 0 ? _options$withCredenti : true,
|
51
51
|
method: (options === null || options === void 0 ? void 0 : options.method) || 'POST'
|
52
52
|
});
|
53
|
+
console.log('baseURL', baseURL);
|
54
|
+
console.log('_headers', _headers);
|
53
55
|
return instance.request;
|
54
56
|
}
|
55
57
|
|
@@ -97,21 +99,25 @@ function _request() {
|
|
97
99
|
})];
|
98
100
|
startTime = Date.now();
|
99
101
|
_context.prev = 5;
|
102
|
+
console.log('requestInstance options', options);
|
103
|
+
console.log('requestInstance -data', _data);
|
100
104
|
myRequest = requestInstance(options);
|
101
|
-
_context.next =
|
105
|
+
_context.next = 11;
|
102
106
|
return myRequest({
|
103
107
|
data: _data
|
104
108
|
});
|
105
|
-
case
|
109
|
+
case 11:
|
106
110
|
_yield$myRequest = _context.sent;
|
107
111
|
data = _yield$myRequest.data;
|
108
112
|
headers = _yield$myRequest.headers;
|
113
|
+
console.log('requestInstance data', data);
|
114
|
+
console.log('requestInstance headers', headers);
|
109
115
|
resData = data || {};
|
110
116
|
traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
|
111
117
|
resData.traceId = traceId || '';
|
112
118
|
handleGetWayError = fomatGetwayError(headers, traceId);
|
113
119
|
if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
|
114
|
-
_context.next =
|
120
|
+
_context.next = 25;
|
115
121
|
break;
|
116
122
|
}
|
117
123
|
errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
|
@@ -130,7 +136,7 @@ function _request() {
|
|
130
136
|
errorCode: errorCode,
|
131
137
|
success: false
|
132
138
|
}));
|
133
|
-
case
|
139
|
+
case 25:
|
134
140
|
logger.reportRPC({
|
135
141
|
name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
|
136
142
|
label: 'request',
|
@@ -141,8 +147,8 @@ function _request() {
|
|
141
147
|
traceId: traceId
|
142
148
|
}).send();
|
143
149
|
return _context.abrupt("return", resData);
|
144
|
-
case
|
145
|
-
_context.prev =
|
150
|
+
case 29:
|
151
|
+
_context.prev = 29;
|
146
152
|
_context.t0 = _context["catch"](5);
|
147
153
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
148
154
|
success: false,
|
@@ -164,11 +170,11 @@ function _request() {
|
|
164
170
|
errorCode: _errorCode,
|
165
171
|
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
166
172
|
}));
|
167
|
-
case
|
173
|
+
case 36:
|
168
174
|
case "end":
|
169
175
|
return _context.stop();
|
170
176
|
}
|
171
|
-
}, _callee, null, [[5,
|
177
|
+
}, _callee, null, [[5, 29]]);
|
172
178
|
}));
|
173
179
|
return _request.apply(this, arguments);
|
174
180
|
}
|
package/esm/service/index.d.ts
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
-
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
|
1
|
+
import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
3
|
export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
|
4
4
|
export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
|
5
5
|
export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
|
6
|
+
/**
|
7
|
+
* Get merchant session by Apple Pay
|
8
|
+
* @param paymentSessionData
|
9
|
+
* @param params
|
10
|
+
* @param options
|
11
|
+
* @param logger
|
12
|
+
*/
|
13
|
+
export declare function getApplePayPaymentSession(paymentSessionData: string, params: ApplePayPaymentSessionRequest, options: RequestConfig, logger: Logger): Promise<ApplePayPaymentSessionResult>;
|
package/esm/service/index.js
CHANGED
@@ -78,6 +78,14 @@ function _antomConfig() {
|
|
78
78
|
export function submitPayInfo(_x6, _x7, _x8) {
|
79
79
|
return _submitPayInfo.apply(this, arguments);
|
80
80
|
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Get merchant session by Apple Pay
|
84
|
+
* @param paymentSessionData
|
85
|
+
* @param params
|
86
|
+
* @param options
|
87
|
+
* @param logger
|
88
|
+
*/
|
81
89
|
function _submitPayInfo() {
|
82
90
|
_submitPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params, options, logger) {
|
83
91
|
var hostSign;
|
@@ -97,4 +105,27 @@ function _submitPayInfo() {
|
|
97
105
|
}, _callee3);
|
98
106
|
}));
|
99
107
|
return _submitPayInfo.apply(this, arguments);
|
108
|
+
}
|
109
|
+
export function getApplePayPaymentSession(_x9, _x10, _x11, _x12) {
|
110
|
+
return _getApplePayPaymentSession.apply(this, arguments);
|
111
|
+
}
|
112
|
+
function _getApplePayPaymentSession() {
|
113
|
+
_getApplePayPaymentSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(paymentSessionData, params, options, logger) {
|
114
|
+
var hostSign;
|
115
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
116
|
+
while (1) switch (_context4.prev = _context4.next) {
|
117
|
+
case 0:
|
118
|
+
hostSign = (paymentSessionData || '').split('&&')[1] || '';
|
119
|
+
console.log('getApplePayPaymentSession hostSign', hostSign);
|
120
|
+
return _context4.abrupt("return", request(params, _objectSpread(_objectSpread({}, options), {}, {
|
121
|
+
hostSign: hostSign,
|
122
|
+
'Operation-Type': 'com.ipay.iexpcashier.cashier.createApplePayPaymentSession'
|
123
|
+
}), logger));
|
124
|
+
case 3:
|
125
|
+
case "end":
|
126
|
+
return _context4.stop();
|
127
|
+
}
|
128
|
+
}, _callee4);
|
129
|
+
}));
|
130
|
+
return _getApplePayPaymentSession.apply(this, arguments);
|
100
131
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -24,6 +24,8 @@ export interface IoptionsParams {
|
|
24
24
|
};
|
25
25
|
product?: string;
|
26
26
|
}
|
27
|
+
export interface IApplePayOptionsParams extends Pick<IoptionsParams, 'locale' | 'environment' | 'onEventCallback' | 'analytics'> {
|
28
|
+
}
|
27
29
|
export type Iselector = string;
|
28
30
|
export declare enum renderDisplayTypeEnum {
|
29
31
|
'popup' = "popup",
|
@@ -51,7 +53,8 @@ export declare enum productSceneEnum {
|
|
51
53
|
'CASHIER_PAYMENT' = "CASHIER_PAYMENT",
|
52
54
|
'AUTO_DEBIT' = "AUTO_DEBIT",
|
53
55
|
'VAULTING' = "VAULTING",
|
54
|
-
'FLASH_BUY' = "FLASH_BUY"
|
56
|
+
'FLASH_BUY' = "FLASH_BUY",
|
57
|
+
'CARD_APPLE_PAY' = "CARD_APPLE_PAY"
|
55
58
|
}
|
56
59
|
export declare enum paymentMethodCategoryTypeEnum {
|
57
60
|
'CARD' = "CARD",
|
@@ -129,6 +132,26 @@ export interface IpaymentSessionMetaData {
|
|
129
132
|
autoDebitWithToken: boolean;
|
130
133
|
skipSdkQuery: boolean;
|
131
134
|
};
|
135
|
+
paymentSessionFactor?: {
|
136
|
+
applePay?: {
|
137
|
+
merchantCapabilities?: string[];
|
138
|
+
supportedNetworks?: string[];
|
139
|
+
};
|
140
|
+
merchantInfo?: {
|
141
|
+
registeredCountry?: string;
|
142
|
+
partnerId?: string;
|
143
|
+
};
|
144
|
+
order?: {
|
145
|
+
orderDescription?: string;
|
146
|
+
};
|
147
|
+
paymentAmount?: {
|
148
|
+
value?: string;
|
149
|
+
currency?: string;
|
150
|
+
};
|
151
|
+
paymentMethodInfo?: {
|
152
|
+
paymentMethodType?: string;
|
153
|
+
};
|
154
|
+
};
|
132
155
|
}
|
133
156
|
export declare enum localeEnum {
|
134
157
|
'en-US' = "en-US"
|
@@ -331,6 +354,23 @@ export interface CashierSdkActionQueryResult {
|
|
331
354
|
schemeUrl?: string;
|
332
355
|
authUrl?: string;
|
333
356
|
}
|
357
|
+
/**
|
358
|
+
* Get App Pay Payment Session Request.
|
359
|
+
*/
|
360
|
+
export interface ApplePayPaymentSessionRequest {
|
361
|
+
validateUrl: string;
|
362
|
+
paymentSessionData: string;
|
363
|
+
}
|
364
|
+
/**
|
365
|
+
* Get App Pay Payment Session Result.
|
366
|
+
*/
|
367
|
+
export interface ApplePayPaymentSessionResult {
|
368
|
+
merchantSessionObject: string;
|
369
|
+
success: boolean;
|
370
|
+
errorCode?: string;
|
371
|
+
errorMessage?: string;
|
372
|
+
message?: string;
|
373
|
+
}
|
334
374
|
export declare enum redirectTypeEnum {
|
335
375
|
UNSAFE_BROWSER = "UNSAFE_BROWSER",
|
336
376
|
SAFETY_BROWSER = "SAFETY_BROWSER",
|
@@ -363,7 +403,10 @@ export declare enum eventCodeEnum {
|
|
363
403
|
SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
|
364
404
|
SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
|
365
405
|
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
|
366
|
-
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
|
406
|
+
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
|
407
|
+
SDK_PAYMENT_FINISH = "SDK_PAYMENT_FINISH",
|
408
|
+
SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
|
409
|
+
SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL"
|
367
410
|
}
|
368
411
|
export declare enum RedirectType {
|
369
412
|
ApplinkUrl = "ApplinkUrl",
|