@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730107332-dev.6
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/channel.d.ts +1 -1
- package/esm/component/channel.js +74 -28
- package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -1
- package/esm/foundation/product-processor/easysafepay/index.js +108 -231
- package/esm/types/index.d.ts +2 -0
- package/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { IPaymentSessionMetaData } from "../types";
|
2
2
|
export type IChannelBehavior = {
|
3
3
|
usePaymentSessionAsQueryResult: boolean;
|
4
|
-
|
4
|
+
allowSubmitPayCallAhead: boolean;
|
5
5
|
createIframeNode: boolean;
|
6
6
|
loadApp: boolean;
|
7
7
|
buildSubmitPayExtParams?: (params: GetDoubleFaParams) => any;
|
package/esm/component/channel.js
CHANGED
@@ -1,36 +1,68 @@
|
|
1
1
|
export function getChannelBehavior(paymentSessionMetaData) {
|
2
|
-
var _paymentSessionMetaDa
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
2
|
+
var _paymentSessionMetaDa;
|
3
|
+
var usePaymentSessionAsQueryResult = false;
|
4
|
+
var allowSubmitPayCallAhead = false;
|
5
|
+
var allowClickOutsideClose = false;
|
6
|
+
var buildSubmitPayExtParams = undefined;
|
7
|
+
|
8
|
+
// EASYPAY
|
9
|
+
if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.productScene) === 'EASY_PAY') {
|
10
|
+
var _paymentSessionMetaDa2, _paymentSessionMetaDa3, _paymentSessionMetaDa4, _paymentSessionMetaDa5;
|
11
|
+
var amountConfirmRequired = (_paymentSessionMetaDa2 = paymentSessionMetaData.action) === null || _paymentSessionMetaDa2 === void 0 ? void 0 : _paymentSessionMetaDa2.amountConfirmRequired;
|
12
|
+
var isFirstTimeToPay = !((_paymentSessionMetaDa3 = paymentSessionMetaData.action) !== null && _paymentSessionMetaDa3 !== void 0 && _paymentSessionMetaDa3.autoDebitWithToken);
|
13
|
+
// EASYPAY 1.0
|
14
|
+
if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa4 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa4 === void 0 ? void 0 : _paymentSessionMetaDa4.productSceneVersion) === '1.0') {
|
15
|
+
if (amountConfirmRequired) {
|
16
|
+
usePaymentSessionAsQueryResult = true;
|
17
|
+
}
|
18
|
+
if (!isFirstTimeToPay && amountConfirmRequired) {
|
19
|
+
allowSubmitPayCallAhead = false;
|
20
|
+
} else {
|
21
|
+
allowSubmitPayCallAhead = true;
|
22
|
+
}
|
23
|
+
} else if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa5 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa5 === void 0 ? void 0 : _paymentSessionMetaDa5.productSceneVersion) === '2.0') {
|
24
|
+
if (isFirstTimeToPay) {
|
25
|
+
var _paymentSessionMetaDa6;
|
26
|
+
if ('TNG' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa6 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa6 === void 0 ? void 0 : _paymentSessionMetaDa6.paymentMethodType) || isEasyPayTossWallet(paymentSessionMetaData)) {
|
27
|
+
allowSubmitPayCallAhead = true;
|
28
|
+
} else {
|
29
|
+
allowSubmitPayCallAhead = false;
|
30
|
+
}
|
31
|
+
} else {
|
32
|
+
if (amountConfirmRequired) {
|
33
|
+
if (isEasyPayTossWallet(paymentSessionMetaData)) {
|
34
|
+
allowSubmitPayCallAhead = true;
|
35
|
+
} else {
|
36
|
+
allowSubmitPayCallAhead = false;
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
allowSubmitPayCallAhead = true;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
if (isEasyPayTossWallet(paymentSessionMetaData)) {
|
43
|
+
usePaymentSessionAsQueryResult = true;
|
44
|
+
allowClickOutsideClose = true;
|
45
|
+
buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
|
46
|
+
var callBackUrl = getDoubleFaUrl(params);
|
47
|
+
return {
|
48
|
+
callBackUrl: callBackUrl
|
49
|
+
};
|
15
50
|
};
|
16
51
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
return {
|
22
|
-
usePaymentSessionAsQueryResult: false,
|
23
|
-
submitPayInSdk: false,
|
24
|
-
createIframeNode: true,
|
25
|
-
loadApp: true,
|
26
|
-
allowClickOutsideClose: false,
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
28
|
-
buildSubmitPayExtParams: function buildSubmitPayExtParams(params) {
|
29
|
-
return {};
|
52
|
+
if (isEasyPayTngWallet(paymentSessionMetaData)) {
|
53
|
+
buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
|
54
|
+
return {};
|
55
|
+
};
|
30
56
|
}
|
31
|
-
}
|
57
|
+
}
|
32
58
|
}
|
33
|
-
return
|
59
|
+
return {
|
60
|
+
usePaymentSessionAsQueryResult: usePaymentSessionAsQueryResult,
|
61
|
+
allowSubmitPayCallAhead: allowSubmitPayCallAhead,
|
62
|
+
buildSubmitPayExtParams: buildSubmitPayExtParams,
|
63
|
+
createIframeNode: true,
|
64
|
+
loadApp: true
|
65
|
+
};
|
34
66
|
}
|
35
67
|
export function getDoubleFaUrl(params) {
|
36
68
|
var instanceId = params.instanceId,
|
@@ -50,4 +82,18 @@ export function getDoubleFaUrl(params) {
|
|
50
82
|
};
|
51
83
|
var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
|
52
84
|
return "".concat(doubleFaBaseUrl, "?scene=cashierResultPage&instanceId=").concat(instanceId, "&paymentSessionData=").concat(encodeURIComponent(paymentSessionData), "&isLandscape=").concat(isLandscapeOrientation ? 'true' : '', "&pmt=").concat(paymentMethodType, "&locale=").concat(locale, "&sdkVersion=").concat(sdkVersion);
|
85
|
+
}
|
86
|
+
function isEasyPayTossWallet(paymentSessionMetaData) {
|
87
|
+
var _paymentSessionMetaDa7, _paymentSessionMetaDa8, _paymentSessionMetaDa9;
|
88
|
+
if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa7 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa7 === void 0 ? void 0 : _paymentSessionMetaDa7.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa8 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa8 === void 0 ? void 0 : _paymentSessionMetaDa8.paymentMethodType) === 'BANKTRANSFER_QUICKPAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa9 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa9 === void 0 ? void 0 : _paymentSessionMetaDa9.paymentMethodCategoryType) === 'APM') {
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
return false;
|
92
|
+
}
|
93
|
+
function isEasyPayTngWallet(paymentSessionMetaData) {
|
94
|
+
var _paymentSessionMetaDa10, _paymentSessionMetaDa11, _paymentSessionMetaDa12;
|
95
|
+
if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa10 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa10 === void 0 ? void 0 : _paymentSessionMetaDa10.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa11 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa11 === void 0 ? void 0 : _paymentSessionMetaDa11.paymentMethodType) === 'TNG' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa12 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa12 === void 0 ? void 0 : _paymentSessionMetaDa12.paymentMethodCategoryType) === 'WALLET') {
|
96
|
+
return true;
|
97
|
+
}
|
98
|
+
return false;
|
53
99
|
}
|
@@ -20,7 +20,6 @@ export declare class EasySafePayProcessor implements ProductProcessor {
|
|
20
20
|
* start waiting web launch, then send renderComponent event
|
21
21
|
* */
|
22
22
|
private sendRequestAndWaitWebLaunch;
|
23
|
-
private processPaymentQuery;
|
24
23
|
private processSubmitPay;
|
25
24
|
private acquireApdidToken;
|
26
25
|
private initSecuritySDK;
|
@@ -16,7 +16,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
16
16
|
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; }
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
18
18
|
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); }
|
19
|
-
import { ChannelCustomize, DisplayTypeEnum, getBackScheme,
|
19
|
+
import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isPC, ProductInfoCacheUtil, ProductSceneEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
|
20
20
|
export var EasySafePayProcessor = /*#__PURE__*/function () {
|
21
21
|
function EasySafePayProcessor() {
|
22
22
|
_classCallCheck(this, EasySafePayProcessor);
|
@@ -88,7 +88,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
88
88
|
hostSign: this.hostSign,
|
89
89
|
productSceneVersion: productSceneVersion
|
90
90
|
});
|
91
|
-
// 返回结果之前,发送
|
91
|
+
// 返回结果之前,发送 sessionData,并且等待Web应用启动的事件,内部是异步处理,不阻塞。
|
92
92
|
this.sendRequestAndWaitWebLaunch();
|
93
93
|
// 返回结果,RENDER,让外层去处理iframe加载等逻辑
|
94
94
|
return _context.abrupt("return", {
|
@@ -209,15 +209,6 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
209
209
|
value: function sendRequestAndWaitWebLaunch() {
|
210
210
|
var _this2 = this;
|
211
211
|
var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
212
|
-
var requestPromise = Promise.all([this.processPaymentQuery(), this.processSubmitPay()]).then(function (_ref) {
|
213
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
214
|
-
queryRes = _ref2[0],
|
215
|
-
submitRes = _ref2[1];
|
216
|
-
return {
|
217
|
-
queryRes: queryRes,
|
218
|
-
submitRes: submitRes
|
219
|
-
};
|
220
|
-
});
|
221
212
|
var webLaunchPromise = new Promise(function (resolve) {
|
222
213
|
eventCenter.listen('onLaunch', function (res) {
|
223
214
|
resolve(res);
|
@@ -225,25 +216,27 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
225
216
|
});
|
226
217
|
|
227
218
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
228
|
-
Promise.all([
|
229
|
-
var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6;
|
230
|
-
var
|
231
|
-
|
232
|
-
launchRes =
|
219
|
+
Promise.all([this.processSubmitPay, webLaunchPromise]).then(function (_ref) {
|
220
|
+
var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6, _this2$paymentContext7, _this2$paymentContext8;
|
221
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
222
|
+
submitRes = _ref2[0],
|
223
|
+
launchRes = _ref2[1];
|
233
224
|
var logMetaData = _this2.logger.getLogConfig().mdata;
|
234
225
|
eventCenter.dispatchToApp({
|
235
226
|
event: 'renderComponent',
|
236
227
|
data: {
|
237
|
-
queryResult:
|
238
|
-
|
239
|
-
|
240
|
-
|
228
|
+
queryResult: _objectSpread(_objectSpread({}, (_this2$paymentContext = _this2.paymentContext) === null || _this2$paymentContext === void 0 ? void 0 : _this2$paymentContext.paymentSessionObj), {}, {
|
229
|
+
orderAmount: (_this2$paymentContext2 = _this2.paymentContext) === null || _this2$paymentContext2 === void 0 || (_this2$paymentContext2 = _this2$paymentContext2.paymentSessionObj) === null || _this2$paymentContext2 === void 0 ? void 0 : _this2$paymentContext2.paymentView // For ESP 1.0
|
230
|
+
}),
|
231
|
+
sessionResult: (_this2$paymentContext3 = _this2.paymentContext) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.paymentSessionObj,
|
232
|
+
submitResult: submitRes,
|
233
|
+
paymentSessionData: (_this2$paymentContext4 = _this2.paymentContext) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.paymentSession,
|
241
234
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
242
235
|
renderDisplayType: _this2.paymentContext.displayInfo.type,
|
243
|
-
appearance: (_this2$
|
244
|
-
notRedirectAfterComplete: ((_this2$
|
236
|
+
appearance: (_this2$paymentContext5 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.appearance,
|
237
|
+
notRedirectAfterComplete: ((_this2$paymentContext6 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext6 === void 0 ? void 0 : _this2$paymentContext6.notRedirectAfterComplete) === true,
|
245
238
|
isAppWebview: _this2.paymentContext.startBizFlowOptions.isAppWebview,
|
246
|
-
merchantAppointParam: (_this2$
|
239
|
+
merchantAppointParam: (_this2$paymentContext7 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext7 === void 0 ? void 0 : _this2$paymentContext7.merchantAppointParam,
|
247
240
|
allowSubmitPayCallAhead: _this2.allowSubmitPayCallAhead,
|
248
241
|
envInfo: {
|
249
242
|
screenHeight: screen.height,
|
@@ -253,7 +246,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
253
246
|
trackId: logMetaData.requestSeq,
|
254
247
|
platform: logMetaData.platform,
|
255
248
|
firstLogTime: logMetaData.firstLogTime
|
256
|
-
}, ((_this2$
|
249
|
+
}, ((_this2$paymentContext8 = _this2.paymentContext.paymentSessionObj) === null || _this2$paymentContext8 === void 0 ? void 0 : _this2$paymentContext8.paymentSessionConfig) || {}), {}, {
|
257
250
|
renderDisplayType: logMetaData.renderDisplayType,
|
258
251
|
sdkVersion: logMetaData.sdkVersion,
|
259
252
|
merchantId: logMetaData.merchantId,
|
@@ -265,149 +258,20 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
265
258
|
});
|
266
259
|
}
|
267
260
|
}, {
|
268
|
-
key: "
|
261
|
+
key: "processSubmitPay",
|
269
262
|
value: function () {
|
270
|
-
var
|
271
|
-
var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$
|
272
|
-
var
|
263
|
+
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
264
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext3, _this$channelBehavior2, _this$channelBehavior3, _this$paymentContext$2;
|
265
|
+
var submitParams, _ref3, _ref3$productSceneVer, productSceneVersion, _ref4, _ref4$action, _ref4$action2, _ref4$action2$enableS, enableSignAgreement, _ref4$action2$autoDeb, autoDebitWithToken, _this$paymentContext$, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, res;
|
273
266
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
274
267
|
while (1) switch (_context2.prev = _context2.next) {
|
275
|
-
case 0:
|
276
|
-
envInfo = {
|
277
|
-
locale: this.initConfig.locale
|
278
|
-
}; //
|
279
|
-
requestData = {
|
280
|
-
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSession) || '',
|
281
|
-
paymentSessionConfig: (_this$paymentContext2 = this.paymentContext) === null || _this$paymentContext2 === void 0 || (_this$paymentContext2 = _this$paymentContext2.paymentSessionObj) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionConfig,
|
282
|
-
notRedirectAfterComplete: ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.startBizFlowOptions.submitPayRequestExtra.notRedirectAfterComplete) === true
|
283
|
-
// merchantAppointParam: this._merchantAppointParam,
|
284
|
-
};
|
285
|
-
extendInfo = ((_this$paymentContext4 = this.paymentContext) === null || _this$paymentContext4 === void 0 || (_this$paymentContext4 = _this$paymentContext4.paymentSessionObj) === null || _this$paymentContext4 === void 0 ? void 0 : _this$paymentContext4.extendInfo) || '';
|
286
|
-
actionData = (_this$paymentContext5 = this.paymentContext) === null || _this$paymentContext5 === void 0 || (_this$paymentContext5 = _this$paymentContext5.paymentSessionObj) === null || _this$paymentContext5 === void 0 ? void 0 : _this$paymentContext5.action;
|
287
|
-
enableEasypayApiOptimize = false;
|
288
|
-
try {
|
289
|
-
extendInfoData = JSON.parse(extendInfo);
|
290
|
-
enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
|
291
|
-
} catch (error) {
|
292
|
-
console.log(error);
|
293
|
-
}
|
294
|
-
if (!isLocalMock()) {
|
295
|
-
_context2.next = 8;
|
296
|
-
break;
|
297
|
-
}
|
298
|
-
return _context2.abrupt("return", {
|
299
|
-
message: 'sdk no need to make query request',
|
300
|
-
success: true
|
301
|
-
});
|
302
|
-
case 8:
|
303
|
-
if (!((_this$channelBehavior2 = this.channelBehavior) !== null && _this$channelBehavior2 !== void 0 && _this$channelBehavior2.usePaymentSessionAsQueryResult)) {
|
304
|
-
_context2.next = 10;
|
305
|
-
break;
|
306
|
-
}
|
307
|
-
return _context2.abrupt("return", {
|
308
|
-
autoDebitWithToken: actionData === null || actionData === void 0 ? void 0 : actionData.autoDebitWithToken,
|
309
|
-
amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
|
310
|
-
success: true
|
311
|
-
});
|
312
|
-
case 10:
|
313
|
-
if (!(actionData.skipSdkQuery && enableEasypayApiOptimize)) {
|
314
|
-
_context2.next = 12;
|
315
|
-
break;
|
316
|
-
}
|
317
|
-
return _context2.abrupt("return", {
|
318
|
-
message: 'sdk no need to make query request',
|
319
|
-
success: true
|
320
|
-
});
|
321
|
-
case 12:
|
322
|
-
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion; // ESP 2.0 无需Query
|
323
|
-
if (!(productSceneVersion === '2.0')) {
|
324
|
-
_context2.next = 15;
|
325
|
-
break;
|
326
|
-
}
|
327
|
-
return _context2.abrupt("return", {
|
328
|
-
message: 'sdk no need to make query request',
|
329
|
-
success: true
|
330
|
-
});
|
331
|
-
case 15:
|
332
|
-
_context2.next = 17;
|
333
|
-
return this.acquireApdidToken();
|
334
|
-
case 17:
|
335
|
-
envInfo.deviceId = _context2.sent;
|
336
|
-
requestBizId = uuid(); // 打日志
|
337
|
-
this.logger.logInfo({
|
338
|
-
title: 'sdk_event_sdkQuery'
|
339
|
-
}, {
|
340
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
341
|
-
requestBizId: requestBizId
|
342
|
-
});
|
343
|
-
|
344
|
-
// 真正发请求
|
345
|
-
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
346
|
-
_context2.prev = 21;
|
347
|
-
_context2.next = 24;
|
348
|
-
return requester.request(requestData, {
|
349
|
-
env: this.initConfig.environment,
|
350
|
-
envInfo: envInfo,
|
351
|
-
hostSign: this.hostSign,
|
352
|
-
'Operation-Type': 'com.ipay.iexpcashier.sdkAction.query'
|
353
|
-
});
|
354
|
-
case 24:
|
355
|
-
res = _context2.sent;
|
356
|
-
this.logger.logInfo({
|
357
|
-
title: 'sdk_event_sdkQueryEnd'
|
358
|
-
}, {
|
359
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
360
|
-
requestBizId: requestBizId,
|
361
|
-
traceId: res.traceId
|
362
|
-
});
|
363
|
-
return _context2.abrupt("return", res);
|
364
|
-
case 29:
|
365
|
-
_context2.prev = 29;
|
366
|
-
_context2.t0 = _context2["catch"](21);
|
367
|
-
this.logger.logError({
|
368
|
-
title: 'sdk_event_sdkQuery_failed'
|
369
|
-
}, {
|
370
|
-
paymentSessionConfig: JSON.stringify(requestData.paymentSessionConfig),
|
371
|
-
errorReason: _context2.t0,
|
372
|
-
requestBizId: requestBizId,
|
373
|
-
traceId: _context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.traceId
|
374
|
-
});
|
375
|
-
throw _context2.t0;
|
376
|
-
case 33:
|
377
|
-
case "end":
|
378
|
-
return _context2.stop();
|
379
|
-
}
|
380
|
-
}, _callee2, this, [[21, 29]]);
|
381
|
-
}));
|
382
|
-
function processPaymentQuery() {
|
383
|
-
return _processPaymentQuery.apply(this, arguments);
|
384
|
-
}
|
385
|
-
return processPaymentQuery;
|
386
|
-
}()
|
387
|
-
}, {
|
388
|
-
key: "processSubmitPay",
|
389
|
-
value: function () {
|
390
|
-
var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
391
|
-
var _this$paymentContext6, _this$paymentContext7, _this$paymentContext9, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$2;
|
392
|
-
var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext8, _ref5, _ref5$productSceneVer, productSceneVersion, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, _this$paymentContext$, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, res;
|
393
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
394
|
-
while (1) switch (_context3.prev = _context3.next) {
|
395
268
|
case 0:
|
396
269
|
submitParams = {
|
397
|
-
paymentSessionData: ((_this$
|
398
|
-
paymentSessionConfig: (_this$
|
270
|
+
paymentSessionData: ((_this$paymentContext = this.paymentContext) === null || _this$paymentContext === void 0 ? void 0 : _this$paymentContext.paymentSession) || '',
|
271
|
+
paymentSessionConfig: (_this$paymentContext2 = this.paymentContext) === null || _this$paymentContext2 === void 0 || (_this$paymentContext2 = _this$paymentContext2.paymentSessionObj) === null || _this$paymentContext2 === void 0 ? void 0 : _this$paymentContext2.paymentSessionConfig
|
399
272
|
};
|
400
|
-
|
401
|
-
|
402
|
-
// 新逻辑走 channelBehavior判断
|
403
|
-
shouldSkipSubmitPayInSDK = !this.channelBehavior.submitPayInSdk;
|
404
|
-
} else {
|
405
|
-
// TODO: 拉会找栎昂、甘颜一起对下
|
406
|
-
// 老逻辑,只要服务端标记不跳过sdkquery,就需要跳过submitpay
|
407
|
-
shouldSkipSubmitPayInSDK = !((_this$paymentContext8 = this.paymentContext) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.paymentSessionObj) !== null && _this$paymentContext8 !== void 0 && (_this$paymentContext8 = _this$paymentContext8.action) !== null && _this$paymentContext8 !== void 0 && _this$paymentContext8.skipSdkQuery);
|
408
|
-
}
|
409
|
-
_ref5 = submitParams.paymentSessionConfig || {}, _ref5$productSceneVer = _ref5.productSceneVersion, productSceneVersion = _ref5$productSceneVer === void 0 ? '' : _ref5$productSceneVer;
|
410
|
-
_ref6 = ((_this$paymentContext9 = this.paymentContext) === null || _this$paymentContext9 === void 0 ? void 0 : _this$paymentContext9.paymentSessionObj) || {}, _ref6$action = _ref6.action, _ref6$action2 = _ref6$action === void 0 ? {} : _ref6$action, _ref6$action2$enableS = _ref6$action2.enableSignAgreement, enableSignAgreement = _ref6$action2$enableS === void 0 ? false : _ref6$action2$enableS, _ref6$action2$autoDeb = _ref6$action2.autoDebitWithToken, autoDebitWithToken = _ref6$action2$autoDeb === void 0 ? false : _ref6$action2$autoDeb;
|
273
|
+
_ref3 = submitParams.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer;
|
274
|
+
_ref4 = ((_this$paymentContext3 = this.paymentContext) === null || _this$paymentContext3 === void 0 ? void 0 : _this$paymentContext3.paymentSessionObj) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$enableS = _ref4$action2.enableSignAgreement, enableSignAgreement = _ref4$action2$enableS === void 0 ? false : _ref4$action2$enableS, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
411
275
|
if (productSceneVersion === '2.0' && !autoDebitWithToken) {
|
412
276
|
///EasyPay 2.0 首次传signAgreement字段
|
413
277
|
submitParams['signAgreement'] = enableSignAgreement;
|
@@ -420,17 +284,16 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
420
284
|
}
|
421
285
|
}
|
422
286
|
}
|
423
|
-
|
424
|
-
this.allowSubmitPayCallAhead
|
425
|
-
|
426
|
-
_context3.next = 9;
|
287
|
+
this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
|
288
|
+
if (this.allowSubmitPayCallAhead) {
|
289
|
+
_context2.next = 7;
|
427
290
|
break;
|
428
291
|
}
|
429
|
-
return
|
292
|
+
return _context2.abrupt("return", {
|
430
293
|
message: 'sdk no need to make submitPay request',
|
431
294
|
success: true
|
432
295
|
});
|
433
|
-
case
|
296
|
+
case 7:
|
434
297
|
requestBizId = uuid(); // 下面真实发请求
|
435
298
|
this.logger.logInfo({
|
436
299
|
title: 'sdk_event_submitPay'
|
@@ -439,7 +302,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
439
302
|
requestBizId: requestBizId
|
440
303
|
});
|
441
304
|
// 由渠道定制点来构建额外参数
|
442
|
-
extParams = ((_this$
|
305
|
+
extParams = ((_this$channelBehavior2 = this.channelBehavior) === null || _this$channelBehavior2 === void 0 || (_this$channelBehavior3 = _this$channelBehavior2.buildSubmitPayExtParams) === null || _this$channelBehavior3 === void 0 ? void 0 : _this$channelBehavior3.call(_this$channelBehavior2, {
|
443
306
|
instanceId: this.instanceId,
|
444
307
|
locale: this.initConfig.locale,
|
445
308
|
paymentMethodType: (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType,
|
@@ -447,32 +310,33 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
447
310
|
env: this.initConfig.environment,
|
448
311
|
sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
|
449
312
|
})) || {};
|
313
|
+
extParams.complianceSDK = true;
|
450
314
|
submitParams.extParams = extParams;
|
451
315
|
requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
316
|
+
_context2.prev = 13;
|
317
|
+
_context2.t0 = requester;
|
318
|
+
_context2.t1 = submitParams;
|
319
|
+
_context2.t2 = this.initConfig.environment;
|
320
|
+
_context2.next = 19;
|
457
321
|
return this.acquireApdidToken();
|
458
|
-
case
|
459
|
-
|
460
|
-
|
461
|
-
deviceId:
|
322
|
+
case 19:
|
323
|
+
_context2.t3 = _context2.sent;
|
324
|
+
_context2.t4 = {
|
325
|
+
deviceId: _context2.t3
|
462
326
|
};
|
463
|
-
|
464
|
-
|
465
|
-
env:
|
327
|
+
_context2.t5 = this.hostSign;
|
328
|
+
_context2.t6 = {
|
329
|
+
env: _context2.t2,
|
466
330
|
timeout: 15000,
|
467
|
-
envInfo:
|
468
|
-
hostSign:
|
331
|
+
envInfo: _context2.t4,
|
332
|
+
hostSign: _context2.t5,
|
469
333
|
needEnvInfo: true,
|
470
334
|
'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
|
471
335
|
};
|
472
|
-
|
473
|
-
return
|
474
|
-
case
|
475
|
-
res =
|
336
|
+
_context2.next = 25;
|
337
|
+
return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
|
338
|
+
case 25:
|
339
|
+
res = _context2.sent;
|
476
340
|
this.logger.logInfo({
|
477
341
|
title: 'sdk_event_submitPayEnd'
|
478
342
|
}, {
|
@@ -480,50 +344,50 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
480
344
|
requestBizId: requestBizId,
|
481
345
|
traceId: res.traceId
|
482
346
|
});
|
483
|
-
return
|
484
|
-
case
|
485
|
-
|
486
|
-
|
347
|
+
return _context2.abrupt("return", res);
|
348
|
+
case 30:
|
349
|
+
_context2.prev = 30;
|
350
|
+
_context2.t7 = _context2["catch"](13);
|
487
351
|
this.logger.logError({
|
488
352
|
title: 'sdk_event_submitPay_failed'
|
489
353
|
}, {
|
490
354
|
paymentSessionConfig: JSON.stringify(submitParams.paymentSessionConfig),
|
491
|
-
errorReason:
|
355
|
+
errorReason: _context2.t7,
|
492
356
|
requestBizId: requestBizId,
|
493
|
-
traceId:
|
357
|
+
traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
494
358
|
});
|
495
|
-
throw
|
496
|
-
case
|
359
|
+
throw _context2.t7;
|
360
|
+
case 34:
|
497
361
|
case "end":
|
498
|
-
return
|
362
|
+
return _context2.stop();
|
499
363
|
}
|
500
|
-
},
|
364
|
+
}, _callee2, this, [[13, 30]]);
|
501
365
|
}));
|
502
366
|
function processSubmitPay() {
|
503
367
|
return _processSubmitPay.apply(this, arguments);
|
504
368
|
}
|
505
369
|
return processSubmitPay;
|
506
|
-
}()
|
370
|
+
}()
|
507
371
|
}, {
|
508
372
|
key: "acquireApdidToken",
|
509
373
|
value: function () {
|
510
|
-
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
374
|
+
var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
511
375
|
var _this$paymentContext$3;
|
512
376
|
var securityService, productScene, deviceId;
|
513
|
-
return _regeneratorRuntime().wrap(function
|
514
|
-
while (1) switch (
|
377
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
378
|
+
while (1) switch (_context3.prev = _context3.next) {
|
515
379
|
case 0:
|
516
380
|
securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
|
517
381
|
productScene = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentSessionConfig) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.productScene;
|
518
382
|
deviceId = securityService.getDeviceId({
|
519
383
|
productScene: productScene
|
520
384
|
});
|
521
|
-
return
|
385
|
+
return _context3.abrupt("return", deviceId);
|
522
386
|
case 4:
|
523
387
|
case "end":
|
524
|
-
return
|
388
|
+
return _context3.stop();
|
525
389
|
}
|
526
|
-
},
|
390
|
+
}, _callee3, this);
|
527
391
|
}));
|
528
392
|
function acquireApdidToken() {
|
529
393
|
return _acquireApdidToken.apply(this, arguments);
|
@@ -533,58 +397,71 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
533
397
|
}, {
|
534
398
|
key: "initSecuritySDK",
|
535
399
|
value: function () {
|
536
|
-
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
537
|
-
var _this$paymentContext$4, productSceneVersion, nonCompliant, isFirstTimeToPay;
|
538
|
-
return _regeneratorRuntime().wrap(function
|
539
|
-
while (1) switch (
|
400
|
+
var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
401
|
+
var _this$paymentContext$4, _this$paymentContext$5, productSceneVersion, nonCompliant, nonInitSecuritySDK, isFirstTimeToPay;
|
402
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
403
|
+
while (1) switch (_context4.prev = _context4.next) {
|
540
404
|
case 0:
|
541
|
-
|
405
|
+
_context4.prev = 0;
|
542
406
|
productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
|
543
407
|
nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
|
408
|
+
nonInitSecuritySDK = (_this$paymentContext$5 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$5 === void 0 ? void 0 : _this$paymentContext$5.nonCompliant;
|
544
409
|
isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
|
410
|
+
if (!nonInitSecuritySDK) {
|
411
|
+
_context4.next = 8;
|
412
|
+
break;
|
413
|
+
}
|
414
|
+
// 钱包不依赖风控
|
415
|
+
console.log('[web-sdk][security-sdk] DO NOT init security sdk when nonInitSecuritySDK is true');
|
416
|
+
return _context4.abrupt("return");
|
417
|
+
case 8:
|
545
418
|
if (!(productSceneVersion === '1.0')) {
|
546
|
-
|
419
|
+
_context4.next = 13;
|
547
420
|
break;
|
548
421
|
}
|
549
|
-
console.log('[web-sdk][security-sdk] skip init security sdk for easypay 1.0');
|
550
422
|
// 1.0 不初始化 SecuritySDK
|
551
|
-
|
552
|
-
|
423
|
+
console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 1.0');
|
424
|
+
return _context4.abrupt("return");
|
425
|
+
case 13:
|
553
426
|
if (!(productSceneVersion === '2.0')) {
|
554
|
-
|
427
|
+
_context4.next = 27;
|
555
428
|
break;
|
556
429
|
}
|
557
430
|
if (!(nonCompliant === true)) {
|
558
|
-
|
431
|
+
_context4.next = 20;
|
559
432
|
break;
|
560
433
|
}
|
561
434
|
// 未切流「隐私合规」
|
562
|
-
console.log('[web-sdk][security-sdk] init security sdk for easypay 2.0 and nonCompliant is true');
|
563
|
-
|
435
|
+
console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and nonCompliant is true');
|
436
|
+
_context4.next = 18;
|
564
437
|
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
565
|
-
case
|
566
|
-
|
438
|
+
case 18:
|
439
|
+
_context4.next = 27;
|
567
440
|
break;
|
568
|
-
case
|
569
|
-
if (isFirstTimeToPay) {
|
570
|
-
|
441
|
+
case 20:
|
442
|
+
if (!isFirstTimeToPay) {
|
443
|
+
_context4.next = 24;
|
571
444
|
break;
|
572
445
|
}
|
446
|
+
console.log('[web-sdk][security-sdk] DO NOT init security sdk for easypay 2.0 and when first time to pay');
|
447
|
+
_context4.next = 27;
|
448
|
+
break;
|
449
|
+
case 24:
|
573
450
|
// 切流「隐私合规」且非首次支付
|
574
|
-
console.log('[web-sdk][security-sdk] init security sdk for easypay 2.0 and when not first time to pay');
|
575
|
-
|
451
|
+
console.log('[web-sdk][security-sdk] DO init security sdk for easypay 2.0 and when not first time to pay');
|
452
|
+
_context4.next = 27;
|
576
453
|
return this.securityService.initSecurity(this.SECURITY_SDK_INIT_TIMEOUT);
|
577
|
-
case
|
578
|
-
|
454
|
+
case 27:
|
455
|
+
_context4.next = 31;
|
579
456
|
break;
|
580
|
-
case
|
581
|
-
|
582
|
-
|
583
|
-
case
|
457
|
+
case 29:
|
458
|
+
_context4.prev = 29;
|
459
|
+
_context4.t0 = _context4["catch"](0);
|
460
|
+
case 31:
|
584
461
|
case "end":
|
585
|
-
return
|
462
|
+
return _context4.stop();
|
586
463
|
}
|
587
|
-
},
|
464
|
+
}, _callee4, this, [[0, 29]]);
|
588
465
|
}));
|
589
466
|
function initSecuritySDK() {
|
590
467
|
return _initSecuritySDK.apply(this, arguments);
|