@alipay/ams-checkout 0.0.1709715270-dev.1 → 0.0.1709715270-dev.3

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.
Files changed (35) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/core/bus/ability/callback.d.ts +9 -0
  3. package/esm/core/bus/ability/callback.js +55 -0
  4. package/esm/core/bus/ability/security.d.ts +10 -0
  5. package/esm/core/bus/ability/security.js +104 -0
  6. package/esm/core/bus/ability/tracker.d.ts +9 -0
  7. package/esm/core/bus/ability/tracker.js +77 -0
  8. package/esm/core/bus/index.d.ts +72 -0
  9. package/esm/core/bus/index.js +309 -0
  10. package/esm/core/bus/interface.d.ts +32 -0
  11. package/esm/core/bus/interface.js +35 -0
  12. package/esm/core/component/index.d.ts +15 -1
  13. package/esm/core/component/index.js +185 -28
  14. package/esm/core/instance/index.d.ts +5 -1
  15. package/esm/core/instance/index.js +41 -4
  16. package/esm/index.d.ts +0 -3
  17. package/esm/index.js +8 -18
  18. package/esm/{core/applepay/index.d.ts → plugin/applepay/component.d.ts} +17 -8
  19. package/esm/{core/applepay/index.js → plugin/applepay/component.js} +124 -170
  20. package/esm/plugin/applepay/index.d.ts +17 -0
  21. package/esm/plugin/applepay/index.js +100 -0
  22. package/esm/{common → plugin}/applepay/interface.d.ts +62 -1
  23. package/esm/plugin/applepay/interface.js +73 -0
  24. package/esm/{common/applepay/index.d.ts → plugin/applepay/service.d.ts} +6 -3
  25. package/esm/{common/applepay/index.js → plugin/applepay/service.js} +95 -23
  26. package/esm/plugin/component/index.d.ts +2 -2
  27. package/esm/plugin/component/index.js +9 -9
  28. package/esm/plugin/const.d.ts +2 -0
  29. package/esm/plugin/const.js +19 -0
  30. package/esm/plugin/type.d.ts +33 -0
  31. package/esm/plugin/type.js +2 -0
  32. package/esm/types/index.d.ts +60 -6
  33. package/esm/types/index.js +8 -1
  34. package/package.json +1 -1
  35. package/esm/common/applepay/interface.js +0 -1
@@ -6,6 +6,8 @@
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;
9
11
  export interface IApplePayValidateMerchantEvent {
10
12
  validationURL: string;
11
13
  }
@@ -35,10 +37,41 @@ export interface IApplePayPaymentContact {
35
37
  countryCode: string;
36
38
  }
37
39
  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
+ */
38
55
  export interface IApplePayLineItem {
56
+ /**
57
+ * A value that indicates whether the line item is final or pending.
58
+ */
39
59
  type: IApplePayLineItemType;
60
+ /**
61
+ * A required value that’s a short, localized description of the line item.
62
+ */
40
63
  label: string;
64
+ /**
65
+ * A required value that’s the monetary amount of the line item.
66
+ */
41
67
  amount: string;
68
+ paymentTiming?: ApplePayPaymentTiming;
69
+ recurringPaymentStartDate?: Date;
70
+ recurringPaymentEndDate?: Date;
71
+ recurringPaymentIntervalUnit?: ApplePayRecurringPaymentDateUnit;
72
+ recurringPaymentIntervalCount?: number;
73
+ deferredPaymentDate?: Date;
74
+ automaticReloadPaymentThresholdAmount?: string;
42
75
  }
43
76
  export type applePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
44
77
  export interface IApplePayShippingMethod {
@@ -75,6 +108,34 @@ export interface IApplePayPaymentRequest {
75
108
  currencyCode: string;
76
109
  shippingType?: applePayShippingType;
77
110
  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;
78
139
  }
79
140
  export interface IApplePaySession {
80
141
  supportsVersion?: (version: Version) => boolean;
@@ -97,6 +158,6 @@ export type ICompletePaymentAuthorized = (params: {
97
158
  paymentToken?: string;
98
159
  }) => Promise<any>;
99
160
  export type ICompleteApplePay = (data: any) => void;
100
- export type ILogError = (msg: string, error?: any) => void;
161
+ export type ILogError = (code: string, msg: string, error?: any) => void;
101
162
  export type traceMsg = 'start' | 'sessionBegin' | 'onValidateMerchant' | 'completeMerchantValidation' | 'onpaymentauthorized' | 'completePaymentAuthorized' | 'completeApplePay';
102
163
  export type IApplePayTrace = (msg: traceMsg) => void;
@@ -0,0 +1,73 @@
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
@@ -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 { IpaymentSessionMetaData } from '../../types';
9
+ import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
10
10
  /**
11
11
  * Apple Pay Service
12
12
  */
@@ -14,6 +14,7 @@ declare class ApplePayService {
14
14
  private merchantIdentifier;
15
15
  private merchantName;
16
16
  private session;
17
+ private paymentState;
17
18
  private getMerchantSession;
18
19
  private completePaymentAuthorized;
19
20
  private completeApplePay;
@@ -30,9 +31,11 @@ declare class ApplePayService {
30
31
  */
31
32
  setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError, applePayTrace: IApplePayTrace): void;
32
33
  /**
33
- * Apple Pay is enabled
34
+ * Is Apple Pay Enabled
35
+ * @param subTypeEnum
36
+ * @returns
34
37
  */
35
- isEnabled: () => boolean;
38
+ static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
36
39
  /**
37
40
  * has Active Card in Apple Pay
38
41
  * @param merchantIdentifier
@@ -16,6 +16,15 @@ 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 { eventCodeEnum } from "../../types";
21
+ var PaymentState = /*#__PURE__*/function (PaymentState) {
22
+ PaymentState[PaymentState["notStarted"] = 0] = "notStarted";
23
+ PaymentState[PaymentState["pending"] = 1] = "pending";
24
+ PaymentState[PaymentState["fail"] = 2] = "fail";
25
+ PaymentState[PaymentState["success"] = 3] = "success";
26
+ return PaymentState;
27
+ }(PaymentState || {});
19
28
  /**
20
29
  * Apple Pay Service
21
30
  */
@@ -26,17 +35,12 @@ var ApplePayService = /*#__PURE__*/function () {
26
35
  _defineProperty(this, "merchantIdentifier", void 0);
27
36
  _defineProperty(this, "merchantName", void 0);
28
37
  _defineProperty(this, "session", void 0);
38
+ _defineProperty(this, "paymentState", void 0);
29
39
  _defineProperty(this, "getMerchantSession", void 0);
30
40
  _defineProperty(this, "completePaymentAuthorized", void 0);
31
41
  _defineProperty(this, "completeApplePay", void 0);
32
42
  _defineProperty(this, "logError", void 0);
33
43
  _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
- });
40
44
  _defineProperty(this, "onvalidatemerchant", function (event) {
41
45
  _this.applePayTrace('onValidateMerchant');
42
46
  _this.getMerchantSession({
@@ -44,11 +48,12 @@ var ApplePayService = /*#__PURE__*/function () {
44
48
  merchantIdentifier: _this.merchantIdentifier,
45
49
  validationUrl: event.validationURL
46
50
  }).then(function (merchantSessionObjectString) {
51
+ console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
47
52
  var merchantSessionObject = JSON.parse(merchantSessionObjectString);
48
53
  _this.session.completeMerchantValidation(merchantSessionObject);
49
54
  _this.applePayTrace('completeMerchantValidation');
50
55
  }).catch(function (error) {
51
- _this.logError('MerchantValidationError', error);
56
+ _this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'MerchantValidationError', error);
52
57
  _this.session.abort();
53
58
  });
54
59
  });
@@ -59,19 +64,22 @@ var ApplePayService = /*#__PURE__*/function () {
59
64
  ApplePaySession = _window.ApplePaySession;
60
65
  var exception = function exception(error) {
61
66
  _this.session.completePayment(ApplePaySession.STATUS_FAILURE);
62
- _this.logError('PaymentAuthorizedError', error);
67
+ _this.logError(eventCodeEnum.SDK_PAYMENT_FAIL, 'PaymentAuthorizedError', error);
63
68
  _this.session.abort();
64
69
  };
65
70
  if (event !== null && event !== void 0 && (_event$payment = event.payment) !== null && _event$payment !== void 0 && _event$payment.token) {
66
71
  _this.applePayTrace('completePaymentAuthorized');
72
+ _this.paymentState = PaymentState.pending;
67
73
  _this.completePaymentAuthorized({
68
74
  paymentToken: JSON.stringify(event.payment.token)
69
75
  }).then(function (data) {
70
76
  _this.applePayTrace('completeApplePay');
71
77
  _this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
72
78
  _this.completeApplePay(data);
79
+ _this.paymentState = PaymentState.success;
73
80
  }).catch(function (error) {
74
81
  exception(error);
82
+ _this.paymentState = PaymentState.fail;
75
83
  });
76
84
  } else {
77
85
  exception();
@@ -88,28 +96,77 @@ var ApplePayService = /*#__PURE__*/function () {
88
96
  throw Error('ApplePaySession is null in window');
89
97
  }
90
98
  var paymentSessionFactor = param.paymentSessionFactor;
91
- var applePay = paymentSessionFactor.applePay,
99
+ var extendInfo = paymentSessionFactor.extendInfo,
92
100
  merchantInfo = paymentSessionFactor.merchantInfo,
93
101
  paymentAmount = paymentSessionFactor.paymentAmount,
94
- order = paymentSessionFactor.order;
102
+ order = paymentSessionFactor.order,
103
+ recurringInfo = paymentSessionFactor.recurringInfo;
95
104
  _this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
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: {
102
- type: 'final',
103
- label: order === null || order === void 0 ? void 0 : order.orderDescription,
104
- amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
105
+ 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)) {
106
+ _this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal paymentSessionFactor");
107
+ return;
108
+ }
109
+ if (recurringInfo) {
110
+ var _recurringInfo$interv;
111
+ if (!(order !== null && order !== void 0 && order.orderDescription) || !(recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.managementURL)) {
112
+ _this.logError(eventCodeEnum.SDK_PAYMENT_ERROR, "Abnormal recurringInfo");
113
+ return;
105
114
  }
106
- };
107
- _this.session = new ApplePaySession(2, request);
115
+ var lineItem = {
116
+ type: 'final',
117
+ label: recurringInfo.title,
118
+ amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value,
119
+ paymentTiming: "recurring",
120
+ recurringPaymentStartDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.startDate ? new Date(Number(recurringInfo.startDate) * 1000) : null,
121
+ recurringPaymentEndDate: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.endDate ? new Date(Number(recurringInfo.endDate) * 1000) : null,
122
+ recurringPaymentIntervalUnit: recurringInfo !== null && recurringInfo !== void 0 && recurringInfo.intervalUnit ? recurringInfo.intervalUnit : "month",
123
+ recurringPaymentIntervalCount: (_recurringInfo$interv = recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.intervalCount) !== null && _recurringInfo$interv !== void 0 ? _recurringInfo$interv : 1
124
+ };
125
+ var recurringRequest = {
126
+ // 不知道显示在哪里
127
+ paymentDescription: order === null || order === void 0 ? void 0 : order.orderDescription,
128
+ billingAgreement: recurringInfo.agreementDescription,
129
+ regularBilling: lineItem,
130
+ managementURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.managementURL,
131
+ tokenNotificationURL: recurringInfo === null || recurringInfo === void 0 ? void 0 : recurringInfo.tokenNotificationURL
132
+ };
133
+ var request = {
134
+ merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
135
+ supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
136
+ countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
137
+ currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
138
+ total: lineItem,
139
+ recurringPaymentRequest: recurringRequest,
140
+ lineItems: [lineItem]
141
+ };
142
+ _this.session = new ApplePaySession(APPLE_PAY_RECURRING_VERSION, request);
143
+ } else {
144
+ var _request = {
145
+ merchantCapabilities: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantCapabilities,
146
+ supportedNetworks: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.supportedNetworks,
147
+ countryCode: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.registeredCountry,
148
+ currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
149
+ total: {
150
+ type: 'final',
151
+ label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
152
+ amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
153
+ }
154
+ };
155
+ _this.session = new ApplePaySession(APPLE_PAY_VERSION, _request);
156
+ }
108
157
  _this.session.onvalidatemerchant = _this.onvalidatemerchant;
109
158
  _this.session.onpaymentauthorized = _this.onpaymentauthorized;
110
159
  _this.session.oncancel = function () {
111
- _this.logError('UserCancel');
112
- _this.session.abort();
160
+ if (_this.paymentState === PaymentState.pending) {
161
+ _this.logError(eventCodeEnum.SDK_PAYMENT_PROCESSING, 'Payment processing but user dismissed the sheet');
162
+ } else {
163
+ _this.logError(eventCodeEnum.SDK_PAYMENT_CANCEL, 'User dismissed the sheet');
164
+ }
165
+ try {
166
+ _this.session.abort();
167
+ } catch (error) {
168
+ console.log("session.abort() error");
169
+ }
113
170
  };
114
171
  _this.session.begin();
115
172
  _this.applePayTrace('sessionBegin');
@@ -132,7 +189,14 @@ var ApplePayService = /*#__PURE__*/function () {
132
189
  this.completeApplePay = completeApplePay;
133
190
  this.logError = logError;
134
191
  this.applePayTrace = applePayTrace;
192
+ this.paymentState = PaymentState.notStarted;
135
193
  }
194
+
195
+ /**
196
+ * Is Apple Pay Enabled
197
+ * @param subTypeEnum
198
+ * @returns
199
+ */
136
200
  }, {
137
201
  key: "hasActiveCard",
138
202
  value: (
@@ -165,6 +229,14 @@ var ApplePayService = /*#__PURE__*/function () {
165
229
  }
166
230
  return hasActiveCard;
167
231
  }())
232
+ }], [{
233
+ key: "canMakePayments",
234
+ value: function canMakePayments(subTypeEnum) {
235
+ if ('ApplePayRecurringPayment' === subTypeEnum) {
236
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
237
+ }
238
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
239
+ }
168
240
  }]);
169
241
  return ApplePayService;
170
242
  }();
@@ -1,6 +1,6 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
2
  import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, IMerchantAppointParam, Iselector } from '../../types';
3
- import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
3
+ import { componentSignEnum, DeviceIdParameter, platformEnum, renderDisplayTypeEnum } from '../../types';
4
4
  type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
5
5
  export default class ComponentApp {
6
6
  app: null | HTMLIFrameElement;
@@ -44,7 +44,7 @@ export default class ComponentApp {
44
44
  setPreloadRender(renderFunc: any): void;
45
45
  private initSecurity;
46
46
  private logDeviceId;
47
- private getDeviceIdAndLog;
47
+ getDeviceIdAndLog(deviceIdParameter?: DeviceIdParameter, isPolling?: boolean): Promise<string>;
48
48
  /**
49
49
  * @description render iframe content
50
50
  */
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
364
364
  this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
365
365
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
366
366
  var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
367
- var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
367
+ var envInfo, params, _ref3, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref4, _ref4$productSceneVer, productSceneVersion, _ref4$productScene, productScene, _ref5, _ref5$action, _ref5$action2, _ref5$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
368
368
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
369
369
  while (1) switch (_context2.prev = _context2.next) {
370
370
  case 0:
@@ -380,7 +380,7 @@ var ComponentApp = /*#__PURE__*/function () {
380
380
  /**
381
381
  * @description Simulated or unnecessary scenarios
382
382
  */
383
- _this5$_renderParams$ = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData, extendInfo = _this5$_renderParams$.extendInfo;
383
+ _ref3 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, extendInfo = _ref3.extendInfo;
384
384
  enableVaultingApiOptimize = false;
385
385
  enableEasypayApiOptimize = false;
386
386
  try {
@@ -427,8 +427,8 @@ var ComponentApp = /*#__PURE__*/function () {
427
427
  _context2.next = 26;
428
428
  break;
429
429
  }
430
- _ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
431
- _ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
430
+ _ref4 = params.paymentSessionConfig || {}, _ref4$productSceneVer = _ref4.productSceneVersion, productSceneVersion = _ref4$productSceneVer === void 0 ? '' : _ref4$productSceneVer, _ref4$productScene = _ref4.productScene, productScene = _ref4$productScene === void 0 ? '' : _ref4$productScene;
431
+ _ref5 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref5$action = _ref5.action, _ref5$action2 = _ref5$action === void 0 ? {} : _ref5$action, _ref5$action2$autoDeb = _ref5$action2.autoDebitWithToken, autoDebitWithToken = _ref5$action2$autoDeb === void 0 ? false : _ref5$action2$autoDeb;
432
432
  if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
433
433
  _context2.next = 21;
434
434
  break;
@@ -542,7 +542,7 @@ var ComponentApp = /*#__PURE__*/function () {
542
542
 
543
543
  // eslint-disable-next-line no-async-promise-executor
544
544
  this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
545
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
545
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
546
546
  var _this6$_renderParams;
547
547
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
548
548
  while (1) switch (_context3.prev = _context3.next) {
@@ -605,7 +605,7 @@ var ComponentApp = /*#__PURE__*/function () {
605
605
  }, _callee3);
606
606
  }));
607
607
  return function (_x3) {
608
- return _ref5.apply(this, arguments);
608
+ return _ref6.apply(this, arguments);
609
609
  };
610
610
  }());
611
611
  }
@@ -1196,9 +1196,9 @@ var ComponentApp = /*#__PURE__*/function () {
1196
1196
  }
1197
1197
  }, {
1198
1198
  key: "handleDeclareInfo",
1199
- value: function handleDeclareInfo(_ref6) {
1200
- var _ref6$closeDialogData = _ref6.closeDialogData,
1201
- closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
1199
+ value: function handleDeclareInfo(_ref7) {
1200
+ var _ref7$closeDialogData = _ref7.closeDialogData,
1201
+ closeDialogData = _ref7$closeDialogData === void 0 ? {} : _ref7$closeDialogData;
1202
1202
  _handleDeclareInfo({
1203
1203
  closeDialogData: closeDialogData
1204
1204
  });
@@ -0,0 +1,2 @@
1
+ import { IExtendPlugin } from './type';
2
+ export declare const ExtendPlugin: IExtendPlugin;
@@ -0,0 +1,19 @@
1
+ import { ApplePayActionEnum, PaymentActionEnum } from "../core/bus/interface";
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
3
+ export var ExtendPlugin = [{
4
+ sessionMatcher: {
5
+ productScene: productSceneEnum.CASHIER_PAYMENT,
6
+ productSceneVersion: ProductSceneVersion.V1,
7
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum.CARD,
8
+ paymentMethodTypes: ["CARD_APPLE_PAY"]
9
+ },
10
+ paymentChannelMatcher: {
11
+ paymentMethod: 'ApplePay'
12
+ },
13
+ busActionNames: {
14
+ canMakePayments: ApplePayActionEnum.canMakePayments,
15
+ optional_init: PaymentActionEnum.optional_init,
16
+ createComponent: ApplePayActionEnum.createComponent,
17
+ destoryComponent: ApplePayActionEnum.destoryComponent
18
+ }
19
+ }];
@@ -0,0 +1,33 @@
1
+ import { BusSubscriber } from '../core/bus';
2
+ import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from '../types';
3
+ export type IExtendPlugin = IExtendPluginItem[];
4
+ export interface ComponentActionNamesType {
5
+ canMakePayments?: string;
6
+ optional_init?: string;
7
+ createComponent?: string;
8
+ mountComponent?: string;
9
+ submit?: string;
10
+ destoryComponent?: string;
11
+ }
12
+ export type IExtendPluginItem = {
13
+ /**
14
+ * 以下为sessionData匹配的场景
15
+ */
16
+ sessionMatcher?: {
17
+ productScene: productSceneEnum;
18
+ productSceneVersion: ProductSceneVersion;
19
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum;
20
+ paymentMethodTypes: string[];
21
+ };
22
+ /**
23
+ * 用于无sessionData场景,比如:canMakePayments
24
+ */
25
+ paymentChannelMatcher?: {
26
+ paymentMethod: string;
27
+ };
28
+ /**
29
+ * 以下plugin 实现的定义
30
+ */
31
+ busActionNames: ComponentActionNamesType;
32
+ busSubscriber?: BusSubscriber;
33
+ };
@@ -0,0 +1,2 @@
1
+ ;
2
+ export {};
@@ -135,16 +135,17 @@ export interface IpaymentSessionMetaData {
135
135
  skipSdkQuery: boolean;
136
136
  };
137
137
  paymentSessionFactor?: {
138
- applePay?: {
138
+ extendInfo?: {
139
139
  merchantCapabilities?: string[];
140
140
  supportedNetworks?: string[];
141
141
  };
142
142
  merchantInfo?: {
143
143
  registeredCountry?: string;
144
144
  partnerId?: string;
145
+ merchantName?: string;
145
146
  };
146
147
  order?: {
147
- orderDescription?: string;
148
+ orderDescription: string;
148
149
  };
149
150
  paymentAmount?: {
150
151
  value?: string;
@@ -156,6 +157,43 @@ export interface IpaymentSessionMetaData {
156
157
  paymentMethodViewMetaData?: any;
157
158
  paymentRequestId?: string;
158
159
  supportedLanguages?: any;
160
+ /**
161
+ * 当前为苹果分期场景的信息
162
+ */
163
+ recurringInfo?: {
164
+ /**
165
+ * 代扣协议开始日期 不传为当前系统时间
166
+ */
167
+ startDate?: number;
168
+ /**
169
+ * 代扣协议结束日期 不传不限制结束时间
170
+ */
171
+ endDate?: number;
172
+ /**
173
+ * 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
174
+ */
175
+ intervalUnit?: string;
176
+ /**
177
+ * 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
178
+ */
179
+ intervalCount?: number;
180
+ /**
181
+ * 分期标题信息
182
+ */
183
+ title?: string;
184
+ /**
185
+ * 分期管理页面
186
+ */
187
+ managementURL?: string;
188
+ /**
189
+ * 苹果通知ipay MAPN信息变更的地址
190
+ */
191
+ tokenNotificationURL?: string;
192
+ /**
193
+ * 分期协议描述
194
+ */
195
+ agreementDescription?: string;
196
+ };
159
197
  };
160
198
  }
161
199
  export declare enum localeEnum {
@@ -201,8 +239,8 @@ export declare enum platformEnum {
201
239
  desktop = "desktop",
202
240
  mobile = "mobile"
203
241
  }
204
- type EventCallbackResult = {
205
- result: {
242
+ export type EventCallbackResult = {
243
+ result?: {
206
244
  resultCode: string;
207
245
  resultStatus: string;
208
246
  resultMessage: string;
@@ -410,9 +448,14 @@ export declare enum eventCodeEnum {
410
448
  SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
411
449
  SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
412
450
  SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
413
- SDK_PAYMENT_FINISH = "SDK_PAYMENT_FINISH",
451
+ SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
414
452
  SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
415
- SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL"
453
+ SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
454
+ SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
455
+ /**
456
+ * 当前为Apple Pay发起了Pay请求,但是用户关闭了页面
457
+ */
458
+ SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
416
459
  }
417
460
  export declare enum RedirectType {
418
461
  ApplinkUrl = "ApplinkUrl",
@@ -433,4 +476,15 @@ export interface CallbackEventInfo {
433
476
  export interface MultipleCallbackEvents {
434
477
  [key: string]: CallbackEventInfo;
435
478
  }
479
+ export type PaymentMethodTypeEnum = 'ApplePay';
480
+ export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
481
+ export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
482
+ export declare enum ProductSceneVersion {
483
+ V1 = "1.0",
484
+ V2 = "2.0"
485
+ }
486
+ export type IAppendParams = {
487
+ componentSign: componentSignEnum;
488
+ iframeNodesParams: IappendIframeNodesParams;
489
+ };
436
490
  export {};