@xsolla/payment-client-core 0.2.90 → 0.2.92

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 (70) hide show
  1. package/esm2022/lib/core/payment/actions/next-action.service.mjs +17 -8
  2. package/esm2022/lib/core/payment/actions/next-actions.mjs +3 -1
  3. package/esm2022/lib/core/payment/actions/redirect/google-three-ds-redirect.action.class.mjs +20 -0
  4. package/esm2022/lib/core/payment/actions/redirect/redirect.action.class.mjs +16 -8
  5. package/esm2022/lib/core/payment/actions/redirect/redirect.action.type.mjs +1 -1
  6. package/esm2022/lib/core/payment/external-change-fields.const.mjs +2 -1
  7. package/esm2022/lib/core/payment/field-names.enum.mjs +3 -1
  8. package/esm2022/lib/core/payment/finance-details/finance-details.service.mjs +17 -5
  9. package/esm2022/lib/core/payment/form/form.service.mjs +13 -5
  10. package/esm2022/lib/core/payment/form/validators/required/required.validator.mjs +1 -2
  11. package/esm2022/lib/core/payment/initialize-actions/initialize-next-action.service.mjs +11 -4
  12. package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.service.mjs +15 -5
  13. package/esm2022/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.mjs +2 -1
  14. package/esm2022/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.mjs +1 -1
  15. package/esm2022/lib/core/payment/payment-behaviour/strategies/google-pay-instant-flow/google-pay-instant-flow.strategy.mjs +2 -1
  16. package/esm2022/lib/core/payment/payment-behaviour/strategies/google-pay-regular-flow/google-pay-regular-flow.strategy.mjs +2 -1
  17. package/esm2022/lib/core/payment/payment-configuration.interface.mjs +1 -1
  18. package/esm2022/lib/core/payment/payment-configurations/types/google-pay-form-configuration.interface.mjs +2 -0
  19. package/esm2022/lib/core/payment/payment-configurations/types/is-credit-card-settings.guard.mjs +5 -0
  20. package/esm2022/lib/core/payment/payment-configurations/types/is-google-pay-settings.guard.mjs +5 -0
  21. package/esm2022/lib/core/payment/payment-settings/payment-settings.service.mjs +8 -5
  22. package/esm2022/lib/core/payment/payment.service.mjs +43 -12
  23. package/esm2022/lib/core/payment/requests/initialize/initialize.service.mjs +2 -1
  24. package/esm2022/lib/core/payment/requests/submit/submit.service.mjs +2 -1
  25. package/esm2022/lib/core/payment/requests/sync/sync.service.mjs +2 -1
  26. package/esm2022/lib/core/payment/status/listen-status/listen-status.service.mjs +5 -2
  27. package/esm2022/lib/core/payment/three-ds/three-ds-20/three-ds20.service.mjs +11 -4
  28. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +13 -5
  29. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +9 -5
  30. package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +9 -4
  31. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +19 -4
  32. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +17 -4
  33. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +9 -4
  34. package/esm2022/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.mjs +1 -1
  35. package/esm2022/lib/core/user-behaviour-analytics/one-time-analytics-events.const.mjs +2 -5
  36. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.mjs +42 -3
  37. package/esm2022/lib/core-library.service.mjs +1 -1
  38. package/fesm2022/xsolla-payment-client-core.mjs +705 -519
  39. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  40. package/lib/core/payment/actions/next-action.service.d.ts +5 -2
  41. package/lib/core/payment/actions/redirect/google-three-ds-redirect.action.class.d.ts +9 -0
  42. package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +2 -1
  43. package/lib/core/payment/actions/redirect/redirect.action.type.d.ts +1 -0
  44. package/lib/core/payment/field-names.enum.d.ts +3 -1
  45. package/lib/core/payment/finance-details/finance-details.service.d.ts +5 -2
  46. package/lib/core/payment/form/form.service.d.ts +5 -2
  47. package/lib/core/payment/initialize-actions/initialize-next-action.service.d.ts +4 -1
  48. package/lib/core/payment/payment-behaviour/payment-behaviour.service.d.ts +4 -1
  49. package/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.d.ts +1 -0
  50. package/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.d.ts +1 -0
  51. package/lib/core/payment/payment-behaviour/strategies/google-pay-instant-flow/google-pay-instant-flow.strategy.d.ts +1 -0
  52. package/lib/core/payment/payment-behaviour/strategies/google-pay-regular-flow/google-pay-regular-flow.strategy.d.ts +1 -0
  53. package/lib/core/payment/payment-configuration.interface.d.ts +4 -2
  54. package/lib/core/payment/payment-configurations/types/google-pay-form-configuration.interface.d.ts +8 -0
  55. package/lib/core/payment/payment-configurations/types/is-credit-card-settings.guard.d.ts +3 -0
  56. package/lib/core/payment/payment-configurations/types/is-google-pay-settings.guard.d.ts +3 -0
  57. package/lib/core/payment/payment.service.d.ts +10 -2
  58. package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +3 -1
  59. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +3 -1
  60. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +3 -1
  61. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +3 -1
  62. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +3 -1
  63. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +3 -1
  64. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +3 -1
  65. package/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.d.ts +1 -0
  66. package/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.d.ts +40 -3
  67. package/lib/core-library.service.d.ts +4 -1
  68. package/package.json +1 -1
  69. package/xsolla-payment-client-core-0.2.92.tgz +0 -0
  70. package/xsolla-payment-client-core-0.2.90.tgz +0 -0
@@ -1353,7 +1353,9 @@ var FieldNames;
1353
1353
  FieldNames["payViaCheckoutUrl"] = "payViaCheckoutUrl";
1354
1354
  FieldNames["googlePayInitData"] = "googlePayInitData";
1355
1355
  FieldNames["googlePayPaymentData"] = "googlePayPaymentData";
1356
+ FieldNames["googlePay3dsRedirect"] = "googlePay3DSRedirect";
1356
1357
  FieldNames["externalCardIssuerCountry"] = "externalCardIssuerCountry";
1358
+ FieldNames["pmId"] = "pm_id";
1357
1359
  })(FieldNames || (FieldNames = {}));
1358
1360
 
1359
1361
  class SubmitResponse {
@@ -1444,6 +1446,68 @@ class InitializeResponse {
1444
1446
  }
1445
1447
  }
1446
1448
 
1449
+ var UserBehaviourEventName;
1450
+ (function (UserBehaviourEventName) {
1451
+ UserBehaviourEventName["openPaystation"] = "open-paystation";
1452
+ UserBehaviourEventName["showErrorMessage"] = "show-error-message";
1453
+ UserBehaviourEventName["openStatusError"] = "open-status-error";
1454
+ UserBehaviourEventName["changeStatus"] = "change-status";
1455
+ UserBehaviourEventName["checkStatusUpdate"] = "check-status-update";
1456
+ UserBehaviourEventName["sysTrackedScripts"] = "sys-tracked_scripts";
1457
+ UserBehaviourEventName["showShoppingCart"] = "show-shopping_cart";
1458
+ UserBehaviourEventName["attemptBuyNow"] = "attempt-buy_now";
1459
+ UserBehaviourEventName["attemptContinue"] = "attempt-continue";
1460
+ UserBehaviourEventName["clickBtnPay"] = "click-btn-pay";
1461
+ UserBehaviourEventName["initializeNextAction"] = "initialize-next-action";
1462
+ UserBehaviourEventName["nextAction"] = "next-action";
1463
+ UserBehaviourEventName["createForm"] = "create-form";
1464
+ UserBehaviourEventName["applicablePaymentStrategies"] = "applicable-payment-strategies";
1465
+ UserBehaviourEventName["initializeRequest"] = "initialize-request";
1466
+ UserBehaviourEventName["submitRequest"] = "submit-request";
1467
+ UserBehaviourEventName["syncRequest"] = "sync-request";
1468
+ UserBehaviourEventName["threeDs2complete"] = "3DS-2.0-complete";
1469
+ UserBehaviourEventName["threeDs2challenge"] = "3DS-2.0-challenge";
1470
+ UserBehaviourEventName["threeDs2collectDfp"] = "3DS-2.0-collect-dfp";
1471
+ // Apple Pay
1472
+ UserBehaviourEventName["applePayRecalculateCartTaxes"] = "apple-pay-recalculate-cart-taxes";
1473
+ UserBehaviourEventName["applePayRecalculateCartError"] = "apple-pay-recalculate-cart-error";
1474
+ UserBehaviourEventName["applePayOpenWebSocketConnection"] = "apple-pay-open-web-socket-connection";
1475
+ UserBehaviourEventName["applePaySendMessageToAnotherWindow"] = "apple-pay-send-message-to-another-window";
1476
+ UserBehaviourEventName["applePayBraintreeStartSession"] = "apple-pay-braintree-start-session";
1477
+ UserBehaviourEventName["applePayBraintreeSelectShipping"] = "apple-pay-braintree-select-shipping";
1478
+ UserBehaviourEventName["applePayBraintreeCartSuccessfulRecalculated"] = "apple-pay-braintree-cart-successful-recalculated";
1479
+ UserBehaviourEventName["applePayBraintreeCartErrorRecalculated"] = "apple-pay-braintree-cart-error-recalculated";
1480
+ UserBehaviourEventName["applePayBraintreeValidateMerchant"] = "apple-pay-braintree-validate-merchant";
1481
+ UserBehaviourEventName["applePayBraintreeValidateMerchantError"] = "apple-pay-braintree-validate-merchant-error";
1482
+ UserBehaviourEventName["applePayBraintreePaymentAuthorized"] = "apple-pay-braintree-payment-authorized";
1483
+ UserBehaviourEventName["applePayBraintreePaymentTokenizationError"] = "apple-pay-braintree-payment-tokenization-error";
1484
+ UserBehaviourEventName["applePayBraintreePaymentCancel"] = "apple-pay-braintree-payment-cancel";
1485
+ UserBehaviourEventName["applePayCheckoutSelectShipping"] = "apple-pay-checkout-select-shipping";
1486
+ UserBehaviourEventName["applePayCheckoutCartSuccessfulRecalculated"] = "apple-pay-checkout-cart-successful-recalculated";
1487
+ UserBehaviourEventName["applePayCheckoutCartErrorRecalculated"] = "apple-pay-checkout-cart-error-recalculated";
1488
+ UserBehaviourEventName["applePayCheckoutValidateMerchant"] = "apple-pay-checkout-validate-merchant";
1489
+ UserBehaviourEventName["applePayCheckoutValidateMerchantError"] = "apple-pay-checkout-validate-merchant-error";
1490
+ UserBehaviourEventName["applePayCheckoutPaymentAuthorized"] = "apple-pay-checkout-payment-authorized";
1491
+ UserBehaviourEventName["applePayCheckoutPaymentCancel"] = "apple-pay-checkout-payment-cancel";
1492
+ UserBehaviourEventName["applePayAcquirer"] = "apple-pay-acquirer";
1493
+ // Google Pay
1494
+ UserBehaviourEventName["googlePayHandleFailedPayment"] = "google-pay-handle-failed-payment";
1495
+ UserBehaviourEventName["googlePayHandleSuccessfulPayment"] = "google-pay-handle-successful-payment";
1496
+ })(UserBehaviourEventName || (UserBehaviourEventName = {}));
1497
+
1498
+ const userBehaviourEventTypes = {
1499
+ open: 'open',
1500
+ show: 'show',
1501
+ click: 'click',
1502
+ manual: 'manual',
1503
+ store: 'store',
1504
+ };
1505
+
1506
+ const eventCategories = {
1507
+ withoutInvoice: 'withoutInvoice',
1508
+ withInvoice: 'withInvoice',
1509
+ };
1510
+
1447
1511
  const isSubmitResponse = (value) => {
1448
1512
  return value instanceof SubmitResponse;
1449
1513
  };
@@ -1526,8 +1590,15 @@ const updateAfterErrorRules = [
1526
1590
  const fieldsAllowedToExternalChange = new Set([
1527
1591
  FieldNames.email,
1528
1592
  FieldNames.externalCardIssuerCountry,
1593
+ FieldNames.pmId,
1529
1594
  ]);
1530
1595
 
1596
+ const googlePayPid = 3431;
1597
+
1598
+ const isGooglePaySettingsGuard = (settings) => {
1599
+ return settings.paymentMethodId === googlePayPid;
1600
+ };
1601
+
1531
1602
  const masterCardAndVisaPaymentMethodId = 26;
1532
1603
  const maestroPaymentMethodId = 490;
1533
1604
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
@@ -1544,30 +1615,16 @@ const cardsWith3ds = new Set([
1544
1615
  creditCardPaymentMethodId,
1545
1616
  ]);
1546
1617
 
1618
+ const isCreditCardSettingsGuard = (settings) => {
1619
+ return settings.paymentMethodId === creditCardPaymentMethodId;
1620
+ };
1621
+
1547
1622
  const initializeResponseFactoryToken = new InjectionToken('InitializeResponse');
1548
1623
  const initializeResponseFactoryProvider = {
1549
1624
  provide: initializeResponseFactoryToken,
1550
1625
  useValue: (...args) => new InitializeResponse(...args),
1551
1626
  };
1552
1627
 
1553
- var UserBehaviourEventName;
1554
- (function (UserBehaviourEventName) {
1555
- UserBehaviourEventName["openPaystation"] = "open-paystation";
1556
- UserBehaviourEventName["showMethodHeader"] = "show-method-header";
1557
- UserBehaviourEventName["showErrorMessage"] = "show-error-message";
1558
- UserBehaviourEventName["openStatusError"] = "open-status-error";
1559
- UserBehaviourEventName["statusUpdated"] = "status-updated";
1560
- UserBehaviourEventName["sysTrackedScripts"] = "sys-tracked_scripts";
1561
- })(UserBehaviourEventName || (UserBehaviourEventName = {}));
1562
-
1563
- const userBehaviourEventTypes = {
1564
- open: 'open',
1565
- show: 'show',
1566
- click: 'click',
1567
- manual: 'manual',
1568
- store: 'store',
1569
- };
1570
-
1571
1628
  class XpsApiService {
1572
1629
  constructor(window, secureApiClient, settingsService, countryService, userAgentService) {
1573
1630
  this.window = window;
@@ -1688,13 +1745,6 @@ class RedirectActionCreator {
1688
1745
  return (response.currentCommand === XpsCommand.checkout &&
1689
1746
  Boolean(response.parameters.checkout));
1690
1747
  }
1691
- getRedirect(submitResponse) {
1692
- return {
1693
- redirectUrl: this.getRedirectUrl(submitResponse),
1694
- isNewWindowRequired: this.getIsNewWindowRequired(submitResponse),
1695
- data: submitResponse.parameters.checkout.data,
1696
- };
1697
- }
1698
1748
  getRedirectUrl(submitResponse) {
1699
1749
  const responseRedirectUrl = submitResponse.parameters.checkout.action;
1700
1750
  const pid = submitResponse?.fields?.find(({ name }) => name === 'fix_pid')?.value;
@@ -1707,6 +1757,14 @@ class RedirectActionCreator {
1707
1757
  }
1708
1758
  return this.preparePagesUrl(pagesPath);
1709
1759
  }
1760
+ getRedirect(submitResponse) {
1761
+ return {
1762
+ redirectUrl: this.getRedirectUrl(submitResponse),
1763
+ isNewWindowRequired: this.getIsNewWindowRequired(submitResponse),
1764
+ isSameWindowRequired: this.getIsSameWindowRequired(submitResponse),
1765
+ data: submitResponse.parameters.checkout?.data ?? {},
1766
+ };
1767
+ }
1710
1768
  getIsNewWindowRequired(submitResponse) {
1711
1769
  if (!cardsWith3ds.has(submitResponse?.parameters?.pid)) {
1712
1770
  return false;
@@ -1717,6 +1775,13 @@ class RedirectActionCreator {
1717
1775
  const isJapanCard = cardBinCountry === 'JP';
1718
1776
  return isAcquirerWithRedirectInNewWindow || isJapanCard;
1719
1777
  }
1778
+ getIsSameWindowRequired(submitResponse) {
1779
+ if (this.getIsNewWindowRequired(submitResponse)) {
1780
+ return false;
1781
+ }
1782
+ // 3DS with redirect case
1783
+ return cardsWith3ds.has(submitResponse?.parameters?.pid);
1784
+ }
1720
1785
  preparePagesUrl(pagesPath) {
1721
1786
  const isSandbox = this.settingsService.isSandboxMode();
1722
1787
  const token = this.settingsService.token;
@@ -1981,8 +2046,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
1981
2046
  type: Injectable
1982
2047
  }] });
1983
2048
 
1984
- const googlePayPid = 3431;
1985
-
1986
2049
  class SpecialButtonActionCreator {
1987
2050
  constructor() {
1988
2051
  this.type = 'special_button';
@@ -2122,8 +2185,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
2122
2185
  type: Injectable
2123
2186
  }] });
2124
2187
 
2188
+ class GoogleThreeDsRedirectActionCreator extends RedirectActionCreator {
2189
+ isSuitable(response) {
2190
+ return (response.currentCommand === XpsCommand.checkout &&
2191
+ !response.parameters.checkout &&
2192
+ Boolean(response.parameters.form?.googlePay3DSRedirect?.value));
2193
+ }
2194
+ getRedirectUrl(submitResponse) {
2195
+ return (String(submitResponse.parameters.form?.googlePay3DSRedirect?.value) ?? '');
2196
+ }
2197
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
2198
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator }); }
2199
+ }
2200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator, decorators: [{
2201
+ type: Injectable
2202
+ }] });
2203
+
2125
2204
  const nextActionsToken = new InjectionToken('Action');
2126
2205
  const nextActions = [
2206
+ GoogleThreeDsRedirectActionCreator,
2127
2207
  ShowFieldsActionCreator,
2128
2208
  CheckStatusActionCreator,
2129
2209
  SpecialButtonActionCreator,
@@ -2139,85 +2219,390 @@ const flowUpdateNextActions = [
2139
2219
  ThreeDsActionCreator,
2140
2220
  ];
2141
2221
 
2142
- class NextActionService {
2143
- get flowUpdates$() {
2144
- return this.flowUpdatesSubject.asObservable();
2222
+ const oneTimeAnalyticsEvents = new Set([]);
2223
+
2224
+ var EventParameterType;
2225
+ (function (EventParameterType) {
2226
+ EventParameterType["string"] = "0";
2227
+ EventParameterType["int"] = "1";
2228
+ EventParameterType["float"] = "2";
2229
+ EventParameterType["bool"] = "3";
2230
+ EventParameterType["intArray"] = "4";
2231
+ EventParameterType["stringArray"] = "5";
2232
+ })(EventParameterType || (EventParameterType = {}));
2233
+
2234
+ class EventBuilderService {
2235
+ constructor(settingsService, userAgentService, window) {
2236
+ this.settingsService = settingsService;
2237
+ this.userAgentService = userAgentService;
2238
+ this.window = window;
2145
2239
  }
2146
- constructor(nextActionTokens, injector, showErrorsActionCreator) {
2147
- this.nextActionTokens = nextActionTokens;
2148
- this.injector = injector;
2149
- this.showErrorsActionCreator = showErrorsActionCreator;
2150
- this.flowUpdatesSubject = new Subject();
2151
- this.nextActionsList = [];
2152
- this.fillNextActionsList();
2240
+ createEvent(options, userSessionOptions) {
2241
+ return {
2242
+ action: options.action,
2243
+ type: options.type,
2244
+ value: this.convertToEventParameterType(options.value, options.valueType ?? EventParameterType.string),
2245
+ state: options.state,
2246
+ date: this.getDate(options.date),
2247
+ milliseconds: options.date.getTime(),
2248
+ timezone: this.getTimezone(options.date),
2249
+ session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2250
+ referrer_url: this.window?.document?.referrer,
2251
+ project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2252
+ payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2253
+ this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2254
+ geotype_id: this.convertToEventParameterType(options.invoice?.geotype_id, EventParameterType.int),
2255
+ instance_id: this.convertToEventParameterType(options.instanceId ??
2256
+ this.getPaymentMethodId(userSessionOptions.instanceId), EventParameterType.int),
2257
+ payment_method_contr_id: this.convertToEventParameterType(options.invoice?.payment_method_contr_id, EventParameterType.int),
2258
+ ps_type: this.convertToEventParameterType(options.invoice?.ps_type, EventParameterType.int),
2259
+ is_pay_with_saved_method: this.convertToEventParameterType(userSessionOptions.isPayWithSavedMethod, EventParameterType.bool),
2260
+ purchase_invoice_id: this.convertToEventParameterType(options.invoice?.purchase_invoice_id, EventParameterType.int),
2261
+ purchase_external_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.purchase_external_id, EventParameterType.string),
2262
+ purchase_type: this.settingsService.unsafeUtilsResponse?.purchase
2263
+ ?.purchase_type,
2264
+ purchase_sum: this.convertToEventParameterType(options.invoice?.purchase_sum, EventParameterType.float),
2265
+ purchase_currency: this.convertToEventParameterType(options.invoice?.purchase_currency, EventParameterType.string),
2266
+ purchase_sku: this.convertToEventParameterType(options.invoice?.purchase_sku, EventParameterType.string),
2267
+ purchase_digital_content_sku: null,
2268
+ purchase_description: this.convertToEventParameterType(options.invoice?.purchase_description, EventParameterType.string),
2269
+ virtual_currency_amount: null, // TODO: add value
2270
+ digital_content_cart_id: this.convertToEventParameterType(options.invoice?.digital_content_cart_id, EventParameterType.int),
2271
+ digital_good_cart_id: this.convertToEventParameterType(options.invoice?.digital_good_cart_id, EventParameterType.int),
2272
+ coupon_code: this.convertToEventParameterType(userSessionOptions.couponCode, EventParameterType.string),
2273
+ theme_version: this.userAgentService.isMobileDevice
2274
+ ? Device.mobile
2275
+ : Device.desktop,
2276
+ subscription_package_id: this.convertToEventParameterType(userSessionOptions.subscriptionPackageId, EventParameterType.int),
2277
+ subscription_product_id: this.convertToEventParameterType(userSessionOptions.subscriptionProductId, EventParameterType.int),
2278
+ subscription_recurrent_id: this.convertToEventParameterType(userSessionOptions.subscriptionRecurrentId, EventParameterType.int),
2279
+ user_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.id, EventParameterType.string),
2280
+ user_access_token: this.settingsService.token,
2281
+ user_name: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.v2, EventParameterType.string),
2282
+ user_email: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.email?.value, EventParameterType.string),
2283
+ user_country: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2284
+ user_ip: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.ip, EventParameterType.string),
2285
+ user_mobile_operator_name: this.convertToEventParameterType(userSessionOptions.userMobileOperatorName, EventParameterType.string),
2286
+ user_operation_system: this.userAgentService.platform,
2287
+ user_browser: this.userAgentService.browserDescription,
2288
+ user_browser_version: this.userAgentService.browserVersion,
2289
+ user_locale: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.local, EventParameterType.string),
2290
+ user_utm: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.utm_parameters, EventParameterType.string),
2291
+ xsolla_product_tag: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.xsolla_product_tag, EventParameterType.string),
2292
+ experiment_id: null,
2293
+ is_test_session: +isDevMode(),
2294
+ babka_value: null,
2295
+ extra_value: this.convertToEventParameterType(options?.extraValue, EventParameterType.string),
2296
+ is_subscription: this.convertToEventParameterType(this.isSubscription(), EventParameterType.bool),
2297
+ is_iframe: this.convertToEventParameterType(this.window.parent !== this.window, EventParameterType.bool),
2298
+ web3wallet: null, // TODO: add value
2299
+ dimension_1: this.convertToEventParameterType(options?.dimension1, EventParameterType.string),
2300
+ dimension_2: this.convertToEventParameterType(options?.dimension2, EventParameterType.string),
2301
+ dimension_3: this.convertToEventParameterType(options?.dimension3, EventParameterType.string),
2302
+ dimension_4: this.convertToEventParameterType(options?.dimension4, EventParameterType.string),
2303
+ dimension_5: this.convertToEventParameterType(options?.dimension5, EventParameterType.string),
2304
+ client_version: 'Headless Checkout',
2305
+ };
2153
2306
  }
2154
- getNextAction(submitResponse) {
2155
- if (submitResponse.errors?.length) {
2156
- this.emitFlowErrors(submitResponse.errors);
2307
+ getDate(date) {
2308
+ const nullIndex = 0;
2309
+ return date.toISOString().replace('T', ' ').replace('Z', '').split('.')[nullIndex];
2310
+ }
2311
+ getTimezone(date) {
2312
+ const hour = 60;
2313
+ const nullHour = 0;
2314
+ const hourOffset = -date.getTimezoneOffset() / hour;
2315
+ if (hourOffset === nullHour) {
2316
+ return '0';
2157
2317
  }
2158
- if (!submitResponse.currentCommand) {
2318
+ return hourOffset > nullHour ? `+${hourOffset}` : hourOffset.toString();
2319
+ }
2320
+ convertToEventParameterType(value, type
2321
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2322
+ ) {
2323
+ if (value === null || value === undefined) {
2159
2324
  return null;
2160
2325
  }
2161
- const nextAction = this.findNextAction(submitResponse);
2162
- if (nextAction) {
2163
- return nextAction.getActionData(submitResponse);
2326
+ if (typeof value === 'boolean') {
2327
+ value = value ? 1 : 0;
2328
+ }
2329
+ switch (type) {
2330
+ case EventParameterType.string:
2331
+ return String(value);
2332
+ case EventParameterType.int:
2333
+ value = parseInt(String(value), 10);
2334
+ return isNaN(value) ? 0 : value;
2335
+ case EventParameterType.stringArray:
2336
+ case EventParameterType.intArray:
2337
+ return Array.isArray(value) ? value : [];
2338
+ case EventParameterType.float:
2339
+ value = parseFloat(String(value));
2340
+ return isNaN(value) ? 0 : value;
2341
+ case EventParameterType.bool:
2342
+ return value ? 1 : 0;
2164
2343
  }
2165
- throw new Error('Next action is undefined.');
2166
- }
2167
- emitFlowUpdates(action) {
2168
- this.flowUpdatesSubject.next(action);
2169
2344
  }
2170
- emitFlowErrors(errors) {
2171
- if (errors.length === 0)
2172
- return;
2173
- this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(errors));
2345
+ convertValueForPostMessage(value) {
2346
+ if (value === null || value === undefined) {
2347
+ return null;
2348
+ }
2349
+ return String(value);
2174
2350
  }
2175
- fillNextActionsList() {
2176
- this.nextActionTokens.forEach((nextAction) => {
2177
- const item = this.injector.get(nextAction);
2178
- this.nextActionsList.push(item);
2179
- });
2351
+ isSubscription() {
2352
+ return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2353
+ 'subscription');
2180
2354
  }
2181
- findNextAction(submitResponse) {
2182
- const actionType = this.nextActionsList.find((nextAction) => {
2183
- return nextAction.isSuitable(submitResponse);
2184
- });
2185
- if (!actionType) {
2186
- return;
2187
- }
2188
- return actionType;
2355
+ getPaymentMethodId(instanceId) {
2356
+ return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2357
+ instanceId);
2189
2358
  }
2190
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }, { token: ShowErrorsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2191
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, providedIn: 'root' }); }
2359
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, deps: [{ token: SettingsService }, { token: UserAgentService }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable }); }
2360
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, providedIn: 'root' }); }
2192
2361
  }
2193
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, decorators: [{
2362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, decorators: [{
2194
2363
  type: Injectable,
2195
2364
  args: [{
2196
2365
  providedIn: 'root',
2197
2366
  }]
2198
- }], ctorParameters: () => [{ type: undefined, decorators: [{
2367
+ }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2199
2368
  type: Inject,
2200
- args: [nextActionsToken]
2201
- }] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }] });
2202
-
2203
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2204
- const cardNumberSanctionErrorCodes = [
2205
- 2034, 2035, 5027, 5024, 5025, 2036,
2206
- ];
2207
-
2208
- const fieldSpecialErrorsMap = [
2209
- {
2210
- errorCodes: new Set(cardNumberSanctionErrorCodes),
2211
- fieldName: FieldNames.cardNumber,
2212
- },
2213
- ];
2369
+ args: [windowToken]
2370
+ }] }] });
2214
2371
 
2215
- class UnescapeHtmlPipe {
2216
- transform(html) {
2217
- if (!html) {
2218
- return '';
2219
- }
2220
- if (html.includes('&gt')) {
2372
+ class UserBehaviourAnalyticsService {
2373
+ set isPayWithSavedMethod(value) {
2374
+ this.userSessionOptions.isPayWithSavedMethod = value;
2375
+ }
2376
+ set subscriptionPackageId(value) {
2377
+ this.userSessionOptions.subscriptionPackageId = value;
2378
+ }
2379
+ set couponCode(value) {
2380
+ this.userSessionOptions.couponCode = value;
2381
+ }
2382
+ set paymentStatus(value) {
2383
+ this.userSessionOptions.paymentStatus = value;
2384
+ }
2385
+ get sessionOptions() {
2386
+ return this.userSessionOptions;
2387
+ }
2388
+ get purchaseType() {
2389
+ return this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type
2390
+ ? 'subscription'
2391
+ : null;
2392
+ }
2393
+ constructor(http, eventBuilderService, settingsService) {
2394
+ this.http = http;
2395
+ this.eventBuilderService = eventBuilderService;
2396
+ this.settingsService = settingsService;
2397
+ this.apiUrl = 'https://datagather.xsolla.com/paystation-user-sessions';
2398
+ this._events$ = new Subject();
2399
+ this.userSessionOptions = {
2400
+ invoice: null,
2401
+ instanceId: null,
2402
+ subscriptionRecurrentId: null,
2403
+ userMobileOperatorName: null,
2404
+ isPayWithSavedMethod: false,
2405
+ subscriptionPackageId: null,
2406
+ subscriptionProductId: null,
2407
+ couponCode: null,
2408
+ totalSum: null,
2409
+ totalCurrency: null,
2410
+ paymentInstanceName: null,
2411
+ paymentStatus: null,
2412
+ };
2413
+ this.sentEvents = new Set();
2414
+ }
2415
+ init() {
2416
+ this.setPid(this.settingsService.unsafeUtilsResponse?.purchase?.payment_system?.id);
2417
+ this.onOpenPayStation();
2418
+ }
2419
+ setPid(pid) {
2420
+ if (pid) {
2421
+ this.userSessionOptions.instanceId = pid;
2422
+ }
2423
+ }
2424
+ fillUserSession(paymentForm) {
2425
+ if (paymentForm.subscriptionRecurrentId) {
2426
+ this.userSessionOptions.subscriptionRecurrentId =
2427
+ paymentForm.subscriptionRecurrentId;
2428
+ }
2429
+ const operator = paymentForm.fields.find((field) => field.name === 'operator');
2430
+ if (operator) {
2431
+ this.userSessionOptions.userMobileOperatorName = operator.value;
2432
+ }
2433
+ if (paymentForm.pid) {
2434
+ this.setPid(paymentForm.pid);
2435
+ }
2436
+ if (paymentForm.userSession) {
2437
+ this.userSessionOptions.invoice = paymentForm.userSession;
2438
+ const createInvoiceOptions = {
2439
+ eventCategory: eventCategories.withInvoice,
2440
+ };
2441
+ this.send('create-invoice', userBehaviourEventTypes.manual, createInvoiceOptions);
2442
+ if (paymentForm.errors?.length) {
2443
+ this.resetInvoice();
2444
+ }
2445
+ }
2446
+ const total = paymentForm?.summary?.finance?.total;
2447
+ if (total) {
2448
+ this.userSessionOptions.totalSum = total.amount;
2449
+ this.userSessionOptions.totalCurrency = total.currency;
2450
+ }
2451
+ if (paymentForm.title) {
2452
+ this.userSessionOptions.paymentInstanceName = paymentForm.title;
2453
+ }
2454
+ }
2455
+ send(action, type, options) {
2456
+ if (oneTimeAnalyticsEvents.has(action) && this.sentEvents.has(action)) {
2457
+ return;
2458
+ }
2459
+ const date = new Date();
2460
+ const invoice = options?.eventCategory === eventCategories.withInvoice
2461
+ ? this.userSessionOptions.invoice
2462
+ : null;
2463
+ const eventOptions = {
2464
+ action,
2465
+ type,
2466
+ value: options?.value ?? null,
2467
+ valueType: options?.valueType ?? null,
2468
+ date,
2469
+ invoice,
2470
+ state: '',
2471
+ extraValue: options?.extraValue ?? null,
2472
+ purchase_type: options?.purchaseType ?? null,
2473
+ instanceId: options?.instanceId ?? null,
2474
+ dimension1: options?.dimension1 ?? null,
2475
+ dimension2: options?.dimension2 ?? null,
2476
+ dimension3: options?.dimension3 ?? null,
2477
+ dimension4: options?.dimension4 ?? null,
2478
+ dimension5: options?.dimension5 ?? null,
2479
+ };
2480
+ const sendEvent = () => {
2481
+ this.sentEvents.add(action);
2482
+ const event = this.eventBuilderService.createEvent(eventOptions, this.userSessionOptions);
2483
+ this._events$.next(event);
2484
+ const requestBody = JSON.stringify(event);
2485
+ if (navigator.sendBeacon) {
2486
+ navigator.sendBeacon(this.apiUrl, requestBody);
2487
+ }
2488
+ else {
2489
+ void this.http.post(this.apiUrl, requestBody).toPromise();
2490
+ }
2491
+ };
2492
+ if (options?.syncRequest) {
2493
+ sendEvent();
2494
+ return;
2495
+ }
2496
+ setTimeout(() => sendEvent());
2497
+ }
2498
+ onOpenPayStation() {
2499
+ this.send(UserBehaviourEventName.openPaystation, userBehaviourEventTypes.open, {
2500
+ value: null,
2501
+ purchaseType: this.purchaseType,
2502
+ });
2503
+ }
2504
+ resetInvoice() {
2505
+ this.userSessionOptions.invoice = null;
2506
+ }
2507
+ resetPid() {
2508
+ this.userSessionOptions.instanceId = null;
2509
+ }
2510
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, deps: [{ token: i1.HttpClient }, { token: EventBuilderService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2511
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, providedIn: 'root' }); }
2512
+ }
2513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, decorators: [{
2514
+ type: Injectable,
2515
+ args: [{
2516
+ providedIn: 'root',
2517
+ }]
2518
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
2519
+
2520
+ class NextActionService {
2521
+ get flowUpdates$() {
2522
+ return this.flowUpdatesSubject.asObservable();
2523
+ }
2524
+ constructor(nextActionTokens, injector, showErrorsActionCreator, userBehaviourAnalyticsService) {
2525
+ this.nextActionTokens = nextActionTokens;
2526
+ this.injector = injector;
2527
+ this.showErrorsActionCreator = showErrorsActionCreator;
2528
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
2529
+ this.flowUpdatesSubject = new Subject();
2530
+ this.nextActionsList = [];
2531
+ this.fillNextActionsList();
2532
+ }
2533
+ getNextAction(submitResponse) {
2534
+ if (submitResponse.errors?.length) {
2535
+ this.emitFlowErrors(submitResponse.errors);
2536
+ }
2537
+ if (!submitResponse.currentCommand) {
2538
+ return null;
2539
+ }
2540
+ const nextActionCreator = this.findNextActionCreator(submitResponse);
2541
+ if (nextActionCreator) {
2542
+ const nextAction = nextActionCreator.getActionData(submitResponse);
2543
+ this.logNextAction(nextAction);
2544
+ return nextAction;
2545
+ }
2546
+ throw new Error('Next action is undefined.');
2547
+ }
2548
+ emitFlowUpdates(action) {
2549
+ this.flowUpdatesSubject.next(action);
2550
+ this.logNextAction(action);
2551
+ }
2552
+ emitFlowErrors(errors) {
2553
+ if (errors.length === 0)
2554
+ return;
2555
+ this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(errors));
2556
+ }
2557
+ fillNextActionsList() {
2558
+ this.nextActionTokens.forEach((nextAction) => {
2559
+ const item = this.injector.get(nextAction);
2560
+ this.nextActionsList.push(item);
2561
+ });
2562
+ }
2563
+ findNextActionCreator(submitResponse) {
2564
+ const actionType = this.nextActionsList.find((nextAction) => {
2565
+ return nextAction.isSuitable(submitResponse);
2566
+ });
2567
+ if (!actionType) {
2568
+ return;
2569
+ }
2570
+ return actionType;
2571
+ }
2572
+ logNextAction(nextAction) {
2573
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.nextAction, 'manual', { value: nextAction.type });
2574
+ }
2575
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2576
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, providedIn: 'root' }); }
2577
+ }
2578
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, decorators: [{
2579
+ type: Injectable,
2580
+ args: [{
2581
+ providedIn: 'root',
2582
+ }]
2583
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2584
+ type: Inject,
2585
+ args: [nextActionsToken]
2586
+ }] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }] });
2587
+
2588
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2589
+ const cardNumberSanctionErrorCodes = [
2590
+ 2034, 2035, 5027, 5024, 5025, 2036,
2591
+ ];
2592
+
2593
+ const fieldSpecialErrorsMap = [
2594
+ {
2595
+ errorCodes: new Set(cardNumberSanctionErrorCodes),
2596
+ fieldName: FieldNames.cardNumber,
2597
+ },
2598
+ ];
2599
+
2600
+ class UnescapeHtmlPipe {
2601
+ transform(html) {
2602
+ if (!html) {
2603
+ return '';
2604
+ }
2605
+ if (html.includes('&gt')) {
2221
2606
  const messageDocument = new DOMParser().parseFromString(html, 'text/html');
2222
2607
  return messageDocument?.documentElement?.textContent ?? '';
2223
2608
  }
@@ -2559,417 +2944,114 @@ class CreditCardService {
2559
2944
  getAccountSuffix(cardNumber) {
2560
2945
  const accountSuffixLength = 4;
2561
2946
  return cardNumber
2562
- .replace(/\s+/g, '')
2563
- .substring(cardNumber.length - accountSuffixLength);
2564
- }
2565
- getTypeByNumber(cardNumber) {
2566
- cardNumber = cardNumber.replace(/\s+/g, '');
2567
- const cardSettings = orderedCardSettings.find((settings) => {
2568
- const isNumberMatched = settings.checkNumber(cardNumber);
2569
- return isNumberMatched ? settings.id : false;
2570
- });
2571
- return cardSettings ? cardSettings.id : defaultCard.id;
2572
- }
2573
- getCreditCardSettings(cardType) {
2574
- const creditCard = creditCardsMap[cardType];
2575
- if (!creditCard) {
2576
- return defaultCard;
2577
- }
2578
- return creditCard;
2579
- }
2580
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2581
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, providedIn: 'root' }); }
2582
- }
2583
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, decorators: [{
2584
- type: Injectable,
2585
- args: [{
2586
- providedIn: 'root',
2587
- }]
2588
- }] });
2589
-
2590
- // eslint-disable-next-line @typescript-eslint/naming-convention
2591
- class EncryptCreditCardService {
2592
- constructor(creditCardService) {
2593
- this.creditCardService = creditCardService;
2594
- this.secureFieldNames = [
2595
- 'xps_card_number',
2596
- 'xps_cvv',
2597
- 'xps_extra_cvv',
2598
- 'xps_card_year',
2599
- 'xps_card_month',
2600
- ];
2601
- this.jsEncrypt = new JSEncrypt();
2602
- }
2603
- setPublicKey(publicKey) {
2604
- this.jsEncrypt.setPublicKey(publicKey);
2605
- }
2606
- encryptCreditCard(request) {
2607
- if (request.xps_card_number) {
2608
- const openCard = this.createOpenCard(request);
2609
- request.xps_open_card = JSON.stringify(openCard);
2610
- }
2611
- const encryptedCard = this.createEncryptedCard(request);
2612
- if (request.xps_card_number || request.xps_extra_card_number) {
2613
- request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
2614
- }
2615
- this.secureFieldNames.forEach((secureFieldName) => {
2616
- delete request[secureFieldName];
2617
- });
2618
- return request;
2619
- }
2620
- encrypt(value) {
2621
- if (!this.jsEncrypt?.getPublicKey()) {
2622
- throw new EncryptCreditCardError('Empty public key');
2623
- }
2624
- const encryptedValue = this.jsEncrypt.encrypt(value);
2625
- if (!encryptedValue) {
2626
- throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
2627
- }
2628
- return encryptedValue;
2629
- }
2630
- createEncryptedCard(request) {
2631
- const encryptedCard = {
2632
- card_number: request.xps_card_number,
2633
- card_year: request.xps_card_year,
2634
- card_month: request.xps_card_month,
2635
- cvv: request.xps_cvv,
2636
- };
2637
- if (request.xps_extra_cvv) {
2638
- encryptedCard.cvv = request.xps_extra_cvv;
2639
- }
2640
- return encryptedCard;
2641
- }
2642
- createOpenCard(request) {
2643
- return {
2644
- card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
2645
- card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
2646
- card_year: request.xps_card_year,
2647
- card_month: request.xps_card_month,
2648
- };
2649
- }
2650
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2651
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' }); }
2652
- }
2653
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, decorators: [{
2654
- type: Injectable,
2655
- args: [{ providedIn: 'root' }]
2656
- }], ctorParameters: () => [{ type: CreditCardService }] });
2657
-
2658
- const eventCategories = {
2659
- withoutInvoice: 'withoutInvoice',
2660
- withInvoice: 'withInvoice',
2661
- };
2662
-
2663
- const oneTimeAnalyticsEvents = new Set([
2664
- UserBehaviourEventName.showMethodHeader,
2665
- ]);
2666
-
2667
- var EventParameterType;
2668
- (function (EventParameterType) {
2669
- EventParameterType["string"] = "0";
2670
- EventParameterType["int"] = "1";
2671
- EventParameterType["float"] = "2";
2672
- EventParameterType["bool"] = "3";
2673
- EventParameterType["intArray"] = "4";
2674
- EventParameterType["stringArray"] = "5";
2675
- })(EventParameterType || (EventParameterType = {}));
2676
-
2677
- class EventBuilderService {
2678
- constructor(settingsService, userAgentService, window) {
2679
- this.settingsService = settingsService;
2680
- this.userAgentService = userAgentService;
2681
- this.window = window;
2682
- }
2683
- createEvent(options, userSessionOptions) {
2684
- return {
2685
- action: options.action,
2686
- type: options.type,
2687
- value: this.convertToEventParameterType(options.value, options.valueType ?? EventParameterType.string),
2688
- state: options.state,
2689
- date: this.getDate(options.date),
2690
- milliseconds: options.date.getTime(),
2691
- timezone: this.getTimezone(options.date),
2692
- session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2693
- referrer_url: this.window?.document?.referrer,
2694
- project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2695
- payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2696
- this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2697
- geotype_id: this.convertToEventParameterType(options.invoice?.geotype_id, EventParameterType.int),
2698
- instance_id: this.convertToEventParameterType(options.instanceId ??
2699
- this.getPaymentMethodId(userSessionOptions.instanceId), EventParameterType.int),
2700
- payment_method_contr_id: this.convertToEventParameterType(options.invoice?.payment_method_contr_id, EventParameterType.int),
2701
- ps_type: this.convertToEventParameterType(options.invoice?.ps_type, EventParameterType.int),
2702
- is_pay_with_saved_method: this.convertToEventParameterType(userSessionOptions.isPayWithSavedMethod, EventParameterType.bool),
2703
- purchase_invoice_id: this.convertToEventParameterType(options.invoice?.purchase_invoice_id, EventParameterType.int),
2704
- purchase_external_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.purchase_external_id, EventParameterType.string),
2705
- purchase_type: this.settingsService.unsafeUtilsResponse?.purchase
2706
- ?.purchase_type,
2707
- purchase_sum: this.convertToEventParameterType(options.invoice?.purchase_sum, EventParameterType.float),
2708
- purchase_currency: this.convertToEventParameterType(options.invoice?.purchase_currency, EventParameterType.string),
2709
- purchase_sku: this.convertToEventParameterType(options.invoice?.purchase_sku, EventParameterType.string),
2710
- purchase_digital_content_sku: null,
2711
- purchase_description: this.convertToEventParameterType(options.invoice?.purchase_description, EventParameterType.string),
2712
- virtual_currency_amount: null, // TODO: add value
2713
- digital_content_cart_id: this.convertToEventParameterType(options.invoice?.digital_content_cart_id, EventParameterType.int),
2714
- digital_good_cart_id: this.convertToEventParameterType(options.invoice?.digital_good_cart_id, EventParameterType.int),
2715
- coupon_code: this.convertToEventParameterType(userSessionOptions.couponCode, EventParameterType.string),
2716
- theme_version: this.userAgentService.isMobileDevice
2717
- ? Device.mobile
2718
- : Device.desktop,
2719
- subscription_package_id: this.convertToEventParameterType(userSessionOptions.subscriptionPackageId, EventParameterType.int),
2720
- subscription_product_id: this.convertToEventParameterType(userSessionOptions.subscriptionProductId, EventParameterType.int),
2721
- subscription_recurrent_id: this.convertToEventParameterType(userSessionOptions.subscriptionRecurrentId, EventParameterType.int),
2722
- user_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.id, EventParameterType.string),
2723
- user_access_token: this.settingsService.token,
2724
- user_name: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.v2, EventParameterType.string),
2725
- user_email: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.email?.value, EventParameterType.string),
2726
- user_country: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2727
- user_ip: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.ip, EventParameterType.string),
2728
- user_mobile_operator_name: this.convertToEventParameterType(userSessionOptions.userMobileOperatorName, EventParameterType.string),
2729
- user_operation_system: this.userAgentService.platform,
2730
- user_browser: this.userAgentService.browserDescription,
2731
- user_browser_version: this.userAgentService.browserVersion,
2732
- user_locale: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.local, EventParameterType.string),
2733
- user_utm: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.utm_parameters, EventParameterType.string),
2734
- xsolla_product_tag: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.xsolla_product_tag, EventParameterType.string),
2735
- experiment_id: null,
2736
- is_test_session: +isDevMode(),
2737
- babka_value: null,
2738
- extra_value: this.convertToEventParameterType(options?.extraValue, EventParameterType.string),
2739
- is_subscription: this.convertToEventParameterType(this.isSubscription(), EventParameterType.bool),
2740
- is_iframe: this.convertToEventParameterType(this.window.parent !== this.window, EventParameterType.bool),
2741
- web3wallet: null, // TODO: add value
2742
- dimension_1: this.convertToEventParameterType(options?.dimension1, EventParameterType.string),
2743
- dimension_2: this.convertToEventParameterType(options?.dimension2, EventParameterType.string),
2744
- dimension_3: this.convertToEventParameterType(options?.dimension3, EventParameterType.string),
2745
- dimension_4: this.convertToEventParameterType(options?.dimension4, EventParameterType.string),
2746
- dimension_5: this.convertToEventParameterType(options?.dimension5, EventParameterType.string),
2747
- client_version: 'Headless Checkout',
2748
- };
2749
- }
2750
- getDate(date) {
2751
- const nullIndex = 0;
2752
- return date.toISOString().replace('T', ' ').replace('Z', '').split('.')[nullIndex];
2753
- }
2754
- getTimezone(date) {
2755
- const hour = 60;
2756
- const nullHour = 0;
2757
- const hourOffset = -date.getTimezoneOffset() / hour;
2758
- if (hourOffset === nullHour) {
2759
- return '0';
2760
- }
2761
- return hourOffset > nullHour ? `+${hourOffset}` : hourOffset.toString();
2762
- }
2763
- convertToEventParameterType(value, type
2764
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2765
- ) {
2766
- if (value === null || value === undefined) {
2767
- return null;
2768
- }
2769
- if (typeof value === 'boolean') {
2770
- value = value ? 1 : 0;
2771
- }
2772
- switch (type) {
2773
- case EventParameterType.string:
2774
- return String(value);
2775
- case EventParameterType.int:
2776
- value = parseInt(String(value), 10);
2777
- return isNaN(value) ? 0 : value;
2778
- case EventParameterType.stringArray:
2779
- case EventParameterType.intArray:
2780
- return Array.isArray(value) ? value : [];
2781
- case EventParameterType.float:
2782
- value = parseFloat(String(value));
2783
- return isNaN(value) ? 0 : value;
2784
- case EventParameterType.bool:
2785
- return value ? 1 : 0;
2786
- }
2787
- }
2788
- convertValueForPostMessage(value) {
2789
- if (value === null || value === undefined) {
2790
- return null;
2791
- }
2792
- return String(value);
2947
+ .replace(/\s+/g, '')
2948
+ .substring(cardNumber.length - accountSuffixLength);
2793
2949
  }
2794
- isSubscription() {
2795
- return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2796
- 'subscription');
2950
+ getTypeByNumber(cardNumber) {
2951
+ cardNumber = cardNumber.replace(/\s+/g, '');
2952
+ const cardSettings = orderedCardSettings.find((settings) => {
2953
+ const isNumberMatched = settings.checkNumber(cardNumber);
2954
+ return isNumberMatched ? settings.id : false;
2955
+ });
2956
+ return cardSettings ? cardSettings.id : defaultCard.id;
2797
2957
  }
2798
- getPaymentMethodId(instanceId) {
2799
- return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2800
- instanceId);
2958
+ getCreditCardSettings(cardType) {
2959
+ const creditCard = creditCardsMap[cardType];
2960
+ if (!creditCard) {
2961
+ return defaultCard;
2962
+ }
2963
+ return creditCard;
2801
2964
  }
2802
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, deps: [{ token: SettingsService }, { token: UserAgentService }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable }); }
2803
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, providedIn: 'root' }); }
2965
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2966
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, providedIn: 'root' }); }
2804
2967
  }
2805
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, decorators: [{
2968
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, decorators: [{
2806
2969
  type: Injectable,
2807
2970
  args: [{
2808
2971
  providedIn: 'root',
2809
2972
  }]
2810
- }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2811
- type: Inject,
2812
- args: [windowToken]
2813
- }] }] });
2973
+ }] });
2814
2974
 
2815
- class UserBehaviourAnalyticsService {
2816
- set isPayWithSavedMethod(value) {
2817
- this.userSessionOptions.isPayWithSavedMethod = value;
2818
- }
2819
- set subscriptionPackageId(value) {
2820
- this.userSessionOptions.subscriptionPackageId = value;
2821
- }
2822
- set couponCode(value) {
2823
- this.userSessionOptions.couponCode = value;
2824
- }
2825
- set paymentStatus(value) {
2826
- this.userSessionOptions.paymentStatus = value;
2827
- }
2828
- get sessionOptions() {
2829
- return this.userSessionOptions;
2830
- }
2831
- get purchaseType() {
2832
- return this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type
2833
- ? 'subscription'
2834
- : null;
2835
- }
2836
- constructor(http, eventBuilderService, settingsService) {
2837
- this.http = http;
2838
- this.eventBuilderService = eventBuilderService;
2839
- this.settingsService = settingsService;
2840
- this.apiUrl = 'https://datagather.xsolla.com/paystation-user-sessions';
2841
- this._events$ = new Subject();
2842
- this.userSessionOptions = {
2843
- invoice: null,
2844
- instanceId: null,
2845
- subscriptionRecurrentId: null,
2846
- userMobileOperatorName: null,
2847
- isPayWithSavedMethod: false,
2848
- subscriptionPackageId: null,
2849
- subscriptionProductId: null,
2850
- couponCode: null,
2851
- totalSum: null,
2852
- totalCurrency: null,
2853
- paymentInstanceName: null,
2854
- paymentStatus: null,
2855
- };
2856
- this.sentEvents = new Set();
2857
- }
2858
- init() {
2859
- this.setPid(this.settingsService.unsafeUtilsResponse?.purchase?.payment_system?.id);
2860
- this.onOpenPayStation();
2975
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2976
+ class EncryptCreditCardService {
2977
+ constructor(creditCardService) {
2978
+ this.creditCardService = creditCardService;
2979
+ this.secureFieldNames = [
2980
+ 'xps_card_number',
2981
+ 'xps_cvv',
2982
+ 'xps_extra_cvv',
2983
+ 'xps_card_year',
2984
+ 'xps_card_month',
2985
+ ];
2986
+ this.jsEncrypt = new JSEncrypt();
2861
2987
  }
2862
- setPid(pid) {
2863
- if (pid) {
2864
- this.userSessionOptions.instanceId = pid;
2865
- }
2988
+ setPublicKey(publicKey) {
2989
+ this.jsEncrypt.setPublicKey(publicKey);
2866
2990
  }
2867
- fillUserSession(paymentForm) {
2868
- if (paymentForm.subscriptionRecurrentId) {
2869
- this.userSessionOptions.subscriptionRecurrentId =
2870
- paymentForm.subscriptionRecurrentId;
2871
- }
2872
- const operator = paymentForm.fields.find((field) => field.name === 'operator');
2873
- if (operator) {
2874
- this.userSessionOptions.userMobileOperatorName = operator.value;
2875
- }
2876
- if (paymentForm.pid) {
2877
- this.setPid(paymentForm.pid);
2991
+ encryptCreditCard(request) {
2992
+ if (request.xps_card_number) {
2993
+ const openCard = this.createOpenCard(request);
2994
+ request.xps_open_card = JSON.stringify(openCard);
2878
2995
  }
2879
- if (paymentForm.userSession) {
2880
- this.userSessionOptions.invoice = paymentForm.userSession;
2881
- const createInvoiceOptions = {
2882
- eventCategory: eventCategories.withInvoice,
2883
- };
2884
- this.send('create-invoice', userBehaviourEventTypes.manual, createInvoiceOptions);
2885
- if (paymentForm.errors?.length) {
2886
- this.resetInvoice();
2887
- }
2996
+ const encryptedCard = this.createEncryptedCard(request);
2997
+ if (request.xps_card_number || request.xps_extra_card_number) {
2998
+ request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
2888
2999
  }
2889
- const total = paymentForm?.summary?.finance?.total;
2890
- if (total) {
2891
- this.userSessionOptions.totalSum = total.amount;
2892
- this.userSessionOptions.totalCurrency = total.currency;
3000
+ this.secureFieldNames.forEach((secureFieldName) => {
3001
+ delete request[secureFieldName];
3002
+ });
3003
+ return request;
3004
+ }
3005
+ encrypt(value) {
3006
+ if (!this.jsEncrypt?.getPublicKey()) {
3007
+ throw new EncryptCreditCardError('Empty public key');
2893
3008
  }
2894
- if (paymentForm.title) {
2895
- this.userSessionOptions.paymentInstanceName = paymentForm.title;
3009
+ const encryptedValue = this.jsEncrypt.encrypt(value);
3010
+ if (!encryptedValue) {
3011
+ throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
2896
3012
  }
3013
+ return encryptedValue;
2897
3014
  }
2898
- send(action, type, options) {
2899
- if (oneTimeAnalyticsEvents.has(action) && this.sentEvents.has(action)) {
2900
- return;
2901
- }
2902
- const date = new Date();
2903
- const invoice = options?.eventCategory === eventCategories.withInvoice
2904
- ? this.userSessionOptions.invoice
2905
- : null;
2906
- const eventOptions = {
2907
- action,
2908
- type,
2909
- value: options?.value ?? null,
2910
- valueType: options?.valueType ?? null,
2911
- date,
2912
- invoice,
2913
- state: '',
2914
- extraValue: options?.extraValue ?? null,
2915
- purchase_type: options?.purchaseType ?? null,
2916
- instanceId: options?.instanceId ?? null,
2917
- dimension1: options?.dimension1 ?? null,
2918
- dimension2: options?.dimension2 ?? null,
2919
- dimension3: options?.dimension3 ?? null,
2920
- dimension4: options?.dimension4 ?? null,
2921
- dimension5: options?.dimension5 ?? null,
2922
- };
2923
- const sendEvent = () => {
2924
- this.sentEvents.add(action);
2925
- const event = this.eventBuilderService.createEvent(eventOptions, this.userSessionOptions);
2926
- this._events$.next(event);
2927
- const requestBody = JSON.stringify(event);
2928
- if (navigator.sendBeacon) {
2929
- navigator.sendBeacon(this.apiUrl, requestBody);
2930
- }
2931
- else {
2932
- void this.http.post(this.apiUrl, requestBody).toPromise();
2933
- }
3015
+ createEncryptedCard(request) {
3016
+ const encryptedCard = {
3017
+ card_number: request.xps_card_number,
3018
+ card_year: request.xps_card_year,
3019
+ card_month: request.xps_card_month,
3020
+ cvv: request.xps_cvv,
2934
3021
  };
2935
- if (options?.syncRequest) {
2936
- sendEvent();
2937
- return;
3022
+ if (request.xps_extra_cvv) {
3023
+ encryptedCard.cvv = request.xps_extra_cvv;
2938
3024
  }
2939
- setTimeout(() => sendEvent());
2940
- }
2941
- onOpenPayStation() {
2942
- this.send(UserBehaviourEventName.openPaystation, userBehaviourEventTypes.open, {
2943
- value: null,
2944
- purchaseType: this.purchaseType,
2945
- });
2946
- }
2947
- resetInvoice() {
2948
- this.userSessionOptions.invoice = null;
3025
+ return encryptedCard;
2949
3026
  }
2950
- resetPid() {
2951
- this.userSessionOptions.instanceId = null;
3027
+ createOpenCard(request) {
3028
+ return {
3029
+ card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
3030
+ card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
3031
+ card_year: request.xps_card_year,
3032
+ card_month: request.xps_card_month,
3033
+ };
2952
3034
  }
2953
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, deps: [{ token: i1.HttpClient }, { token: EventBuilderService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2954
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, providedIn: 'root' }); }
3035
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3036
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' }); }
2955
3037
  }
2956
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, decorators: [{
3038
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, decorators: [{
2957
3039
  type: Injectable,
2958
- args: [{
2959
- providedIn: 'root',
2960
- }]
2961
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
3040
+ args: [{ providedIn: 'root' }]
3041
+ }], ctorParameters: () => [{ type: CreditCardService }] });
2962
3042
 
2963
3043
  class PaymentSettingsService {
2964
3044
  getPaymentSettingsParams(config) {
2965
3045
  if (!config?.paymentMethodSettings) {
2966
3046
  return {};
2967
3047
  }
2968
- const settings = config.paymentMethodSettings;
2969
3048
  const params = {};
2970
- params.useSingleExpirationDateField = this.toXps(settings.useSingleExpirationDateField);
2971
- params.useExternalVault = this.toXps(settings.useExternalVault);
2972
- params.isPaymentViaSavedMethod = this.toXps(settings.isPaymentViaSavedMethod);
3049
+ if (isCreditCardSettingsGuard(config)) {
3050
+ const settings = config.paymentMethodSettings;
3051
+ params.useSingleExpirationDateField = this.toXps(settings.useSingleExpirationDateField);
3052
+ params.useExternalVault = this.toXps(settings.useExternalVault);
3053
+ params.isPaymentViaSavedMethod = this.toXps(settings.isPaymentViaSavedMethod);
3054
+ }
2973
3055
  return params;
2974
3056
  }
2975
3057
  toXps(value) {
@@ -3077,6 +3159,7 @@ class InitializeService {
3077
3159
  if (config.savedMethodId) {
3078
3160
  requestParams.saved_method_id = config.savedMethodId;
3079
3161
  }
3162
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.initializeRequest, userBehaviourEventTypes.manual, { value: requestParams.pid });
3080
3163
  return this.xpsApiService
3081
3164
  .directPaymentRequest(requestParams)
3082
3165
  .then((xpsResponse) => {
@@ -3265,6 +3348,7 @@ class SubmitService {
3265
3348
  // In this way two promises become unequal, that can broke XPS API requests logic.
3266
3349
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3267
3350
  request(fields, form, config) {
3351
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.submitRequest, userBehaviourEventTypes.manual, { value: config.paymentMethodId });
3268
3352
  return (this.deviceFingerPrintService
3269
3353
  .getHash()
3270
3354
  // eslint-disable-next-line @typescript-eslint/promise-function-async
@@ -3501,6 +3585,7 @@ class SyncService extends EmitDataService {
3501
3585
  ...paymentSettingsParams,
3502
3586
  });
3503
3587
  const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
3588
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.syncRequest, userBehaviourEventTypes.manual, { extraValue: field?.name ?? '' });
3504
3589
  return this.xpsApiService
3505
3590
  .directPaymentRequest(encryptedRequest)
3506
3591
  .then((xpsResponse) => {
@@ -3583,7 +3668,6 @@ function convertedEmailValidator() {
3583
3668
  }
3584
3669
 
3585
3670
  function convertedRequiredValidator() {
3586
- console.log();
3587
3671
  return convert(Validators.required, TranslateHelper.t('errors.validation.required', 'Required'));
3588
3672
  }
3589
3673
 
@@ -4772,18 +4856,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
4772
4856
  }] }, { type: i0.Injector }] });
4773
4857
 
4774
4858
  class FormService {
4775
- constructor(controlConfigService) {
4859
+ constructor(controlConfigService, userBehaviourAnalyticsService) {
4776
4860
  this.controlConfigService = controlConfigService;
4861
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
4777
4862
  this.fieldFormStates = {};
4778
4863
  }
4779
4864
  createForm(fields) {
4780
- const controls = this.getVisibleFields(fields).reduce((result, field) => {
4865
+ const visibleFields = this.getVisibleFields(fields);
4866
+ const controls = visibleFields.reduce((result, field) => {
4781
4867
  const formControl = this.controlConfigService.getFormControl(field);
4782
4868
  if (formControl) {
4783
4869
  result[field.name] = formControl;
4784
4870
  }
4785
4871
  return result;
4786
4872
  }, {});
4873
+ this.logCreateForm(visibleFields);
4787
4874
  return new UntypedFormGroup(controls);
4788
4875
  }
4789
4876
  getFieldFormState(fieldName) {
@@ -4809,12 +4896,15 @@ class FormService {
4809
4896
  getVisibleFields(fields) {
4810
4897
  return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
4811
4898
  }
4812
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, deps: [{ token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4899
+ logCreateForm(fields) {
4900
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.createForm, 'manual', { value: fields.map((field) => field.name) });
4901
+ }
4902
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, deps: [{ token: ControlConfigService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4813
4903
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService }); }
4814
4904
  }
4815
4905
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, decorators: [{
4816
4906
  type: Injectable
4817
- }], ctorParameters: () => [{ type: ControlConfigService }] });
4907
+ }], ctorParameters: () => [{ type: ControlConfigService }, { type: UserBehaviourAnalyticsService }] });
4818
4908
 
4819
4909
  var StatusSearchParam;
4820
4910
  (function (StatusSearchParam) {
@@ -5637,20 +5727,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
5637
5727
  }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
5638
5728
 
5639
5729
  class FinanceDetailsService extends EmitDataService {
5640
- constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService) {
5730
+ constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService, userBehaviourAnalyticsService) {
5641
5731
  super();
5642
5732
  this.sessionService = sessionService;
5643
5733
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
5644
5734
  this.statusFinanceDetailsAdapterService = statusFinanceDetailsAdapterService;
5735
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
5645
5736
  this.purchaseSessionKey = 'purchase';
5646
5737
  }
5647
- emitWithSummary(summary) {
5738
+ emitWithSummary(summary, needLogCart = true) {
5648
5739
  if (summary) {
5649
5740
  const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5650
5741
  if (financeDetails.purchase) {
5651
5742
  this.sessionService.set(this.purchaseSessionKey, financeDetails.purchase);
5652
5743
  }
5653
5744
  super.emit(financeDetails);
5745
+ if (needLogCart) {
5746
+ this.logCartEvent(financeDetails);
5747
+ }
5654
5748
  }
5655
5749
  }
5656
5750
  emitWithStatus(status) {
@@ -5663,13 +5757,18 @@ class FinanceDetailsService extends EmitDataService {
5663
5757
  getDetailsFromSummary(summary) {
5664
5758
  return this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5665
5759
  }
5666
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, deps: [{ token: SessionService }, { token: SummaryFinanceDetailsAdapterService }, { token: StatusFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
5760
+ logCartEvent(financeDetails) {
5761
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.showShoppingCart, userBehaviourEventTypes.show, {
5762
+ value: financeDetails.finance ? 'success' : 'fail',
5763
+ });
5764
+ }
5765
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, deps: [{ token: SessionService }, { token: SummaryFinanceDetailsAdapterService }, { token: StatusFinanceDetailsAdapterService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
5667
5766
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' }); }
5668
5767
  }
5669
5768
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, decorators: [{
5670
5769
  type: Injectable,
5671
5770
  args: [{ providedIn: 'root' }]
5672
- }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }] });
5771
+ }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }, { type: UserBehaviourAnalyticsService }] });
5673
5772
 
5674
5773
  /* eslint-disable @typescript-eslint/naming-convention */
5675
5774
  class CheckStatusRequest extends XpsApiPartRequest {
@@ -6249,7 +6348,7 @@ class ListenStatusService {
6249
6348
  const isStatusError = statusSettings.statusState === StatusEnum.canceled ||
6250
6349
  statusSettings.statusState === StatusEnum.error ||
6251
6350
  statusSettings.isCancelUser;
6252
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.statusUpdated, userBehaviourEventTypes.manual, {
6351
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.changeStatus, userBehaviourEventTypes.manual, {
6253
6352
  instanceId: statusResponse.status.pid,
6254
6353
  value: statusResponse.status.statusState,
6255
6354
  });
@@ -6272,6 +6371,9 @@ class ListenStatusService {
6272
6371
  .subscribe((checkStatusResponse) => {
6273
6372
  if (!checkStatusResponse?.status)
6274
6373
  return;
6374
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.checkStatusUpdate, userBehaviourEventTypes.manual, {
6375
+ value: checkStatusResponse.status ?? '',
6376
+ });
6275
6377
  if (checkStatusResponse.status === StatusEnum.done) {
6276
6378
  this.statusService.request();
6277
6379
  this.websocketStatusService.closeWebSocket();
@@ -6589,8 +6691,9 @@ const initializeNextActions = [
6589
6691
  ];
6590
6692
 
6591
6693
  class InitializeNextActionService {
6592
- constructor(initializeNextActionTokens, injector) {
6694
+ constructor(initializeNextActionTokens, userBehaviourAnalyticsService, injector) {
6593
6695
  this.initializeNextActionTokens = initializeNextActionTokens;
6696
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6594
6697
  this.injector = injector;
6595
6698
  this.initializeNextActionsList = [];
6596
6699
  this.fillNextActionsList();
@@ -6599,6 +6702,7 @@ class InitializeNextActionService {
6599
6702
  const nextAction = this.findNextAction(response);
6600
6703
  if (!nextAction)
6601
6704
  return null;
6705
+ this.logNextAction(nextAction);
6602
6706
  return nextAction.getActionData(response);
6603
6707
  }
6604
6708
  fillNextActionsList() {
@@ -6612,7 +6716,10 @@ class InitializeNextActionService {
6612
6716
  return nextAction.isSuitable(response);
6613
6717
  });
6614
6718
  }
6615
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, deps: [{ token: initializeNextActionsToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
6719
+ logNextAction(nextAction) {
6720
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.initializeNextAction, 'manual', { value: nextAction.type });
6721
+ }
6722
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, deps: [{ token: initializeNextActionsToken }, { token: UserBehaviourAnalyticsService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
6616
6723
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, providedIn: 'root' }); }
6617
6724
  }
6618
6725
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, decorators: [{
@@ -6623,7 +6730,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
6623
6730
  }], ctorParameters: () => [{ type: undefined, decorators: [{
6624
6731
  type: Inject,
6625
6732
  args: [initializeNextActionsToken]
6626
- }] }, { type: i0.Injector }] });
6733
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
6627
6734
 
6628
6735
  var ThreeDsStatusWebSocketTypes;
6629
6736
  (function (ThreeDsStatusWebSocketTypes) {
@@ -6914,12 +7021,13 @@ class ThreeDs20Service {
6914
7021
  get statusUpdates$() {
6915
7022
  return this.statusUpdates.asObservable();
6916
7023
  }
6917
- constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService) {
7024
+ constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService, userBehaviourAnalyticsService) {
6918
7025
  this.statusThreeDsService = statusThreeDsService;
6919
7026
  this.notifyDfpStatusService = notifyDfpStatusService;
6920
7027
  this.webSocketFactory = webSocketFactory;
6921
7028
  this.dfpCollectService = dfpCollectService;
6922
7029
  this.reinsuranceCheckService = reinsuranceCheckService;
7030
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6923
7031
  this.webSocketClient = null;
6924
7032
  this.statusUpdates = new Subject();
6925
7033
  this.statusRequestSubscription = null;
@@ -6972,6 +7080,7 @@ class ThreeDs20Service {
6972
7080
  }
6973
7081
  if (threeDsStatus.status === ThreeDsStatusTypes.completed) {
6974
7082
  this.stopReinsuranceMethods();
7083
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2complete, userBehaviourEventTypes.manual);
6975
7084
  this.statusUpdates.next({
6976
7085
  type: 'complete',
6977
7086
  data: {
@@ -6983,6 +7092,7 @@ class ThreeDs20Service {
6983
7092
  if (threeDsStatus.status === ThreeDsStatusTypes.challenge &&
6984
7093
  threeDsStatus.checkoutForm) {
6985
7094
  this.stopReinsuranceMethods();
7095
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2challenge, userBehaviourEventTypes.manual);
6986
7096
  this.statusUpdates.next({
6987
7097
  type: 'challenge',
6988
7098
  data: threeDsStatus.checkoutForm,
@@ -6990,6 +7100,7 @@ class ThreeDs20Service {
6990
7100
  }
6991
7101
  if (threeDsStatus.status === ThreeDsStatusTypes.collectDfp) {
6992
7102
  this.dfpCollectService.collectDfpStatus(threeDsForm);
7103
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2collectDfp, userBehaviourEventTypes.manual);
6993
7104
  }
6994
7105
  });
6995
7106
  }
@@ -6999,7 +7110,7 @@ class ThreeDs20Service {
6999
7110
  this.webSocketClient?.close();
7000
7111
  this.statusRequestSubscription?.unsubscribe();
7001
7112
  }
7002
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, deps: [{ token: StatusThreeDsService }, { token: NotifyDfpStatusService }, { token: WebSocketFactory }, { token: DfpCollectService }, { token: ReinsuranceCheckService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7113
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, deps: [{ token: StatusThreeDsService }, { token: NotifyDfpStatusService }, { token: WebSocketFactory }, { token: DfpCollectService }, { token: ReinsuranceCheckService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7003
7114
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, providedIn: 'root' }); }
7004
7115
  }
7005
7116
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, decorators: [{
@@ -7007,7 +7118,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7007
7118
  args: [{
7008
7119
  providedIn: 'root',
7009
7120
  }]
7010
- }], ctorParameters: () => [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }] });
7121
+ }], ctorParameters: () => [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }, { type: UserBehaviourAnalyticsService }] });
7011
7122
 
7012
7123
  class ThreeDsService {
7013
7124
  constructor(threeDs20Service, nextActionService, checkStatusActionCreator, threeDsActionCreator) {
@@ -7137,6 +7248,7 @@ const isInitializeResponse = (value) => {
7137
7248
  class ApplePayWithShippingAddressStrategy extends BehaviourStrategy {
7138
7249
  constructor() {
7139
7250
  super();
7251
+ this.name = 'ApplePayWithShippingAddressStrategy';
7140
7252
  }
7141
7253
  isSuitable() {
7142
7254
  if (isInitializeResponse(this.paymentData)) {
@@ -7176,6 +7288,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7176
7288
  class GooglePayInstantFlowStrategy extends BehaviourStrategy {
7177
7289
  constructor() {
7178
7290
  super();
7291
+ this.name = 'GooglePayInstantFlowStrategy';
7179
7292
  }
7180
7293
  isSuitable() {
7181
7294
  if (!isInitializeResponse(this.paymentData)) {
@@ -7211,6 +7324,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7211
7324
  class GooglePayRegularFlowStrategy extends BehaviourStrategy {
7212
7325
  constructor() {
7213
7326
  super();
7327
+ this.name = 'GooglePayRegularFlowStrategy';
7214
7328
  }
7215
7329
  isSuitable() {
7216
7330
  if (!isInitializeResponse(this.paymentData)) {
@@ -7246,22 +7360,30 @@ const behaviourStrategies = [
7246
7360
  ];
7247
7361
 
7248
7362
  class PaymentBehaviourService {
7249
- constructor(behaviourStrategyTokens, injector) {
7363
+ constructor(behaviourStrategyTokens, userBehaviourAnalyticsService, injector) {
7250
7364
  this.behaviourStrategyTokens = behaviourStrategyTokens;
7365
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7251
7366
  this.injector = injector;
7252
7367
  }
7253
7368
  getApplicableBehaviourStrategies(paymentData, config) {
7254
7369
  const strategies = this.getBehaviourStrategies();
7255
- return strategies.filter((behaviourStrategy) => {
7370
+ const applicableStrategies = strategies.filter((behaviourStrategy) => {
7256
7371
  behaviourStrategy.setPaymentData(paymentData);
7257
7372
  behaviourStrategy.setPaymentConfig(config);
7258
7373
  return behaviourStrategy.isSuitable();
7259
7374
  });
7375
+ this.logApplicableStrategies(applicableStrategies);
7376
+ return applicableStrategies;
7260
7377
  }
7261
7378
  getBehaviourStrategies() {
7262
7379
  return this.behaviourStrategyTokens.map((behaviourStrategyToken) => this.injector.get(behaviourStrategyToken));
7263
7380
  }
7264
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, deps: [{ token: behaviourStrategiesToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
7381
+ logApplicableStrategies(strategies) {
7382
+ if (!strategies.length)
7383
+ return;
7384
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applicablePaymentStrategies, 'manual', { value: strategies.map((strategy) => strategy.name) });
7385
+ }
7386
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, deps: [{ token: behaviourStrategiesToken }, { token: UserBehaviourAnalyticsService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
7265
7387
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService }); }
7266
7388
  }
7267
7389
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, decorators: [{
@@ -7269,7 +7391,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7269
7391
  }], ctorParameters: () => [{ type: undefined, decorators: [{
7270
7392
  type: Inject,
7271
7393
  args: [behaviourStrategiesToken]
7272
- }] }, { type: i0.Injector }] });
7394
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
7273
7395
 
7274
7396
  class PaymentService {
7275
7397
  get formFieldsStatus$() {
@@ -7284,7 +7406,7 @@ class PaymentService {
7284
7406
  get formResponseValue() {
7285
7407
  return this._formResponse$.getValue();
7286
7408
  }
7287
- constructor(loggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService, paymentBehaviourService, translateService) {
7409
+ constructor(loggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService, paymentBehaviourService, translateService, userBehaviourAnalyticsService) {
7288
7410
  this.loggerService = loggerService;
7289
7411
  this.initializeService = initializeService;
7290
7412
  this.submitService = submitService;
@@ -7304,11 +7426,13 @@ class PaymentService {
7304
7426
  this.printInstructionService = printInstructionService;
7305
7427
  this.paymentBehaviourService = paymentBehaviourService;
7306
7428
  this.translateService = translateService;
7429
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7307
7430
  this.form = null;
7308
7431
  this.data = null;
7309
7432
  this.financeDetails = null;
7310
7433
  this.focusFieldName = null;
7311
7434
  this.fields = [];
7435
+ this.isSubmitAttempted = false;
7312
7436
  this.destroy$ = new Subject();
7313
7437
  this.formDestroy$ = new Subject();
7314
7438
  this._paymentForm$ = new BehaviorSubject(null);
@@ -7319,6 +7443,7 @@ class PaymentService {
7319
7443
  async initialize(config) {
7320
7444
  this.destroy$ = new Subject();
7321
7445
  this.formDestroy$ = new Subject();
7446
+ this.isSubmitAttempted = false;
7322
7447
  this.listenFinanceDetails();
7323
7448
  this.config = config;
7324
7449
  this.data = await this.initializeService.request(config);
@@ -7351,10 +7476,13 @@ class PaymentService {
7351
7476
  throw new Error('form is empty!');
7352
7477
  }
7353
7478
  if (!this.form.valid) {
7479
+ this.logSubmitAttempt();
7480
+ this.isSubmitAttempted = true;
7354
7481
  this.form.markAllAsTouched();
7355
7482
  this.emitFormFieldsStatus(this.form);
7356
7483
  return;
7357
7484
  }
7485
+ this.logSubmit();
7358
7486
  this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
7359
7487
  const submitResponse = await this.submitService.request(this.fields, this.form, this.config);
7360
7488
  this.handleSubmitWithErrors(submitResponse);
@@ -7362,7 +7490,7 @@ class PaymentService {
7362
7490
  this.initializeBehaviourStrategies();
7363
7491
  this.emitFormResponse(this.data);
7364
7492
  if (!this.isSavingMethodMode) {
7365
- this.emitFinanceDetails(submitResponse.summary);
7493
+ this.emitFinanceDetails(submitResponse.summary, false);
7366
7494
  }
7367
7495
  this.emitFormMessages(submitResponse.messages);
7368
7496
  // Handle 3ds flow
@@ -7389,13 +7517,16 @@ class PaymentService {
7389
7517
  this.data = submitResponse;
7390
7518
  this.emitFormResponse(this.data);
7391
7519
  if (!this.isSavingMethodMode) {
7392
- this.emitFinanceDetails(submitResponse.summary);
7520
+ this.emitFinanceDetails(submitResponse.summary, false);
7393
7521
  }
7394
7522
  this.emitFormMessages(submitResponse.messages);
7395
7523
  this.fields = this.getFields();
7396
7524
  this.form = this.formService.createForm(this.fields);
7397
7525
  this.syncService.setup(this.form, this.fields, this.config);
7398
- return submitResponse;
7526
+ return {
7527
+ response: submitResponse,
7528
+ nextAction: this.nextActionService.getNextAction(submitResponse),
7529
+ };
7399
7530
  }
7400
7531
  setupInitialFieldValues() {
7401
7532
  const fieldsToOverride = this.config.overrideFormFields;
@@ -7437,6 +7568,9 @@ class PaymentService {
7437
7568
  throw new Error('Should submit form first');
7438
7569
  }
7439
7570
  const sdkPaymentData = this.getSdkPaymentDataFromResponse(this.data);
7571
+ const shouldHandleUserBackRedirectOnSdkSide = isGooglePaySettingsGuard(this.config)
7572
+ ? !!this.config.paymentMethodSettings?.useSdkHandlerForUserBackRedirect
7573
+ : false;
7440
7574
  return Promise.resolve({
7441
7575
  data: sdkPaymentData.checkoutData,
7442
7576
  sandbox: this.settingsService.isSandboxMode()
@@ -7447,6 +7581,7 @@ class PaymentService {
7447
7581
  submitResponse: isSubmitResponse(this.data) ? this.data : null,
7448
7582
  summary: sdkPaymentData.summary,
7449
7583
  locale: this.translateService.getCurrentLang(),
7584
+ shouldHandleUserBackRedirectOnSdkSide,
7450
7585
  });
7451
7586
  }
7452
7587
  getQrCode() {
@@ -7553,8 +7688,8 @@ class PaymentService {
7553
7688
  }
7554
7689
  externalChangeFieldValue(name, value) {
7555
7690
  const isFieldAllowedForExternalChange = fieldsAllowedToExternalChange.has(name);
7556
- const isExternalVault = this.config.paymentMethodSettings?.useExternalVault &&
7557
- this.config.paymentMethodId === creditCardPaymentMethodId;
7691
+ const isExternalVault = isCreditCardSettingsGuard(this.config) &&
7692
+ this.config.paymentMethodSettings?.useExternalVault;
7558
7693
  if (!isFieldAllowedForExternalChange || !isExternalVault)
7559
7694
  return;
7560
7695
  const formControl = this.form?.get(name);
@@ -7613,8 +7748,8 @@ class PaymentService {
7613
7748
  this.destroy$.next();
7614
7749
  this.threeDsService.stopChecking();
7615
7750
  }
7616
- emitFinanceDetails(summary) {
7617
- this.financeDetailsService.emitWithSummary(summary);
7751
+ emitFinanceDetails(summary, needLogCart = true) {
7752
+ this.financeDetailsService.emitWithSummary(summary, needLogCart);
7618
7753
  }
7619
7754
  emitCreditCardState({ idCardType, cardBinCountry, }) {
7620
7755
  this.creditCardStateService.emit({ idCardType, cardBinCountry });
@@ -7760,7 +7895,20 @@ class PaymentService {
7760
7895
  }, new Map());
7761
7896
  updateAfterErrorRules.forEach((rule) => rule.apply(submitResponse, fieldsMap));
7762
7897
  }
7763
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, deps: [{ token: LoggerService }, { token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: InitializeNextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }, { token: CheckStatusActionCreator }, { token: PrintInstructionService }, { token: PaymentBehaviourService }, { token: i19.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7898
+ logSubmitAttempt() {
7899
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.attemptBuyNow, userBehaviourEventTypes.click);
7900
+ }
7901
+ logSubmit() {
7902
+ if (this.isSubmitAttempted) {
7903
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.attemptContinue, userBehaviourEventTypes.click, {
7904
+ eventCategory: eventCategories.withInvoice,
7905
+ });
7906
+ }
7907
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.clickBtnPay, userBehaviourEventTypes.click, {
7908
+ eventCategory: eventCategories.withInvoice,
7909
+ });
7910
+ }
7911
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, deps: [{ token: LoggerService }, { token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: InitializeNextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }, { token: CheckStatusActionCreator }, { token: PrintInstructionService }, { token: PaymentBehaviourService }, { token: i19.TranslateService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7764
7912
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, providedIn: 'root' }); }
7765
7913
  }
7766
7914
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, decorators: [{
@@ -7768,7 +7916,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7768
7916
  args: [{
7769
7917
  providedIn: 'root',
7770
7918
  }]
7771
- }], ctorParameters: () => [{ type: LoggerService }, { type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: InitializeNextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }, { type: PrintInstructionService }, { type: PaymentBehaviourService }, { type: i19.TranslateService }] });
7919
+ }], ctorParameters: () => [{ type: LoggerService }, { type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: InitializeNextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }, { type: PrintInstructionService }, { type: PaymentBehaviourService }, { type: i19.TranslateService }, { type: UserBehaviourAnalyticsService }] });
7772
7920
 
7773
7921
  const euCountries = new Set([
7774
7922
  'AT',
@@ -8800,7 +8948,8 @@ class ApplePayCartService {
8800
8948
  get cartRecalculationRequest$() {
8801
8949
  return this.cartRecalculationRequest.asObservable();
8802
8950
  }
8803
- constructor(summaryFinanceDetailsAdapterService) {
8951
+ constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
8952
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8804
8953
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
8805
8954
  this.cartSuccessfulRecalculated = new Subject();
8806
8955
  this.cartErrorRecalculated = new Subject();
@@ -8818,6 +8967,10 @@ class ApplePayCartService {
8818
8967
  zip: parsedZip,
8819
8968
  country,
8820
8969
  });
8970
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
8971
+ dimension1: country,
8972
+ dimension2: parsedZip || '',
8973
+ });
8821
8974
  }
8822
8975
  buildShippingContactUpdate(paymentParams, updatedPrice) {
8823
8976
  return {
@@ -8841,6 +8994,7 @@ class ApplePayCartService {
8841
8994
  this.cartSuccessfulRecalculated.next(updatedPrice);
8842
8995
  }
8843
8996
  sendErrorRecalculatedCart(error) {
8997
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
8844
8998
  this.cartErrorRecalculated.next(error);
8845
8999
  }
8846
9000
  isZipCountry(country) {
@@ -8875,7 +9029,7 @@ class ApplePayCartService {
8875
9029
  getTotalAmount(finance) {
8876
9030
  return finance?.grand_total?.amount ?? finance?.total?.amount;
8877
9031
  }
8878
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9032
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token: UserBehaviourAnalyticsService }, { token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8879
9033
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
8880
9034
  }
8881
9035
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -8883,14 +9037,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8883
9037
  args: [{
8884
9038
  providedIn: 'root',
8885
9039
  }]
8886
- }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9040
+ }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
8887
9041
 
8888
9042
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8889
- constructor(window, loggerService, applePayCartService) {
9043
+ constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
8890
9044
  super();
8891
9045
  this.window = window;
8892
9046
  this.loggerService = loggerService;
8893
9047
  this.applePayCartService = applePayCartService;
9048
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8894
9049
  this.paymentClient = null;
8895
9050
  }
8896
9051
  setClient(client) {
@@ -8908,14 +9063,18 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8908
9063
  const applePayRequest = this.paymentClient.createPaymentRequest(request);
8909
9064
  const session = new this.window.ApplePaySession(applePayVersion, applePayRequest);
8910
9065
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9066
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
8911
9067
  session.onshippingcontactselected = (event) => {
9068
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
8912
9069
  this.applePayCartService.cartSuccessfulRecalculated$
8913
9070
  .pipe(take(1))
8914
9071
  .subscribe((updatedPrice) => {
8915
9072
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9073
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
8916
9074
  session.completeShippingContactSelection(contactUpdate);
8917
9075
  });
8918
9076
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9077
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
8919
9078
  session.completeShippingContactSelection({
8920
9079
  errors: [error],
8921
9080
  newTotal: {
@@ -8928,6 +9087,10 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8928
9087
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
8929
9088
  };
8930
9089
  session.onvalidatemerchant = (event) => {
9090
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9091
+ value: event.validationURL,
9092
+ extraValue: params.totalLabel,
9093
+ });
8931
9094
  const validationParams = {
8932
9095
  validationURL: event.validationURL,
8933
9096
  displayName: params.totalLabel,
@@ -8942,12 +9105,14 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8942
9105
  session.completeMerchantValidation(merchantSession);
8943
9106
  })
8944
9107
  .catch((error) => {
9108
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
8945
9109
  console.error(ApplePayErrors.merchantValidationError, error);
8946
9110
  session.abort();
8947
9111
  applePayFinallyCallback();
8948
9112
  });
8949
9113
  };
8950
9114
  session.onpaymentauthorized = (event) => {
9115
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
8951
9116
  this.paymentClient
8952
9117
  ?.tokenize({ token: event.payment.token })
8953
9118
  .then((response) => {
@@ -8960,19 +9125,21 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8960
9125
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
8961
9126
  })
8962
9127
  .catch((error) => {
9128
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
8963
9129
  console.error('Apple Pay: Tokenization error', error);
8964
9130
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
8965
9131
  applePayFinallyCallback();
8966
9132
  });
8967
9133
  };
8968
9134
  session.oncancel = (event) => {
9135
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
8969
9136
  console.error(ApplePayErrors.cancelled, event);
8970
9137
  this.emitError(ApplePayErrors.cancelled);
8971
9138
  applePayFinallyCallback();
8972
9139
  };
8973
9140
  session.begin();
8974
9141
  }
8975
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9142
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8976
9143
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler }); }
8977
9144
  }
8978
9145
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -8980,26 +9147,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8980
9147
  }], ctorParameters: () => [{ type: undefined, decorators: [{
8981
9148
  type: Inject,
8982
9149
  args: [windowToken]
8983
- }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9150
+ }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
8984
9151
 
8985
9152
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8986
- constructor(window, http, applePayCartService) {
9153
+ constructor(window, http, applePayCartService, userBehaviourAnalyticsService) {
8987
9154
  super();
8988
9155
  this.window = window;
8989
9156
  this.http = http;
8990
9157
  this.applePayCartService = applePayCartService;
9158
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8991
9159
  }
8992
9160
  startSession(params, additionalParams, applePayFinallyCallback) {
8993
9161
  const request = this.buildPaymentRequest(params);
8994
9162
  const session = new this.window.ApplePaySession(applePayVersion, request);
8995
9163
  session.onshippingcontactselected = (event) => {
9164
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
8996
9165
  this.applePayCartService.cartSuccessfulRecalculated$
8997
9166
  .pipe(take(1))
8998
9167
  .subscribe((updatedPrice) => {
8999
9168
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9169
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
9000
9170
  session.completeShippingContactSelection(contactUpdate);
9001
9171
  });
9002
9172
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9173
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
9003
9174
  session.completeShippingContactSelection({
9004
9175
  errors: [error],
9005
9176
  newTotal: {
@@ -9012,6 +9183,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9012
9183
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9013
9184
  };
9014
9185
  session.onvalidatemerchant = (event) => {
9186
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9187
+ value: event.validationURL,
9188
+ extraValue: params.totalLabel,
9189
+ });
9015
9190
  const validationParams = {
9016
9191
  validationURL: event.validationURL,
9017
9192
  accountId: params.payInstanceAccountId,
@@ -9031,6 +9206,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9031
9206
  session.completeMerchantValidation(response.merchantSession);
9032
9207
  },
9033
9208
  error: (error) => {
9209
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9034
9210
  console.error(ApplePayErrors.merchantValidationError, error);
9035
9211
  session.abort();
9036
9212
  applePayFinallyCallback();
@@ -9038,6 +9214,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9038
9214
  });
9039
9215
  };
9040
9216
  session.onpaymentauthorized = (event) => {
9217
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9041
9218
  this.payment.next(JSON.stringify({
9042
9219
  token: event.payment.token ?? '',
9043
9220
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9047,13 +9224,14 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9047
9224
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9048
9225
  };
9049
9226
  session.oncancel = (event) => {
9227
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9050
9228
  console.error(ApplePayErrors.cancelled, event);
9051
9229
  this.emitError(ApplePayErrors.cancelled);
9052
9230
  applePayFinallyCallback();
9053
9231
  };
9054
9232
  session.begin();
9055
9233
  }
9056
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9234
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9057
9235
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler }); }
9058
9236
  }
9059
9237
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9061,7 +9239,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9061
9239
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9062
9240
  type: Inject,
9063
9241
  args: [windowToken]
9064
- }] }, { type: i1.HttpClient }, { type: ApplePayCartService }] });
9242
+ }] }, { type: i1.HttpClient }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9065
9243
 
9066
9244
  class PaymentBehaviourModule {
9067
9245
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -9287,8 +9465,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9287
9465
  }] }] });
9288
9466
 
9289
9467
  class GooglePayCheckoutPaymentService {
9290
- constructor(paymentSystemProcessingService) {
9468
+ constructor(paymentSystemProcessingService, userBehaviourAnalyticsService) {
9291
9469
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9470
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9292
9471
  this.checkout = null;
9293
9472
  }
9294
9473
  preparePayment({ initParams, checkDeviceData, }) {
@@ -9328,6 +9507,7 @@ class GooglePayCheckoutPaymentService {
9328
9507
  return paymentDataRequest.allowedPaymentMethods;
9329
9508
  }
9330
9509
  handleSuccessfulPayment(response) {
9510
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleSuccessfulPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '' });
9331
9511
  if (!this.checkout)
9332
9512
  return;
9333
9513
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -9336,6 +9516,7 @@ class GooglePayCheckoutPaymentService {
9336
9516
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
9337
9517
  }
9338
9518
  handleFailedPayment(error) {
9519
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleFailedPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '' });
9339
9520
  if (!this.checkout)
9340
9521
  return;
9341
9522
  const statusCode = error?.statusCode;
@@ -9348,7 +9529,7 @@ class GooglePayCheckoutPaymentService {
9348
9529
  isCancelledStatus(statusCode) {
9349
9530
  return statusCode.toLowerCase() === 'canceled';
9350
9531
  }
9351
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9532
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9352
9533
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
9353
9534
  }
9354
9535
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -9356,7 +9537,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9356
9537
  args: [{
9357
9538
  providedIn: 'root',
9358
9539
  }]
9359
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }] });
9540
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }] });
9360
9541
 
9361
9542
  class GooglePayInstantPaymentService {
9362
9543
  constructor(summaryFinanceDetailsAdapterService) {
@@ -9949,10 +10130,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9949
10130
  }], ctorParameters: () => [{ type: SecureApiClient }] });
9950
10131
 
9951
10132
  class ApplePayExternalWindowCommunicationService {
9952
- constructor(window, webSocketFactory, socketBridgeService) {
10133
+ constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
9953
10134
  this.window = window;
9954
10135
  this.webSocketFactory = webSocketFactory;
9955
10136
  this.socketBridgeService = socketBridgeService;
10137
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9956
10138
  }
9957
10139
  getWindowClose$() {
9958
10140
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -9977,6 +10159,7 @@ class ApplePayExternalWindowCommunicationService {
9977
10159
  return this.getEventSource(isRecalculateCartMessage);
9978
10160
  }
9979
10161
  async openWebSocketConnection(token) {
10162
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
9980
10163
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
9981
10164
  if (this.websocketClient) {
9982
10165
  this.websocketClient.close();
@@ -9985,6 +10168,7 @@ class ApplePayExternalWindowCommunicationService {
9985
10168
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
9986
10169
  }
9987
10170
  async sendMessageToAnotherWindow(command, payload) {
10171
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
9988
10172
  await this.socketBridgeService.publishMessage(command, payload);
9989
10173
  }
9990
10174
  getEventSource(eventHandler) {
@@ -9993,7 +10177,7 @@ class ApplePayExternalWindowCommunicationService {
9993
10177
  return JSON.parse(message);
9994
10178
  }), filter(eventHandler));
9995
10179
  }
9996
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10180
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9997
10181
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
9998
10182
  }
9999
10183
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -10004,7 +10188,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
10004
10188
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10005
10189
  type: Inject,
10006
10190
  args: [windowToken]
10007
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10191
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10008
10192
 
10009
10193
  class ApplePayService {
10010
10194
  get paymentParameters() {
@@ -10047,7 +10231,7 @@ class ApplePayService {
10047
10231
  .getWindowReturnMessage$()
10048
10232
  .pipe(takeUntil(this.destroy$));
10049
10233
  }
10050
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10234
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10051
10235
  this.window = window;
10052
10236
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10053
10237
  this.braintreeHandler = braintreeHandler;
@@ -10056,6 +10240,7 @@ class ApplePayService {
10056
10240
  this.loggerService = loggerService;
10057
10241
  this.applePaySdkService = applePaySdkService;
10058
10242
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10243
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10059
10244
  this.settingsService = settingsService;
10060
10245
  this.payment = new Subject();
10061
10246
  this.error = new Subject();
@@ -10183,6 +10368,7 @@ class ApplePayService {
10183
10368
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
10184
10369
  }
10185
10370
  proceedCheckout(parameters, additionalParams) {
10371
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayAcquirer, 'manual', { value: parameters.acquirer });
10186
10372
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
10187
10373
  if (!sessionHandler) {
10188
10374
  console.error('Apple Pay: Unsupported acquirer:', parameters.acquirer);
@@ -10240,7 +10426,7 @@ class ApplePayService {
10240
10426
  this.applePayQrOpened.next();
10241
10427
  }
10242
10428
  }
10243
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: LoggerService }, { token: ApplePaySdkService }, { token: ApplePayExternalWindowCommunicationService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10429
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: LoggerService }, { token: ApplePaySdkService }, { token: ApplePayExternalWindowCommunicationService }, { token: UserBehaviourAnalyticsService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10244
10430
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
10245
10431
  }
10246
10432
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
@@ -10251,7 +10437,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
10251
10437
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10252
10438
  type: Inject,
10253
10439
  args: [windowToken]
10254
- }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
10440
+ }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: UserBehaviourAnalyticsService }, { type: SettingsService }] });
10255
10441
 
10256
10442
  /*
10257
10443
  * Public API Surface of core-library