@alipay/ams-checkout 0.0.1710212811-dev.1 → 0.0.1710212811-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.
@@ -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
  */
@@ -19,7 +19,6 @@ declare class ApplePayService {
19
19
  private completeApplePay;
20
20
  private logError;
21
21
  private applePayTrace;
22
- private onEventCallback;
23
22
  constructor();
24
23
  /**
25
24
  * set Apple Pay Params
@@ -31,9 +30,11 @@ declare class ApplePayService {
31
30
  */
32
31
  setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError, applePayTrace: IApplePayTrace): void;
33
32
  /**
34
- * Apple Pay is enabled
33
+ * Is Apple Pay Enabled
34
+ * @param subTypeEnum
35
+ * @returns
35
36
  */
36
- isEnabled: () => boolean;
37
+ static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
37
38
  /**
38
39
  * has Active Card in Apple Pay
39
40
  * @param merchantIdentifier
@@ -17,6 +17,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  */
18
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
19
19
  import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
20
+ import { ApplePaySubTypeEnum } from "../../types";
21
+
20
22
  /**
21
23
  * Apple Pay Service
22
24
  */
@@ -32,13 +34,6 @@ var ApplePayService = /*#__PURE__*/function () {
32
34
  _defineProperty(this, "completeApplePay", void 0);
33
35
  _defineProperty(this, "logError", void 0);
34
36
  _defineProperty(this, "applePayTrace", void 0);
35
- _defineProperty(this, "onEventCallback", void 0);
36
- /**
37
- * Apple Pay is enabled
38
- */
39
- _defineProperty(this, "isEnabled", function () {
40
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() : false;
41
- });
42
37
  _defineProperty(this, "onvalidatemerchant", function (event) {
43
38
  _this.applePayTrace('onValidateMerchant');
44
39
  _this.getMerchantSession({
@@ -46,6 +41,7 @@ var ApplePayService = /*#__PURE__*/function () {
46
41
  merchantIdentifier: _this.merchantIdentifier,
47
42
  validationUrl: event.validationURL
48
43
  }).then(function (merchantSessionObjectString) {
44
+ console.log("onvalidatemerchant#merchantSessionObjectString", merchantSessionObjectString);
49
45
  var merchantSessionObject = JSON.parse(merchantSessionObjectString);
50
46
  _this.session.completeMerchantValidation(merchantSessionObject);
51
47
  _this.applePayTrace('completeMerchantValidation');
@@ -96,7 +92,7 @@ var ApplePayService = /*#__PURE__*/function () {
96
92
  order = paymentSessionFactor.order,
97
93
  recurringInfo = paymentSessionFactor.recurringInfo;
98
94
  _this.merchantIdentifier = merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.partnerId;
99
- 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)) {
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)) {
100
96
  _this.logError("invalid session data");
101
97
  return;
102
98
  }
@@ -134,7 +130,7 @@ var ApplePayService = /*#__PURE__*/function () {
134
130
  currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
135
131
  total: {
136
132
  type: 'final',
137
- label: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantName,
133
+ label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
138
134
  amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
139
135
  },
140
136
  recurringPaymentRequest: recurringRequest,
@@ -149,7 +145,7 @@ var ApplePayService = /*#__PURE__*/function () {
149
145
  currencyCode: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.currency,
150
146
  total: {
151
147
  type: 'final',
152
- label: extendInfo === null || extendInfo === void 0 ? void 0 : extendInfo.merchantName,
148
+ label: merchantInfo === null || merchantInfo === void 0 ? void 0 : merchantInfo.merchantName,
153
149
  amount: paymentAmount === null || paymentAmount === void 0 ? void 0 : paymentAmount.value
154
150
  }
155
151
  };
@@ -159,7 +155,11 @@ var ApplePayService = /*#__PURE__*/function () {
159
155
  _this.session.onpaymentauthorized = _this.onpaymentauthorized;
160
156
  _this.session.oncancel = function () {
161
157
  _this.logError('UserCancel');
162
- _this.session.abort();
158
+ try {
159
+ _this.session.abort();
160
+ } catch (error) {
161
+ console.log("session.abort() error");
162
+ }
163
163
  };
164
164
  _this.session.begin();
165
165
  _this.applePayTrace('sessionBegin');
@@ -183,6 +183,12 @@ var ApplePayService = /*#__PURE__*/function () {
183
183
  this.logError = logError;
184
184
  this.applePayTrace = applePayTrace;
185
185
  }
186
+
187
+ /**
188
+ * Is Apple Pay Enabled
189
+ * @param subTypeEnum
190
+ * @returns
191
+ */
186
192
  }, {
187
193
  key: "hasActiveCard",
188
194
  value: (
@@ -215,6 +221,14 @@ var ApplePayService = /*#__PURE__*/function () {
215
221
  }
216
222
  return hasActiveCard;
217
223
  }())
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
+ }
218
232
  }]);
219
233
  return ApplePayService;
220
234
  }();
@@ -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
  });
@@ -138,11 +138,11 @@ export interface IpaymentSessionMetaData {
138
138
  extendInfo?: {
139
139
  merchantCapabilities?: string[];
140
140
  supportedNetworks?: string[];
141
- merchantName?: string;
142
141
  };
143
142
  merchantInfo?: {
144
143
  registeredCountry?: string;
145
144
  partnerId?: string;
145
+ merchantName?: string;
146
146
  };
147
147
  order?: {
148
148
  orderDescription: string;
@@ -239,8 +239,8 @@ export declare enum platformEnum {
239
239
  desktop = "desktop",
240
240
  mobile = "mobile"
241
241
  }
242
- type EventCallbackResult = {
243
- result: {
242
+ export type EventCallbackResult = {
243
+ result?: {
244
244
  resultCode: string;
245
245
  resultStatus: string;
246
246
  resultMessage: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1710212811-dev.1",
3
+ "version": "0.0.1710212811-dev.11",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",
File without changes
File without changes