@xsolla/payment-client-core 0.2.89 → 0.2.91

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 (51) hide show
  1. package/esm2022/lib/core/payment/actions/next-action.service.mjs +23 -9
  2. package/esm2022/lib/core/payment/external-change-fields.const.mjs +2 -1
  3. package/esm2022/lib/core/payment/field-names.enum.mjs +2 -1
  4. package/esm2022/lib/core/payment/finance-details/finance-details.service.mjs +17 -5
  5. package/esm2022/lib/core/payment/form/form.service.mjs +13 -5
  6. package/esm2022/lib/core/payment/initialize-actions/initialize-next-action.service.mjs +11 -4
  7. package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.service.mjs +15 -5
  8. package/esm2022/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.mjs +2 -1
  9. package/esm2022/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.mjs +1 -1
  10. package/esm2022/lib/core/payment/payment-behaviour/strategies/google-pay-instant-flow/google-pay-instant-flow.strategy.mjs +2 -1
  11. package/esm2022/lib/core/payment/payment-behaviour/strategies/google-pay-regular-flow/google-pay-regular-flow.strategy.mjs +2 -1
  12. package/esm2022/lib/core/payment/payment.service.mjs +31 -8
  13. package/esm2022/lib/core/payment/requests/initialize/initialize.service.mjs +2 -1
  14. package/esm2022/lib/core/payment/requests/submit/submit.service.mjs +2 -1
  15. package/esm2022/lib/core/payment/requests/sync/sync.service.mjs +2 -1
  16. package/esm2022/lib/core/payment/status/listen-status/listen-status.service.mjs +5 -2
  17. package/esm2022/lib/core/payment/three-ds/three-ds-20/three-ds20.service.mjs +11 -4
  18. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +13 -5
  19. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +9 -5
  20. package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +9 -4
  21. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +19 -4
  22. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +17 -4
  23. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +9 -4
  24. package/esm2022/lib/core/user-behaviour-analytics/one-time-analytics-events.const.mjs +2 -5
  25. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.mjs +42 -3
  26. package/esm2022/lib/core-library.service.mjs +4 -1
  27. package/fesm2022/xsolla-payment-client-core.mjs +682 -530
  28. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  29. package/lib/core/payment/actions/next-action.service.d.ts +7 -2
  30. package/lib/core/payment/field-names.enum.d.ts +2 -1
  31. package/lib/core/payment/finance-details/finance-details.service.d.ts +5 -2
  32. package/lib/core/payment/form/form.service.d.ts +5 -2
  33. package/lib/core/payment/initialize-actions/initialize-next-action.service.d.ts +4 -1
  34. package/lib/core/payment/payment-behaviour/payment-behaviour.service.d.ts +4 -1
  35. package/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.d.ts +1 -0
  36. package/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.d.ts +1 -0
  37. package/lib/core/payment/payment-behaviour/strategies/google-pay-instant-flow/google-pay-instant-flow.strategy.d.ts +1 -0
  38. package/lib/core/payment/payment-behaviour/strategies/google-pay-regular-flow/google-pay-regular-flow.strategy.d.ts +1 -0
  39. package/lib/core/payment/payment.service.d.ts +6 -1
  40. package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +3 -1
  41. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +3 -1
  42. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +3 -1
  43. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +3 -1
  44. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +3 -1
  45. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +3 -1
  46. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +3 -1
  47. package/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.d.ts +40 -3
  48. package/lib/core-library.service.d.ts +2 -0
  49. package/package.json +1 -1
  50. package/xsolla-payment-client-core-0.2.91.tgz +0 -0
  51. package/xsolla-payment-client-core-0.2.89.tgz +0 -0
@@ -1354,6 +1354,7 @@ var FieldNames;
1354
1354
  FieldNames["googlePayInitData"] = "googlePayInitData";
1355
1355
  FieldNames["googlePayPaymentData"] = "googlePayPaymentData";
1356
1356
  FieldNames["externalCardIssuerCountry"] = "externalCardIssuerCountry";
1357
+ FieldNames["pmId"] = "pm_id";
1357
1358
  })(FieldNames || (FieldNames = {}));
1358
1359
 
1359
1360
  class SubmitResponse {
@@ -1444,6 +1445,68 @@ class InitializeResponse {
1444
1445
  }
1445
1446
  }
1446
1447
 
1448
+ var UserBehaviourEventName;
1449
+ (function (UserBehaviourEventName) {
1450
+ UserBehaviourEventName["openPaystation"] = "open-paystation";
1451
+ UserBehaviourEventName["showErrorMessage"] = "show-error-message";
1452
+ UserBehaviourEventName["openStatusError"] = "open-status-error";
1453
+ UserBehaviourEventName["changeStatus"] = "change-status";
1454
+ UserBehaviourEventName["checkStatusUpdate"] = "check-status-update";
1455
+ UserBehaviourEventName["sysTrackedScripts"] = "sys-tracked_scripts";
1456
+ UserBehaviourEventName["showShoppingCart"] = "show-shopping_cart";
1457
+ UserBehaviourEventName["attemptBuyNow"] = "attempt-buy_now";
1458
+ UserBehaviourEventName["attemptContinue"] = "attempt-continue";
1459
+ UserBehaviourEventName["clickBtnPay"] = "click-btn-pay";
1460
+ UserBehaviourEventName["initializeNextAction"] = "initialize-next-action";
1461
+ UserBehaviourEventName["nextAction"] = "next-action";
1462
+ UserBehaviourEventName["createForm"] = "create-form";
1463
+ UserBehaviourEventName["applicablePaymentStrategies"] = "applicable-payment-strategies";
1464
+ UserBehaviourEventName["initializeRequest"] = "initialize-request";
1465
+ UserBehaviourEventName["submitRequest"] = "submit-request";
1466
+ UserBehaviourEventName["syncRequest"] = "sync-request";
1467
+ UserBehaviourEventName["threeDs2complete"] = "3DS-2.0-complete";
1468
+ UserBehaviourEventName["threeDs2challenge"] = "3DS-2.0-challenge";
1469
+ UserBehaviourEventName["threeDs2collectDfp"] = "3DS-2.0-collect-dfp";
1470
+ // Apple Pay
1471
+ UserBehaviourEventName["applePayRecalculateCartTaxes"] = "apple-pay-recalculate-cart-taxes";
1472
+ UserBehaviourEventName["applePayRecalculateCartError"] = "apple-pay-recalculate-cart-error";
1473
+ UserBehaviourEventName["applePayOpenWebSocketConnection"] = "apple-pay-open-web-socket-connection";
1474
+ UserBehaviourEventName["applePaySendMessageToAnotherWindow"] = "apple-pay-send-message-to-another-window";
1475
+ UserBehaviourEventName["applePayBraintreeStartSession"] = "apple-pay-braintree-start-session";
1476
+ UserBehaviourEventName["applePayBraintreeSelectShipping"] = "apple-pay-braintree-select-shipping";
1477
+ UserBehaviourEventName["applePayBraintreeCartSuccessfulRecalculated"] = "apple-pay-braintree-cart-successful-recalculated";
1478
+ UserBehaviourEventName["applePayBraintreeCartErrorRecalculated"] = "apple-pay-braintree-cart-error-recalculated";
1479
+ UserBehaviourEventName["applePayBraintreeValidateMerchant"] = "apple-pay-braintree-validate-merchant";
1480
+ UserBehaviourEventName["applePayBraintreeValidateMerchantError"] = "apple-pay-braintree-validate-merchant-error";
1481
+ UserBehaviourEventName["applePayBraintreePaymentAuthorized"] = "apple-pay-braintree-payment-authorized";
1482
+ UserBehaviourEventName["applePayBraintreePaymentTokenizationError"] = "apple-pay-braintree-payment-tokenization-error";
1483
+ UserBehaviourEventName["applePayBraintreePaymentCancel"] = "apple-pay-braintree-payment-cancel";
1484
+ UserBehaviourEventName["applePayCheckoutSelectShipping"] = "apple-pay-checkout-select-shipping";
1485
+ UserBehaviourEventName["applePayCheckoutCartSuccessfulRecalculated"] = "apple-pay-checkout-cart-successful-recalculated";
1486
+ UserBehaviourEventName["applePayCheckoutCartErrorRecalculated"] = "apple-pay-checkout-cart-error-recalculated";
1487
+ UserBehaviourEventName["applePayCheckoutValidateMerchant"] = "apple-pay-checkout-validate-merchant";
1488
+ UserBehaviourEventName["applePayCheckoutValidateMerchantError"] = "apple-pay-checkout-validate-merchant-error";
1489
+ UserBehaviourEventName["applePayCheckoutPaymentAuthorized"] = "apple-pay-checkout-payment-authorized";
1490
+ UserBehaviourEventName["applePayCheckoutPaymentCancel"] = "apple-pay-checkout-payment-cancel";
1491
+ UserBehaviourEventName["applePayAcquirer"] = "apple-pay-acquirer";
1492
+ // Google Pay
1493
+ UserBehaviourEventName["googlePayHandleFailedPayment"] = "google-pay-handle-failed-payment";
1494
+ UserBehaviourEventName["googlePayHandleSuccessfulPayment"] = "google-pay-handle-successful-payment";
1495
+ })(UserBehaviourEventName || (UserBehaviourEventName = {}));
1496
+
1497
+ const userBehaviourEventTypes = {
1498
+ open: 'open',
1499
+ show: 'show',
1500
+ click: 'click',
1501
+ manual: 'manual',
1502
+ store: 'store',
1503
+ };
1504
+
1505
+ const eventCategories = {
1506
+ withoutInvoice: 'withoutInvoice',
1507
+ withInvoice: 'withInvoice',
1508
+ };
1509
+
1447
1510
  const isSubmitResponse = (value) => {
1448
1511
  return value instanceof SubmitResponse;
1449
1512
  };
@@ -1526,6 +1589,7 @@ const updateAfterErrorRules = [
1526
1589
  const fieldsAllowedToExternalChange = new Set([
1527
1590
  FieldNames.email,
1528
1591
  FieldNames.externalCardIssuerCountry,
1592
+ FieldNames.pmId,
1529
1593
  ]);
1530
1594
 
1531
1595
  const masterCardAndVisaPaymentMethodId = 26;
@@ -1550,24 +1614,6 @@ const initializeResponseFactoryProvider = {
1550
1614
  useValue: (...args) => new InitializeResponse(...args),
1551
1615
  };
1552
1616
 
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
1617
  class XpsApiService {
1572
1618
  constructor(window, secureApiClient, settingsService, countryService, userAgentService) {
1573
1619
  this.window = window;
@@ -2139,114 +2185,424 @@ const flowUpdateNextActions = [
2139
2185
  ThreeDsActionCreator,
2140
2186
  ];
2141
2187
 
2142
- class NextActionService {
2143
- get flowUpdates$() {
2144
- return this.flowUpdatesSubject.asObservable();
2188
+ const oneTimeAnalyticsEvents = new Set([]);
2189
+
2190
+ var EventParameterType;
2191
+ (function (EventParameterType) {
2192
+ EventParameterType["string"] = "0";
2193
+ EventParameterType["int"] = "1";
2194
+ EventParameterType["float"] = "2";
2195
+ EventParameterType["bool"] = "3";
2196
+ EventParameterType["intArray"] = "4";
2197
+ EventParameterType["stringArray"] = "5";
2198
+ })(EventParameterType || (EventParameterType = {}));
2199
+
2200
+ class EventBuilderService {
2201
+ constructor(settingsService, userAgentService, window) {
2202
+ this.settingsService = settingsService;
2203
+ this.userAgentService = userAgentService;
2204
+ this.window = window;
2145
2205
  }
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();
2206
+ createEvent(options, userSessionOptions) {
2207
+ return {
2208
+ action: options.action,
2209
+ type: options.type,
2210
+ value: this.convertToEventParameterType(options.value, options.valueType ?? EventParameterType.string),
2211
+ state: options.state,
2212
+ date: this.getDate(options.date),
2213
+ milliseconds: options.date.getTime(),
2214
+ timezone: this.getTimezone(options.date),
2215
+ session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2216
+ referrer_url: this.window?.document?.referrer,
2217
+ project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2218
+ payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2219
+ this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2220
+ geotype_id: this.convertToEventParameterType(options.invoice?.geotype_id, EventParameterType.int),
2221
+ instance_id: this.convertToEventParameterType(options.instanceId ??
2222
+ this.getPaymentMethodId(userSessionOptions.instanceId), EventParameterType.int),
2223
+ payment_method_contr_id: this.convertToEventParameterType(options.invoice?.payment_method_contr_id, EventParameterType.int),
2224
+ ps_type: this.convertToEventParameterType(options.invoice?.ps_type, EventParameterType.int),
2225
+ is_pay_with_saved_method: this.convertToEventParameterType(userSessionOptions.isPayWithSavedMethod, EventParameterType.bool),
2226
+ purchase_invoice_id: this.convertToEventParameterType(options.invoice?.purchase_invoice_id, EventParameterType.int),
2227
+ purchase_external_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.purchase_external_id, EventParameterType.string),
2228
+ purchase_type: this.settingsService.unsafeUtilsResponse?.purchase
2229
+ ?.purchase_type,
2230
+ purchase_sum: this.convertToEventParameterType(options.invoice?.purchase_sum, EventParameterType.float),
2231
+ purchase_currency: this.convertToEventParameterType(options.invoice?.purchase_currency, EventParameterType.string),
2232
+ purchase_sku: this.convertToEventParameterType(options.invoice?.purchase_sku, EventParameterType.string),
2233
+ purchase_digital_content_sku: null,
2234
+ purchase_description: this.convertToEventParameterType(options.invoice?.purchase_description, EventParameterType.string),
2235
+ virtual_currency_amount: null, // TODO: add value
2236
+ digital_content_cart_id: this.convertToEventParameterType(options.invoice?.digital_content_cart_id, EventParameterType.int),
2237
+ digital_good_cart_id: this.convertToEventParameterType(options.invoice?.digital_good_cart_id, EventParameterType.int),
2238
+ coupon_code: this.convertToEventParameterType(userSessionOptions.couponCode, EventParameterType.string),
2239
+ theme_version: this.userAgentService.isMobileDevice
2240
+ ? Device.mobile
2241
+ : Device.desktop,
2242
+ subscription_package_id: this.convertToEventParameterType(userSessionOptions.subscriptionPackageId, EventParameterType.int),
2243
+ subscription_product_id: this.convertToEventParameterType(userSessionOptions.subscriptionProductId, EventParameterType.int),
2244
+ subscription_recurrent_id: this.convertToEventParameterType(userSessionOptions.subscriptionRecurrentId, EventParameterType.int),
2245
+ user_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.id, EventParameterType.string),
2246
+ user_access_token: this.settingsService.token,
2247
+ user_name: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.v2, EventParameterType.string),
2248
+ user_email: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.email?.value, EventParameterType.string),
2249
+ user_country: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2250
+ user_ip: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.ip, EventParameterType.string),
2251
+ user_mobile_operator_name: this.convertToEventParameterType(userSessionOptions.userMobileOperatorName, EventParameterType.string),
2252
+ user_operation_system: this.userAgentService.platform,
2253
+ user_browser: this.userAgentService.browserDescription,
2254
+ user_browser_version: this.userAgentService.browserVersion,
2255
+ user_locale: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.local, EventParameterType.string),
2256
+ user_utm: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.utm_parameters, EventParameterType.string),
2257
+ xsolla_product_tag: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.xsolla_product_tag, EventParameterType.string),
2258
+ experiment_id: null,
2259
+ is_test_session: +isDevMode(),
2260
+ babka_value: null,
2261
+ extra_value: this.convertToEventParameterType(options?.extraValue, EventParameterType.string),
2262
+ is_subscription: this.convertToEventParameterType(this.isSubscription(), EventParameterType.bool),
2263
+ is_iframe: this.convertToEventParameterType(this.window.parent !== this.window, EventParameterType.bool),
2264
+ web3wallet: null, // TODO: add value
2265
+ dimension_1: this.convertToEventParameterType(options?.dimension1, EventParameterType.string),
2266
+ dimension_2: this.convertToEventParameterType(options?.dimension2, EventParameterType.string),
2267
+ dimension_3: this.convertToEventParameterType(options?.dimension3, EventParameterType.string),
2268
+ dimension_4: this.convertToEventParameterType(options?.dimension4, EventParameterType.string),
2269
+ dimension_5: this.convertToEventParameterType(options?.dimension5, EventParameterType.string),
2270
+ client_version: 'Headless Checkout',
2271
+ };
2153
2272
  }
2154
- getNextAction(submitResponse) {
2155
- if (submitResponse.errors?.length) {
2156
- this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(submitResponse.errors));
2273
+ getDate(date) {
2274
+ const nullIndex = 0;
2275
+ return date.toISOString().replace('T', ' ').replace('Z', '').split('.')[nullIndex];
2276
+ }
2277
+ getTimezone(date) {
2278
+ const hour = 60;
2279
+ const nullHour = 0;
2280
+ const hourOffset = -date.getTimezoneOffset() / hour;
2281
+ if (hourOffset === nullHour) {
2282
+ return '0';
2157
2283
  }
2158
- if (!submitResponse.currentCommand) {
2284
+ return hourOffset > nullHour ? `+${hourOffset}` : hourOffset.toString();
2285
+ }
2286
+ convertToEventParameterType(value, type
2287
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2288
+ ) {
2289
+ if (value === null || value === undefined) {
2159
2290
  return null;
2160
2291
  }
2161
- const nextAction = this.findNextAction(submitResponse);
2162
- if (nextAction) {
2163
- return nextAction.getActionData(submitResponse);
2292
+ if (typeof value === 'boolean') {
2293
+ value = value ? 1 : 0;
2294
+ }
2295
+ switch (type) {
2296
+ case EventParameterType.string:
2297
+ return String(value);
2298
+ case EventParameterType.int:
2299
+ value = parseInt(String(value), 10);
2300
+ return isNaN(value) ? 0 : value;
2301
+ case EventParameterType.stringArray:
2302
+ case EventParameterType.intArray:
2303
+ return Array.isArray(value) ? value : [];
2304
+ case EventParameterType.float:
2305
+ value = parseFloat(String(value));
2306
+ return isNaN(value) ? 0 : value;
2307
+ case EventParameterType.bool:
2308
+ return value ? 1 : 0;
2164
2309
  }
2165
- throw new Error('Next action is undefined.');
2166
2310
  }
2167
- emitFlowUpdates(action) {
2168
- this.flowUpdatesSubject.next(action);
2311
+ convertValueForPostMessage(value) {
2312
+ if (value === null || value === undefined) {
2313
+ return null;
2314
+ }
2315
+ return String(value);
2169
2316
  }
2170
- fillNextActionsList() {
2171
- this.nextActionTokens.forEach((nextAction) => {
2172
- const item = this.injector.get(nextAction);
2173
- this.nextActionsList.push(item);
2174
- });
2317
+ isSubscription() {
2318
+ return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2319
+ 'subscription');
2175
2320
  }
2176
- findNextAction(submitResponse) {
2177
- const actionType = this.nextActionsList.find((nextAction) => {
2178
- return nextAction.isSuitable(submitResponse);
2179
- });
2180
- if (!actionType) {
2181
- return;
2182
- }
2183
- return actionType;
2321
+ getPaymentMethodId(instanceId) {
2322
+ return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2323
+ instanceId);
2184
2324
  }
2185
- 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 }); }
2186
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, providedIn: 'root' }); }
2325
+ 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 }); }
2326
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, providedIn: 'root' }); }
2187
2327
  }
2188
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, decorators: [{
2328
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, decorators: [{
2189
2329
  type: Injectable,
2190
2330
  args: [{
2191
2331
  providedIn: 'root',
2192
2332
  }]
2193
- }], ctorParameters: () => [{ type: undefined, decorators: [{
2333
+ }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2194
2334
  type: Inject,
2195
- args: [nextActionsToken]
2196
- }] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }] });
2197
-
2198
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2199
- const cardNumberSanctionErrorCodes = [
2200
- 2034, 2035, 5027, 5024, 5025, 2036,
2201
- ];
2202
-
2203
- const fieldSpecialErrorsMap = [
2204
- {
2205
- errorCodes: new Set(cardNumberSanctionErrorCodes),
2206
- fieldName: FieldNames.cardNumber,
2207
- },
2208
- ];
2335
+ args: [windowToken]
2336
+ }] }] });
2209
2337
 
2210
- class UnescapeHtmlPipe {
2211
- transform(html) {
2212
- if (!html) {
2213
- return '';
2214
- }
2215
- if (html.includes('&gt')) {
2216
- const messageDocument = new DOMParser().parseFromString(html, 'text/html');
2217
- return messageDocument?.documentElement?.textContent ?? '';
2218
- }
2219
- return html;
2338
+ class UserBehaviourAnalyticsService {
2339
+ set isPayWithSavedMethod(value) {
2340
+ this.userSessionOptions.isPayWithSavedMethod = value;
2220
2341
  }
2221
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
2222
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, name: "unescapeHtml" }); }
2223
- }
2224
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, decorators: [{
2225
- type: Pipe,
2226
- args: [{
2227
- name: 'unescapeHtml',
2228
- }]
2229
- }] });
2230
-
2231
- class XpsResponseErrorsMappingService {
2232
- constructor(unescapeHtmlPipe) {
2233
- this.unescapeHtmlPipe = unescapeHtmlPipe;
2342
+ set subscriptionPackageId(value) {
2343
+ this.userSessionOptions.subscriptionPackageId = value;
2234
2344
  }
2235
- mapErrors(response) {
2236
- if (!response.errors?.length) {
2237
- return response;
2238
- }
2239
- let mappedErrors = this.mapFieldSpecialErrors(response.errors);
2240
- mappedErrors = this.unescapeErrorsText(mappedErrors);
2241
- return {
2242
- ...response,
2243
- errors: mappedErrors,
2244
- };
2345
+ set couponCode(value) {
2346
+ this.userSessionOptions.couponCode = value;
2245
2347
  }
2246
- mapFieldSpecialErrors(errors) {
2247
- return errors.map((error) => {
2248
- if (!error.element_name) {
2249
- const errorMap = fieldSpecialErrorsMap.find((map) => map.errorCodes.has(error.code));
2348
+ set paymentStatus(value) {
2349
+ this.userSessionOptions.paymentStatus = value;
2350
+ }
2351
+ get sessionOptions() {
2352
+ return this.userSessionOptions;
2353
+ }
2354
+ get purchaseType() {
2355
+ return this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type
2356
+ ? 'subscription'
2357
+ : null;
2358
+ }
2359
+ constructor(http, eventBuilderService, settingsService) {
2360
+ this.http = http;
2361
+ this.eventBuilderService = eventBuilderService;
2362
+ this.settingsService = settingsService;
2363
+ this.apiUrl = 'https://datagather.xsolla.com/paystation-user-sessions';
2364
+ this._events$ = new Subject();
2365
+ this.userSessionOptions = {
2366
+ invoice: null,
2367
+ instanceId: null,
2368
+ subscriptionRecurrentId: null,
2369
+ userMobileOperatorName: null,
2370
+ isPayWithSavedMethod: false,
2371
+ subscriptionPackageId: null,
2372
+ subscriptionProductId: null,
2373
+ couponCode: null,
2374
+ totalSum: null,
2375
+ totalCurrency: null,
2376
+ paymentInstanceName: null,
2377
+ paymentStatus: null,
2378
+ };
2379
+ this.sentEvents = new Set();
2380
+ }
2381
+ init() {
2382
+ this.setPid(this.settingsService.unsafeUtilsResponse?.purchase?.payment_system?.id);
2383
+ this.onOpenPayStation();
2384
+ }
2385
+ setPid(pid) {
2386
+ if (pid) {
2387
+ this.userSessionOptions.instanceId = pid;
2388
+ }
2389
+ }
2390
+ fillUserSession(paymentForm) {
2391
+ if (paymentForm.subscriptionRecurrentId) {
2392
+ this.userSessionOptions.subscriptionRecurrentId =
2393
+ paymentForm.subscriptionRecurrentId;
2394
+ }
2395
+ const operator = paymentForm.fields.find((field) => field.name === 'operator');
2396
+ if (operator) {
2397
+ this.userSessionOptions.userMobileOperatorName = operator.value;
2398
+ }
2399
+ if (paymentForm.pid) {
2400
+ this.setPid(paymentForm.pid);
2401
+ }
2402
+ if (paymentForm.userSession) {
2403
+ this.userSessionOptions.invoice = paymentForm.userSession;
2404
+ const createInvoiceOptions = {
2405
+ eventCategory: eventCategories.withInvoice,
2406
+ };
2407
+ this.send('create-invoice', userBehaviourEventTypes.manual, createInvoiceOptions);
2408
+ if (paymentForm.errors?.length) {
2409
+ this.resetInvoice();
2410
+ }
2411
+ }
2412
+ const total = paymentForm?.summary?.finance?.total;
2413
+ if (total) {
2414
+ this.userSessionOptions.totalSum = total.amount;
2415
+ this.userSessionOptions.totalCurrency = total.currency;
2416
+ }
2417
+ if (paymentForm.title) {
2418
+ this.userSessionOptions.paymentInstanceName = paymentForm.title;
2419
+ }
2420
+ }
2421
+ send(action, type, options) {
2422
+ if (oneTimeAnalyticsEvents.has(action) && this.sentEvents.has(action)) {
2423
+ return;
2424
+ }
2425
+ const date = new Date();
2426
+ const invoice = options?.eventCategory === eventCategories.withInvoice
2427
+ ? this.userSessionOptions.invoice
2428
+ : null;
2429
+ const eventOptions = {
2430
+ action,
2431
+ type,
2432
+ value: options?.value ?? null,
2433
+ valueType: options?.valueType ?? null,
2434
+ date,
2435
+ invoice,
2436
+ state: '',
2437
+ extraValue: options?.extraValue ?? null,
2438
+ purchase_type: options?.purchaseType ?? null,
2439
+ instanceId: options?.instanceId ?? null,
2440
+ dimension1: options?.dimension1 ?? null,
2441
+ dimension2: options?.dimension2 ?? null,
2442
+ dimension3: options?.dimension3 ?? null,
2443
+ dimension4: options?.dimension4 ?? null,
2444
+ dimension5: options?.dimension5 ?? null,
2445
+ };
2446
+ const sendEvent = () => {
2447
+ this.sentEvents.add(action);
2448
+ const event = this.eventBuilderService.createEvent(eventOptions, this.userSessionOptions);
2449
+ this._events$.next(event);
2450
+ const requestBody = JSON.stringify(event);
2451
+ if (navigator.sendBeacon) {
2452
+ navigator.sendBeacon(this.apiUrl, requestBody);
2453
+ }
2454
+ else {
2455
+ void this.http.post(this.apiUrl, requestBody).toPromise();
2456
+ }
2457
+ };
2458
+ if (options?.syncRequest) {
2459
+ sendEvent();
2460
+ return;
2461
+ }
2462
+ setTimeout(() => sendEvent());
2463
+ }
2464
+ onOpenPayStation() {
2465
+ this.send(UserBehaviourEventName.openPaystation, userBehaviourEventTypes.open, {
2466
+ value: null,
2467
+ purchaseType: this.purchaseType,
2468
+ });
2469
+ }
2470
+ resetInvoice() {
2471
+ this.userSessionOptions.invoice = null;
2472
+ }
2473
+ resetPid() {
2474
+ this.userSessionOptions.instanceId = null;
2475
+ }
2476
+ 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 }); }
2477
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, providedIn: 'root' }); }
2478
+ }
2479
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, decorators: [{
2480
+ type: Injectable,
2481
+ args: [{
2482
+ providedIn: 'root',
2483
+ }]
2484
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
2485
+
2486
+ class NextActionService {
2487
+ get flowUpdates$() {
2488
+ return this.flowUpdatesSubject.asObservable();
2489
+ }
2490
+ constructor(nextActionTokens, injector, showErrorsActionCreator, userBehaviourAnalyticsService) {
2491
+ this.nextActionTokens = nextActionTokens;
2492
+ this.injector = injector;
2493
+ this.showErrorsActionCreator = showErrorsActionCreator;
2494
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
2495
+ this.flowUpdatesSubject = new Subject();
2496
+ this.nextActionsList = [];
2497
+ this.fillNextActionsList();
2498
+ }
2499
+ getNextAction(submitResponse) {
2500
+ if (submitResponse.errors?.length) {
2501
+ this.emitFlowErrors(submitResponse.errors);
2502
+ }
2503
+ if (!submitResponse.currentCommand) {
2504
+ return null;
2505
+ }
2506
+ const nextActionCreator = this.findNextActionCreator(submitResponse);
2507
+ if (nextActionCreator) {
2508
+ const nextAction = nextActionCreator.getActionData(submitResponse);
2509
+ this.logNextAction(nextAction);
2510
+ return nextAction;
2511
+ }
2512
+ throw new Error('Next action is undefined.');
2513
+ }
2514
+ emitFlowUpdates(action) {
2515
+ this.flowUpdatesSubject.next(action);
2516
+ this.logNextAction(action);
2517
+ }
2518
+ emitFlowErrors(errors) {
2519
+ if (errors.length === 0)
2520
+ return;
2521
+ this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(errors));
2522
+ }
2523
+ fillNextActionsList() {
2524
+ this.nextActionTokens.forEach((nextAction) => {
2525
+ const item = this.injector.get(nextAction);
2526
+ this.nextActionsList.push(item);
2527
+ });
2528
+ }
2529
+ findNextActionCreator(submitResponse) {
2530
+ const actionType = this.nextActionsList.find((nextAction) => {
2531
+ return nextAction.isSuitable(submitResponse);
2532
+ });
2533
+ if (!actionType) {
2534
+ return;
2535
+ }
2536
+ return actionType;
2537
+ }
2538
+ logNextAction(nextAction) {
2539
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.nextAction, 'manual', { value: nextAction.type });
2540
+ }
2541
+ 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 }); }
2542
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, providedIn: 'root' }); }
2543
+ }
2544
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, decorators: [{
2545
+ type: Injectable,
2546
+ args: [{
2547
+ providedIn: 'root',
2548
+ }]
2549
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2550
+ type: Inject,
2551
+ args: [nextActionsToken]
2552
+ }] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }] });
2553
+
2554
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2555
+ const cardNumberSanctionErrorCodes = [
2556
+ 2034, 2035, 5027, 5024, 5025, 2036,
2557
+ ];
2558
+
2559
+ const fieldSpecialErrorsMap = [
2560
+ {
2561
+ errorCodes: new Set(cardNumberSanctionErrorCodes),
2562
+ fieldName: FieldNames.cardNumber,
2563
+ },
2564
+ ];
2565
+
2566
+ class UnescapeHtmlPipe {
2567
+ transform(html) {
2568
+ if (!html) {
2569
+ return '';
2570
+ }
2571
+ if (html.includes('&gt')) {
2572
+ const messageDocument = new DOMParser().parseFromString(html, 'text/html');
2573
+ return messageDocument?.documentElement?.textContent ?? '';
2574
+ }
2575
+ return html;
2576
+ }
2577
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
2578
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, name: "unescapeHtml" }); }
2579
+ }
2580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, decorators: [{
2581
+ type: Pipe,
2582
+ args: [{
2583
+ name: 'unescapeHtml',
2584
+ }]
2585
+ }] });
2586
+
2587
+ class XpsResponseErrorsMappingService {
2588
+ constructor(unescapeHtmlPipe) {
2589
+ this.unescapeHtmlPipe = unescapeHtmlPipe;
2590
+ }
2591
+ mapErrors(response) {
2592
+ if (!response.errors?.length) {
2593
+ return response;
2594
+ }
2595
+ let mappedErrors = this.mapFieldSpecialErrors(response.errors);
2596
+ mappedErrors = this.unescapeErrorsText(mappedErrors);
2597
+ return {
2598
+ ...response,
2599
+ errors: mappedErrors,
2600
+ };
2601
+ }
2602
+ mapFieldSpecialErrors(errors) {
2603
+ return errors.map((error) => {
2604
+ if (!error.element_name) {
2605
+ const errorMap = fieldSpecialErrorsMap.find((map) => map.errorCodes.has(error.code));
2250
2606
  if (errorMap) {
2251
2607
  return {
2252
2608
  ...error,
@@ -2552,408 +2908,103 @@ class CreditCardService {
2552
2908
  return cardNumber.replace(/\s+/g, '').substring(0, binNumberLength);
2553
2909
  }
2554
2910
  getAccountSuffix(cardNumber) {
2555
- const accountSuffixLength = 4;
2556
- return cardNumber
2557
- .replace(/\s+/g, '')
2558
- .substring(cardNumber.length - accountSuffixLength);
2559
- }
2560
- getTypeByNumber(cardNumber) {
2561
- cardNumber = cardNumber.replace(/\s+/g, '');
2562
- const cardSettings = orderedCardSettings.find((settings) => {
2563
- const isNumberMatched = settings.checkNumber(cardNumber);
2564
- return isNumberMatched ? settings.id : false;
2565
- });
2566
- return cardSettings ? cardSettings.id : defaultCard.id;
2567
- }
2568
- getCreditCardSettings(cardType) {
2569
- const creditCard = creditCardsMap[cardType];
2570
- if (!creditCard) {
2571
- return defaultCard;
2572
- }
2573
- return creditCard;
2574
- }
2575
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2576
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, providedIn: 'root' }); }
2577
- }
2578
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, decorators: [{
2579
- type: Injectable,
2580
- args: [{
2581
- providedIn: 'root',
2582
- }]
2583
- }] });
2584
-
2585
- // eslint-disable-next-line @typescript-eslint/naming-convention
2586
- class EncryptCreditCardService {
2587
- constructor(creditCardService) {
2588
- this.creditCardService = creditCardService;
2589
- this.secureFieldNames = [
2590
- 'xps_card_number',
2591
- 'xps_cvv',
2592
- 'xps_extra_cvv',
2593
- 'xps_card_year',
2594
- 'xps_card_month',
2595
- ];
2596
- this.jsEncrypt = new JSEncrypt();
2597
- }
2598
- setPublicKey(publicKey) {
2599
- this.jsEncrypt.setPublicKey(publicKey);
2600
- }
2601
- encryptCreditCard(request) {
2602
- if (request.xps_card_number) {
2603
- const openCard = this.createOpenCard(request);
2604
- request.xps_open_card = JSON.stringify(openCard);
2605
- }
2606
- const encryptedCard = this.createEncryptedCard(request);
2607
- if (request.xps_card_number || request.xps_extra_card_number) {
2608
- request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
2609
- }
2610
- this.secureFieldNames.forEach((secureFieldName) => {
2611
- delete request[secureFieldName];
2612
- });
2613
- return request;
2614
- }
2615
- encrypt(value) {
2616
- if (!this.jsEncrypt?.getPublicKey()) {
2617
- throw new EncryptCreditCardError('Empty public key');
2618
- }
2619
- const encryptedValue = this.jsEncrypt.encrypt(value);
2620
- if (!encryptedValue) {
2621
- throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
2622
- }
2623
- return encryptedValue;
2624
- }
2625
- createEncryptedCard(request) {
2626
- const encryptedCard = {
2627
- card_number: request.xps_card_number,
2628
- card_year: request.xps_card_year,
2629
- card_month: request.xps_card_month,
2630
- cvv: request.xps_cvv,
2631
- };
2632
- if (request.xps_extra_cvv) {
2633
- encryptedCard.cvv = request.xps_extra_cvv;
2634
- }
2635
- return encryptedCard;
2636
- }
2637
- createOpenCard(request) {
2638
- return {
2639
- card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
2640
- card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
2641
- card_year: request.xps_card_year,
2642
- card_month: request.xps_card_month,
2643
- };
2644
- }
2645
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2646
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' }); }
2647
- }
2648
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, decorators: [{
2649
- type: Injectable,
2650
- args: [{ providedIn: 'root' }]
2651
- }], ctorParameters: () => [{ type: CreditCardService }] });
2652
-
2653
- const eventCategories = {
2654
- withoutInvoice: 'withoutInvoice',
2655
- withInvoice: 'withInvoice',
2656
- };
2657
-
2658
- const oneTimeAnalyticsEvents = new Set([
2659
- UserBehaviourEventName.showMethodHeader,
2660
- ]);
2661
-
2662
- var EventParameterType;
2663
- (function (EventParameterType) {
2664
- EventParameterType["string"] = "0";
2665
- EventParameterType["int"] = "1";
2666
- EventParameterType["float"] = "2";
2667
- EventParameterType["bool"] = "3";
2668
- EventParameterType["intArray"] = "4";
2669
- EventParameterType["stringArray"] = "5";
2670
- })(EventParameterType || (EventParameterType = {}));
2671
-
2672
- class EventBuilderService {
2673
- constructor(settingsService, userAgentService, window) {
2674
- this.settingsService = settingsService;
2675
- this.userAgentService = userAgentService;
2676
- this.window = window;
2677
- }
2678
- createEvent(options, userSessionOptions) {
2679
- return {
2680
- action: options.action,
2681
- type: options.type,
2682
- value: this.convertToEventParameterType(options.value, options.valueType ?? EventParameterType.string),
2683
- state: options.state,
2684
- date: this.getDate(options.date),
2685
- milliseconds: options.date.getTime(),
2686
- timezone: this.getTimezone(options.date),
2687
- session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2688
- referrer_url: this.window?.document?.referrer,
2689
- project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2690
- payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2691
- this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2692
- geotype_id: this.convertToEventParameterType(options.invoice?.geotype_id, EventParameterType.int),
2693
- instance_id: this.convertToEventParameterType(options.instanceId ??
2694
- this.getPaymentMethodId(userSessionOptions.instanceId), EventParameterType.int),
2695
- payment_method_contr_id: this.convertToEventParameterType(options.invoice?.payment_method_contr_id, EventParameterType.int),
2696
- ps_type: this.convertToEventParameterType(options.invoice?.ps_type, EventParameterType.int),
2697
- is_pay_with_saved_method: this.convertToEventParameterType(userSessionOptions.isPayWithSavedMethod, EventParameterType.bool),
2698
- purchase_invoice_id: this.convertToEventParameterType(options.invoice?.purchase_invoice_id, EventParameterType.int),
2699
- purchase_external_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.purchase_external_id, EventParameterType.string),
2700
- purchase_type: this.settingsService.unsafeUtilsResponse?.purchase
2701
- ?.purchase_type,
2702
- purchase_sum: this.convertToEventParameterType(options.invoice?.purchase_sum, EventParameterType.float),
2703
- purchase_currency: this.convertToEventParameterType(options.invoice?.purchase_currency, EventParameterType.string),
2704
- purchase_sku: this.convertToEventParameterType(options.invoice?.purchase_sku, EventParameterType.string),
2705
- purchase_digital_content_sku: null,
2706
- purchase_description: this.convertToEventParameterType(options.invoice?.purchase_description, EventParameterType.string),
2707
- virtual_currency_amount: null, // TODO: add value
2708
- digital_content_cart_id: this.convertToEventParameterType(options.invoice?.digital_content_cart_id, EventParameterType.int),
2709
- digital_good_cart_id: this.convertToEventParameterType(options.invoice?.digital_good_cart_id, EventParameterType.int),
2710
- coupon_code: this.convertToEventParameterType(userSessionOptions.couponCode, EventParameterType.string),
2711
- theme_version: this.userAgentService.isMobileDevice
2712
- ? Device.mobile
2713
- : Device.desktop,
2714
- subscription_package_id: this.convertToEventParameterType(userSessionOptions.subscriptionPackageId, EventParameterType.int),
2715
- subscription_product_id: this.convertToEventParameterType(userSessionOptions.subscriptionProductId, EventParameterType.int),
2716
- subscription_recurrent_id: this.convertToEventParameterType(userSessionOptions.subscriptionRecurrentId, EventParameterType.int),
2717
- user_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.id, EventParameterType.string),
2718
- user_access_token: this.settingsService.token,
2719
- user_name: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.v2, EventParameterType.string),
2720
- user_email: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.email?.value, EventParameterType.string),
2721
- user_country: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2722
- user_ip: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.ip, EventParameterType.string),
2723
- user_mobile_operator_name: this.convertToEventParameterType(userSessionOptions.userMobileOperatorName, EventParameterType.string),
2724
- user_operation_system: this.userAgentService.platform,
2725
- user_browser: this.userAgentService.browserDescription,
2726
- user_browser_version: this.userAgentService.browserVersion,
2727
- user_locale: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.local, EventParameterType.string),
2728
- user_utm: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.utm_parameters, EventParameterType.string),
2729
- xsolla_product_tag: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.xsolla_product_tag, EventParameterType.string),
2730
- experiment_id: null,
2731
- is_test_session: +isDevMode(),
2732
- babka_value: null,
2733
- extra_value: this.convertToEventParameterType(options?.extraValue, EventParameterType.string),
2734
- is_subscription: this.convertToEventParameterType(this.isSubscription(), EventParameterType.bool),
2735
- is_iframe: this.convertToEventParameterType(this.window.parent !== this.window, EventParameterType.bool),
2736
- web3wallet: null, // TODO: add value
2737
- dimension_1: this.convertToEventParameterType(options?.dimension1, EventParameterType.string),
2738
- dimension_2: this.convertToEventParameterType(options?.dimension2, EventParameterType.string),
2739
- dimension_3: this.convertToEventParameterType(options?.dimension3, EventParameterType.string),
2740
- dimension_4: this.convertToEventParameterType(options?.dimension4, EventParameterType.string),
2741
- dimension_5: this.convertToEventParameterType(options?.dimension5, EventParameterType.string),
2742
- client_version: 'Headless Checkout',
2743
- };
2744
- }
2745
- getDate(date) {
2746
- const nullIndex = 0;
2747
- return date.toISOString().replace('T', ' ').replace('Z', '').split('.')[nullIndex];
2748
- }
2749
- getTimezone(date) {
2750
- const hour = 60;
2751
- const nullHour = 0;
2752
- const hourOffset = -date.getTimezoneOffset() / hour;
2753
- if (hourOffset === nullHour) {
2754
- return '0';
2755
- }
2756
- return hourOffset > nullHour ? `+${hourOffset}` : hourOffset.toString();
2757
- }
2758
- convertToEventParameterType(value, type
2759
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2760
- ) {
2761
- if (value === null || value === undefined) {
2762
- return null;
2763
- }
2764
- if (typeof value === 'boolean') {
2765
- value = value ? 1 : 0;
2766
- }
2767
- switch (type) {
2768
- case EventParameterType.string:
2769
- return String(value);
2770
- case EventParameterType.int:
2771
- value = parseInt(String(value), 10);
2772
- return isNaN(value) ? 0 : value;
2773
- case EventParameterType.stringArray:
2774
- case EventParameterType.intArray:
2775
- return Array.isArray(value) ? value : [];
2776
- case EventParameterType.float:
2777
- value = parseFloat(String(value));
2778
- return isNaN(value) ? 0 : value;
2779
- case EventParameterType.bool:
2780
- return value ? 1 : 0;
2781
- }
2782
- }
2783
- convertValueForPostMessage(value) {
2784
- if (value === null || value === undefined) {
2785
- return null;
2786
- }
2787
- return String(value);
2911
+ const accountSuffixLength = 4;
2912
+ return cardNumber
2913
+ .replace(/\s+/g, '')
2914
+ .substring(cardNumber.length - accountSuffixLength);
2788
2915
  }
2789
- isSubscription() {
2790
- return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2791
- 'subscription');
2916
+ getTypeByNumber(cardNumber) {
2917
+ cardNumber = cardNumber.replace(/\s+/g, '');
2918
+ const cardSettings = orderedCardSettings.find((settings) => {
2919
+ const isNumberMatched = settings.checkNumber(cardNumber);
2920
+ return isNumberMatched ? settings.id : false;
2921
+ });
2922
+ return cardSettings ? cardSettings.id : defaultCard.id;
2792
2923
  }
2793
- getPaymentMethodId(instanceId) {
2794
- return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2795
- instanceId);
2924
+ getCreditCardSettings(cardType) {
2925
+ const creditCard = creditCardsMap[cardType];
2926
+ if (!creditCard) {
2927
+ return defaultCard;
2928
+ }
2929
+ return creditCard;
2796
2930
  }
2797
- 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 }); }
2798
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, providedIn: 'root' }); }
2931
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2932
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, providedIn: 'root' }); }
2799
2933
  }
2800
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, decorators: [{
2934
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, decorators: [{
2801
2935
  type: Injectable,
2802
2936
  args: [{
2803
2937
  providedIn: 'root',
2804
2938
  }]
2805
- }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2806
- type: Inject,
2807
- args: [windowToken]
2808
- }] }] });
2939
+ }] });
2809
2940
 
2810
- class UserBehaviourAnalyticsService {
2811
- set isPayWithSavedMethod(value) {
2812
- this.userSessionOptions.isPayWithSavedMethod = value;
2813
- }
2814
- set subscriptionPackageId(value) {
2815
- this.userSessionOptions.subscriptionPackageId = value;
2816
- }
2817
- set couponCode(value) {
2818
- this.userSessionOptions.couponCode = value;
2819
- }
2820
- set paymentStatus(value) {
2821
- this.userSessionOptions.paymentStatus = value;
2822
- }
2823
- get sessionOptions() {
2824
- return this.userSessionOptions;
2825
- }
2826
- get purchaseType() {
2827
- return this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type
2828
- ? 'subscription'
2829
- : null;
2830
- }
2831
- constructor(http, eventBuilderService, settingsService) {
2832
- this.http = http;
2833
- this.eventBuilderService = eventBuilderService;
2834
- this.settingsService = settingsService;
2835
- this.apiUrl = 'https://datagather.xsolla.com/paystation-user-sessions';
2836
- this._events$ = new Subject();
2837
- this.userSessionOptions = {
2838
- invoice: null,
2839
- instanceId: null,
2840
- subscriptionRecurrentId: null,
2841
- userMobileOperatorName: null,
2842
- isPayWithSavedMethod: false,
2843
- subscriptionPackageId: null,
2844
- subscriptionProductId: null,
2845
- couponCode: null,
2846
- totalSum: null,
2847
- totalCurrency: null,
2848
- paymentInstanceName: null,
2849
- paymentStatus: null,
2850
- };
2851
- this.sentEvents = new Set();
2852
- }
2853
- init() {
2854
- this.setPid(this.settingsService.unsafeUtilsResponse?.purchase?.payment_system?.id);
2855
- this.onOpenPayStation();
2941
+ // eslint-disable-next-line @typescript-eslint/naming-convention
2942
+ class EncryptCreditCardService {
2943
+ constructor(creditCardService) {
2944
+ this.creditCardService = creditCardService;
2945
+ this.secureFieldNames = [
2946
+ 'xps_card_number',
2947
+ 'xps_cvv',
2948
+ 'xps_extra_cvv',
2949
+ 'xps_card_year',
2950
+ 'xps_card_month',
2951
+ ];
2952
+ this.jsEncrypt = new JSEncrypt();
2856
2953
  }
2857
- setPid(pid) {
2858
- if (pid) {
2859
- this.userSessionOptions.instanceId = pid;
2860
- }
2954
+ setPublicKey(publicKey) {
2955
+ this.jsEncrypt.setPublicKey(publicKey);
2861
2956
  }
2862
- fillUserSession(paymentForm) {
2863
- if (paymentForm.subscriptionRecurrentId) {
2864
- this.userSessionOptions.subscriptionRecurrentId =
2865
- paymentForm.subscriptionRecurrentId;
2866
- }
2867
- const operator = paymentForm.fields.find((field) => field.name === 'operator');
2868
- if (operator) {
2869
- this.userSessionOptions.userMobileOperatorName = operator.value;
2870
- }
2871
- if (paymentForm.pid) {
2872
- this.setPid(paymentForm.pid);
2957
+ encryptCreditCard(request) {
2958
+ if (request.xps_card_number) {
2959
+ const openCard = this.createOpenCard(request);
2960
+ request.xps_open_card = JSON.stringify(openCard);
2873
2961
  }
2874
- if (paymentForm.userSession) {
2875
- this.userSessionOptions.invoice = paymentForm.userSession;
2876
- const createInvoiceOptions = {
2877
- eventCategory: eventCategories.withInvoice,
2878
- };
2879
- this.send('create-invoice', userBehaviourEventTypes.manual, createInvoiceOptions);
2880
- if (paymentForm.errors?.length) {
2881
- this.resetInvoice();
2882
- }
2962
+ const encryptedCard = this.createEncryptedCard(request);
2963
+ if (request.xps_card_number || request.xps_extra_card_number) {
2964
+ request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
2883
2965
  }
2884
- const total = paymentForm?.summary?.finance?.total;
2885
- if (total) {
2886
- this.userSessionOptions.totalSum = total.amount;
2887
- this.userSessionOptions.totalCurrency = total.currency;
2966
+ this.secureFieldNames.forEach((secureFieldName) => {
2967
+ delete request[secureFieldName];
2968
+ });
2969
+ return request;
2970
+ }
2971
+ encrypt(value) {
2972
+ if (!this.jsEncrypt?.getPublicKey()) {
2973
+ throw new EncryptCreditCardError('Empty public key');
2888
2974
  }
2889
- if (paymentForm.title) {
2890
- this.userSessionOptions.paymentInstanceName = paymentForm.title;
2975
+ const encryptedValue = this.jsEncrypt.encrypt(value);
2976
+ if (!encryptedValue) {
2977
+ throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
2891
2978
  }
2979
+ return encryptedValue;
2892
2980
  }
2893
- send(action, type, options) {
2894
- if (oneTimeAnalyticsEvents.has(action) && this.sentEvents.has(action)) {
2895
- return;
2896
- }
2897
- const date = new Date();
2898
- const invoice = options?.eventCategory === eventCategories.withInvoice
2899
- ? this.userSessionOptions.invoice
2900
- : null;
2901
- const eventOptions = {
2902
- action,
2903
- type,
2904
- value: options?.value ?? null,
2905
- valueType: options?.valueType ?? null,
2906
- date,
2907
- invoice,
2908
- state: '',
2909
- extraValue: options?.extraValue ?? null,
2910
- purchase_type: options?.purchaseType ?? null,
2911
- instanceId: options?.instanceId ?? null,
2912
- dimension1: options?.dimension1 ?? null,
2913
- dimension2: options?.dimension2 ?? null,
2914
- dimension3: options?.dimension3 ?? null,
2915
- dimension4: options?.dimension4 ?? null,
2916
- dimension5: options?.dimension5 ?? null,
2917
- };
2918
- const sendEvent = () => {
2919
- this.sentEvents.add(action);
2920
- const event = this.eventBuilderService.createEvent(eventOptions, this.userSessionOptions);
2921
- this._events$.next(event);
2922
- const requestBody = JSON.stringify(event);
2923
- if (navigator.sendBeacon) {
2924
- navigator.sendBeacon(this.apiUrl, requestBody);
2925
- }
2926
- else {
2927
- void this.http.post(this.apiUrl, requestBody).toPromise();
2928
- }
2981
+ createEncryptedCard(request) {
2982
+ const encryptedCard = {
2983
+ card_number: request.xps_card_number,
2984
+ card_year: request.xps_card_year,
2985
+ card_month: request.xps_card_month,
2986
+ cvv: request.xps_cvv,
2929
2987
  };
2930
- if (options?.syncRequest) {
2931
- sendEvent();
2932
- return;
2988
+ if (request.xps_extra_cvv) {
2989
+ encryptedCard.cvv = request.xps_extra_cvv;
2933
2990
  }
2934
- setTimeout(() => sendEvent());
2935
- }
2936
- onOpenPayStation() {
2937
- this.send(UserBehaviourEventName.openPaystation, userBehaviourEventTypes.open, {
2938
- value: null,
2939
- purchaseType: this.purchaseType,
2940
- });
2941
- }
2942
- resetInvoice() {
2943
- this.userSessionOptions.invoice = null;
2991
+ return encryptedCard;
2944
2992
  }
2945
- resetPid() {
2946
- this.userSessionOptions.instanceId = null;
2993
+ createOpenCard(request) {
2994
+ return {
2995
+ card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
2996
+ card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
2997
+ card_year: request.xps_card_year,
2998
+ card_month: request.xps_card_month,
2999
+ };
2947
3000
  }
2948
- 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 }); }
2949
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, providedIn: 'root' }); }
3001
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3002
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' }); }
2950
3003
  }
2951
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, decorators: [{
3004
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, decorators: [{
2952
3005
  type: Injectable,
2953
- args: [{
2954
- providedIn: 'root',
2955
- }]
2956
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
3006
+ args: [{ providedIn: 'root' }]
3007
+ }], ctorParameters: () => [{ type: CreditCardService }] });
2957
3008
 
2958
3009
  class PaymentSettingsService {
2959
3010
  getPaymentSettingsParams(config) {
@@ -3072,6 +3123,7 @@ class InitializeService {
3072
3123
  if (config.savedMethodId) {
3073
3124
  requestParams.saved_method_id = config.savedMethodId;
3074
3125
  }
3126
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.initializeRequest, userBehaviourEventTypes.manual, { value: requestParams.pid });
3075
3127
  return this.xpsApiService
3076
3128
  .directPaymentRequest(requestParams)
3077
3129
  .then((xpsResponse) => {
@@ -3260,6 +3312,7 @@ class SubmitService {
3260
3312
  // In this way two promises become unequal, that can broke XPS API requests logic.
3261
3313
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3262
3314
  request(fields, form, config) {
3315
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.submitRequest, userBehaviourEventTypes.manual, { value: config.paymentMethodId });
3263
3316
  return (this.deviceFingerPrintService
3264
3317
  .getHash()
3265
3318
  // eslint-disable-next-line @typescript-eslint/promise-function-async
@@ -3496,6 +3549,7 @@ class SyncService extends EmitDataService {
3496
3549
  ...paymentSettingsParams,
3497
3550
  });
3498
3551
  const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
3552
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.syncRequest, userBehaviourEventTypes.manual, { extraValue: field?.name ?? '' });
3499
3553
  return this.xpsApiService
3500
3554
  .directPaymentRequest(encryptedRequest)
3501
3555
  .then((xpsResponse) => {
@@ -4767,18 +4821,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
4767
4821
  }] }, { type: i0.Injector }] });
4768
4822
 
4769
4823
  class FormService {
4770
- constructor(controlConfigService) {
4824
+ constructor(controlConfigService, userBehaviourAnalyticsService) {
4771
4825
  this.controlConfigService = controlConfigService;
4826
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
4772
4827
  this.fieldFormStates = {};
4773
4828
  }
4774
4829
  createForm(fields) {
4775
- const controls = this.getVisibleFields(fields).reduce((result, field) => {
4830
+ const visibleFields = this.getVisibleFields(fields);
4831
+ const controls = visibleFields.reduce((result, field) => {
4776
4832
  const formControl = this.controlConfigService.getFormControl(field);
4777
4833
  if (formControl) {
4778
4834
  result[field.name] = formControl;
4779
4835
  }
4780
4836
  return result;
4781
4837
  }, {});
4838
+ this.logCreateForm(visibleFields);
4782
4839
  return new UntypedFormGroup(controls);
4783
4840
  }
4784
4841
  getFieldFormState(fieldName) {
@@ -4804,12 +4861,15 @@ class FormService {
4804
4861
  getVisibleFields(fields) {
4805
4862
  return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
4806
4863
  }
4807
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, deps: [{ token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4864
+ logCreateForm(fields) {
4865
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.createForm, 'manual', { value: fields.map((field) => field.name) });
4866
+ }
4867
+ 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 }); }
4808
4868
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService }); }
4809
4869
  }
4810
4870
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, decorators: [{
4811
4871
  type: Injectable
4812
- }], ctorParameters: () => [{ type: ControlConfigService }] });
4872
+ }], ctorParameters: () => [{ type: ControlConfigService }, { type: UserBehaviourAnalyticsService }] });
4813
4873
 
4814
4874
  var StatusSearchParam;
4815
4875
  (function (StatusSearchParam) {
@@ -5632,20 +5692,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
5632
5692
  }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
5633
5693
 
5634
5694
  class FinanceDetailsService extends EmitDataService {
5635
- constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService) {
5695
+ constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService, userBehaviourAnalyticsService) {
5636
5696
  super();
5637
5697
  this.sessionService = sessionService;
5638
5698
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
5639
5699
  this.statusFinanceDetailsAdapterService = statusFinanceDetailsAdapterService;
5700
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
5640
5701
  this.purchaseSessionKey = 'purchase';
5641
5702
  }
5642
- emitWithSummary(summary) {
5703
+ emitWithSummary(summary, needLogCart = true) {
5643
5704
  if (summary) {
5644
5705
  const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5645
5706
  if (financeDetails.purchase) {
5646
5707
  this.sessionService.set(this.purchaseSessionKey, financeDetails.purchase);
5647
5708
  }
5648
5709
  super.emit(financeDetails);
5710
+ if (needLogCart) {
5711
+ this.logCartEvent(financeDetails);
5712
+ }
5649
5713
  }
5650
5714
  }
5651
5715
  emitWithStatus(status) {
@@ -5658,13 +5722,18 @@ class FinanceDetailsService extends EmitDataService {
5658
5722
  getDetailsFromSummary(summary) {
5659
5723
  return this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5660
5724
  }
5661
- 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 }); }
5725
+ logCartEvent(financeDetails) {
5726
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.showShoppingCart, userBehaviourEventTypes.show, {
5727
+ value: financeDetails.finance ? 'success' : 'fail',
5728
+ });
5729
+ }
5730
+ 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 }); }
5662
5731
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' }); }
5663
5732
  }
5664
5733
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, decorators: [{
5665
5734
  type: Injectable,
5666
5735
  args: [{ providedIn: 'root' }]
5667
- }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }] });
5736
+ }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }, { type: UserBehaviourAnalyticsService }] });
5668
5737
 
5669
5738
  /* eslint-disable @typescript-eslint/naming-convention */
5670
5739
  class CheckStatusRequest extends XpsApiPartRequest {
@@ -6244,7 +6313,7 @@ class ListenStatusService {
6244
6313
  const isStatusError = statusSettings.statusState === StatusEnum.canceled ||
6245
6314
  statusSettings.statusState === StatusEnum.error ||
6246
6315
  statusSettings.isCancelUser;
6247
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.statusUpdated, userBehaviourEventTypes.manual, {
6316
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.changeStatus, userBehaviourEventTypes.manual, {
6248
6317
  instanceId: statusResponse.status.pid,
6249
6318
  value: statusResponse.status.statusState,
6250
6319
  });
@@ -6267,6 +6336,9 @@ class ListenStatusService {
6267
6336
  .subscribe((checkStatusResponse) => {
6268
6337
  if (!checkStatusResponse?.status)
6269
6338
  return;
6339
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.checkStatusUpdate, userBehaviourEventTypes.manual, {
6340
+ value: checkStatusResponse.status ?? '',
6341
+ });
6270
6342
  if (checkStatusResponse.status === StatusEnum.done) {
6271
6343
  this.statusService.request();
6272
6344
  this.websocketStatusService.closeWebSocket();
@@ -6584,8 +6656,9 @@ const initializeNextActions = [
6584
6656
  ];
6585
6657
 
6586
6658
  class InitializeNextActionService {
6587
- constructor(initializeNextActionTokens, injector) {
6659
+ constructor(initializeNextActionTokens, userBehaviourAnalyticsService, injector) {
6588
6660
  this.initializeNextActionTokens = initializeNextActionTokens;
6661
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6589
6662
  this.injector = injector;
6590
6663
  this.initializeNextActionsList = [];
6591
6664
  this.fillNextActionsList();
@@ -6594,6 +6667,7 @@ class InitializeNextActionService {
6594
6667
  const nextAction = this.findNextAction(response);
6595
6668
  if (!nextAction)
6596
6669
  return null;
6670
+ this.logNextAction(nextAction);
6597
6671
  return nextAction.getActionData(response);
6598
6672
  }
6599
6673
  fillNextActionsList() {
@@ -6607,7 +6681,10 @@ class InitializeNextActionService {
6607
6681
  return nextAction.isSuitable(response);
6608
6682
  });
6609
6683
  }
6610
- 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 }); }
6684
+ logNextAction(nextAction) {
6685
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.initializeNextAction, 'manual', { value: nextAction.type });
6686
+ }
6687
+ 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 }); }
6611
6688
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, providedIn: 'root' }); }
6612
6689
  }
6613
6690
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, decorators: [{
@@ -6618,7 +6695,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
6618
6695
  }], ctorParameters: () => [{ type: undefined, decorators: [{
6619
6696
  type: Inject,
6620
6697
  args: [initializeNextActionsToken]
6621
- }] }, { type: i0.Injector }] });
6698
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
6622
6699
 
6623
6700
  var ThreeDsStatusWebSocketTypes;
6624
6701
  (function (ThreeDsStatusWebSocketTypes) {
@@ -6909,12 +6986,13 @@ class ThreeDs20Service {
6909
6986
  get statusUpdates$() {
6910
6987
  return this.statusUpdates.asObservable();
6911
6988
  }
6912
- constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService) {
6989
+ constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService, userBehaviourAnalyticsService) {
6913
6990
  this.statusThreeDsService = statusThreeDsService;
6914
6991
  this.notifyDfpStatusService = notifyDfpStatusService;
6915
6992
  this.webSocketFactory = webSocketFactory;
6916
6993
  this.dfpCollectService = dfpCollectService;
6917
6994
  this.reinsuranceCheckService = reinsuranceCheckService;
6995
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6918
6996
  this.webSocketClient = null;
6919
6997
  this.statusUpdates = new Subject();
6920
6998
  this.statusRequestSubscription = null;
@@ -6967,6 +7045,7 @@ class ThreeDs20Service {
6967
7045
  }
6968
7046
  if (threeDsStatus.status === ThreeDsStatusTypes.completed) {
6969
7047
  this.stopReinsuranceMethods();
7048
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2complete, userBehaviourEventTypes.manual);
6970
7049
  this.statusUpdates.next({
6971
7050
  type: 'complete',
6972
7051
  data: {
@@ -6978,6 +7057,7 @@ class ThreeDs20Service {
6978
7057
  if (threeDsStatus.status === ThreeDsStatusTypes.challenge &&
6979
7058
  threeDsStatus.checkoutForm) {
6980
7059
  this.stopReinsuranceMethods();
7060
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2challenge, userBehaviourEventTypes.manual);
6981
7061
  this.statusUpdates.next({
6982
7062
  type: 'challenge',
6983
7063
  data: threeDsStatus.checkoutForm,
@@ -6985,6 +7065,7 @@ class ThreeDs20Service {
6985
7065
  }
6986
7066
  if (threeDsStatus.status === ThreeDsStatusTypes.collectDfp) {
6987
7067
  this.dfpCollectService.collectDfpStatus(threeDsForm);
7068
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2collectDfp, userBehaviourEventTypes.manual);
6988
7069
  }
6989
7070
  });
6990
7071
  }
@@ -6994,7 +7075,7 @@ class ThreeDs20Service {
6994
7075
  this.webSocketClient?.close();
6995
7076
  this.statusRequestSubscription?.unsubscribe();
6996
7077
  }
6997
- 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 }); }
7078
+ 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 }); }
6998
7079
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, providedIn: 'root' }); }
6999
7080
  }
7000
7081
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, decorators: [{
@@ -7002,7 +7083,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7002
7083
  args: [{
7003
7084
  providedIn: 'root',
7004
7085
  }]
7005
- }], ctorParameters: () => [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }] });
7086
+ }], ctorParameters: () => [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }, { type: UserBehaviourAnalyticsService }] });
7006
7087
 
7007
7088
  class ThreeDsService {
7008
7089
  constructor(threeDs20Service, nextActionService, checkStatusActionCreator, threeDsActionCreator) {
@@ -7132,6 +7213,7 @@ const isInitializeResponse = (value) => {
7132
7213
  class ApplePayWithShippingAddressStrategy extends BehaviourStrategy {
7133
7214
  constructor() {
7134
7215
  super();
7216
+ this.name = 'ApplePayWithShippingAddressStrategy';
7135
7217
  }
7136
7218
  isSuitable() {
7137
7219
  if (isInitializeResponse(this.paymentData)) {
@@ -7171,6 +7253,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7171
7253
  class GooglePayInstantFlowStrategy extends BehaviourStrategy {
7172
7254
  constructor() {
7173
7255
  super();
7256
+ this.name = 'GooglePayInstantFlowStrategy';
7174
7257
  }
7175
7258
  isSuitable() {
7176
7259
  if (!isInitializeResponse(this.paymentData)) {
@@ -7206,6 +7289,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7206
7289
  class GooglePayRegularFlowStrategy extends BehaviourStrategy {
7207
7290
  constructor() {
7208
7291
  super();
7292
+ this.name = 'GooglePayRegularFlowStrategy';
7209
7293
  }
7210
7294
  isSuitable() {
7211
7295
  if (!isInitializeResponse(this.paymentData)) {
@@ -7241,22 +7325,30 @@ const behaviourStrategies = [
7241
7325
  ];
7242
7326
 
7243
7327
  class PaymentBehaviourService {
7244
- constructor(behaviourStrategyTokens, injector) {
7328
+ constructor(behaviourStrategyTokens, userBehaviourAnalyticsService, injector) {
7245
7329
  this.behaviourStrategyTokens = behaviourStrategyTokens;
7330
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7246
7331
  this.injector = injector;
7247
7332
  }
7248
7333
  getApplicableBehaviourStrategies(paymentData, config) {
7249
7334
  const strategies = this.getBehaviourStrategies();
7250
- return strategies.filter((behaviourStrategy) => {
7335
+ const applicableStrategies = strategies.filter((behaviourStrategy) => {
7251
7336
  behaviourStrategy.setPaymentData(paymentData);
7252
7337
  behaviourStrategy.setPaymentConfig(config);
7253
7338
  return behaviourStrategy.isSuitable();
7254
7339
  });
7340
+ this.logApplicableStrategies(applicableStrategies);
7341
+ return applicableStrategies;
7255
7342
  }
7256
7343
  getBehaviourStrategies() {
7257
7344
  return this.behaviourStrategyTokens.map((behaviourStrategyToken) => this.injector.get(behaviourStrategyToken));
7258
7345
  }
7259
- 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 }); }
7346
+ logApplicableStrategies(strategies) {
7347
+ if (!strategies.length)
7348
+ return;
7349
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applicablePaymentStrategies, 'manual', { value: strategies.map((strategy) => strategy.name) });
7350
+ }
7351
+ 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 }); }
7260
7352
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService }); }
7261
7353
  }
7262
7354
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, decorators: [{
@@ -7264,7 +7356,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7264
7356
  }], ctorParameters: () => [{ type: undefined, decorators: [{
7265
7357
  type: Inject,
7266
7358
  args: [behaviourStrategiesToken]
7267
- }] }, { type: i0.Injector }] });
7359
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
7268
7360
 
7269
7361
  class PaymentService {
7270
7362
  get formFieldsStatus$() {
@@ -7279,7 +7371,7 @@ class PaymentService {
7279
7371
  get formResponseValue() {
7280
7372
  return this._formResponse$.getValue();
7281
7373
  }
7282
- constructor(loggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService, paymentBehaviourService, translateService) {
7374
+ constructor(loggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService, paymentBehaviourService, translateService, userBehaviourAnalyticsService) {
7283
7375
  this.loggerService = loggerService;
7284
7376
  this.initializeService = initializeService;
7285
7377
  this.submitService = submitService;
@@ -7299,11 +7391,13 @@ class PaymentService {
7299
7391
  this.printInstructionService = printInstructionService;
7300
7392
  this.paymentBehaviourService = paymentBehaviourService;
7301
7393
  this.translateService = translateService;
7394
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7302
7395
  this.form = null;
7303
7396
  this.data = null;
7304
7397
  this.financeDetails = null;
7305
7398
  this.focusFieldName = null;
7306
7399
  this.fields = [];
7400
+ this.isSubmitAttempted = false;
7307
7401
  this.destroy$ = new Subject();
7308
7402
  this.formDestroy$ = new Subject();
7309
7403
  this._paymentForm$ = new BehaviorSubject(null);
@@ -7314,6 +7408,7 @@ class PaymentService {
7314
7408
  async initialize(config) {
7315
7409
  this.destroy$ = new Subject();
7316
7410
  this.formDestroy$ = new Subject();
7411
+ this.isSubmitAttempted = false;
7317
7412
  this.listenFinanceDetails();
7318
7413
  this.config = config;
7319
7414
  this.data = await this.initializeService.request(config);
@@ -7346,10 +7441,13 @@ class PaymentService {
7346
7441
  throw new Error('form is empty!');
7347
7442
  }
7348
7443
  if (!this.form.valid) {
7444
+ this.logSubmitAttempt();
7445
+ this.isSubmitAttempted = true;
7349
7446
  this.form.markAllAsTouched();
7350
7447
  this.emitFormFieldsStatus(this.form);
7351
7448
  return;
7352
7449
  }
7450
+ this.logSubmit();
7353
7451
  this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
7354
7452
  const submitResponse = await this.submitService.request(this.fields, this.form, this.config);
7355
7453
  this.handleSubmitWithErrors(submitResponse);
@@ -7357,7 +7455,7 @@ class PaymentService {
7357
7455
  this.initializeBehaviourStrategies();
7358
7456
  this.emitFormResponse(this.data);
7359
7457
  if (!this.isSavingMethodMode) {
7360
- this.emitFinanceDetails(submitResponse.summary);
7458
+ this.emitFinanceDetails(submitResponse.summary, false);
7361
7459
  }
7362
7460
  this.emitFormMessages(submitResponse.messages);
7363
7461
  // Handle 3ds flow
@@ -7384,7 +7482,7 @@ class PaymentService {
7384
7482
  this.data = submitResponse;
7385
7483
  this.emitFormResponse(this.data);
7386
7484
  if (!this.isSavingMethodMode) {
7387
- this.emitFinanceDetails(submitResponse.summary);
7485
+ this.emitFinanceDetails(submitResponse.summary, false);
7388
7486
  }
7389
7487
  this.emitFormMessages(submitResponse.messages);
7390
7488
  this.fields = this.getFields();
@@ -7608,8 +7706,8 @@ class PaymentService {
7608
7706
  this.destroy$.next();
7609
7707
  this.threeDsService.stopChecking();
7610
7708
  }
7611
- emitFinanceDetails(summary) {
7612
- this.financeDetailsService.emitWithSummary(summary);
7709
+ emitFinanceDetails(summary, needLogCart = true) {
7710
+ this.financeDetailsService.emitWithSummary(summary, needLogCart);
7613
7711
  }
7614
7712
  emitCreditCardState({ idCardType, cardBinCountry, }) {
7615
7713
  this.creditCardStateService.emit({ idCardType, cardBinCountry });
@@ -7755,7 +7853,20 @@ class PaymentService {
7755
7853
  }, new Map());
7756
7854
  updateAfterErrorRules.forEach((rule) => rule.apply(submitResponse, fieldsMap));
7757
7855
  }
7758
- 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 }); }
7856
+ logSubmitAttempt() {
7857
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.attemptBuyNow, userBehaviourEventTypes.click);
7858
+ }
7859
+ logSubmit() {
7860
+ if (this.isSubmitAttempted) {
7861
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.attemptContinue, userBehaviourEventTypes.click, {
7862
+ eventCategory: eventCategories.withInvoice,
7863
+ });
7864
+ }
7865
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.clickBtnPay, userBehaviourEventTypes.click, {
7866
+ eventCategory: eventCategories.withInvoice,
7867
+ });
7868
+ }
7869
+ 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 }); }
7759
7870
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, providedIn: 'root' }); }
7760
7871
  }
7761
7872
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, decorators: [{
@@ -7763,7 +7874,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7763
7874
  args: [{
7764
7875
  providedIn: 'root',
7765
7876
  }]
7766
- }], 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 }] });
7877
+ }], 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 }] });
7767
7878
 
7768
7879
  const euCountries = new Set([
7769
7880
  'AT',
@@ -8559,6 +8670,9 @@ class CoreLibraryService {
8559
8670
  registerLogHandler(handler) {
8560
8671
  this.loggerService.register(handler);
8561
8672
  }
8673
+ emitFlowErrors(errors) {
8674
+ this.nextActionService.emitFlowErrors(errors);
8675
+ }
8562
8676
  get paymentForm$() {
8563
8677
  return this.paymentService.paymentForm$;
8564
8678
  }
@@ -8792,7 +8906,8 @@ class ApplePayCartService {
8792
8906
  get cartRecalculationRequest$() {
8793
8907
  return this.cartRecalculationRequest.asObservable();
8794
8908
  }
8795
- constructor(summaryFinanceDetailsAdapterService) {
8909
+ constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
8910
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8796
8911
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
8797
8912
  this.cartSuccessfulRecalculated = new Subject();
8798
8913
  this.cartErrorRecalculated = new Subject();
@@ -8810,6 +8925,10 @@ class ApplePayCartService {
8810
8925
  zip: parsedZip,
8811
8926
  country,
8812
8927
  });
8928
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
8929
+ dimension1: country,
8930
+ dimension2: parsedZip || '',
8931
+ });
8813
8932
  }
8814
8933
  buildShippingContactUpdate(paymentParams, updatedPrice) {
8815
8934
  return {
@@ -8833,6 +8952,7 @@ class ApplePayCartService {
8833
8952
  this.cartSuccessfulRecalculated.next(updatedPrice);
8834
8953
  }
8835
8954
  sendErrorRecalculatedCart(error) {
8955
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
8836
8956
  this.cartErrorRecalculated.next(error);
8837
8957
  }
8838
8958
  isZipCountry(country) {
@@ -8867,7 +8987,7 @@ class ApplePayCartService {
8867
8987
  getTotalAmount(finance) {
8868
8988
  return finance?.grand_total?.amount ?? finance?.total?.amount;
8869
8989
  }
8870
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8990
+ 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 }); }
8871
8991
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
8872
8992
  }
8873
8993
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -8875,14 +8995,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8875
8995
  args: [{
8876
8996
  providedIn: 'root',
8877
8997
  }]
8878
- }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
8998
+ }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
8879
8999
 
8880
9000
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8881
- constructor(window, loggerService, applePayCartService) {
9001
+ constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
8882
9002
  super();
8883
9003
  this.window = window;
8884
9004
  this.loggerService = loggerService;
8885
9005
  this.applePayCartService = applePayCartService;
9006
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8886
9007
  this.paymentClient = null;
8887
9008
  }
8888
9009
  setClient(client) {
@@ -8900,14 +9021,18 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8900
9021
  const applePayRequest = this.paymentClient.createPaymentRequest(request);
8901
9022
  const session = new this.window.ApplePaySession(applePayVersion, applePayRequest);
8902
9023
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9024
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
8903
9025
  session.onshippingcontactselected = (event) => {
9026
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
8904
9027
  this.applePayCartService.cartSuccessfulRecalculated$
8905
9028
  .pipe(take(1))
8906
9029
  .subscribe((updatedPrice) => {
8907
9030
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9031
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
8908
9032
  session.completeShippingContactSelection(contactUpdate);
8909
9033
  });
8910
9034
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9035
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
8911
9036
  session.completeShippingContactSelection({
8912
9037
  errors: [error],
8913
9038
  newTotal: {
@@ -8920,6 +9045,10 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8920
9045
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
8921
9046
  };
8922
9047
  session.onvalidatemerchant = (event) => {
9048
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9049
+ value: event.validationURL,
9050
+ extraValue: params.totalLabel,
9051
+ });
8923
9052
  const validationParams = {
8924
9053
  validationURL: event.validationURL,
8925
9054
  displayName: params.totalLabel,
@@ -8934,12 +9063,14 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8934
9063
  session.completeMerchantValidation(merchantSession);
8935
9064
  })
8936
9065
  .catch((error) => {
9066
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
8937
9067
  console.error(ApplePayErrors.merchantValidationError, error);
8938
9068
  session.abort();
8939
9069
  applePayFinallyCallback();
8940
9070
  });
8941
9071
  };
8942
9072
  session.onpaymentauthorized = (event) => {
9073
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
8943
9074
  this.paymentClient
8944
9075
  ?.tokenize({ token: event.payment.token })
8945
9076
  .then((response) => {
@@ -8952,19 +9083,21 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8952
9083
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
8953
9084
  })
8954
9085
  .catch((error) => {
9086
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
8955
9087
  console.error('Apple Pay: Tokenization error', error);
8956
9088
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
8957
9089
  applePayFinallyCallback();
8958
9090
  });
8959
9091
  };
8960
9092
  session.oncancel = (event) => {
9093
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
8961
9094
  console.error(ApplePayErrors.cancelled, event);
8962
9095
  this.emitError(ApplePayErrors.cancelled);
8963
9096
  applePayFinallyCallback();
8964
9097
  };
8965
9098
  session.begin();
8966
9099
  }
8967
- 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 }); }
9100
+ 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 }); }
8968
9101
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler }); }
8969
9102
  }
8970
9103
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -8972,26 +9105,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8972
9105
  }], ctorParameters: () => [{ type: undefined, decorators: [{
8973
9106
  type: Inject,
8974
9107
  args: [windowToken]
8975
- }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9108
+ }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
8976
9109
 
8977
9110
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8978
- constructor(window, http, applePayCartService) {
9111
+ constructor(window, http, applePayCartService, userBehaviourAnalyticsService) {
8979
9112
  super();
8980
9113
  this.window = window;
8981
9114
  this.http = http;
8982
9115
  this.applePayCartService = applePayCartService;
9116
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8983
9117
  }
8984
9118
  startSession(params, additionalParams, applePayFinallyCallback) {
8985
9119
  const request = this.buildPaymentRequest(params);
8986
9120
  const session = new this.window.ApplePaySession(applePayVersion, request);
8987
9121
  session.onshippingcontactselected = (event) => {
9122
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
8988
9123
  this.applePayCartService.cartSuccessfulRecalculated$
8989
9124
  .pipe(take(1))
8990
9125
  .subscribe((updatedPrice) => {
8991
9126
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9127
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
8992
9128
  session.completeShippingContactSelection(contactUpdate);
8993
9129
  });
8994
9130
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9131
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
8995
9132
  session.completeShippingContactSelection({
8996
9133
  errors: [error],
8997
9134
  newTotal: {
@@ -9004,6 +9141,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9004
9141
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9005
9142
  };
9006
9143
  session.onvalidatemerchant = (event) => {
9144
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9145
+ value: event.validationURL,
9146
+ extraValue: params.totalLabel,
9147
+ });
9007
9148
  const validationParams = {
9008
9149
  validationURL: event.validationURL,
9009
9150
  accountId: params.payInstanceAccountId,
@@ -9023,6 +9164,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9023
9164
  session.completeMerchantValidation(response.merchantSession);
9024
9165
  },
9025
9166
  error: (error) => {
9167
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9026
9168
  console.error(ApplePayErrors.merchantValidationError, error);
9027
9169
  session.abort();
9028
9170
  applePayFinallyCallback();
@@ -9030,6 +9172,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9030
9172
  });
9031
9173
  };
9032
9174
  session.onpaymentauthorized = (event) => {
9175
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9033
9176
  this.payment.next(JSON.stringify({
9034
9177
  token: event.payment.token ?? '',
9035
9178
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9039,13 +9182,14 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9039
9182
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9040
9183
  };
9041
9184
  session.oncancel = (event) => {
9185
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9042
9186
  console.error(ApplePayErrors.cancelled, event);
9043
9187
  this.emitError(ApplePayErrors.cancelled);
9044
9188
  applePayFinallyCallback();
9045
9189
  };
9046
9190
  session.begin();
9047
9191
  }
9048
- 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 }); }
9192
+ 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 }); }
9049
9193
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler }); }
9050
9194
  }
9051
9195
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9053,7 +9197,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9053
9197
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9054
9198
  type: Inject,
9055
9199
  args: [windowToken]
9056
- }] }, { type: i1.HttpClient }, { type: ApplePayCartService }] });
9200
+ }] }, { type: i1.HttpClient }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9057
9201
 
9058
9202
  class PaymentBehaviourModule {
9059
9203
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -9279,8 +9423,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9279
9423
  }] }] });
9280
9424
 
9281
9425
  class GooglePayCheckoutPaymentService {
9282
- constructor(paymentSystemProcessingService) {
9426
+ constructor(paymentSystemProcessingService, userBehaviourAnalyticsService) {
9283
9427
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9428
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9284
9429
  this.checkout = null;
9285
9430
  }
9286
9431
  preparePayment({ initParams, checkDeviceData, }) {
@@ -9320,6 +9465,7 @@ class GooglePayCheckoutPaymentService {
9320
9465
  return paymentDataRequest.allowedPaymentMethods;
9321
9466
  }
9322
9467
  handleSuccessfulPayment(response) {
9468
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleSuccessfulPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '' });
9323
9469
  if (!this.checkout)
9324
9470
  return;
9325
9471
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -9328,6 +9474,7 @@ class GooglePayCheckoutPaymentService {
9328
9474
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
9329
9475
  }
9330
9476
  handleFailedPayment(error) {
9477
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleFailedPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '' });
9331
9478
  if (!this.checkout)
9332
9479
  return;
9333
9480
  const statusCode = error?.statusCode;
@@ -9340,7 +9487,7 @@ class GooglePayCheckoutPaymentService {
9340
9487
  isCancelledStatus(statusCode) {
9341
9488
  return statusCode.toLowerCase() === 'canceled';
9342
9489
  }
9343
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9490
+ 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 }); }
9344
9491
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
9345
9492
  }
9346
9493
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -9348,7 +9495,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9348
9495
  args: [{
9349
9496
  providedIn: 'root',
9350
9497
  }]
9351
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }] });
9498
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }] });
9352
9499
 
9353
9500
  class GooglePayInstantPaymentService {
9354
9501
  constructor(summaryFinanceDetailsAdapterService) {
@@ -9941,10 +10088,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9941
10088
  }], ctorParameters: () => [{ type: SecureApiClient }] });
9942
10089
 
9943
10090
  class ApplePayExternalWindowCommunicationService {
9944
- constructor(window, webSocketFactory, socketBridgeService) {
10091
+ constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
9945
10092
  this.window = window;
9946
10093
  this.webSocketFactory = webSocketFactory;
9947
10094
  this.socketBridgeService = socketBridgeService;
10095
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9948
10096
  }
9949
10097
  getWindowClose$() {
9950
10098
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -9969,6 +10117,7 @@ class ApplePayExternalWindowCommunicationService {
9969
10117
  return this.getEventSource(isRecalculateCartMessage);
9970
10118
  }
9971
10119
  async openWebSocketConnection(token) {
10120
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
9972
10121
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
9973
10122
  if (this.websocketClient) {
9974
10123
  this.websocketClient.close();
@@ -9977,6 +10126,7 @@ class ApplePayExternalWindowCommunicationService {
9977
10126
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
9978
10127
  }
9979
10128
  async sendMessageToAnotherWindow(command, payload) {
10129
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
9980
10130
  await this.socketBridgeService.publishMessage(command, payload);
9981
10131
  }
9982
10132
  getEventSource(eventHandler) {
@@ -9985,7 +10135,7 @@ class ApplePayExternalWindowCommunicationService {
9985
10135
  return JSON.parse(message);
9986
10136
  }), filter(eventHandler));
9987
10137
  }
9988
- 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 }); }
10138
+ 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 }); }
9989
10139
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
9990
10140
  }
9991
10141
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -9996,7 +10146,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9996
10146
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9997
10147
  type: Inject,
9998
10148
  args: [windowToken]
9999
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10149
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10000
10150
 
10001
10151
  class ApplePayService {
10002
10152
  get paymentParameters() {
@@ -10039,7 +10189,7 @@ class ApplePayService {
10039
10189
  .getWindowReturnMessage$()
10040
10190
  .pipe(takeUntil(this.destroy$));
10041
10191
  }
10042
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10192
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10043
10193
  this.window = window;
10044
10194
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10045
10195
  this.braintreeHandler = braintreeHandler;
@@ -10048,6 +10198,7 @@ class ApplePayService {
10048
10198
  this.loggerService = loggerService;
10049
10199
  this.applePaySdkService = applePaySdkService;
10050
10200
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10201
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10051
10202
  this.settingsService = settingsService;
10052
10203
  this.payment = new Subject();
10053
10204
  this.error = new Subject();
@@ -10175,6 +10326,7 @@ class ApplePayService {
10175
10326
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
10176
10327
  }
10177
10328
  proceedCheckout(parameters, additionalParams) {
10329
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayAcquirer, 'manual', { value: parameters.acquirer });
10178
10330
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
10179
10331
  if (!sessionHandler) {
10180
10332
  console.error('Apple Pay: Unsupported acquirer:', parameters.acquirer);
@@ -10232,7 +10384,7 @@ class ApplePayService {
10232
10384
  this.applePayQrOpened.next();
10233
10385
  }
10234
10386
  }
10235
- 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 }); }
10387
+ 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 }); }
10236
10388
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
10237
10389
  }
10238
10390
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
@@ -10243,7 +10395,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
10243
10395
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10244
10396
  type: Inject,
10245
10397
  args: [windowToken]
10246
- }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
10398
+ }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: UserBehaviourAnalyticsService }, { type: SettingsService }] });
10247
10399
 
10248
10400
  /*
10249
10401
  * Public API Surface of core-library