@alipay/ams-checkout 0.0.1710212811-dev.9 → 0.0.1710748686-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.
@@ -6,7 +6,7 @@
6
6
  * 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.
7
7
  */
8
8
  import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError, IApplePayTrace } from './interface';
9
- import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
9
+ import { IpaymentSessionMetaData } from '../../types';
10
10
  /**
11
11
  * Apple Pay Service
12
12
  */
@@ -30,11 +30,9 @@ declare class ApplePayService {
30
30
  */
31
31
  setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError, applePayTrace: IApplePayTrace): void;
32
32
  /**
33
- * Is Apple Pay Enabled
34
- * @param subTypeEnum
35
- * @returns
33
+ * Apple Pay is enabled
36
34
  */
37
- static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
35
+ isEnabled: () => boolean;
38
36
  /**
39
37
  * has Active Card in Apple Pay
40
38
  * @param merchantIdentifier
@@ -16,9 +16,6 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
16
16
  * 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.
17
17
  */
18
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
19
- import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
20
- import { ApplePaySubTypeEnum } from "../../types";
21
-
22
19
  /**
23
20
  * Apple Pay Service
24
21
  */
@@ -34,6 +31,12 @@ var ApplePayService = /*#__PURE__*/function () {
34
31
  _defineProperty(this, "completeApplePay", void 0);
35
32
  _defineProperty(this, "logError", void 0);
36
33
  _defineProperty(this, "applePayTrace", void 0);
34
+ /**
35
+ * Apple Pay is enabled
36
+ */
37
+ _defineProperty(this, "isEnabled", function () {
38
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() : false;
39
+ });
37
40
  _defineProperty(this, "onvalidatemerchant", function (event) {
38
41
  _this.applePayTrace('onValidateMerchant');
39
42
  _this.getMerchantSession({
@@ -41,7 +44,6 @@ var ApplePayService = /*#__PURE__*/function () {
41
44
  merchantIdentifier: _this.merchantIdentifier,
42
45
  validationUrl: event.validationURL
43
46
  }).then(function (merchantSessionObjectString) {
44
- console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
45
47
  var merchantSessionObject = JSON.parse(merchantSessionObjectString);
46
48
  _this.session.completeMerchantValidation(merchantSessionObject);
47
49
  _this.applePayTrace('completeMerchantValidation');
@@ -86,80 +88,28 @@ var ApplePayService = /*#__PURE__*/function () {
86
88
  throw Error('ApplePaySession is null in window');
87
89
  }
88
90
  var paymentSessionFactor = param.paymentSessionFactor;
89
- var extendInfo = paymentSessionFactor.extendInfo,
91
+ var applePay = paymentSessionFactor.applePay,
90
92
  merchantInfo = paymentSessionFactor.merchantInfo,
91
93
  paymentAmount = paymentSessionFactor.paymentAmount,
92
- order = paymentSessionFactor.order,
93
- recurringInfo = paymentSessionFactor.recurringInfo;
94
+ order = paymentSessionFactor.order;
94
95
  _this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
95
- if (!(extendInfo !== null && extendInfo !== void 0 && extendInfo.merchantCapabilities) || !(extendInfo !== null && extendInfo !== void 0 && extendInfo.supportedNetworks) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.registeredCountry) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.currency) || !(paymentAmount !== null && paymentAmount !== void 0 && paymentAmount.value) || !(merchantInfo !== null && merchantInfo !== void 0 && merchantInfo.merchantName)) {
96
- _this.logError("invalid session data");
97
- return;
98
- }
99
- // todo 补充参数校验
100
- if (recurringInfo) {
101
- var _recurringInfo$interv;
102
- if (!(order !== null && order !== void 0 && order.orderDescription) || recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL) {
103
- _this.logError("invalid session data");
104
- return;
105
- }
106
- // && order
107
- var lineItem = {
96
+ var request = {
97
+ merchantCapabilities: applePay === null || applePay === void 0 ? void 0 : applePay.merchantCapabilities,
98
+ supportedNetworks: applePay === null || applePay === void 0 ? void 0 : applePay.supportedNetworks,
99
+ countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
100
+ currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
101
+ total: {
108
102
  type: 'final',
109
- label: recurringInfo.title,
110
- amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value,
111
- paymentTiming: "recurring",
112
- recurringPaymentStartDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.startDate ? new Date(recurringInfo.startDate) : null,
113
- recurringPaymentEndDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.endDate ? new Date(recurringInfo.endDate) : null,
114
- recurringPaymentIntervalUnit: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.intervalUnit ? recurringInfo.intervalUnit : "month",
115
- recurringPaymentIntervalCount: (_recurringInfo$interv = recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.intervalCount) !== null && _recurringInfo$interv !== void 0 ? _recurringInfo$interv : 1
116
- };
117
- var recurringRequest = {
118
- // 不知道显示在哪里
119
- paymentDescription: order === null || order === void 0 ? void 0 : order.orderDescription,
120
- billingAgreement: recurringInfo.agreementDescription,
121
- // todo
122
- regularBilling: lineItem,
123
- managementURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.managementURL,
124
- tokenNotificationURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.tokenNotificationURL
125
- };
126
- var request = {
127
- merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
128
- supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
129
- countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
130
- currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
131
- total: {
132
- type: 'final',
133
- label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
134
- amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
135
- },
136
- recurringPaymentRequest: recurringRequest,
137
- lineItems: [lineItem]
138
- };
139
- _this.session = new ApplePaySession(APPLE_PAY_RECURRING_VERSION, request);
140
- } else {
141
- var _request = {
142
- merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
143
- supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
144
- countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
145
- currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
146
- total: {
147
- type: 'final',
148
- label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
149
- amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
150
- }
151
- };
152
- _this.session = new ApplePaySession(APPLE_PAY_VERSION, _request);
153
- }
103
+ label: order === null || order === void 0 ? void 0 : order.orderDescription,
104
+ amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
105
+ }
106
+ };
107
+ _this.session = new ApplePaySession(2, request);
154
108
  _this.session.onvalidatemerchant = _this.onvalidatemerchant;
155
109
  _this.session.onpaymentauthorized = _this.onpaymentauthorized;
156
110
  _this.session.oncancel = function () {
157
111
  _this.logError('UserCancel');
158
- try {
159
- _this.session.abort();
160
- } catch (error) {
161
- console.log("session.abort() error");
162
- }
112
+ _this.session.abort();
163
113
  };
164
114
  _this.session.begin();
165
115
  _this.applePayTrace('sessionBegin');
@@ -183,12 +133,6 @@ var ApplePayService = /*#__PURE__*/function () {
183
133
  this.logError = logError;
184
134
  this.applePayTrace = applePayTrace;
185
135
  }
186
-
187
- /**
188
- * Is Apple Pay Enabled
189
- * @param subTypeEnum
190
- * @returns
191
- */
192
136
  }, {
193
137
  key: "hasActiveCard",
194
138
  value: (
@@ -221,14 +165,6 @@ var ApplePayService = /*#__PURE__*/function () {
221
165
  }
222
166
  return hasActiveCard;
223
167
  }())
224
- }], [{
225
- key: "canMakePayments",
226
- value: function canMakePayments(subTypeEnum) {
227
- if (ApplePaySubTypeEnum.ApplePayRecurringPayment === subTypeEnum) {
228
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
229
- }
230
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
231
- }
232
168
  }]);
233
169
  return ApplePayService;
234
170
  }();
@@ -6,8 +6,6 @@
6
6
  * 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.
7
7
  */
8
8
  export type Version = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
9
- export declare const APPLE_PAY_VERSION = 2;
10
- export declare const APPLE_PAY_RECURRING_VERSION = 14;
11
9
  export interface IApplePayValidateMerchantEvent {
12
10
  validationURL: string;
13
11
  }
@@ -37,41 +35,10 @@ export interface IApplePayPaymentContact {
37
35
  countryCode: string;
38
36
  }
39
37
  export type IApplePayLineItemType = 'final' | 'pending';
40
- export type ApplePayPaymentTiming = "immediate" | "recurring" | "deferred" | "automaticReload";
41
- export type ApplePayRecurringPaymentDateUnit = "year" | "month" | "day" | "hour" | "minute";
42
- /**
43
- *
44
- {
45
- "label": "Subscription",
46
- "amount": "20.00",
47
- "type": "final",
48
- "paymentTiming": "recurring",
49
- "recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
50
- "recurringPaymentIntervalUnit": "month",
51
- "recurringPaymentIntervalCount": 6,
52
- "recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
53
- }
54
- */
55
38
  export interface IApplePayLineItem {
56
- /**
57
- * A value that indicates whether the line item is final or pending.
58
- */
59
39
  type: IApplePayLineItemType;
60
- /**
61
- * A required value that’s a short, localized description of the line item.
62
- */
63
40
  label: string;
64
- /**
65
- * A required value that’s the monetary amount of the line item.
66
- */
67
41
  amount: string;
68
- paymentTiming?: ApplePayPaymentTiming;
69
- recurringPaymentStartDate?: Date;
70
- recurringPaymentEndDate?: Date;
71
- recurringPaymentIntervalUnit?: ApplePayRecurringPaymentDateUnit;
72
- recurringPaymentIntervalCount?: number;
73
- deferredPaymentDate?: Date;
74
- automaticReloadPaymentThresholdAmount?: string;
75
42
  }
76
43
  export type applePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
77
44
  export interface IApplePayShippingMethod {
@@ -108,34 +75,6 @@ export interface IApplePayPaymentRequest {
108
75
  currencyCode: string;
109
76
  shippingType?: applePayShippingType;
110
77
  shippingMethods?: IApplePayShippingMethod[];
111
- recurringPaymentRequest?: IApplePayRecurringPaymentRequest;
112
- }
113
- export interface IApplePayRecurringPaymentRequest {
114
- /**
115
- * A description of the recurring payment that Apple Pay displays to the user in the payment sheet.
116
- */
117
- paymentDescription: string;
118
- /**
119
- * A localized billing agreement that the payment sheet displays to the user before the user authorizes the payment.
120
- */
121
- billingAgreement?: string;
122
- /**
123
- * The regular billing cycle for the recurring payment, including start and end dates, an interval, and an interval count.
124
- */
125
- regularBilling: IApplePayLineItem;
126
- /**
127
- * 订阅试用的周期控制,暂时不需要
128
- * The trial billing cycle for the recurring payment.
129
- */
130
- trialBilling?: IApplePayLineItem;
131
- /**
132
- * A URL to a web page where the user can update or delete the payment method for the recurring payment.
133
- */
134
- managementURL: string;
135
- /**
136
- * A URL you provide for receiving life-cycle notifications from the Apple Pay servers about the Apple Pay merchant token for the recurring payment.
137
- */
138
- tokenNotificationURL?: string;
139
78
  }
140
79
  export interface IApplePaySession {
141
80
  supportsVersion?: (version: Version) => boolean;
@@ -1,73 +1 @@
1
- /**
2
- * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
- * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
- * 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.
7
- */
8
- /* eslint-disable @typescript-eslint/no-explicit-any */
9
- // https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_on_the_web_version_history
10
-
11
- export var APPLE_PAY_VERSION = 2;
12
- export var APPLE_PAY_RECURRING_VERSION = 14;
13
-
14
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayvalidatemerchantevent
15
-
16
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaymerchantcapability
17
-
18
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest/1916122-supportednetworks
19
-
20
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaycontactfield
21
-
22
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentcontact
23
-
24
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitemtype
25
-
26
- //https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymenttiming
27
-
28
- //https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentdateunit
29
-
30
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaylineitem
31
- /**
32
- *
33
- {
34
- "label": "Subscription",
35
- "amount": "20.00",
36
- "type": "final",
37
- "paymentTiming": "recurring",
38
- "recurringPaymentStartDate": new Date("2022-01-01T00:00:00"),
39
- "recurringPaymentIntervalUnit": "month",
40
- "recurringPaymentIntervalCount": 6,
41
- "recurringPaymentEndDate": new Date("2024-01-01T00:00:00"),
42
- }
43
- */
44
-
45
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingtype
46
-
47
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingmethod
48
-
49
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment
50
-
51
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizedevent
52
-
53
- // https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/apple_pay_status_codes
54
-
55
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentauthorizationresult
56
-
57
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypaymentrequest
58
-
59
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest
60
-
61
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaysession
62
-
63
- // IGetMerchantSession spi type
64
-
65
- // ICompletePaymentAuthorized spi type
66
-
67
- // ICompleteApplePay spi type
68
-
69
- // ILogError spi type
70
-
71
- // trace msg type
72
-
73
- // IApplePayTrace spi type
1
+ export {};
@@ -155,10 +155,10 @@ export declare const EVENT: {
155
155
  getGlobalData: {
156
156
  name: string;
157
157
  };
158
- sendMuitiAppEventToSdk: {
158
+ sendMultiAppEventToSdk: {
159
159
  name: string;
160
160
  };
161
- receiveMuitiAppFromSdk: {
161
+ receiveMultiAppFromSdk: {
162
162
  name: string;
163
163
  };
164
164
  getUserAgentFromSdk: {
@@ -155,11 +155,11 @@ export var EVENT = {
155
155
  getGlobalData: {
156
156
  name: 'getGlobalData'
157
157
  },
158
- sendMuitiAppEventToSdk: {
159
- name: 'sendMuitiAppEventToSdk'
158
+ sendMultiAppEventToSdk: {
159
+ name: 'sendMultiAppEventToSdk'
160
160
  },
161
- receiveMuitiAppFromSdk: {
162
- name: 'receiveMuitiAppFromSdk'
161
+ receiveMultiAppFromSdk: {
162
+ name: 'receiveMultiAppFromSdk'
163
163
  },
164
164
  getUserAgentFromSdk: {
165
165
  name: 'getUserAgentFromSdk'
@@ -5,7 +5,7 @@
5
5
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
6
6
  * 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.
7
7
  */
8
- import { ApplePaySubTypeEnum, IApplePayOptionsParams } from '../../types';
8
+ import { IApplePayOptionsParams } from '../../types';
9
9
  import CoreInstance from '../instance';
10
10
  /**
11
11
  * Apple pay Component
@@ -20,10 +20,7 @@ declare class ApplePayComponent extends CoreInstance {
20
20
  private logDeviceId;
21
21
  /**
22
22
  * Is Apple Pay Enabled
23
- * @param subTypeEnum
24
- * @returns
25
23
  */
26
- canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): boolean;
27
24
  isAppPayEnabled(): boolean;
28
25
  /**
29
26
  * Submit Pay
@@ -132,18 +132,11 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
132
132
 
133
133
  /**
134
134
  * Is Apple Pay Enabled
135
- * @param subTypeEnum
136
- * @returns
137
135
  */
138
- }, {
139
- key: "canMakePayments",
140
- value: function canMakePayments(subTypeEnum) {
141
- return ApplePayService.canMakePayments(subTypeEnum);
142
- }
143
136
  }, {
144
137
  key: "isAppPayEnabled",
145
138
  value: function isAppPayEnabled() {
146
- return true;
139
+ return this._applePayService.isEnabled();
147
140
  }
148
141
 
149
142
  /**
@@ -363,14 +356,12 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
363
356
  biz: 'sdk'
364
357
  }).send();
365
358
  };
359
+
366
360
  // set Apple Pay params
367
361
  this._applePayService.setApplePayParams(getMerchantSession, completePaymentAuthorized, completeApplePay, logError, applePayTrace);
362
+
368
363
  // init Apple Pay service
369
- try {
370
- this._applePayService.startPay(this._parseData);
371
- } catch (error) {
372
- logError("appple runtime excepiton", error);
373
- }
364
+ this._applePayService.startPay(this._parseData);
374
365
  }
375
366
  }]);
376
367
  return ApplePayComponent;
@@ -1,5 +1,5 @@
1
1
  import ComponentApp from '../../plugin/component';
2
- import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
2
+ import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit } from '../../types';
3
3
  import CoreInstance from '../instance/index';
4
4
  export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
5
5
  export declare const parseSessionData: (sessionData: string) => [IpaymentSessionMetaData, string];
@@ -11,17 +11,11 @@ export declare class AMSComponent extends CoreInstance {
11
11
  private parameterInitAndCheck;
12
12
  private pluginAppendIframe;
13
13
  private savePreviousChannel;
14
- /**
15
- * 初始化 Bus总线的能力
16
- */
17
- private registerBusAbility;
18
- canMakePayments(paymentMethod: PaymentMethodTypeEnum, subPaymentMethod: SubPaymentMethodTypeEnum): Promise<boolean>;
19
14
  /**
20
15
  * @description Create component application
21
16
  * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
22
17
  */
23
18
  createComponent(params: IcreateComponent): Promise<void>;
24
- isApplePay(paymentSessionData: string): boolean;
25
19
  preloadComponent(channelType: any, productSceneVersion: any): void;
26
20
  clearPreloadIframe(isTimeOut?: boolean): void;
27
21
  /**
@@ -1,6 +1,4 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
2
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
4
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -30,15 +28,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
28
  import { v4 as uuid } from 'uuid';
31
29
  import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
32
30
  import ComponentApp from "../../plugin/component";
33
- import { componentSignEnum, modeEnum, networkModeEnum, PaymentMethodTypeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
31
+ import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
34
32
  import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
35
33
  import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
36
34
  import { getSecurityConfigStorageKey } from "../../util/security";
37
35
  import CoreInstance from "../instance/index";
38
- import { BusManager, BusMessage } from "../bus";
39
- import { ApplePayActionEnum, PaymentActionEnum } from "../bus/interface";
40
- import { SDKCallbackBusSubscriber } from "../bus/ability/sdk";
41
- import { ApplePayBusSubscriber } from "../../plugin/applepay";
42
36
  export var getComponentSign = function getComponentSign(params) {
43
37
  var _params$paymentSessio = params.paymentSessionConfig,
44
38
  _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
@@ -120,7 +114,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
120
114
  // Register Cashier Application Plug in
121
115
  _this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
122
116
  _this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
123
- _this.registerBusAbility();
124
117
  return _this;
125
118
  }
126
119
  _createClass(AMSComponent, [{
@@ -195,54 +188,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
195
188
  localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
196
189
  }
197
190
  }
198
-
199
- /**
200
- * 初始化 Bus总线的能力
201
- */
202
- }, {
203
- key: "registerBusAbility",
204
- value: function registerBusAbility() {
205
- var _this2 = this,
206
- _this$originOptions;
207
- BusManager.clear();
208
- BusManager.addInterceptor({
209
- onPublishException: function onPublishException(message, e) {
210
- _this2.logger.logInfo({
211
- title: 'onPublishException'
212
- }, _objectSpread(_objectSpread({}, message), {}, {
213
- errorMessage: JSON.stringify(e)
214
- }));
215
- }
216
- });
217
- BusManager.subscribe(new SDKCallbackBusSubscriber((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.onEventCallback));
218
- BusManager.subscribe(new ApplePayBusSubscriber());
219
- BusManager.publish(new BusMessage(PaymentActionEnum.optional_init, JSON.stringify(this.originOptions)));
220
- }
221
- }, {
222
- key: "canMakePayments",
223
- value: function canMakePayments(paymentMethod, subPaymentMethod) {
224
- var _this3 = this;
225
- // 判断支付方式是否可用
226
- return new Promise(function (resolve) {
227
- if (paymentMethod === PaymentMethodTypeEnum.ApplePay) {
228
- BusManager.publishForResult(new BusMessage(ApplePayActionEnum.canMakePayments, JSON.stringify({
229
- subPaymentMethod: subPaymentMethod
230
- }))).then(function (message) {
231
- resolve(message.getJSONObject().result);
232
- }).catch(function (e) {
233
- _this3.logger.logInfo({
234
- title: 'canMakePayments_error'
235
- }, {
236
- params: JSON.stringify(e)
237
- });
238
- resolve(false);
239
- });
240
- } else {
241
- resolve(true);
242
- }
243
- });
244
- }
245
-
246
191
  /**
247
192
  * @description Create component application
248
193
  * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
@@ -250,7 +195,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
250
195
  }, {
251
196
  key: "createComponent",
252
197
  value: function createComponent(params) {
253
- var _this4 = this;
198
+ var _this2 = this;
254
199
  this.clearPreloadIframe();
255
200
  return this.parameterInitAndCheck({
256
201
  params: params,
@@ -258,42 +203,23 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
258
203
  }).then(function (_params) {
259
204
  return handleParams(_params);
260
205
  }).catch(function (error) {
261
- _this4.logger.logError({
206
+ _this2.logger.logError({
262
207
  title: 'sdk_error_parameter'
263
208
  }, {
264
209
  params: JSON.stringify(params)
265
210
  }).send();
266
- _this4._eventCenter.emit(EVENT.error.name, error);
211
+ _this2._eventCenter.emit(EVENT.error.name, error);
267
212
  return Promise.reject(error);
268
213
  }).then(function (appendParams) {
269
- if (_this4.isApplePay(params === null || params === void 0 ? void 0 : params.paymentSessionData) && BusManager.isSubscribed(ApplePayActionEnum.createComponent)) {
270
- // 执行出错了,在通用拦截器返回
271
- BusManager.publish(new BusMessage(ApplePayActionEnum.createComponent, JSON.stringify({
272
- paymentSessionData: params === null || params === void 0 ? void 0 : params.paymentSessionData,
273
- options: _this4.originOptions
274
- })));
275
- return;
276
- }
277
214
  var iframeNodesParams = appendParams.iframeNodesParams;
278
- _this4.savePreviousChannel(iframeNodesParams);
279
- return _this4.pluginAppendIframe(appendParams);
215
+ _this2.savePreviousChannel(iframeNodesParams);
216
+ return _this2.pluginAppendIframe(appendParams);
280
217
  });
281
218
  }
282
- }, {
283
- key: "isApplePay",
284
- value: function isApplePay(paymentSessionData) {
285
- var _parseData$paymentSes2;
286
- var _parseSessionData3 = parseSessionData(paymentSessionData),
287
- _parseSessionData4 = _slicedToArray(_parseSessionData3, 2),
288
- parseData = _parseSessionData4[0],
289
- sessionData = _parseSessionData4[1];
290
- // todo 补充全量判断
291
- return sessionData && (parseData === null || parseData === void 0 || (_parseData$paymentSes2 = parseData.paymentSessionFactor) === null || _parseData$paymentSes2 === void 0 || (_parseData$paymentSes2 = _parseData$paymentSes2.paymentMethodInfo) === null || _parseData$paymentSes2 === void 0 ? void 0 : _parseData$paymentSes2.paymentMethodType) === "CARD_APPLE_PAY";
292
- }
293
219
  }, {
294
220
  key: "preloadComponent",
295
221
  value: function preloadComponent(channelType, productSceneVersion) {
296
- var _this5 = this;
222
+ var _this3 = this;
297
223
  this.channelType = channelType;
298
224
  this.productSceneVersion = productSceneVersion;
299
225
  var MAX_CLEAR_TIME = 10000;
@@ -309,7 +235,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
309
235
  });
310
236
  }
311
237
  setTimeout(function () {
312
- _this5.clearPreloadIframe(true);
238
+ _this3.clearPreloadIframe(true);
313
239
  }, MAX_CLEAR_TIME);
314
240
  }
315
241
  }, {
@@ -340,7 +266,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
340
266
  }, {
341
267
  key: "mountComponent",
342
268
  value: function mountComponent(params, selector) {
343
- var _this6 = this;
269
+ var _this4 = this;
344
270
  this.clearPreloadIframe();
345
271
  return this.parameterInitAndCheck({
346
272
  params: params,
@@ -349,17 +275,17 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
349
275
  }).then(function (_params) {
350
276
  return handleParams(_params);
351
277
  }).catch(function (error) {
352
- _this6.logger.logError({
278
+ _this4.logger.logError({
353
279
  title: 'sdk_error_parameter'
354
280
  }, {
355
281
  params: JSON.stringify(params)
356
282
  }).send();
357
- _this6._eventCenter.emit(EVENT.error.name, error);
283
+ _this4._eventCenter.emit(EVENT.error.name, error);
358
284
  return Promise.reject(error);
359
285
  }).then(function (appendParams) {
360
286
  var iframeNodesParams = appendParams.iframeNodesParams;
361
- _this6.savePreviousChannel(iframeNodesParams);
362
- return _this6.pluginAppendIframe(appendParams);
287
+ _this4.savePreviousChannel(iframeNodesParams);
288
+ return _this4.pluginAppendIframe(appendParams);
363
289
  });
364
290
  }
365
291
  /**
@@ -370,22 +296,22 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
370
296
  }, {
371
297
  key: "submit",
372
298
  value: function submit(data) {
373
- var _this7 = this;
299
+ var _this5 = this;
374
300
  return new Promise(function (resolve, reject) {
375
301
  try {
376
302
  var eventCallbackId = uuid();
377
303
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
378
- _this7._eventCenter.once(eventCallbackId, function (_data) {
304
+ _this5._eventCenter.once(eventCallbackId, function (_data) {
379
305
  resolve(_data);
380
306
  });
381
- _this7._componentApp.dispatchToApp({
307
+ _this5._componentApp.dispatchToApp({
382
308
  context: {
383
309
  event: 'submitPay',
384
310
  eventCallbackId: eventCallbackId,
385
311
  data: data
386
312
  }
387
313
  });
388
- _this7.logger.logInfo({
314
+ _this5.logger.logInfo({
389
315
  title: 'sdk_event_apiSubmit'
390
316
  });
391
317
  } catch (error) {