@alipay/ams-checkout 0.0.1730107332-dev.1 → 0.0.1730107332-dev.11

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,7 +1,6 @@
1
1
  import type { IPaymentSessionMetaData } from "../types";
2
2
  export type IChannelBehavior = {
3
- usePaymentSessionAsQueryResult: boolean;
4
- submitPayInSdk: boolean;
3
+ allowSubmitPayCallAhead: boolean;
5
4
  createIframeNode: boolean;
6
5
  loadApp: boolean;
7
6
  buildSubmitPayExtParams?: (params: GetDoubleFaParams) => any;
@@ -1,36 +1,64 @@
1
1
  export function getChannelBehavior(paymentSessionMetaData) {
2
- var _paymentSessionMetaDa, _paymentSessionMetaDa2, _paymentSessionMetaDa3, _paymentSessionMetaDa4, _paymentSessionMetaDa5, _paymentSessionMetaDa6, _paymentSessionMetaDa7, _paymentSessionMetaDa8;
3
- // TOSS EASYPAY 2.0
4
- if ('BANKTRANSFER_QUICKPAY' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType) && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa2 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa2 === void 0 ? void 0 : _paymentSessionMetaDa2.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa3 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa3 === void 0 ? void 0 : _paymentSessionMetaDa3.paymentMethodCategoryType) === 'APM' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa4 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa4 === void 0 ? void 0 : _paymentSessionMetaDa4.productSceneVersion) === '2.0') {
5
- return {
6
- usePaymentSessionAsQueryResult: true,
7
- submitPayInSdk: true,
8
- createIframeNode: true,
9
- loadApp: true,
10
- allowClickOutsideClose: true,
11
- buildSubmitPayExtParams: function buildSubmitPayExtParams(params) {
12
- var callBackUrl = getDoubleFaUrl(params);
13
- return {
14
- callBackUrl: callBackUrl
15
- };
2
+ var _paymentSessionMetaDa;
3
+ var allowSubmitPayCallAhead = false;
4
+ var allowClickOutsideClose = false;
5
+ var buildSubmitPayExtParams = undefined;
6
+
7
+ // EASYPAY
8
+ if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.productScene) === 'EASY_PAY') {
9
+ var _paymentSessionMetaDa2, _paymentSessionMetaDa3, _paymentSessionMetaDa4, _paymentSessionMetaDa5;
10
+ var amountConfirmRequired = (_paymentSessionMetaDa2 = paymentSessionMetaData.action) === null || _paymentSessionMetaDa2 === void 0 ? void 0 : _paymentSessionMetaDa2.amountConfirmRequired;
11
+ var isFirstTimeToPay = !((_paymentSessionMetaDa3 = paymentSessionMetaData.action) !== null && _paymentSessionMetaDa3 !== void 0 && _paymentSessionMetaDa3.autoDebitWithToken);
12
+ // EASYPAY 1.0
13
+ if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa4 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa4 === void 0 ? void 0 : _paymentSessionMetaDa4.productSceneVersion) === '1.0') {
14
+ if (!isFirstTimeToPay && amountConfirmRequired) {
15
+ allowSubmitPayCallAhead = false;
16
+ } else {
17
+ allowSubmitPayCallAhead = true;
16
18
  }
17
- };
18
- }
19
- // TNG EASYPAY 2.0
20
- if ('TNG' === (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa5 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa5 === void 0 ? void 0 : _paymentSessionMetaDa5.paymentMethodType) && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa6 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa6 === void 0 ? void 0 : _paymentSessionMetaDa6.productScene) === 'EASY_PAY' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa7 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa7 === void 0 ? void 0 : _paymentSessionMetaDa7.paymentMethodCategoryType) === 'WALLET' && (paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa8 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa8 === void 0 ? void 0 : _paymentSessionMetaDa8.productSceneVersion) === '2.0') {
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 {};
19
+ } else if ((paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa5 = paymentSessionMetaData.paymentSessionConfig) === null || _paymentSessionMetaDa5 === void 0 ? void 0 : _paymentSessionMetaDa5.productSceneVersion) === '2.0') {
20
+ var _paymentSessionMetaDa8;
21
+ if (isFirstTimeToPay) {
22
+ var _paymentSessionMetaDa6;
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)) {
26
+ allowSubmitPayCallAhead = true;
27
+ } else {
28
+ allowSubmitPayCallAhead = false;
29
+ }
30
+ } else {
31
+ if (amountConfirmRequired) {
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)) {
35
+ allowSubmitPayCallAhead = true;
36
+ } else {
37
+ allowSubmitPayCallAhead = false;
38
+ }
39
+ } else {
40
+ allowSubmitPayCallAhead = true;
41
+ }
30
42
  }
31
- };
43
+
44
+ // TOSS
45
+ if (['BANKTRANSFER_QUICKPAY'].includes(paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa8 = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa8 === void 0 ? void 0 : _paymentSessionMetaDa8.paymentMethodType)) {
46
+ allowClickOutsideClose = true;
47
+ buildSubmitPayExtParams = function buildSubmitPayExtParams(params) {
48
+ var callBackUrl = getDoubleFaUrl(params);
49
+ return {
50
+ callBackUrl: callBackUrl
51
+ };
52
+ };
53
+ }
54
+ }
32
55
  }
33
- return undefined;
56
+ return {
57
+ allowSubmitPayCallAhead: allowSubmitPayCallAhead,
58
+ buildSubmitPayExtParams: buildSubmitPayExtParams,
59
+ createIframeNode: true,
60
+ loadApp: true
61
+ };
34
62
  }
35
63
  export function getDoubleFaUrl(params) {
36
64
  var instanceId = params.instanceId,
@@ -64,7 +64,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
64
64
  var _this = this;
65
65
  var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
66
66
  eventCenter.listen(EVENT.redirect.name, function (data) {
67
- var _data$isDestroy;
67
+ var _data$isDestroy, _data$isCallApp, _data$callAppDetectSu;
68
68
  if (!data) {
69
69
  return;
70
70
  }
@@ -75,7 +75,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
75
75
  applinkUrl: (data === null || data === void 0 ? void 0 : data.applinkUrl) || '',
76
76
  schemeUrl: (data === null || data === void 0 ? void 0 : data.schemeUrl) || '',
77
77
  url: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
78
- browserLinkTarget: data === null || data === void 0 ? void 0 : data.target
78
+ browserLinkTarget: data === null || data === void 0 ? void 0 : data.target,
79
+ isCallApp: (_data$isCallApp = data === null || data === void 0 ? void 0 : data.isCallApp) !== null && _data$isCallApp !== void 0 ? _data$isCallApp : false,
80
+ callAppDetectSuccessDelay: (_data$callAppDetectSu = data === null || data === void 0 ? void 0 : data.callAppDetectSuccessDelay) !== null && _data$callAppDetectSu !== void 0 ? _data$callAppDetectSu : 5000
79
81
  };
80
82
  redirect(redirectBehavior, _this.instanceId);
81
83
  if (needCleanContainer) {
@@ -84,7 +86,8 @@ export var AntomSDKCore = /*#__PURE__*/function () {
84
86
  });
85
87
  eventCenter.listen(EVENT.initSecuritySDK.name, /*#__PURE__*/function () {
86
88
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, payload) {
87
- var securityService, _payload$context, _payload$context2;
89
+ var _payload$context;
90
+ var securityService, success;
88
91
  return _regeneratorRuntime().wrap(function _callee$(_context) {
89
92
  while (1) switch (_context.prev = _context.next) {
90
93
  case 0:
@@ -93,26 +96,22 @@ export var AntomSDKCore = /*#__PURE__*/function () {
93
96
  _context.next = 4;
94
97
  return securityService.initSecurity();
95
98
  case 4:
96
- eventCenter.dispatchToApp({
97
- event: 'appEventCallback',
98
- eventCallbackId: (_payload$context = payload.context) === null || _payload$context === void 0 ? void 0 : _payload$context.eventCallbackId,
99
- data: {
100
- success: true
101
- }
102
- });
99
+ success = true;
103
100
  _context.next = 10;
104
101
  break;
105
102
  case 7:
106
103
  _context.prev = 7;
107
104
  _context.t0 = _context["catch"](1);
105
+ success = false;
106
+ case 10:
108
107
  eventCenter.dispatchToApp({
109
108
  event: 'appEventCallback',
110
- eventCallbackId: (_payload$context2 = payload.context) === null || _payload$context2 === void 0 ? void 0 : _payload$context2.eventCallbackId,
109
+ eventCallbackId: (_payload$context = payload.context) === null || _payload$context === void 0 ? void 0 : _payload$context.eventCallbackId,
111
110
  data: {
112
- success: false
111
+ success: success
113
112
  }
114
113
  });
115
- case 10:
114
+ case 11:
116
115
  case "end":
117
116
  return _context.stop();
118
117
  }
@@ -122,6 +121,35 @@ export var AntomSDKCore = /*#__PURE__*/function () {
122
121
  return _ref.apply(this, arguments);
123
122
  };
124
123
  }());
124
+ eventCenter.listen(EVENT.getDeviceId.name, /*#__PURE__*/function () {
125
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, payload) {
126
+ var _payload$context2;
127
+ var securityService, deviceId;
128
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
129
+ while (1) switch (_context2.prev = _context2.next) {
130
+ case 0:
131
+ securityService = ServiceProvider.getInstance(_this.instanceId).getService('Security');
132
+ _context2.next = 3;
133
+ return securityService.getDeviceId(data);
134
+ case 3:
135
+ deviceId = _context2.sent;
136
+ eventCenter.dispatchToApp({
137
+ event: 'appEventCallback',
138
+ eventCallbackId: (_payload$context2 = payload.context) === null || _payload$context2 === void 0 ? void 0 : _payload$context2.eventCallbackId,
139
+ data: {
140
+ deviceId: deviceId
141
+ }
142
+ });
143
+ case 5:
144
+ case "end":
145
+ return _context2.stop();
146
+ }
147
+ }, _callee2);
148
+ }));
149
+ return function (_x3, _x4) {
150
+ return _ref2.apply(this, arguments);
151
+ };
152
+ }());
125
153
 
126
154
  // execute additional logic from specified product
127
155
  if (this.productProcessors[sdkMetaData.productScene]) {
@@ -131,13 +159,14 @@ export var AntomSDKCore = /*#__PURE__*/function () {
131
159
  }, {
132
160
  key: "startBizFlow",
133
161
  value: function () {
134
- var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
162
+ var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
163
+ var _this$paymentContext$;
135
164
  var paymentSession, displayInfo, _convertPaymentSessio, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
136
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
137
- while (1) switch (_context2.prev = _context2.next) {
165
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
166
+ while (1) switch (_context3.prev = _context3.next) {
138
167
  case 0:
139
168
  if (!(!options || !options.paymentSession)) {
140
- _context2.next = 2;
169
+ _context3.next = 2;
141
170
  break;
142
171
  }
143
172
  throw new Error('paymentSession is empty');
@@ -165,62 +194,62 @@ export var AntomSDKCore = /*#__PURE__*/function () {
165
194
 
166
195
  // Invoke processor
167
196
  productScene = this.paymentContext.paymentSessionObj.paymentSessionConfig.productScene;
168
- paymentMethod = this.paymentContext.paymentSessionObj.paymentMethodInfoView.paymentMethodType;
169
- _context2.prev = 13;
197
+ paymentMethod = (_this$paymentContext$ = this.paymentContext.paymentSessionObj.paymentMethodInfoView) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.paymentMethodType;
198
+ _context3.prev = 13;
170
199
  if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
171
- _context2.next = 20;
200
+ _context3.next = 20;
172
201
  break;
173
202
  }
174
- _context2.next = 17;
203
+ _context3.next = 17;
175
204
  return this.productProcessors["".concat(productScene, "|").concat(paymentMethod)].startBizFlow(this.paymentContext);
176
205
  case 17:
177
- this.bizFlowStartBehavior = _context2.sent;
178
- _context2.next = 24;
206
+ this.bizFlowStartBehavior = _context3.sent;
207
+ _context3.next = 24;
179
208
  break;
180
209
  case 20:
181
210
  if (!this.productProcessors["".concat(productScene)]) {
182
- _context2.next = 24;
211
+ _context3.next = 24;
183
212
  break;
184
213
  }
185
- _context2.next = 23;
214
+ _context3.next = 23;
186
215
  return this.productProcessors["".concat(productScene)].startBizFlow(this.paymentContext);
187
216
  case 23:
188
- this.bizFlowStartBehavior = _context2.sent;
217
+ this.bizFlowStartBehavior = _context3.sent;
189
218
  case 24:
190
- _context2.next = 29;
219
+ _context3.next = 29;
191
220
  break;
192
221
  case 26:
193
- _context2.prev = 26;
194
- _context2.t0 = _context2["catch"](13);
195
- console.error('Invoke processor failed', _context2.t0);
222
+ _context3.prev = 26;
223
+ _context3.t0 = _context3["catch"](13);
224
+ console.error('Invoke processor failed', _context3.t0);
196
225
  case 29:
197
226
  if (!(!this.bizFlowStartBehavior || this.bizFlowStartBehavior.behaviorType === 'NONE' || !this.bizFlowStartBehavior.payload)) {
198
- _context2.next = 31;
227
+ _context3.next = 31;
199
228
  break;
200
229
  }
201
- return _context2.abrupt("return");
230
+ return _context3.abrupt("return");
202
231
  case 31:
203
232
  if (!(this.bizFlowStartBehavior.behaviorType === 'RENDER')) {
204
- _context2.next = 34;
233
+ _context3.next = 34;
205
234
  break;
206
235
  }
207
236
  this.handleBehaviorRender();
208
- return _context2.abrupt("return");
237
+ return _context3.abrupt("return");
209
238
  case 34:
210
239
  if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
211
- _context2.next = 38;
240
+ _context3.next = 38;
212
241
  break;
213
242
  }
214
243
  payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
215
244
  redirect(payload, this.instanceId);
216
- return _context2.abrupt("return");
245
+ return _context3.abrupt("return");
217
246
  case 38:
218
247
  case "end":
219
- return _context2.stop();
248
+ return _context3.stop();
220
249
  }
221
- }, _callee2, this, [[13, 26]]);
250
+ }, _callee3, this, [[13, 26]]);
222
251
  }));
223
- function startBizFlow(_x3) {
252
+ function startBizFlow(_x5) {
224
253
  return _startBizFlow.apply(this, arguments);
225
254
  }
226
255
  return startBizFlow;
@@ -19,6 +19,7 @@ export interface StartBizFlowOptions {
19
19
  paymentSession: string;
20
20
  displayInfo?: Partial<DisplayInfo>;
21
21
  submitPayRequestExtra?: any;
22
+ isAppWebview?: boolean;
22
23
  }
23
24
  export declare class DisplayInfo {
24
25
  type: DisplayTypeEnum;
@@ -50,6 +51,8 @@ export interface RedirectBehaviorPayload {
50
51
  schemeUrl?: string;
51
52
  applinkUrl?: string;
52
53
  browserLinkTarget?: TargetEnum;
54
+ isCallApp?: boolean;
55
+ callAppDetectSuccessDelay?: number;
53
56
  }
54
57
  /**
55
58
  * Provide some capability, such as MonitorService, EventBusService, SecurityService
@@ -1,17 +1,18 @@
1
1
  export type { SDKMetaData } from "../..";
2
+ export { v4 as uuid } from 'uuid';
3
+ export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBehaviorPayload, RenderBehaviorPayload, } from '../..';
2
4
  export * as ChannelCustomize from '../../../component/channel';
3
5
  export type { IChannelBehavior } from '../../../component/channel';
4
6
  export { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../../types';
5
- export { ProductInfoCacheUtil } from '../../utils/payment_product_utils';
6
- export { v4 as uuid } from 'uuid';
7
7
  export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, IOptionsParams, } from '../../../types';
8
- export { isPC } from '../../../util';
8
+ export { isEmpty, isPC } from '../../../util';
9
+ export { getBackScheme } from '../../../util/getBackScheme';
9
10
  export { isLocalMock } from '../../../util/mock';
10
- export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBehaviorPayload, RenderBehaviorPayload } from '../..';
11
11
  export { ServiceProvider } from '../../service';
12
12
  export type { ContainerService } from '../../service/container';
13
13
  export type { EventCenter } from '../../service/event-center';
14
14
  export { LogService } from '../../service/log';
15
15
  export type { RequesterService } from '../../service/requester/requester';
16
16
  export type { SecurityService } from '../../service/security';
17
+ export { ProductInfoCacheUtil } from '../../utils/payment_product_utils';
17
18
  export * as WebAppUrlUtil from '../../utils/web_app_url_utils';
@@ -1,11 +1,12 @@
1
+ export { v4 as uuid } from 'uuid';
1
2
  import * as _ChannelCustomize from "../../../component/channel";
2
3
  export { _ChannelCustomize as ChannelCustomize };
3
4
  export { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from "../../../types";
4
- export { ProductInfoCacheUtil } from "../../utils/payment_product_utils";
5
- export { v4 as uuid } from 'uuid';
6
- export { isPC } from "../../../util";
5
+ export { isEmpty, isPC } from "../../../util";
6
+ export { getBackScheme } from "../../../util/getBackScheme";
7
7
  export { isLocalMock } from "../../../util/mock";
8
8
  export { ServiceProvider } from "../../service";
9
9
  export { LogService } from "../../service/log";
10
+ export { ProductInfoCacheUtil } from "../../utils/payment_product_utils";
10
11
  import * as _WebAppUrlUtil from "../../utils/web_app_url_utils";
11
12
  export { _WebAppUrlUtil as WebAppUrlUtil };
@@ -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;