@alipay/ams-checkout 1.11.1 → 1.12.0

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) {
@@ -61,9 +62,11 @@ var AMSSDK = /*#__PURE__*/function () {
61
62
  instanceId: this._instanceId
62
63
  });
63
64
  this.logger.initTracker();
65
+ this.logger.setComponentStartTime(Date.now());
66
+ this.logger.setTrackId(this._instanceId);
64
67
  this.logger.logInfo({
65
68
  title: 'NEW_AMSSDK_BY_MECHANT',
66
- msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale, "}")
69
+ msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
67
70
  }).send();
68
71
  this.preInitSecurity(options);
69
72
  }
@@ -110,11 +113,13 @@ var AMSSDK = /*#__PURE__*/function () {
110
113
  this.logger.logInfo({
111
114
  title: 'sdk_event_apiOnDestroy'
112
115
  }).send();
113
- var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destoryComponent;
116
+ var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destroyComponent;
114
117
  if (actionName && BusManager.isSubscribed(actionName)) {
118
+ var _this$_appendParams;
115
119
  // 执行出错了,在通用拦截器返回
116
120
  BusManager.publish(new BusMessage(actionName, JSON.stringify({
117
- options: this.originOptions
121
+ options: this.originOptions,
122
+ 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
118
123
  })));
119
124
  }
120
125
  var _iterator = _createForOfIteratorHelper(this.plugins.values()),
@@ -316,14 +321,14 @@ var AMSSDK = /*#__PURE__*/function () {
316
321
  key: "_registerPlugin",
317
322
  value: function _registerPlugin(pluginId, plugin) {
318
323
  this.plugins.set(pluginId, plugin);
319
- try {
320
- if (plugin.applyPlugin) {
324
+ if (plugin !== null && plugin !== void 0 && plugin.applyPlugin) {
325
+ try {
321
326
  plugin.applyPlugin(this);
327
+ } catch (error) {
328
+ this.plugins.delete(pluginId);
329
+ if (getType(error) === 'error') throw error;
330
+ throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
322
331
  }
323
- } catch (error) {
324
- this.plugins.delete(pluginId);
325
- if (getType(error) === 'error') throw error;
326
- throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
327
332
  }
328
333
  }
329
334
  /**
@@ -338,6 +343,7 @@ var AMSSDK = /*#__PURE__*/function () {
338
343
  }
339
344
  return this.plugins.get(pluginId);
340
345
  }
346
+
341
347
  /**
342
348
  * @description Execute to open app or jump link
343
349
  */
@@ -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());
@@ -54,7 +54,7 @@ var ComponentApp = /*#__PURE__*/function () {
54
54
  _defineProperty(this, "_multipleCallbackEvents", void 0);
55
55
  _defineProperty(this, "_merchantAppointParam", void 0);
56
56
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
57
- this._appVersion = '1.11.1';
57
+ this._appVersion = '1.12.0';
58
58
  this._isInitComponent = false;
59
59
  this._selector = "#".concat(COMPONENT_SECTION_ID);
60
60
  this.createIframeNode = function () {
@@ -94,7 +94,7 @@ var ComponentApp = /*#__PURE__*/function () {
94
94
  }, {
95
95
  key: "initLoggerMeta",
96
96
  value: function initLoggerMeta() {
97
- var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2;
97
+ var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2, _this$_renderParams3;
98
98
  var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
99
99
  var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
100
100
  this.AMSSDK.logger.setMedta({
@@ -110,9 +110,9 @@ var ComponentApp = /*#__PURE__*/function () {
110
110
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
111
111
  paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
112
112
  paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
113
- requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData
113
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
114
+ trackId: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData
114
115
  });
115
- this.AMSSDK.logger.setComponentStartTime(Date.now());
116
116
  }
117
117
 
118
118
  /**
@@ -131,9 +131,9 @@ var ComponentApp = /*#__PURE__*/function () {
131
131
  }, {
132
132
  key: "initSecurity",
133
133
  value: function initSecurity() {
134
- var _this$_renderParams3,
134
+ var _this$_renderParams4,
135
135
  _this = this;
136
- 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;
136
+ 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;
137
137
  if (componentSignEnum.CASHIER_PAYMENT_APM === this._componentSign) return;
138
138
  if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
139
139
  this.AMSSDK.logger.logInfo({
@@ -512,7 +512,8 @@ var ComponentApp = /*#__PURE__*/function () {
512
512
  _this5.AMSSDK.logger.logInfo({
513
513
  title: 'sdk_event_sdkQuery'
514
514
  }, {
515
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
515
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
516
+ requestBody: params
516
517
  }).send();
517
518
  queryPaymentInfo(params, {
518
519
  env: _this5.AMSSDK.options.env.environment,
@@ -523,6 +524,12 @@ var ComponentApp = /*#__PURE__*/function () {
523
524
  value: Date.now()
524
525
  });
525
526
  resolve(res);
527
+ _this5.AMSSDK.logger.logInfo({
528
+ title: 'sdk_event_sdkQueryEnd'
529
+ }, {
530
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
531
+ responseBody: res
532
+ }).send();
526
533
  }).catch(function (err) {
527
534
  if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD, componentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
528
535
  return resolve({
@@ -532,13 +539,13 @@ var ComponentApp = /*#__PURE__*/function () {
532
539
  _this5.dispatchToSDK(EVENT.error.name, {
533
540
  code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
534
541
  });
535
- reject(err);
536
- }).finally(function () {
537
- _this5.AMSSDK.logger.logInfo({
538
- title: 'sdk_event_sdkQueryEnd'
542
+ _this5.AMSSDK.logger.logError({
543
+ title: 'sdk_event_sdkQuery_failed'
539
544
  }, {
540
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
545
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
546
+ errorReason: err
541
547
  }).send();
548
+ reject(err);
542
549
  });
543
550
  case 49:
544
551
  case "end":
@@ -557,16 +564,16 @@ var ComponentApp = /*#__PURE__*/function () {
557
564
  }, {
558
565
  key: "createSubmitPromise",
559
566
  value: function createSubmitPromise() {
560
- var _this$_renderParams4,
561
- _this$_renderParams5,
567
+ var _this$_renderParams5,
568
+ _this$_renderParams6,
562
569
  _this6 = this;
563
570
  this._performanceData.push({
564
571
  key: 'sdk_submit_start',
565
572
  value: Date.now()
566
573
  });
567
574
  var params = {
568
- paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
569
- 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
575
+ paymentSessionData: this._renderParams && ((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData) || '',
576
+ 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
570
577
  };
571
578
 
572
579
  // eslint-disable-next-line no-async-promise-executor
@@ -588,7 +595,8 @@ var ComponentApp = /*#__PURE__*/function () {
588
595
  _this6.AMSSDK.logger.logInfo({
589
596
  title: 'sdk_event_submitPay'
590
597
  }, {
591
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
598
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
599
+ requestBody: params
592
600
  }).send();
593
601
  _context3.t0 = submitPayInfo;
594
602
  _context3.t1 = params;
@@ -611,21 +619,23 @@ var ComponentApp = /*#__PURE__*/function () {
611
619
  key: 'sdk_submit_end',
612
620
  value: Date.now()
613
621
  });
614
- if (res !== null && res !== void 0 && res.success) {
615
- resolve(res);
616
- } else {
617
- resolve(res);
618
- }
619
- }).catch(function () {
620
- resolve({
621
- success: false
622
- });
623
- }).finally(function () {
624
622
  _this6.AMSSDK.logger.logInfo({
625
623
  title: 'sdk_event_submitPayEnd'
626
624
  }, {
627
- paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
625
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
626
+ responseBody: res
628
627
  }).send();
628
+ resolve(res);
629
+ }).catch(function (err) {
630
+ _this6.AMSSDK.logger.logError({
631
+ title: 'sdk_event_submitPay_failed'
632
+ }, {
633
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
634
+ responseBody: err
635
+ }).send();
636
+ resolve({
637
+ success: false
638
+ });
629
639
  });
630
640
  case 13:
631
641
  case "end":
@@ -1376,7 +1386,7 @@ var ComponentApp = /*#__PURE__*/function () {
1376
1386
  key: "sendRenderEvent",
1377
1387
  value: (function () {
1378
1388
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1379
- var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
1389
+ 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;
1380
1390
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1381
1391
  while (1) switch (_context8.prev = _context8.next) {
1382
1392
  case 0:
@@ -1405,17 +1415,29 @@ var ComponentApp = /*#__PURE__*/function () {
1405
1415
  data: {
1406
1416
  queryResult: res,
1407
1417
  submitResult: submitRes,
1408
- sessionResult: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionMetaData,
1409
- paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
1418
+ sessionResult: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.paymentSessionMetaData,
1419
+ paymentSessionData: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.sessionData,
1410
1420
  heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1411
- renderDisplayType: (_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.renderDisplayType,
1412
- appearance: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.appearance,
1413
- notRedirectAfterComplete: ((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.notRedirectAfterComplete) === true,
1421
+ renderDisplayType: (_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.renderDisplayType,
1422
+ appearance: (_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.appearance,
1423
+ notRedirectAfterComplete: ((_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.notRedirectAfterComplete) === true,
1414
1424
  merchantAppointParam: this._merchantAppointParam,
1415
1425
  envInfo: {
1416
1426
  screenHeight: screen.height,
1417
1427
  screenWidth: screen.width
1418
- }
1428
+ },
1429
+ logMetaData: _objectSpread(_objectSpread({
1430
+ trackId: (_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.sessionData,
1431
+ platform: this.platform,
1432
+ firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
1433
+ }, ((_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 || (_this$_renderParams13 = _this$_renderParams13.paymentSessionMetaData) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.paymentSessionConfig) || {}), {}, {
1434
+ renderDisplayType: (_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.renderDisplayType,
1435
+ sdkVersion: this._appVersion,
1436
+ 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,
1437
+ instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1438
+ performanceData: this._performanceData,
1439
+ 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
1440
+ })
1419
1441
  }
1420
1442
  }
1421
1443
  }, 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
+ }