@alipay/ams-checkout 0.0.1713838058-dev.0 → 0.0.1713838058-dev.1

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.
@@ -1,4 +1,4 @@
1
- import type { Logger } from "../../util/logger";
1
+ import type { Logger } from '../../util/logger';
2
2
  /**
3
3
  * Bus 埋点内容定义
4
4
  */
@@ -4,7 +4,11 @@ export declare enum PaymentActionEnum {
4
4
  export declare enum ApplePayActionEnum {
5
5
  canMakePayments = "plugin_CARD_APPLE_PAY_available",
6
6
  createComponent = "plugin_CARD_APPLE_PAY_createComponent",
7
- destoryComponent = "plugin_CARD_APPLE_PAY_destoryComponent"
7
+ destroyComponent = "plugin_CARD_APPLE_PAY_destroyComponent"
8
+ }
9
+ export declare enum PaypalActionEnum {
10
+ mountComponent = "plugin_Paypal_mountComponent",
11
+ destroyComponent = "plugin_Paypal_destroyComponent"
8
12
  }
9
13
  export declare enum SDKCallbackActionEnum {
10
14
  onEventCallback = "onEventCallback"
@@ -5,9 +5,14 @@ export var PaymentActionEnum = /*#__PURE__*/function (PaymentActionEnum) {
5
5
  export var ApplePayActionEnum = /*#__PURE__*/function (ApplePayActionEnum) {
6
6
  ApplePayActionEnum["canMakePayments"] = "plugin_CARD_APPLE_PAY_available";
7
7
  ApplePayActionEnum["createComponent"] = "plugin_CARD_APPLE_PAY_createComponent";
8
- ApplePayActionEnum["destoryComponent"] = "plugin_CARD_APPLE_PAY_destoryComponent";
8
+ ApplePayActionEnum["destroyComponent"] = "plugin_CARD_APPLE_PAY_destroyComponent";
9
9
  return ApplePayActionEnum;
10
10
  }({});
11
+ export var PaypalActionEnum = /*#__PURE__*/function (PaypalActionEnum) {
12
+ PaypalActionEnum["mountComponent"] = "plugin_Paypal_mountComponent";
13
+ PaypalActionEnum["destroyComponent"] = "plugin_Paypal_destroyComponent";
14
+ return PaypalActionEnum;
15
+ }({});
11
16
  export var SDKCallbackActionEnum = /*#__PURE__*/function (SDKCallbackActionEnum) {
12
17
  SDKCallbackActionEnum["onEventCallback"] = "onEventCallback";
13
18
  return SDKCallbackActionEnum;
@@ -29,18 +29,19 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
29
  */
30
30
  import { v4 as uuid } from 'uuid';
31
31
  import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
32
+ import { ApplePayBusSubscriber } from "../../plugin/applepay";
32
33
  import ComponentApp from "../../plugin/component";
34
+ import { ExtendPlugin } from "../../plugin/const";
35
+ import { PaypalBusSubscriber } from "../../plugin/paypal";
33
36
  import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
34
37
  import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
35
38
  import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
36
39
  import { getSecurityConfigStorageKey } from "../../util/security";
37
- import CoreInstance from "../instance/index";
38
40
  import { BusManager, BusMessage } from "../bus";
39
41
  import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
40
- import { ApplePayBusSubscriber } from "../../plugin/applepay";
41
42
  import { SecurityBusSubscriber } from "../bus/ability/security";
42
43
  import { TrackerBusSubscriber } from "../bus/ability/tracker";
43
- import { ExtendPlugin } from "../../plugin/const";
44
+ import CoreInstance from "../instance/index";
44
45
  export var getComponentSign = function getComponentSign(params) {
45
46
  var _params$paymentSessio = params.paymentSessionConfig,
46
47
  _params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
@@ -230,6 +231,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
230
231
  BusManager.subscribe(new TrackerBusSubscriber(this.logger));
231
232
  // subscribe plugin
232
233
  BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
234
+ BusManager.subscribe(new PaypalBusSubscriber(this.logger));
233
235
 
234
236
  // register bus plugin
235
237
  ExtendPlugin.forEach(function (item) {
@@ -265,7 +267,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
265
267
  * only the channel described in the document will be called, and it will be returned as available by default
266
268
  * @param paymentMethod - described in the document
267
269
  * @param subPaymentMethod - described in the document
268
- * @returns
270
+ * @returns
269
271
  */
270
272
  }, {
271
273
  key: "canMakePayments",
@@ -323,6 +325,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
323
325
  _this4._eventCenter.emit(EVENT.error.name, error);
324
326
  return Promise.reject(error);
325
327
  }).then(function (appendParams) {
328
+ var iframeNodesParams = appendParams.iframeNodesParams;
329
+ _this4.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
326
330
  return _this4.createComponentProcess(appendParams);
327
331
  });
328
332
  }
@@ -412,6 +416,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
412
416
  _this6._eventCenter.emit(EVENT.error.name, error);
413
417
  return Promise.reject(error);
414
418
  }).then(function (appendParams) {
419
+ var iframeNodesParams = appendParams.iframeNodesParams;
420
+ _this6.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
415
421
  return _this6.mountComponentProcess(appendParams);
416
422
  });
417
423
  }
@@ -1,8 +1,15 @@
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
+ import { ComponentActionNamesType } from 'src/plugin/type';
1
9
  import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
2
10
  import { EventCenter } from '../../util/index';
3
11
  import { Logger } from '../../util/logger';
4
12
  import { Security } from '../../util/security';
5
- import { ComponentActionNamesType } from 'src/plugin/type';
6
13
  export default class AMSSDK {
7
14
  options: AMSCheckoutOptions;
8
15
  originOptions: IoptionsParams;
@@ -16,6 +16,7 @@ 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
+
19
20
  import { v4 as uuid } from 'uuid';
20
21
  import { sdkVersion } from "../../config/index";
21
22
  import { ERRORMESSAGE, EVENT } from "../../constant";
@@ -24,8 +25,8 @@ import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, productSceneEnu
24
25
  import { checkTimeElapsed, device, EventCenter, getOrSetStorageId, getType, queryParse, safeJson } from "../../util/index";
25
26
  import CallApp from "../../util/intl-callapp/es/main";
26
27
  import { LogConfig, Logger } from "../../util/logger";
27
- import { compareVersion } from "../../util/versionCompare";
28
28
  import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
29
+ import { compareVersion } from "../../util/versionCompare";
29
30
  import { BusManager, BusMessage } from "../bus";
30
31
  var AMSSDK = /*#__PURE__*/function () {
31
32
  function AMSSDK(options) {
@@ -62,9 +63,11 @@ var AMSSDK = /*#__PURE__*/function () {
62
63
  instanceId: this._instanceId
63
64
  });
64
65
  this.logger.initTracker();
66
+ this.logger.setComponentStartTime(Date.now());
67
+ this.logger.setTrackId(this._instanceId);
65
68
  this.logger.logInfo({
66
69
  title: 'NEW_AMSSDK_BY_MECHANT',
67
- msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
70
+ msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
68
71
  }).send();
69
72
  this.preInitSecurity(options);
70
73
  }
@@ -111,11 +114,13 @@ var AMSSDK = /*#__PURE__*/function () {
111
114
  this.logger.logInfo({
112
115
  title: 'sdk_event_apiOnDestroy'
113
116
  }).send();
114
- var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destoryComponent;
117
+ var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destroyComponent;
115
118
  if (actionName && BusManager.isSubscribed(actionName)) {
119
+ var _this$_appendParams;
116
120
  // 执行出错了,在通用拦截器返回
117
121
  BusManager.publish(new BusMessage(actionName, JSON.stringify({
118
- options: this.originOptions
122
+ options: this.originOptions,
123
+ selector: (_this$_appendParams = this._appendParams) === null || _this$_appendParams === void 0 || (_this$_appendParams = _this$_appendParams.iframeNodesParams) === null || _this$_appendParams === void 0 ? void 0 : _this$_appendParams.selector
119
124
  })));
120
125
  }
121
126
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
@@ -317,14 +322,14 @@ var AMSSDK = /*#__PURE__*/function () {
317
322
  key: "_registerPlugin",
318
323
  value: function _registerPlugin(pluginId, plugin) {
319
324
  this.plugins.set(pluginId, plugin);
320
- try {
321
- if (plugin.applyPlugin) {
325
+ if (plugin !== null && plugin !== void 0 && plugin.applyPlugin) {
326
+ try {
322
327
  plugin.applyPlugin(this);
328
+ } catch (error) {
329
+ this.plugins.delete(pluginId);
330
+ if (getType(error) === 'error') throw error;
331
+ throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
323
332
  }
324
- } catch (error) {
325
- this.plugins.delete(pluginId);
326
- if (getType(error) === 'error') throw error;
327
- throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
328
333
  }
329
334
  }
330
335
  /**
@@ -339,6 +344,7 @@ var AMSSDK = /*#__PURE__*/function () {
339
344
  }
340
345
  return this.plugins.get(pluginId);
341
346
  }
347
+
342
348
  /**
343
349
  * @description Execute to open app or jump link
344
350
  */
@@ -14,7 +14,7 @@ export declare enum ApplePayComponentEvent {
14
14
  sdk_event_appleOnvalidatemerchant = "sdk_event_appleOnvalidatemerchant",
15
15
  sdk_event_appleSubmitToken = "sdk_event_appleSubmitToken",
16
16
  sdk_event_applePaymentResult = "sdk_event_applePaymentResult",
17
- sdk_event_appleDestoryComponent = "sdk_event_appleDestoryComponent"
17
+ sdk_event_appleDestroyComponent = "sdk_event_appleDestroyComponent"
18
18
  }
19
19
  /**
20
20
  * Apple pay Component
@@ -27,7 +27,7 @@ export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEven
27
27
  ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
28
28
  ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
29
29
  ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
30
- ApplePayComponentEvent["sdk_event_appleDestoryComponent"] = "sdk_event_appleDestoryComponent";
30
+ ApplePayComponentEvent["sdk_event_appleDestroyComponent"] = "sdk_event_appleDestroyComponent";
31
31
  return ApplePayComponentEvent;
32
32
  }({});
33
33
 
@@ -55,8 +55,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
55
55
 
56
56
  /**
57
57
  * Is Apple Pay Enabled
58
- * @param subTypeEnum
59
- * @returns
58
+ * @param subTypeEnum
59
+ * @returns
60
60
  */
61
61
  _createClass(ApplePayComponent, [{
62
62
  key: "canMakePayments",
@@ -66,8 +66,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
66
66
 
67
67
  /**
68
68
  * Is Apple Pay Enabled
69
- * @param subTypeEnum
70
- * @returns
69
+ * @param subTypeEnum
70
+ * @returns
71
71
  */
72
72
  }, {
73
73
  key: "isAppPayEnabled",
@@ -12,6 +12,6 @@ export declare class ApplePayBusSubscriber extends BusSubscriber {
12
12
  protected onOptionalInit(context: BusContext, message: BusMessage): void;
13
13
  protected onCanMakePayments(context: BusContext, message: BusMessage): void;
14
14
  protected onCreateComponent(context: BusContext, message: BusMessage): void;
15
- protected onDestoryComponent(context: BusContext, message: BusMessage): void;
15
+ protected onDestroyComponent(context: BusContext, message: BusMessage): void;
16
16
  onMessage(context: BusContext, message: BusMessage): void;
17
17
  }
@@ -80,13 +80,13 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
80
80
  this.applePay.submitPay(appendParams);
81
81
  }
82
82
  }, {
83
- key: "onDestoryComponent",
84
- value: function onDestoryComponent(context, message) {
83
+ key: "onDestroyComponent",
84
+ value: function onDestroyComponent(context, message) {
85
85
  this.applePay = null;
86
- console.log('onDestoryComponent', context, message);
86
+ console.log('onDestroyComponent', context, message);
87
87
  this.logger.logInfo({
88
88
  name: 'APPLE_PAY',
89
- title: ApplePayComponentEvent.sdk_event_appleDestoryComponent
89
+ title: ApplePayComponentEvent.sdk_event_appleDestroyComponent
90
90
  }, {
91
91
  biz: 'sdk',
92
92
  type: 'funnel'
@@ -105,8 +105,8 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
105
105
  case ApplePayActionEnum.createComponent:
106
106
  this.onCreateComponent(context, message);
107
107
  break;
108
- case ApplePayActionEnum.destoryComponent:
109
- this.onDestoryComponent(context, message);
108
+ case ApplePayActionEnum.destroyComponent:
109
+ this.onDestroyComponent(context, message);
110
110
  break;
111
111
  default:
112
112
  console.log("Unknown action: " + message.getAction());
@@ -55,7 +55,7 @@ var ComponentApp = /*#__PURE__*/function () {
55
55
  _defineProperty(this, "_multipleCallbackEvents", void 0);
56
56
  _defineProperty(this, "_merchantAppointParam", void 0);
57
57
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
58
- this._appVersion = '1.13.0.1';
58
+ this._appVersion = '1.13.0';
59
59
  this._isInitComponent = false;
60
60
  this._selector = "#".concat(COMPONENT_SECTION_ID);
61
61
  this.createIframeNode = function () {
@@ -95,7 +95,7 @@ var ComponentApp = /*#__PURE__*/function () {
95
95
  }, {
96
96
  key: "initLoggerMeta",
97
97
  value: function initLoggerMeta() {
98
- var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2;
98
+ var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2, _this$_renderParams3;
99
99
  var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
100
100
  var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
101
101
  this.AMSSDK.logger.setMedta({
@@ -112,9 +112,9 @@ var ComponentApp = /*#__PURE__*/function () {
112
112
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
113
113
  paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
114
114
  paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
115
- requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData
115
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
116
+ trackId: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData
116
117
  });
117
- this.AMSSDK.logger.setComponentStartTime(Date.now());
118
118
  }
119
119
 
120
120
  /**
@@ -133,9 +133,9 @@ var ComponentApp = /*#__PURE__*/function () {
133
133
  }, {
134
134
  key: "initSecurity",
135
135
  value: function initSecurity() {
136
- var _this$_renderParams3,
136
+ var _this$_renderParams4,
137
137
  _this = this;
138
- var product = (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionMetaData) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionConfig) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.productScene;
138
+ var product = (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionConfig) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.productScene;
139
139
  if (componentSignEnum.CASHIER_PAYMENT_APM === this._componentSign) return;
140
140
  if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
141
141
  this.AMSSDK.logger.logInfo({
@@ -514,7 +514,8 @@ var ComponentApp = /*#__PURE__*/function () {
514
514
  _this5.AMSSDK.logger.logInfo({
515
515
  title: 'sdk_event_sdkQuery'
516
516
  }, {
517
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
517
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
518
+ requestBody: params
518
519
  }).send();
519
520
  queryPaymentInfo(params, {
520
521
  env: _this5.AMSSDK.options.env.environment,
@@ -525,6 +526,12 @@ var ComponentApp = /*#__PURE__*/function () {
525
526
  value: Date.now()
526
527
  });
527
528
  resolve(res);
529
+ _this5.AMSSDK.logger.logInfo({
530
+ title: 'sdk_event_sdkQueryEnd'
531
+ }, {
532
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
533
+ responseBody: res
534
+ }).send();
528
535
  }).catch(function (err) {
529
536
  if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
530
537
  return resolve({
@@ -534,13 +541,13 @@ var ComponentApp = /*#__PURE__*/function () {
534
541
  _this5.dispatchToSDK(EVENT.error.name, {
535
542
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
536
543
  });
537
- reject(err);
538
- }).finally(function () {
539
- _this5.AMSSDK.logger.logInfo({
540
- title: 'sdk_event_sdkQueryEnd'
544
+ _this5.AMSSDK.logger.logError({
545
+ title: 'sdk_event_sdkQuery_failed'
541
546
  }, {
542
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
547
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
548
+ errorReason: err
543
549
  }).send();
550
+ reject(err);
544
551
  });
545
552
  case 49:
546
553
  case "end":
@@ -559,16 +566,16 @@ var ComponentApp = /*#__PURE__*/function () {
559
566
  }, {
560
567
  key: "createSubmitPromise",
561
568
  value: function createSubmitPromise() {
562
- var _this$_renderParams4,
563
- _this$_renderParams5,
569
+ var _this$_renderParams5,
570
+ _this$_renderParams6,
564
571
  _this6 = this;
565
572
  this._performanceData.push({
566
573
  key: 'sdk_submit_start',
567
574
  value: Date.now()
568
575
  });
569
576
  var params = {
570
- paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
571
- paymentSessionConfig: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 || (_this$_renderParams5 = _this$_renderParams5.paymentSessionMetaData) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.paymentSessionConfig
577
+ paymentSessionData: this._renderParams && ((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData) || '',
578
+ paymentSessionConfig: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 || (_this$_renderParams6 = _this$_renderParams6.paymentSessionMetaData) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionConfig
572
579
  };
573
580
 
574
581
  // eslint-disable-next-line no-async-promise-executor
@@ -590,7 +597,8 @@ var ComponentApp = /*#__PURE__*/function () {
590
597
  _this6.AMSSDK.logger.logInfo({
591
598
  title: 'sdk_event_submitPay'
592
599
  }, {
593
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
600
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
601
+ requestBody: params
594
602
  }).send();
595
603
  _context3.t0 = submitPayInfo;
596
604
  _context3.t1 = params;
@@ -613,21 +621,23 @@ var ComponentApp = /*#__PURE__*/function () {
613
621
  key: 'sdk_submit_end',
614
622
  value: Date.now()
615
623
  });
616
- if (res !== null && res !== void 0 && res.success) {
617
- resolve(res);
618
- } else {
619
- resolve(res);
620
- }
621
- }).catch(function () {
622
- resolve({
623
- success: false
624
- });
625
- }).finally(function () {
626
624
  _this6.AMSSDK.logger.logInfo({
627
625
  title: 'sdk_event_submitPayEnd'
628
626
  }, {
629
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
627
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
628
+ responseBody: res
630
629
  }).send();
630
+ resolve(res);
631
+ }).catch(function (err) {
632
+ _this6.AMSSDK.logger.logError({
633
+ title: 'sdk_event_submitPay_failed'
634
+ }, {
635
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
636
+ responseBody: err
637
+ }).send();
638
+ resolve({
639
+ success: false
640
+ });
631
641
  });
632
642
  case 13:
633
643
  case "end":
@@ -1386,7 +1396,7 @@ var ComponentApp = /*#__PURE__*/function () {
1386
1396
  key: "sendRenderEvent",
1387
1397
  value: (function () {
1388
1398
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1389
- var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
1399
+ var _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, _this$_renderParams11, _this$_renderParams12, _this$AMSSDK$logger, _this$_renderParams13, _this$_renderParams14, _this$_renderParams15, _this$AMSSDK, _this$_renderParams16, res, submitRes;
1390
1400
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1391
1401
  while (1) switch (_context8.prev = _context8.next) {
1392
1402
  case 0:
@@ -1415,17 +1425,29 @@ var ComponentApp = /*#__PURE__*/function () {
1415
1425
  data: {
1416
1426
  queryResult: res,
1417
1427
  submitResult: submitRes,
1418
- sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
1419
- paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
1428
+ sessionResult: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.paymentSessionMetaData,
1429
+ paymentSessionData: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.sessionData,
1420
1430
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1421
- renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
1422
- appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
1423
- notRedirectAfterComplete: ((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.notRedirectAfterComplete) === true,
1431
+ renderDisplayType: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.renderDisplayType,
1432
+ appearance: (_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.appearance,
1433
+ notRedirectAfterComplete: ((_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.notRedirectAfterComplete) === true,
1424
1434
  merchantAppointParam: this._merchantAppointParam,
1425
1435
  envInfo: {
1426
1436
  screenHeight: screen.height,
1427
1437
  screenWidth: screen.width
1428
- }
1438
+ },
1439
+ logMetaData: _objectSpread(_objectSpread({
1440
+ trackId: (_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.sessionData,
1441
+ platform: this.platform,
1442
+ firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
1443
+ }, ((_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 || (_this$_renderParams13 = _this$_renderParams13.paymentSessionMetaData) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.paymentSessionConfig) || {}), {}, {
1444
+ renderDisplayType: (_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.renderDisplayType,
1445
+ sdkVersion: this._appVersion,
1446
+ merchantId: (_this$_renderParams15 = this._renderParams) === null || _this$_renderParams15 === void 0 || (_this$_renderParams15 = _this$_renderParams15.paymentSessionMetaData) === null || _this$_renderParams15 === void 0 ? void 0 : _this$_renderParams15.clientId,
1447
+ instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1448
+ performanceData: this._performanceData,
1449
+ paymentMethodType: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 || (_this$_renderParams16 = _this$_renderParams16.paymentSessionMetaData) === null || _this$_renderParams16 === void 0 || (_this$_renderParams16 = _this$_renderParams16.paymentMethodInfoView) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.paymentMethodType
1450
+ })
1429
1451
  }
1430
1452
  }
1431
1453
  }, null, true);
@@ -1,11 +1,11 @@
1
- import { ApplePayActionEnum, PaymentActionEnum } from "../core/bus/interface";
2
- import { paymentMethodCategoryTypeEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
1
+ import { ApplePayActionEnum, PaymentActionEnum, PaypalActionEnum } from "../core/bus/interface";
2
+ import { paymentMethodCategoryTypeEnum, PaypalMethodEnum, productSceneEnum, ProductSceneVersion } from "../types/index";
3
3
  export var ExtendPlugin = [{
4
4
  sessionMatcher: {
5
5
  productScene: productSceneEnum.CASHIER_PAYMENT,
6
6
  productSceneVersion: ProductSceneVersion.V1,
7
7
  paymentMethodCategoryType: paymentMethodCategoryTypeEnum.CARD,
8
- paymentMethodTypes: ["CARD_APPLE_PAY"]
8
+ paymentMethodTypes: ['CARD_APPLE_PAY']
9
9
  },
10
10
  paymentChannelMatcher: {
11
11
  paymentMethod: 'ApplePay'
@@ -14,6 +14,20 @@ export var ExtendPlugin = [{
14
14
  canMakePayments: ApplePayActionEnum.canMakePayments,
15
15
  optional_init: PaymentActionEnum.optional_init,
16
16
  createComponent: ApplePayActionEnum.createComponent,
17
- destoryComponent: ApplePayActionEnum.destoryComponent
17
+ destroyComponent: ApplePayActionEnum.destroyComponent
18
+ }
19
+ }, {
20
+ sessionMatcher: {
21
+ productScene: productSceneEnum.CASHIER_PAYMENT,
22
+ productSceneVersion: ProductSceneVersion.V1,
23
+ paymentMethodCategoryType: paymentMethodCategoryTypeEnum.APM,
24
+ paymentMethodTypes: [PaypalMethodEnum.PAYPAL_CHECKOUT, PaypalMethodEnum.PAYPAL_PAYLATER, PaypalMethodEnum.PAYPAL_VAULT]
25
+ },
26
+ paymentChannelMatcher: {
27
+ paymentMethod: 'Paypal'
28
+ },
29
+ busActionNames: {
30
+ mountComponent: PaypalActionEnum.mountComponent,
31
+ destroyComponent: PaypalActionEnum.destroyComponent
18
32
  }
19
33
  }];
@@ -0,0 +1,20 @@
1
+ import { BusContext, BusMessage, BusSubscriber } from '../../core/bus';
2
+ import { Logger } from '../../util/logger';
3
+ export declare class PaypalBusSubscriber extends BusSubscriber {
4
+ logger: Logger;
5
+ constructor(logger: Logger);
6
+ actionNames(): string[];
7
+ private onEventCallback;
8
+ protected renderPaypalButton(context: BusContext, message: BusMessage): Promise<never>;
9
+ private appendPaypalLoading;
10
+ private removePaypalLoading;
11
+ private preCheck;
12
+ private loadPaypalResource;
13
+ private createPaypalScript;
14
+ private onShippingChange;
15
+ private createOrder;
16
+ private onApprove;
17
+ private onCancel;
18
+ private destroyComponent;
19
+ onMessage(context: BusContext, message: BusMessage): void;
20
+ }