@alipay/ams-checkout 0.0.1711691167-dev.9 → 0.0.1712728793-dev.0

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.
@@ -81,19 +81,6 @@ export interface IappendIframeNodesParams extends IcreateComponent {
81
81
  paymentSessionMetaData: IpaymentSessionMetaData;
82
82
  renderDisplayType: renderDisplayTypeEnum;
83
83
  selector?: Iselector;
84
- paypalConfiguration?: IPaypalConfiguration;
85
- }
86
- export interface IPaypalConfiguration {
87
- style?: Object;
88
- blockPayPalCreditButton?: boolean;
89
- blockPayPalPayLaterButton?: boolean;
90
- displayPayPalPayLaterButtonOnly?: boolean;
91
- enableMessages?: boolean;
92
- intent?: payPalConfigurationIntentEnum;
93
- }
94
- export declare enum payPalConfigurationIntentEnum {
95
- 'intent' = "intent",
96
- 'capture' = "capture"
97
84
  }
98
85
  export interface IMerchantAppointParam {
99
86
  storedCard?: IStoredCard;
@@ -146,6 +133,11 @@ export interface IpaymentSessionMetaData {
146
133
  action?: {
147
134
  autoDebitWithToken: boolean;
148
135
  skipSdkQuery: boolean;
136
+ skipSdkQueryForm?: {
137
+ value: boolean;
138
+ version: string;
139
+ platform: string;
140
+ };
149
141
  };
150
142
  paymentSessionFactor?: {
151
143
  extendInfo?: {
@@ -209,33 +201,6 @@ export interface IpaymentSessionMetaData {
209
201
  };
210
202
  };
211
203
  }
212
- export interface IPaymentSessionFactor {
213
- merchantInfo?: IMerchantInfo;
214
- paymentMethodInfo: IPaymentMethodInfo;
215
- }
216
- export interface IPaymentMethodInfo {
217
- paymentAmount?: IPaymentAmount;
218
- paymentMethodMetaData?: IPaymentMethodMetaData;
219
- paymentMethodType?: PaypalMethodEnum;
220
- paypal?: IPaypalConfig;
221
- }
222
- export type IPaypalConfig = {
223
- accessToken: string;
224
- };
225
- export interface IPaymentMethodMetaData {
226
- bindPaymentMethod?: string;
227
- boundPaymentMethod?: string;
228
- }
229
- export interface IMerchantInfo {
230
- channelMerchantAccountId?: string;
231
- }
232
- export interface IPaymentAmount {
233
- value?: string;
234
- currency?: PaymentAmountEnum;
235
- }
236
- export declare enum PaymentAmountEnum {
237
- USD = "USD"
238
- }
239
204
  export declare enum localeEnum {
240
205
  'en-US' = "en-US"
241
206
  }
@@ -495,10 +460,7 @@ export declare enum eventCodeEnum {
495
460
  /**
496
461
  * 当前为Apple Pay发起了Pay请求,但是用户关闭了页面
497
462
  */
498
- SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING",
499
- SDK_PAYMENT_WARN = "SDK_PAYMENT_WARN",
500
- SDK_PAYMENT_SHIPPINGCHANGE = "SDK_PAYMENT_SHIPPINGCHANGE",
501
- SDK_PAYMENT_APPROVE = "SDK_PAYMENT_APPROVE"
463
+ SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
502
464
  }
503
465
  export declare enum RedirectType {
504
466
  ApplinkUrl = "ApplinkUrl",
@@ -519,11 +481,6 @@ export interface CallbackEventInfo {
519
481
  export interface MultipleCallbackEvents {
520
482
  [key: string]: CallbackEventInfo;
521
483
  }
522
- export declare enum PaypalMethodEnum {
523
- PAYPAL_CHECKOUT = "PAYPAL_CHECKOUT",
524
- PAYPAL_VAULT = "PAYPAL_VAULT",
525
- PAYPAL_PAYLATER = "PAYPAL_PAYLATER"
526
- }
527
484
  export type PaymentMethodTypeEnum = 'ApplePay';
528
485
  export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
529
486
  export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
@@ -41,15 +41,6 @@ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodC
41
41
  paymentMethodCategoryTypeEnum["APM"] = "APM";
42
42
  return paymentMethodCategoryTypeEnum;
43
43
  }({});
44
- export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {
45
- payPalConfigurationIntentEnum["intent"] = "intent";
46
- payPalConfigurationIntentEnum["capture"] = "capture";
47
- return payPalConfigurationIntentEnum;
48
- }({});
49
- export var PaymentAmountEnum = /*#__PURE__*/function (PaymentAmountEnum) {
50
- PaymentAmountEnum["USD"] = "USD";
51
- return PaymentAmountEnum;
52
- }({});
53
44
  export var localeEnum = /*#__PURE__*/function (localeEnum) {
54
45
  localeEnum["en-US"] = "en-US";
55
46
  return localeEnum;
@@ -167,9 +158,6 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
167
158
  eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
168
159
  eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
169
160
  eventCodeEnum["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
170
- eventCodeEnum["SDK_PAYMENT_WARN"] = "SDK_PAYMENT_WARN";
171
- eventCodeEnum["SDK_PAYMENT_SHIPPINGCHANGE"] = "SDK_PAYMENT_SHIPPINGCHANGE";
172
- eventCodeEnum["SDK_PAYMENT_APPROVE"] = "SDK_PAYMENT_APPROVE";
173
161
  return eventCodeEnum;
174
162
  }({});
175
163
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
@@ -179,12 +167,6 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
179
167
  RedirectType["Unknown"] = "Unknown";
180
168
  return RedirectType;
181
169
  }({});
182
- export var PaypalMethodEnum = /*#__PURE__*/function (PaypalMethodEnum) {
183
- PaypalMethodEnum["PAYPAL_CHECKOUT"] = "PAYPAL_CHECKOUT";
184
- PaypalMethodEnum["PAYPAL_VAULT"] = "PAYPAL_VAULT";
185
- PaypalMethodEnum["PAYPAL_PAYLATER"] = "PAYPAL_PAYLATER";
186
- return PaypalMethodEnum;
187
- }({});
188
170
  export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
189
171
  ProductSceneVersion["V1"] = "1.0";
190
172
  ProductSceneVersion["V2"] = "2.0";
@@ -37,6 +37,5 @@ declare const addSetFontSizeEvent: () => void;
37
37
  */
38
38
  declare const getOrSetStorageId: (key: string, value?: string) => string;
39
39
  declare const checkTimeElapsed: () => boolean;
40
- declare const isFunction: (func: any) => boolean;
41
40
  declare function parseBase64ToString(base64: string): string;
42
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, };
41
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, };
package/esm/util/index.js CHANGED
@@ -246,9 +246,7 @@ var checkTimeElapsed = function checkTimeElapsed() {
246
246
  localStorage.setItem(key, currentTime.toString());
247
247
  return true;
248
248
  };
249
- var isFunction = function isFunction(func) {
250
- return typeof func === 'function';
251
- };
249
+
252
250
  // https://developer.mozilla.org/en-US/docs/Glossary/Base64
253
251
  function parseBase64ToString(base64) {
254
252
  try {
@@ -261,4 +259,4 @@ function parseBase64ToString(base64) {
261
259
  return null;
262
260
  }
263
261
  }
264
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
262
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
@@ -23,7 +23,6 @@ export interface LogMetaData {
23
23
  paymentMethodType?: string;
24
24
  paymentMethodCategoryType?: string;
25
25
  requestSeq?: string;
26
- trackId?: string;
27
26
  }
28
27
  interface Config {
29
28
  scriptUrl: string;
@@ -42,7 +41,6 @@ export declare class Logger {
42
41
  private debug;
43
42
  private componentStartTime;
44
43
  private isLoaded;
45
- private trackId;
46
44
  constructor(config: Config, debug: boolean);
47
45
  setMedta(mdata: LogMetaData): void;
48
46
  logError(error: LogPayload, extra?: Extra): Logger;
@@ -53,8 +51,6 @@ export declare class Logger {
53
51
  initTracker(): void;
54
52
  send(): void;
55
53
  setComponentStartTime(val: number): void;
56
- setTrackId(trackId: string): void;
57
- getComponentStartTime(): number;
58
54
  }
59
55
  export declare const LogConfig: Config;
60
56
  export {};
@@ -15,7 +15,6 @@ export var Logger = /*#__PURE__*/function () {
15
15
  _defineProperty(this, "debug", void 0);
16
16
  _defineProperty(this, "componentStartTime", void 0);
17
17
  _defineProperty(this, "isLoaded", void 0);
18
- _defineProperty(this, "trackId", void 0);
19
18
  this.logs = [];
20
19
  this.config = config;
21
20
  this.debug = debug;
@@ -100,28 +99,19 @@ export var Logger = /*#__PURE__*/function () {
100
99
  try {
101
100
  var log = logs.pop();
102
101
  if (log.type === 'error') {
103
- var _log$logPayload;
104
102
  logError(log.logPayload, _objectSpread({
105
103
  fsDuration: fsDuration,
106
- timeStamp: now,
107
- trackId: this.trackId,
108
- title: (_log$logPayload = log.logPayload) === null || _log$logPayload === void 0 ? void 0 : _log$logPayload.title
104
+ timeStamp: now
109
105
  }, log === null || log === void 0 ? void 0 : log.extra));
110
106
  } else if (log.type === 'info') {
111
- var _log$logPayload2;
112
107
  logInfo(log.logPayload, _objectSpread({
113
108
  fsDuration: fsDuration,
114
- timeStamp: now,
115
- trackId: this.trackId,
116
- title: (_log$logPayload2 = log.logPayload) === null || _log$logPayload2 === void 0 ? void 0 : _log$logPayload2.title
109
+ timeStamp: now
117
110
  }, log === null || log === void 0 ? void 0 : log.extra));
118
111
  } else if (log.type === 'rpc') {
119
- var _log$logPayload3;
120
112
  reportRPC(log.logPayload, _objectSpread({
121
113
  fsDuration: fsDuration,
122
- timeStamp: now,
123
- trackId: this.trackId,
124
- title: (_log$logPayload3 = log.logPayload) === null || _log$logPayload3 === void 0 ? void 0 : _log$logPayload3.title
114
+ timeStamp: now
125
115
  }, log === null || log === void 0 ? void 0 : log.extra));
126
116
  }
127
117
  } catch (error) {
@@ -176,16 +166,6 @@ export var Logger = /*#__PURE__*/function () {
176
166
  value: function setComponentStartTime(val) {
177
167
  this.componentStartTime = val;
178
168
  }
179
- }, {
180
- key: "setTrackId",
181
- value: function setTrackId(trackId) {
182
- this.trackId = trackId;
183
- }
184
- }, {
185
- key: "getComponentStartTime",
186
- value: function getComponentStartTime() {
187
- return this.componentStartTime;
188
- }
189
169
  }]);
190
170
  return Logger;
191
171
  }();
@@ -3,4 +3,6 @@
3
3
  * @param v1
4
4
  * @param v2
5
5
  */
6
- export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
6
+ export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
7
+ export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
8
+ export declare function matchVersion(config: any, currentVersion: any): boolean;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * 返回值0标识一样大,1表示v1大,-1表示v2大
3
9
  * @param v1
@@ -42,4 +48,73 @@ export function compareVersion(v1, v2) {
42
48
  } else {
43
49
  return 1;
44
50
  }
51
+ }
52
+ export function isVersionInRange(currentVersion, minVersion, maxVersion) {
53
+ function splitVersion(version) {
54
+ return version.split('.').map(function (num) {
55
+ return parseInt(num, 10);
56
+ });
57
+ }
58
+ function compareVersions(v1, v2) {
59
+ for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
60
+ var num1 = v1[i] === undefined ? 0 : v1[i];
61
+ var num2 = v2[i] === undefined ? 0 : v2[i];
62
+ if (num1 > num2) return 1;
63
+ if (num1 < num2) return -1;
64
+ }
65
+ return 0;
66
+ }
67
+ var current = splitVersion(currentVersion);
68
+ var min = minVersion ? splitVersion(minVersion) : null;
69
+ var max = maxVersion ? splitVersion(maxVersion) : null;
70
+ if (min && compareVersions(current, min) < 0) {
71
+ // 当前版本小于最小允许版本
72
+ return false;
73
+ }
74
+ if (max && compareVersions(current, max) > 0) {
75
+ // 当前版本大于最大允许版本
76
+ return false;
77
+ }
78
+ // 当前版本在允许的版本范围内
79
+ return true;
80
+ }
81
+ export function matchVersion(config, currentVersion) {
82
+ var value = config.value,
83
+ version = config.version,
84
+ platform = config.platform;
85
+ var CURRENT_PLATFORM = 'WEB';
86
+ var isMatchVersion = false;
87
+ var isMatchPlatform = false;
88
+
89
+ // 平台判断
90
+ if (platform) {
91
+ var platformList = platform.split('|').map(function (platform) {
92
+ return platform.toLocaleUpperCase();
93
+ });
94
+ isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
95
+ } else {
96
+ // 没有表示平台全匹配
97
+ isMatchPlatform = true;
98
+ }
99
+ // 版本判断
100
+ if (!version) {
101
+ // 为空全匹配
102
+ isMatchVersion = true;
103
+ } else if (version.indexOf('|') !== -1) {
104
+ // | 范围匹配
105
+ var _version$split = version.split('|'),
106
+ _version$split2 = _slicedToArray(_version$split, 2),
107
+ _version$split2$ = _version$split2[0],
108
+ minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
109
+ _version$split2$2 = _version$split2[1],
110
+ maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
111
+ isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
112
+ } else if (version.indexOf(',') !== -1) {
113
+ // , 枚举匹配
114
+ var versionList = version.split(',');
115
+ isMatchVersion = versionList.includes(currentVersion);
116
+ } else {
117
+ isMatchVersion = version === currentVersion;
118
+ }
119
+ return value && isMatchPlatform && isMatchVersion;
45
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1711691167-dev.9",
3
+ "version": "0.0.1712728793-dev.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
@@ -1,20 +0,0 @@
1
- import { BusContext, BusMessage, BusSubscriber } from '../../core/bus';
2
- import { Logger } from '../../util/logger';
3
- export declare class PaypalBusSubscriber extends BusSubscriber {
4
- logger: Logger;
5
- constructor(logger: Logger);
6
- actionNames(): string[];
7
- private onEventCallback;
8
- protected renderPaypalButton(context: BusContext, message: BusMessage): Promise<never>;
9
- private appendPaypalLoading;
10
- private removePaypalLoading;
11
- private preCheck;
12
- private loadPaypalResource;
13
- private createPaypalScript;
14
- private onShippingChange;
15
- private createOrder;
16
- private onApprove;
17
- private onCancel;
18
- private destroyComponent;
19
- onMessage(context: BusContext, message: BusMessage): void;
20
- }