@alipay/ams-checkout 0.0.1732700846-dev.7 → 0.0.1732700846-dev.9

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.
@@ -204,6 +204,9 @@ export declare const EVENT: {
204
204
  onPollingEnd: {
205
205
  name: string;
206
206
  };
207
+ getApplePayToken: {
208
+ name: string;
209
+ };
207
210
  };
208
211
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
209
212
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -206,6 +206,9 @@ export var EVENT = {
206
206
  },
207
207
  onPollingEnd: {
208
208
  name: 'onPollingEnd'
209
+ },
210
+ getApplePayToken: {
211
+ name: 'getApplePayToken'
209
212
  }
210
213
  };
211
214
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -33,6 +33,7 @@ export declare class ElementComponent {
33
33
  private mountAuth;
34
34
  private mountAddress;
35
35
  private mountPayment;
36
+ mountErrorHandle(): void;
36
37
  mount(renderOptions: AddressMountOptions, sdkSelector: string): AddressMountResult;
37
38
  mount(renderOptions: PaymentMountOptions, sdkSelector: string): PaymentMountResult;
38
39
  mount(renderOptions: LinkAuthMountOptions, sdkSelector: string): LinkAuthMountResult;
@@ -27,6 +27,8 @@ import { ElementPaymentComponent } from "./components/payment";
27
27
  // import { oneAccount, sdkAction, submitResult } from './mock';
28
28
  import { v4 as uuid } from 'uuid';
29
29
  import { addressTheme, ELEMENT_ENVIRONMENT, ThemeType } from "./type";
30
+ import { LogConfig, Logger } from "../../../util/logger";
31
+ var logger = new Logger(LogConfig, true);
30
32
  var ElementProcessor = /*#__PURE__*/function () {
31
33
  function ElementProcessor(options) {
32
34
  _classCallCheck(this, ElementProcessor);
@@ -210,13 +212,7 @@ export var ElementComponent = /*#__PURE__*/function () {
210
212
  elementProps: renderOptions.elementProps
211
213
  }, _mountParams)).then(function (result) {
212
214
  if (!result) {
213
- var _this4$_options$onEve, _this4$_options2;
214
- (_this4$_options$onEve = (_this4$_options2 = _this4._options).onEventCallback) === null || _this4$_options$onEve === void 0 || _this4$_options$onEve.call(_this4$_options2, {
215
- code: EventCallbackCode.FAILED,
216
- message: 'INTERNAL_FAILED'
217
- // message: 'Address Component loading failed',
218
- });
219
- return undefined;
215
+ return _this4.mountErrorHandle();
220
216
  }
221
217
  _this4.eventService.addIFrame(result);
222
218
  _this4.iframes[ElementPaymentMethod.ADDRESS_ELEMENT] = result;
@@ -229,9 +225,9 @@ export var ElementComponent = /*#__PURE__*/function () {
229
225
  });
230
226
  // 渲染卡支付组件
231
227
  _defineProperty(this, "mountPayment", function (renderOptions, sdkSelector) {
232
- var _this4$_options3;
228
+ var _this4$_options2;
233
229
  var _mountParams = {
234
- appearance: renderOptions.appearance || ((_this4$_options3 = _this4._options) === null || _this4$_options3 === void 0 ? void 0 : _this4$_options3.appearance) || {
230
+ appearance: renderOptions.appearance || ((_this4$_options2 = _this4._options) === null || _this4$_options2 === void 0 ? void 0 : _this4$_options2.appearance) || {
235
231
  theme: ThemeType.Default
236
232
  }
237
233
  };
@@ -241,13 +237,7 @@ export var ElementComponent = /*#__PURE__*/function () {
241
237
  elementProps: renderOptions.elementProps
242
238
  }, _mountParams)).then(function (result) {
243
239
  if (!result) {
244
- var _this4$_options$onEve2, _this4$_options4;
245
- (_this4$_options$onEve2 = (_this4$_options4 = _this4._options).onEventCallback) === null || _this4$_options$onEve2 === void 0 || _this4$_options$onEve2.call(_this4$_options4, {
246
- code: EventCallbackCode.FAILED,
247
- message: 'INTERNAL_FAILED'
248
- // message: 'Payment Component loading failed',
249
- });
250
- return undefined;
240
+ return _this4.mountErrorHandle();
251
241
  }
252
242
  _this4.eventService.addIFrame(result);
253
243
  _this4.iframes[ElementPaymentMethod.PAYMENT_ELEMENT] = result;
@@ -428,6 +418,9 @@ export var ElementComponent = /*#__PURE__*/function () {
428
418
  this.componentsCount = 0;
429
419
  this.iframes = {};
430
420
  this.mountOptions = {};
421
+ logger.logInfo({
422
+ title: 'a3753.b101271.c386688'
423
+ });
431
424
  this.createElement();
432
425
  }
433
426
 
@@ -462,10 +455,13 @@ export var ElementComponent = /*#__PURE__*/function () {
462
455
  var bizFlowBehavior = _this5.elementContainer.getBizFlowBehavior();
463
456
  if (!(bizFlowBehavior !== null && bizFlowBehavior !== void 0 && (_bizFlowBehavior$data = bizFlowBehavior.data) !== null && _bizFlowBehavior$data !== void 0 && _bizFlowBehavior$data.success)) {
464
457
  var _this5$_options, _this5$_options$onEve;
458
+ console.log('demo event callback----', {
459
+ code: EventCallbackCode.FAILED,
460
+ message: 'INTERNAL_FAILED'
461
+ });
465
462
  _this5 === null || _this5 === void 0 || (_this5$_options = _this5._options) === null || _this5$_options === void 0 || (_this5$_options$onEve = _this5$_options.onEventCallback) === null || _this5$_options$onEve === void 0 || _this5$_options$onEve.call(_this5$_options, {
466
463
  code: EventCallbackCode.FAILED,
467
464
  message: 'INTERNAL_FAILED'
468
- // message: bizFlowBehavior?.data?.errorMsg || 'start biz flow fail, please retry.',
469
465
  });
470
466
  } else {
471
467
  var _bizFlowBehavior$data2, _bizFlowBehavior$data3;
@@ -502,6 +498,10 @@ export var ElementComponent = /*#__PURE__*/function () {
502
498
  }, this.isConnect);
503
499
  } catch (error) {
504
500
  var _this$_options$onEven, _this$_options;
501
+ console.log('demo event callback----', {
502
+ code: EventCallbackCode.FAILED,
503
+ message: 'INTERNAL_FAILED'
504
+ });
505
505
  (_this$_options$onEven = (_this$_options = this._options).onEventCallback) === null || _this$_options$onEven === void 0 || _this$_options$onEven.call(_this$_options, {
506
506
  code: EventCallbackCode.FAILED,
507
507
  message: 'INTERNAL_FAILED'
@@ -568,6 +568,7 @@ export var ElementComponent = /*#__PURE__*/function () {
568
568
  });
569
569
  this.eventService.listen(ElementPaymentEvent.SEND_MUITI_APP_EVENT_TO_SDK, function (result) {
570
570
  var _this6$_options$onEve, _this6$_options;
571
+ console.log('demo event callback----', result.data);
571
572
  (_this6$_options$onEve = (_this6$_options = _this6._options).onEventCallback) === null || _this6$_options$onEve === void 0 || _this6$_options$onEve.call(_this6$_options, result.data);
572
573
  });
573
574
  this.eventService.listen(ElementPaymentEvent.CALLBACK, function (result) {
@@ -697,33 +698,40 @@ export var ElementComponent = /*#__PURE__*/function () {
697
698
  url: url
698
699
  }).then(function (result) {
699
700
  if (!result) {
700
- var _this8$_options$onEve, _this8$_options;
701
- (_this8$_options$onEve = (_this8$_options = _this8._options).onEventCallback) === null || _this8$_options$onEve === void 0 || _this8$_options$onEve.call(_this8$_options, {
702
- code: EventCallbackCode.FAILED,
703
- message: 'INTERNAL_FAILED'
704
- // message: 'Auth Component loading failed',
705
- });
706
- return undefined;
701
+ return _this8.mountErrorHandle();
707
702
  }
708
703
  _this8.eventService.addIFrame(result);
709
704
  _this8.iframes[ElementPaymentMethod.AUTH_ELEMENT] = result;
710
705
  });
711
706
  return {};
712
707
  }
708
+ }, {
709
+ key: "mountErrorHandle",
710
+ value: function mountErrorHandle() {
711
+ var _this$_options$onEven2, _this$_options3;
712
+ console.log('demo event callback----', {
713
+ code: EventCallbackCode.FAILED,
714
+ message: 'INTERNAL_FAILED'
715
+ });
716
+ (_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
717
+ code: EventCallbackCode.FAILED,
718
+ message: 'INTERNAL_FAILED'
719
+ });
720
+ logger.logError({
721
+ title: 'a3753.b101271.c386691'
722
+ });
723
+ }
713
724
  }, {
714
725
  key: "mount",
715
726
  value: function mount(renderOptions, sdkSelector) {
727
+ logger.logInfo({
728
+ title: 'a3753.b101271.c386690'
729
+ });
716
730
  if (typeof sdkSelector === 'string') {
717
731
  var _this$_options$loadin4, _renderOptions$debugP, _renderOptions$debugP2;
718
732
  var element = document.querySelector(sdkSelector);
719
733
  if (!element) {
720
- var _this$_options$onEven2, _this$_options3;
721
- (_this$_options$onEven2 = (_this$_options3 = this._options).onEventCallback) === null || _this$_options$onEven2 === void 0 || _this$_options$onEven2.call(_this$_options3, {
722
- code: EventCallbackCode.FAILED,
723
- message: 'INTERNAL_FAILED'
724
- // message: 'Unable to obtain selector',
725
- });
726
- return undefined;
734
+ return this.mountErrorHandle();
727
735
  }
728
736
  this.componentsCount = this.componentsCount + 1;
729
737
  if (!this.loading && (_this$_options$loadin4 = this._options.loading) !== null && _this$_options$loadin4 !== void 0 && _this$_options$loadin4.onStartLoading && this.isConnect) {
@@ -745,12 +753,7 @@ export var ElementComponent = /*#__PURE__*/function () {
745
753
  return this.mountPayment(renderOptions, sdkSelector);
746
754
  }
747
755
  } else {
748
- this._options.onEventCallback({
749
- code: EventCallbackCode.FAILED,
750
- message: 'INTERNAL_FAILED'
751
- // message: 'Invalid argument for mount method',
752
- });
753
- return undefined;
756
+ return this.mountErrorHandle();
754
757
  }
755
758
  }
756
759
 
@@ -37,8 +37,8 @@ export interface IApplePayPaymentContact {
37
37
  countryCode: string;
38
38
  }
39
39
  export type IApplePayLineItemType = 'final' | 'pending';
40
- export type ApplePayPaymentTiming = "immediate" | "recurring" | "deferred" | "automaticReload";
41
- export type ApplePayRecurringPaymentDateUnit = "year" | "month" | "day" | "hour" | "minute";
40
+ export type ApplePayPaymentTiming = 'immediate' | 'recurring' | 'deferred' | 'automaticReload';
41
+ export type ApplePayRecurringPaymentDateUnit = 'year' | 'month' | 'day' | 'hour' | 'minute';
42
42
  /**
43
43
  *
44
44
  {
@@ -1,4 +1,5 @@
1
- import type { EventPayload, IPaymentSessionMetaData } from '../../types';
1
+ import { EventPayloadContext, type EventPayload, type IPaymentMethod, type IPaymentSessionMetaData } from '../../types';
2
+ import { Logger } from '../../util/logger';
2
3
  export type IChannelBehavior = {
3
4
  usePaymentSessionAsQueryResult: boolean;
4
5
  submitPayInSdk: boolean;
@@ -18,4 +19,43 @@ type GetDoubleFaParams = {
18
19
  export declare function getChannelBehavior(paymentSessionMetaData?: IPaymentSessionMetaData): IChannelBehavior | undefined;
19
20
  export declare function getDoubleFaUrl(params: GetDoubleFaParams): string;
20
21
  export declare const handleGooglePay: (data: EventPayload) => Promise<unknown>;
22
+ export declare class ApplePayService {
23
+ private APPLESDKURL;
24
+ private applePaySession;
25
+ private paymentSessionData;
26
+ private sessionResult;
27
+ /**
28
+ * @description 支付状态,pending:支付中,normal:正常
29
+ */
30
+ private paymentStatus;
31
+ /**
32
+ * @description paymentRequest
33
+ */
34
+ private paymentRequest;
35
+ private logger;
36
+ private dispatchToApp;
37
+ private paymentMethod;
38
+ constructor({ sessionData, paymentSessionMetaData, paymentMethod, logger, dispatchToApp, }: {
39
+ sessionData: string;
40
+ paymentSessionMetaData: IPaymentSessionMetaData;
41
+ paymentMethod: IPaymentMethod;
42
+ logger: Logger;
43
+ dispatchToApp: (payload: {
44
+ context: EventPayloadContext;
45
+ }) => void;
46
+ });
47
+ private startPay;
48
+ private setApplePayStatus;
49
+ private submitPay;
50
+ submit(): Promise<void>;
51
+ private getDeviceId;
52
+ private initApplePaySession;
53
+ private isCanMakePayments;
54
+ private loadApplePaySdk;
55
+ private abortPaySession;
56
+ private addEventListener;
57
+ private get initSessionParams();
58
+ private get isRequiredParameters();
59
+ private get checkScriptIsLoaded();
60
+ }
21
61
  export {};