@alipay/ams-checkout 0.0.1730107332-dev.7 → 0.0.1730107332-dev.9

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.
@@ -1,6 +1,5 @@
1
1
  import type { IPaymentSessionMetaData } from "../types";
2
2
  export type IChannelBehavior = {
3
- usePaymentSessionAsQueryResult: boolean;
4
3
  allowSubmitPayCallAhead: boolean;
5
4
  createIframeNode: boolean;
6
5
  loadApp: boolean;
@@ -1,6 +1,5 @@
1
1
  export function getChannelBehavior(paymentSessionMetaData) {
2
2
  var _paymentSessionMetaDa;
3
- var usePaymentSessionAsQueryResult = false;
4
3
  var allowSubmitPayCallAhead = false;
5
4
  var allowClickOutsideClose = false;
6
5
  var buildSubmitPayExtParams = undefined;
@@ -12,25 +11,27 @@ export function getChannelBehavior(paymentSessionMetaData) {
12
11
  var isFirstTimeToPay = !((_paymentSessionMetaDa3 = paymentSessionMetaData.action) !== null && _paymentSessionMetaDa3 !== void 0 && _paymentSessionMetaDa3.autoDebitWithToken);
13
12
  // EASYPAY 1.0
14
13
  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
14
  if (!isFirstTimeToPay && amountConfirmRequired) {
19
15
  allowSubmitPayCallAhead = false;
20
16
  } else {
21
17
  allowSubmitPayCallAhead = true;
22
18
  }
23
19
  } else if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa5 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa5 === void 0 ? void 0 : _paymentSessionMetaDa5.productSceneVersion) === '2.0') {
20
+ var _paymentSessionMetaDa8;
24
21
  if (isFirstTimeToPay) {
25
22
  var _paymentSessionMetaDa6;
26
- if ('TNG' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa6 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa6 === void 0 ? void 0 : _paymentSessionMetaDa6.paymentMethodType) || isEasyPayTossWallet(paymentSessionMetaData)) {
23
+ if (
24
+ // AlipayCN、TOSS
25
+ ['ALIPAY_CN', 'BANKTRANSFER_QUICKPAY'].includes(paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa6 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa6 === void 0 ? void 0 : _paymentSessionMetaDa6.paymentMethodType)) {
27
26
  allowSubmitPayCallAhead = true;
28
27
  } else {
29
28
  allowSubmitPayCallAhead = false;
30
29
  }
31
30
  } else {
32
31
  if (amountConfirmRequired) {
33
- if (isEasyPayTossWallet(paymentSessionMetaData)) {
32
+ var _paymentSessionMetaDa7;
33
+ // TOSS
34
+ if (['BANKTRANSFER_QUICKPAY'].includes(paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa7 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa7 === void 0 ? void 0 : _paymentSessionMetaDa7.paymentMethodType)) {
34
35
  allowSubmitPayCallAhead = true;
35
36
  } else {
36
37
  allowSubmitPayCallAhead = false;
@@ -39,8 +40,9 @@ export function getChannelBehavior(paymentSessionMetaData) {
39
40
  allowSubmitPayCallAhead = true;
40
41
  }
41
42
  }
42
- if (isEasyPayTossWallet(paymentSessionMetaData)) {
43
- usePaymentSessionAsQueryResult = true;
43
+
44
+ // TOSS
45
+ if (['BANKTRANSFER_QUICKPAY'].includes(paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa8 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa8 === void 0 ? void 0 : _paymentSessionMetaDa8.paymentMethodType)) {
44
46
  allowClickOutsideClose = true;
45
47
  buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
46
48
  var callBackUrl = getDoubleFaUrl(params);
@@ -49,15 +51,9 @@ export function getChannelBehavior(paymentSessionMetaData) {
49
51
  };
50
52
  };
51
53
  }
52
- if (isEasyPayTngWallet(paymentSessionMetaData)) {
53
- buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
54
- return {};
55
- };
56
- }
57
54
  }
58
55
  }
59
56
  return {
60
- usePaymentSessionAsQueryResult: usePaymentSessionAsQueryResult,
61
57
  allowSubmitPayCallAhead: allowSubmitPayCallAhead,
62
58
  buildSubmitPayExtParams: buildSubmitPayExtParams,
63
59
  createIframeNode: true,
@@ -82,18 +78,4 @@ export function getDoubleFaUrl(params) {
82
78
  };
83
79
  var doubleFaBaseUrl = DOUBLE_FA_URL_MAPPING[env] || DOUBLE_FA_URL_MAPPING.prod;
84
80
  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;
99
81
  }
@@ -74,9 +74,6 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
74
74
  }
75
75
  return _context.abrupt("return", this.buildRedirectResult(authUrlInfo));
76
76
  case 12:
77
- _context.next = 14;
78
- return this.initSecuritySDK();
79
- case 14:
80
77
  // 下面的场景是需要渲染UI的渠道, 打开WebUrl
81
78
  webAppUrl = this.buildWebAppUrl(); // const webAppUrl = 'http://svc-9kvjxwjf68cptha8.cloudide.svc.et15-sqa.alipay.net:5173/src/component-app/index.html';
82
79
  resultPayload = {
@@ -95,7 +92,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
95
92
  behaviorType: 'RENDER',
96
93
  payload: resultPayload
97
94
  });
98
- case 19:
95
+ case 17:
99
96
  case "end":
100
97
  return _context.stop();
101
98
  }
@@ -216,11 +213,12 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
216
213
  });
217
214
 
218
215
  // 等请求和 Web启动都Ready之后,发送renderComponent
219
- Promise.all([this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
216
+ Promise.all([this.initSecuritySDK(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
220
217
  var _this2$paymentContext, _this2$paymentContext2, _this2$paymentContext3, _this2$paymentContext4, _this2$paymentContext5, _this2$paymentContext6, _this2$paymentContext7, _this2$paymentContext8, _this2$paymentContext9;
221
- var _ref2 = _slicedToArray(_ref, 2),
222
- submitRes = _ref2[0],
223
- launchRes = _ref2[1];
218
+ var _ref2 = _slicedToArray(_ref, 3),
219
+ _initSecurityRes = _ref2[0],
220
+ submitRes = _ref2[1],
221
+ _webLaunchRes = _ref2[2];
224
222
  var logMetaData = _this2.logger.getLogConfig().mdata;
225
223
  eventCenter.dispatchToApp({
226
224
  event: 'renderComponent',
@@ -290,14 +288,15 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
290
288
  this.allowSubmitPayCallAhead = this.channelBehavior.allowSubmitPayCallAhead;
291
289
  console.log('[web-sdk] allowSubmitPayCallAhead =', this.allowSubmitPayCallAhead);
292
290
  if (this.allowSubmitPayCallAhead) {
293
- _context2.next = 8;
291
+ _context2.next = 9;
294
292
  break;
295
293
  }
294
+ console.log('[web-sdk] DO NOT call submitPay');
296
295
  return _context2.abrupt("return", {
297
296
  message: 'sdk no need to make submitPay request',
298
297
  success: true
299
298
  });
300
- case 8:
299
+ case 9:
301
300
  requestBizId = uuid(); // 下面真实发请求
302
301
  this.logger.logInfo({
303
302
  title: 'sdk_event_submitPay'
@@ -317,14 +316,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
317
316
  extParams.complianceSDK = true;
318
317
  submitParams.extParams = extParams;
319
318
  requester = ServiceProvider.getInstance(this.instanceId).getService('Requester');
320
- _context2.prev = 14;
321
- console.log('[web-sdk]call submitPay');
319
+ _context2.prev = 15;
320
+ console.log('[web-sdk] DO call submitPay');
322
321
  _context2.t0 = requester;
323
322
  _context2.t1 = submitParams;
324
323
  _context2.t2 = this.initConfig.environment;
325
- _context2.next = 21;
324
+ _context2.next = 22;
326
325
  return this.acquireApdidToken();
327
- case 21:
326
+ case 22:
328
327
  _context2.t3 = _context2.sent;
329
328
  _context2.t4 = {
330
329
  deviceId: _context2.t3
@@ -338,9 +337,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
338
337
  needEnvInfo: true,
339
338
  'Operation-Type': 'com.ipay.iexpcashier.cashier.submitPayByPaymentSession'
340
339
  };
341
- _context2.next = 27;
340
+ _context2.next = 28;
342
341
  return _context2.t0.request.call(_context2.t0, _context2.t1, _context2.t6);
343
- case 27:
342
+ case 28:
344
343
  res = _context2.sent;
345
344
  this.logger.logInfo({
346
345
  title: 'sdk_event_submitPayEnd'
@@ -350,9 +349,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
350
349
  traceId: res.traceId
351
350
  });
352
351
  return _context2.abrupt("return", res);
353
- case 32:
354
- _context2.prev = 32;
355
- _context2.t7 = _context2["catch"](14);
352
+ case 33:
353
+ _context2.prev = 33;
354
+ _context2.t7 = _context2["catch"](15);
356
355
  this.logger.logError({
357
356
  title: 'sdk_event_submitPay_failed'
358
357
  }, {
@@ -362,11 +361,11 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
362
361
  traceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
363
362
  });
364
363
  throw _context2.t7;
365
- case 36:
364
+ case 37:
366
365
  case "end":
367
366
  return _context2.stop();
368
367
  }
369
- }, _callee2, this, [[14, 32]]);
368
+ }, _callee2, this, [[15, 33]]);
370
369
  }));
371
370
  function processSubmitPay() {
372
371
  return _processSubmitPay.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1730107332-dev.7",
3
+ "version": "0.0.1730107332-dev.9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",