@xsolla/payment-client-core 0.2.90 → 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 (49) hide show
  1. package/esm2022/lib/core/payment/actions/next-action.service.mjs +17 -8
  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/fesm2022/xsolla-payment-client-core.mjs +676 -532
  27. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  28. package/lib/core/payment/actions/next-action.service.d.ts +5 -2
  29. package/lib/core/payment/field-names.enum.d.ts +2 -1
  30. package/lib/core/payment/finance-details/finance-details.service.d.ts +5 -2
  31. package/lib/core/payment/form/form.service.d.ts +5 -2
  32. package/lib/core/payment/initialize-actions/initialize-next-action.service.d.ts +4 -1
  33. package/lib/core/payment/payment-behaviour/payment-behaviour.service.d.ts +4 -1
  34. package/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.d.ts +1 -0
  35. package/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.d.ts +1 -0
  36. package/lib/core/payment/payment-behaviour/strategies/google-pay-instant-flow/google-pay-instant-flow.strategy.d.ts +1 -0
  37. package/lib/core/payment/payment-behaviour/strategies/google-pay-regular-flow/google-pay-regular-flow.strategy.d.ts +1 -0
  38. package/lib/core/payment/payment.service.d.ts +6 -1
  39. package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +3 -1
  40. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +3 -1
  41. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +3 -1
  42. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +3 -1
  43. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +3 -1
  44. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +3 -1
  45. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +3 -1
  46. package/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.d.ts +40 -3
  47. package/package.json +1 -1
  48. package/xsolla-payment-client-core-0.2.91.tgz +0 -0
  49. package/xsolla-payment-client-core-0.2.90.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,419 @@ 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.emitFlowErrors(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
- }
2167
- emitFlowUpdates(action) {
2168
- this.flowUpdatesSubject.next(action);
2169
2310
  }
2170
- emitFlowErrors(errors) {
2171
- if (errors.length === 0)
2172
- return;
2173
- this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(errors));
2311
+ convertValueForPostMessage(value) {
2312
+ if (value === null || value === undefined) {
2313
+ return null;
2314
+ }
2315
+ return String(value);
2174
2316
  }
2175
- fillNextActionsList() {
2176
- this.nextActionTokens.forEach((nextAction) => {
2177
- const item = this.injector.get(nextAction);
2178
- this.nextActionsList.push(item);
2179
- });
2317
+ isSubscription() {
2318
+ return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2319
+ 'subscription');
2180
2320
  }
2181
- findNextAction(submitResponse) {
2182
- const actionType = this.nextActionsList.find((nextAction) => {
2183
- return nextAction.isSuitable(submitResponse);
2184
- });
2185
- if (!actionType) {
2186
- return;
2187
- }
2188
- return actionType;
2321
+ getPaymentMethodId(instanceId) {
2322
+ return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2323
+ instanceId);
2189
2324
  }
2190
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }, { token: ShowErrorsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2191
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: NextActionService, providedIn: 'root' }); }
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' }); }
2192
2327
  }
2193
- 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: [{
2194
2329
  type: Injectable,
2195
2330
  args: [{
2196
2331
  providedIn: 'root',
2197
2332
  }]
2198
- }], ctorParameters: () => [{ type: undefined, decorators: [{
2333
+ }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2199
2334
  type: Inject,
2200
- args: [nextActionsToken]
2201
- }] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }] });
2202
-
2203
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2204
- const cardNumberSanctionErrorCodes = [
2205
- 2034, 2035, 5027, 5024, 5025, 2036,
2206
- ];
2207
-
2208
- const fieldSpecialErrorsMap = [
2209
- {
2210
- errorCodes: new Set(cardNumberSanctionErrorCodes),
2211
- fieldName: FieldNames.cardNumber,
2212
- },
2213
- ];
2335
+ args: [windowToken]
2336
+ }] }] });
2214
2337
 
2215
- class UnescapeHtmlPipe {
2216
- transform(html) {
2217
- if (!html) {
2218
- return '';
2219
- }
2220
- if (html.includes('&gt')) {
2221
- const messageDocument = new DOMParser().parseFromString(html, 'text/html');
2222
- return messageDocument?.documentElement?.textContent ?? '';
2223
- }
2224
- return html;
2338
+ class UserBehaviourAnalyticsService {
2339
+ set isPayWithSavedMethod(value) {
2340
+ this.userSessionOptions.isPayWithSavedMethod = value;
2225
2341
  }
2226
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
2227
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, name: "unescapeHtml" }); }
2228
- }
2229
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UnescapeHtmlPipe, decorators: [{
2230
- type: Pipe,
2231
- args: [{
2232
- name: 'unescapeHtml',
2233
- }]
2234
- }] });
2235
-
2236
- class XpsResponseErrorsMappingService {
2237
- constructor(unescapeHtmlPipe) {
2238
- this.unescapeHtmlPipe = unescapeHtmlPipe;
2342
+ set subscriptionPackageId(value) {
2343
+ this.userSessionOptions.subscriptionPackageId = value;
2239
2344
  }
2240
- mapErrors(response) {
2241
- if (!response.errors?.length) {
2242
- return response;
2243
- }
2244
- let mappedErrors = this.mapFieldSpecialErrors(response.errors);
2245
- mappedErrors = this.unescapeErrorsText(mappedErrors);
2246
- return {
2247
- ...response,
2248
- errors: mappedErrors,
2249
- };
2345
+ set couponCode(value) {
2346
+ this.userSessionOptions.couponCode = value;
2347
+ }
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
+ };
2250
2601
  }
2251
2602
  mapFieldSpecialErrors(errors) {
2252
2603
  return errors.map((error) => {
@@ -2556,409 +2907,104 @@ class CreditCardService {
2556
2907
  const binNumberLength = 6;
2557
2908
  return cardNumber.replace(/\s+/g, '').substring(0, binNumberLength);
2558
2909
  }
2559
- getAccountSuffix(cardNumber) {
2560
- const accountSuffixLength = 4;
2561
- return cardNumber
2562
- .replace(/\s+/g, '')
2563
- .substring(cardNumber.length - accountSuffixLength);
2564
- }
2565
- getTypeByNumber(cardNumber) {
2566
- cardNumber = cardNumber.replace(/\s+/g, '');
2567
- const cardSettings = orderedCardSettings.find((settings) => {
2568
- const isNumberMatched = settings.checkNumber(cardNumber);
2569
- return isNumberMatched ? settings.id : false;
2570
- });
2571
- return cardSettings ? cardSettings.id : defaultCard.id;
2572
- }
2573
- getCreditCardSettings(cardType) {
2574
- const creditCard = creditCardsMap[cardType];
2575
- if (!creditCard) {
2576
- return defaultCard;
2577
- }
2578
- return creditCard;
2579
- }
2580
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2581
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, providedIn: 'root' }); }
2582
- }
2583
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CreditCardService, decorators: [{
2584
- type: Injectable,
2585
- args: [{
2586
- providedIn: 'root',
2587
- }]
2588
- }] });
2589
-
2590
- // eslint-disable-next-line @typescript-eslint/naming-convention
2591
- class EncryptCreditCardService {
2592
- constructor(creditCardService) {
2593
- this.creditCardService = creditCardService;
2594
- this.secureFieldNames = [
2595
- 'xps_card_number',
2596
- 'xps_cvv',
2597
- 'xps_extra_cvv',
2598
- 'xps_card_year',
2599
- 'xps_card_month',
2600
- ];
2601
- this.jsEncrypt = new JSEncrypt();
2602
- }
2603
- setPublicKey(publicKey) {
2604
- this.jsEncrypt.setPublicKey(publicKey);
2605
- }
2606
- encryptCreditCard(request) {
2607
- if (request.xps_card_number) {
2608
- const openCard = this.createOpenCard(request);
2609
- request.xps_open_card = JSON.stringify(openCard);
2610
- }
2611
- const encryptedCard = this.createEncryptedCard(request);
2612
- if (request.xps_card_number || request.xps_extra_card_number) {
2613
- request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
2614
- }
2615
- this.secureFieldNames.forEach((secureFieldName) => {
2616
- delete request[secureFieldName];
2617
- });
2618
- return request;
2619
- }
2620
- encrypt(value) {
2621
- if (!this.jsEncrypt?.getPublicKey()) {
2622
- throw new EncryptCreditCardError('Empty public key');
2623
- }
2624
- const encryptedValue = this.jsEncrypt.encrypt(value);
2625
- if (!encryptedValue) {
2626
- throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
2627
- }
2628
- return encryptedValue;
2629
- }
2630
- createEncryptedCard(request) {
2631
- const encryptedCard = {
2632
- card_number: request.xps_card_number,
2633
- card_year: request.xps_card_year,
2634
- card_month: request.xps_card_month,
2635
- cvv: request.xps_cvv,
2636
- };
2637
- if (request.xps_extra_cvv) {
2638
- encryptedCard.cvv = request.xps_extra_cvv;
2639
- }
2640
- return encryptedCard;
2641
- }
2642
- createOpenCard(request) {
2643
- return {
2644
- card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
2645
- card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
2646
- card_year: request.xps_card_year,
2647
- card_month: request.xps_card_month,
2648
- };
2649
- }
2650
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2651
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' }); }
2652
- }
2653
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EncryptCreditCardService, decorators: [{
2654
- type: Injectable,
2655
- args: [{ providedIn: 'root' }]
2656
- }], ctorParameters: () => [{ type: CreditCardService }] });
2657
-
2658
- const eventCategories = {
2659
- withoutInvoice: 'withoutInvoice',
2660
- withInvoice: 'withInvoice',
2661
- };
2662
-
2663
- const oneTimeAnalyticsEvents = new Set([
2664
- UserBehaviourEventName.showMethodHeader,
2665
- ]);
2666
-
2667
- var EventParameterType;
2668
- (function (EventParameterType) {
2669
- EventParameterType["string"] = "0";
2670
- EventParameterType["int"] = "1";
2671
- EventParameterType["float"] = "2";
2672
- EventParameterType["bool"] = "3";
2673
- EventParameterType["intArray"] = "4";
2674
- EventParameterType["stringArray"] = "5";
2675
- })(EventParameterType || (EventParameterType = {}));
2676
-
2677
- class EventBuilderService {
2678
- constructor(settingsService, userAgentService, window) {
2679
- this.settingsService = settingsService;
2680
- this.userAgentService = userAgentService;
2681
- this.window = window;
2682
- }
2683
- createEvent(options, userSessionOptions) {
2684
- return {
2685
- action: options.action,
2686
- type: options.type,
2687
- value: this.convertToEventParameterType(options.value, options.valueType ?? EventParameterType.string),
2688
- state: options.state,
2689
- date: this.getDate(options.date),
2690
- milliseconds: options.date.getTime(),
2691
- timezone: this.getTimezone(options.date),
2692
- session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2693
- referrer_url: this.window?.document?.referrer,
2694
- project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2695
- payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2696
- this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2697
- geotype_id: this.convertToEventParameterType(options.invoice?.geotype_id, EventParameterType.int),
2698
- instance_id: this.convertToEventParameterType(options.instanceId ??
2699
- this.getPaymentMethodId(userSessionOptions.instanceId), EventParameterType.int),
2700
- payment_method_contr_id: this.convertToEventParameterType(options.invoice?.payment_method_contr_id, EventParameterType.int),
2701
- ps_type: this.convertToEventParameterType(options.invoice?.ps_type, EventParameterType.int),
2702
- is_pay_with_saved_method: this.convertToEventParameterType(userSessionOptions.isPayWithSavedMethod, EventParameterType.bool),
2703
- purchase_invoice_id: this.convertToEventParameterType(options.invoice?.purchase_invoice_id, EventParameterType.int),
2704
- purchase_external_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.purchase_external_id, EventParameterType.string),
2705
- purchase_type: this.settingsService.unsafeUtilsResponse?.purchase
2706
- ?.purchase_type,
2707
- purchase_sum: this.convertToEventParameterType(options.invoice?.purchase_sum, EventParameterType.float),
2708
- purchase_currency: this.convertToEventParameterType(options.invoice?.purchase_currency, EventParameterType.string),
2709
- purchase_sku: this.convertToEventParameterType(options.invoice?.purchase_sku, EventParameterType.string),
2710
- purchase_digital_content_sku: null,
2711
- purchase_description: this.convertToEventParameterType(options.invoice?.purchase_description, EventParameterType.string),
2712
- virtual_currency_amount: null, // TODO: add value
2713
- digital_content_cart_id: this.convertToEventParameterType(options.invoice?.digital_content_cart_id, EventParameterType.int),
2714
- digital_good_cart_id: this.convertToEventParameterType(options.invoice?.digital_good_cart_id, EventParameterType.int),
2715
- coupon_code: this.convertToEventParameterType(userSessionOptions.couponCode, EventParameterType.string),
2716
- theme_version: this.userAgentService.isMobileDevice
2717
- ? Device.mobile
2718
- : Device.desktop,
2719
- subscription_package_id: this.convertToEventParameterType(userSessionOptions.subscriptionPackageId, EventParameterType.int),
2720
- subscription_product_id: this.convertToEventParameterType(userSessionOptions.subscriptionProductId, EventParameterType.int),
2721
- subscription_recurrent_id: this.convertToEventParameterType(userSessionOptions.subscriptionRecurrentId, EventParameterType.int),
2722
- user_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.id, EventParameterType.string),
2723
- user_access_token: this.settingsService.token,
2724
- user_name: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.requisites?.v2, EventParameterType.string),
2725
- user_email: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.email?.value, EventParameterType.string),
2726
- user_country: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
2727
- user_ip: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.ip, EventParameterType.string),
2728
- user_mobile_operator_name: this.convertToEventParameterType(userSessionOptions.userMobileOperatorName, EventParameterType.string),
2729
- user_operation_system: this.userAgentService.platform,
2730
- user_browser: this.userAgentService.browserDescription,
2731
- user_browser_version: this.userAgentService.browserVersion,
2732
- user_locale: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.local, EventParameterType.string),
2733
- user_utm: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.user?.utm_parameters, EventParameterType.string),
2734
- xsolla_product_tag: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.xsolla_product_tag, EventParameterType.string),
2735
- experiment_id: null,
2736
- is_test_session: +isDevMode(),
2737
- babka_value: null,
2738
- extra_value: this.convertToEventParameterType(options?.extraValue, EventParameterType.string),
2739
- is_subscription: this.convertToEventParameterType(this.isSubscription(), EventParameterType.bool),
2740
- is_iframe: this.convertToEventParameterType(this.window.parent !== this.window, EventParameterType.bool),
2741
- web3wallet: null, // TODO: add value
2742
- dimension_1: this.convertToEventParameterType(options?.dimension1, EventParameterType.string),
2743
- dimension_2: this.convertToEventParameterType(options?.dimension2, EventParameterType.string),
2744
- dimension_3: this.convertToEventParameterType(options?.dimension3, EventParameterType.string),
2745
- dimension_4: this.convertToEventParameterType(options?.dimension4, EventParameterType.string),
2746
- dimension_5: this.convertToEventParameterType(options?.dimension5, EventParameterType.string),
2747
- client_version: 'Headless Checkout',
2748
- };
2749
- }
2750
- getDate(date) {
2751
- const nullIndex = 0;
2752
- return date.toISOString().replace('T', ' ').replace('Z', '').split('.')[nullIndex];
2753
- }
2754
- getTimezone(date) {
2755
- const hour = 60;
2756
- const nullHour = 0;
2757
- const hourOffset = -date.getTimezoneOffset() / hour;
2758
- if (hourOffset === nullHour) {
2759
- return '0';
2760
- }
2761
- return hourOffset > nullHour ? `+${hourOffset}` : hourOffset.toString();
2762
- }
2763
- convertToEventParameterType(value, type
2764
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2765
- ) {
2766
- if (value === null || value === undefined) {
2767
- return null;
2768
- }
2769
- if (typeof value === 'boolean') {
2770
- value = value ? 1 : 0;
2771
- }
2772
- switch (type) {
2773
- case EventParameterType.string:
2774
- return String(value);
2775
- case EventParameterType.int:
2776
- value = parseInt(String(value), 10);
2777
- return isNaN(value) ? 0 : value;
2778
- case EventParameterType.stringArray:
2779
- case EventParameterType.intArray:
2780
- return Array.isArray(value) ? value : [];
2781
- case EventParameterType.float:
2782
- value = parseFloat(String(value));
2783
- return isNaN(value) ? 0 : value;
2784
- case EventParameterType.bool:
2785
- return value ? 1 : 0;
2786
- }
2787
- }
2788
- convertValueForPostMessage(value) {
2789
- if (value === null || value === undefined) {
2790
- return null;
2791
- }
2792
- return String(value);
2910
+ getAccountSuffix(cardNumber) {
2911
+ const accountSuffixLength = 4;
2912
+ return cardNumber
2913
+ .replace(/\s+/g, '')
2914
+ .substring(cardNumber.length - accountSuffixLength);
2793
2915
  }
2794
- isSubscription() {
2795
- return (this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type ===
2796
- '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;
2797
2923
  }
2798
- getPaymentMethodId(instanceId) {
2799
- return (this.settingsService.unsafeUtilsResponse?.settings?.payment_system ??
2800
- instanceId);
2924
+ getCreditCardSettings(cardType) {
2925
+ const creditCard = creditCardsMap[cardType];
2926
+ if (!creditCard) {
2927
+ return defaultCard;
2928
+ }
2929
+ return creditCard;
2801
2930
  }
2802
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, deps: [{ token: SettingsService }, { token: UserAgentService }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable }); }
2803
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: EventBuilderService, providedIn: 'root' }); }
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' }); }
2804
2933
  }
2805
- 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: [{
2806
2935
  type: Injectable,
2807
2936
  args: [{
2808
2937
  providedIn: 'root',
2809
2938
  }]
2810
- }], ctorParameters: () => [{ type: SettingsService }, { type: UserAgentService }, { type: undefined, decorators: [{
2811
- type: Inject,
2812
- args: [windowToken]
2813
- }] }] });
2939
+ }] });
2814
2940
 
2815
- class UserBehaviourAnalyticsService {
2816
- set isPayWithSavedMethod(value) {
2817
- this.userSessionOptions.isPayWithSavedMethod = value;
2818
- }
2819
- set subscriptionPackageId(value) {
2820
- this.userSessionOptions.subscriptionPackageId = value;
2821
- }
2822
- set couponCode(value) {
2823
- this.userSessionOptions.couponCode = value;
2824
- }
2825
- set paymentStatus(value) {
2826
- this.userSessionOptions.paymentStatus = value;
2827
- }
2828
- get sessionOptions() {
2829
- return this.userSessionOptions;
2830
- }
2831
- get purchaseType() {
2832
- return this.settingsService.unsafeUtilsResponse?.purchase?.purchase_type
2833
- ? 'subscription'
2834
- : null;
2835
- }
2836
- constructor(http, eventBuilderService, settingsService) {
2837
- this.http = http;
2838
- this.eventBuilderService = eventBuilderService;
2839
- this.settingsService = settingsService;
2840
- this.apiUrl = 'https://datagather.xsolla.com/paystation-user-sessions';
2841
- this._events$ = new Subject();
2842
- this.userSessionOptions = {
2843
- invoice: null,
2844
- instanceId: null,
2845
- subscriptionRecurrentId: null,
2846
- userMobileOperatorName: null,
2847
- isPayWithSavedMethod: false,
2848
- subscriptionPackageId: null,
2849
- subscriptionProductId: null,
2850
- couponCode: null,
2851
- totalSum: null,
2852
- totalCurrency: null,
2853
- paymentInstanceName: null,
2854
- paymentStatus: null,
2855
- };
2856
- this.sentEvents = new Set();
2857
- }
2858
- init() {
2859
- this.setPid(this.settingsService.unsafeUtilsResponse?.purchase?.payment_system?.id);
2860
- this.onOpenPayStation();
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();
2861
2953
  }
2862
- setPid(pid) {
2863
- if (pid) {
2864
- this.userSessionOptions.instanceId = pid;
2865
- }
2954
+ setPublicKey(publicKey) {
2955
+ this.jsEncrypt.setPublicKey(publicKey);
2866
2956
  }
2867
- fillUserSession(paymentForm) {
2868
- if (paymentForm.subscriptionRecurrentId) {
2869
- this.userSessionOptions.subscriptionRecurrentId =
2870
- paymentForm.subscriptionRecurrentId;
2871
- }
2872
- const operator = paymentForm.fields.find((field) => field.name === 'operator');
2873
- if (operator) {
2874
- this.userSessionOptions.userMobileOperatorName = operator.value;
2875
- }
2876
- if (paymentForm.pid) {
2877
- this.setPid(paymentForm.pid);
2957
+ encryptCreditCard(request) {
2958
+ if (request.xps_card_number) {
2959
+ const openCard = this.createOpenCard(request);
2960
+ request.xps_open_card = JSON.stringify(openCard);
2878
2961
  }
2879
- if (paymentForm.userSession) {
2880
- this.userSessionOptions.invoice = paymentForm.userSession;
2881
- const createInvoiceOptions = {
2882
- eventCategory: eventCategories.withInvoice,
2883
- };
2884
- this.send('create-invoice', userBehaviourEventTypes.manual, createInvoiceOptions);
2885
- if (paymentForm.errors?.length) {
2886
- this.resetInvoice();
2887
- }
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));
2888
2965
  }
2889
- const total = paymentForm?.summary?.finance?.total;
2890
- if (total) {
2891
- this.userSessionOptions.totalSum = total.amount;
2892
- 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');
2893
2974
  }
2894
- if (paymentForm.title) {
2895
- 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');
2896
2978
  }
2979
+ return encryptedValue;
2897
2980
  }
2898
- send(action, type, options) {
2899
- if (oneTimeAnalyticsEvents.has(action) && this.sentEvents.has(action)) {
2900
- return;
2901
- }
2902
- const date = new Date();
2903
- const invoice = options?.eventCategory === eventCategories.withInvoice
2904
- ? this.userSessionOptions.invoice
2905
- : null;
2906
- const eventOptions = {
2907
- action,
2908
- type,
2909
- value: options?.value ?? null,
2910
- valueType: options?.valueType ?? null,
2911
- date,
2912
- invoice,
2913
- state: '',
2914
- extraValue: options?.extraValue ?? null,
2915
- purchase_type: options?.purchaseType ?? null,
2916
- instanceId: options?.instanceId ?? null,
2917
- dimension1: options?.dimension1 ?? null,
2918
- dimension2: options?.dimension2 ?? null,
2919
- dimension3: options?.dimension3 ?? null,
2920
- dimension4: options?.dimension4 ?? null,
2921
- dimension5: options?.dimension5 ?? null,
2922
- };
2923
- const sendEvent = () => {
2924
- this.sentEvents.add(action);
2925
- const event = this.eventBuilderService.createEvent(eventOptions, this.userSessionOptions);
2926
- this._events$.next(event);
2927
- const requestBody = JSON.stringify(event);
2928
- if (navigator.sendBeacon) {
2929
- navigator.sendBeacon(this.apiUrl, requestBody);
2930
- }
2931
- else {
2932
- void this.http.post(this.apiUrl, requestBody).toPromise();
2933
- }
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,
2934
2987
  };
2935
- if (options?.syncRequest) {
2936
- sendEvent();
2937
- return;
2988
+ if (request.xps_extra_cvv) {
2989
+ encryptedCard.cvv = request.xps_extra_cvv;
2938
2990
  }
2939
- setTimeout(() => sendEvent());
2940
- }
2941
- onOpenPayStation() {
2942
- this.send(UserBehaviourEventName.openPaystation, userBehaviourEventTypes.open, {
2943
- value: null,
2944
- purchaseType: this.purchaseType,
2945
- });
2946
- }
2947
- resetInvoice() {
2948
- this.userSessionOptions.invoice = null;
2991
+ return encryptedCard;
2949
2992
  }
2950
- resetPid() {
2951
- 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
+ };
2952
3000
  }
2953
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, deps: [{ token: i1.HttpClient }, { token: EventBuilderService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2954
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: UserBehaviourAnalyticsService, providedIn: 'root' }); }
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' }); }
2955
3003
  }
2956
- 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: [{
2957
3005
  type: Injectable,
2958
- args: [{
2959
- providedIn: 'root',
2960
- }]
2961
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
3006
+ args: [{ providedIn: 'root' }]
3007
+ }], ctorParameters: () => [{ type: CreditCardService }] });
2962
3008
 
2963
3009
  class PaymentSettingsService {
2964
3010
  getPaymentSettingsParams(config) {
@@ -3077,6 +3123,7 @@ class InitializeService {
3077
3123
  if (config.savedMethodId) {
3078
3124
  requestParams.saved_method_id = config.savedMethodId;
3079
3125
  }
3126
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.initializeRequest, userBehaviourEventTypes.manual, { value: requestParams.pid });
3080
3127
  return this.xpsApiService
3081
3128
  .directPaymentRequest(requestParams)
3082
3129
  .then((xpsResponse) => {
@@ -3265,6 +3312,7 @@ class SubmitService {
3265
3312
  // In this way two promises become unequal, that can broke XPS API requests logic.
3266
3313
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3267
3314
  request(fields, form, config) {
3315
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.submitRequest, userBehaviourEventTypes.manual, { value: config.paymentMethodId });
3268
3316
  return (this.deviceFingerPrintService
3269
3317
  .getHash()
3270
3318
  // eslint-disable-next-line @typescript-eslint/promise-function-async
@@ -3501,6 +3549,7 @@ class SyncService extends EmitDataService {
3501
3549
  ...paymentSettingsParams,
3502
3550
  });
3503
3551
  const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
3552
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.syncRequest, userBehaviourEventTypes.manual, { extraValue: field?.name ?? '' });
3504
3553
  return this.xpsApiService
3505
3554
  .directPaymentRequest(encryptedRequest)
3506
3555
  .then((xpsResponse) => {
@@ -4772,18 +4821,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
4772
4821
  }] }, { type: i0.Injector }] });
4773
4822
 
4774
4823
  class FormService {
4775
- constructor(controlConfigService) {
4824
+ constructor(controlConfigService, userBehaviourAnalyticsService) {
4776
4825
  this.controlConfigService = controlConfigService;
4826
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
4777
4827
  this.fieldFormStates = {};
4778
4828
  }
4779
4829
  createForm(fields) {
4780
- const controls = this.getVisibleFields(fields).reduce((result, field) => {
4830
+ const visibleFields = this.getVisibleFields(fields);
4831
+ const controls = visibleFields.reduce((result, field) => {
4781
4832
  const formControl = this.controlConfigService.getFormControl(field);
4782
4833
  if (formControl) {
4783
4834
  result[field.name] = formControl;
4784
4835
  }
4785
4836
  return result;
4786
4837
  }, {});
4838
+ this.logCreateForm(visibleFields);
4787
4839
  return new UntypedFormGroup(controls);
4788
4840
  }
4789
4841
  getFieldFormState(fieldName) {
@@ -4809,12 +4861,15 @@ class FormService {
4809
4861
  getVisibleFields(fields) {
4810
4862
  return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
4811
4863
  }
4812
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, deps: [{ token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
4813
4868
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService }); }
4814
4869
  }
4815
4870
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FormService, decorators: [{
4816
4871
  type: Injectable
4817
- }], ctorParameters: () => [{ type: ControlConfigService }] });
4872
+ }], ctorParameters: () => [{ type: ControlConfigService }, { type: UserBehaviourAnalyticsService }] });
4818
4873
 
4819
4874
  var StatusSearchParam;
4820
4875
  (function (StatusSearchParam) {
@@ -5637,20 +5692,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
5637
5692
  }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
5638
5693
 
5639
5694
  class FinanceDetailsService extends EmitDataService {
5640
- constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService) {
5695
+ constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService, userBehaviourAnalyticsService) {
5641
5696
  super();
5642
5697
  this.sessionService = sessionService;
5643
5698
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
5644
5699
  this.statusFinanceDetailsAdapterService = statusFinanceDetailsAdapterService;
5700
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
5645
5701
  this.purchaseSessionKey = 'purchase';
5646
5702
  }
5647
- emitWithSummary(summary) {
5703
+ emitWithSummary(summary, needLogCart = true) {
5648
5704
  if (summary) {
5649
5705
  const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5650
5706
  if (financeDetails.purchase) {
5651
5707
  this.sessionService.set(this.purchaseSessionKey, financeDetails.purchase);
5652
5708
  }
5653
5709
  super.emit(financeDetails);
5710
+ if (needLogCart) {
5711
+ this.logCartEvent(financeDetails);
5712
+ }
5654
5713
  }
5655
5714
  }
5656
5715
  emitWithStatus(status) {
@@ -5663,13 +5722,18 @@ class FinanceDetailsService extends EmitDataService {
5663
5722
  getDetailsFromSummary(summary) {
5664
5723
  return this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
5665
5724
  }
5666
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, deps: [{ token: SessionService }, { token: SummaryFinanceDetailsAdapterService }, { token: StatusFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
5667
5731
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' }); }
5668
5732
  }
5669
5733
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: FinanceDetailsService, decorators: [{
5670
5734
  type: Injectable,
5671
5735
  args: [{ providedIn: 'root' }]
5672
- }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }] });
5736
+ }], ctorParameters: () => [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }, { type: UserBehaviourAnalyticsService }] });
5673
5737
 
5674
5738
  /* eslint-disable @typescript-eslint/naming-convention */
5675
5739
  class CheckStatusRequest extends XpsApiPartRequest {
@@ -6249,7 +6313,7 @@ class ListenStatusService {
6249
6313
  const isStatusError = statusSettings.statusState === StatusEnum.canceled ||
6250
6314
  statusSettings.statusState === StatusEnum.error ||
6251
6315
  statusSettings.isCancelUser;
6252
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.statusUpdated, userBehaviourEventTypes.manual, {
6316
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.changeStatus, userBehaviourEventTypes.manual, {
6253
6317
  instanceId: statusResponse.status.pid,
6254
6318
  value: statusResponse.status.statusState,
6255
6319
  });
@@ -6272,6 +6336,9 @@ class ListenStatusService {
6272
6336
  .subscribe((checkStatusResponse) => {
6273
6337
  if (!checkStatusResponse?.status)
6274
6338
  return;
6339
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.checkStatusUpdate, userBehaviourEventTypes.manual, {
6340
+ value: checkStatusResponse.status ?? '',
6341
+ });
6275
6342
  if (checkStatusResponse.status === StatusEnum.done) {
6276
6343
  this.statusService.request();
6277
6344
  this.websocketStatusService.closeWebSocket();
@@ -6589,8 +6656,9 @@ const initializeNextActions = [
6589
6656
  ];
6590
6657
 
6591
6658
  class InitializeNextActionService {
6592
- constructor(initializeNextActionTokens, injector) {
6659
+ constructor(initializeNextActionTokens, userBehaviourAnalyticsService, injector) {
6593
6660
  this.initializeNextActionTokens = initializeNextActionTokens;
6661
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6594
6662
  this.injector = injector;
6595
6663
  this.initializeNextActionsList = [];
6596
6664
  this.fillNextActionsList();
@@ -6599,6 +6667,7 @@ class InitializeNextActionService {
6599
6667
  const nextAction = this.findNextAction(response);
6600
6668
  if (!nextAction)
6601
6669
  return null;
6670
+ this.logNextAction(nextAction);
6602
6671
  return nextAction.getActionData(response);
6603
6672
  }
6604
6673
  fillNextActionsList() {
@@ -6612,7 +6681,10 @@ class InitializeNextActionService {
6612
6681
  return nextAction.isSuitable(response);
6613
6682
  });
6614
6683
  }
6615
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, deps: [{ token: initializeNextActionsToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
6616
6688
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, providedIn: 'root' }); }
6617
6689
  }
6618
6690
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeNextActionService, decorators: [{
@@ -6623,7 +6695,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
6623
6695
  }], ctorParameters: () => [{ type: undefined, decorators: [{
6624
6696
  type: Inject,
6625
6697
  args: [initializeNextActionsToken]
6626
- }] }, { type: i0.Injector }] });
6698
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
6627
6699
 
6628
6700
  var ThreeDsStatusWebSocketTypes;
6629
6701
  (function (ThreeDsStatusWebSocketTypes) {
@@ -6914,12 +6986,13 @@ class ThreeDs20Service {
6914
6986
  get statusUpdates$() {
6915
6987
  return this.statusUpdates.asObservable();
6916
6988
  }
6917
- constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService) {
6989
+ constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService, userBehaviourAnalyticsService) {
6918
6990
  this.statusThreeDsService = statusThreeDsService;
6919
6991
  this.notifyDfpStatusService = notifyDfpStatusService;
6920
6992
  this.webSocketFactory = webSocketFactory;
6921
6993
  this.dfpCollectService = dfpCollectService;
6922
6994
  this.reinsuranceCheckService = reinsuranceCheckService;
6995
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
6923
6996
  this.webSocketClient = null;
6924
6997
  this.statusUpdates = new Subject();
6925
6998
  this.statusRequestSubscription = null;
@@ -6972,6 +7045,7 @@ class ThreeDs20Service {
6972
7045
  }
6973
7046
  if (threeDsStatus.status === ThreeDsStatusTypes.completed) {
6974
7047
  this.stopReinsuranceMethods();
7048
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2complete, userBehaviourEventTypes.manual);
6975
7049
  this.statusUpdates.next({
6976
7050
  type: 'complete',
6977
7051
  data: {
@@ -6983,6 +7057,7 @@ class ThreeDs20Service {
6983
7057
  if (threeDsStatus.status === ThreeDsStatusTypes.challenge &&
6984
7058
  threeDsStatus.checkoutForm) {
6985
7059
  this.stopReinsuranceMethods();
7060
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2challenge, userBehaviourEventTypes.manual);
6986
7061
  this.statusUpdates.next({
6987
7062
  type: 'challenge',
6988
7063
  data: threeDsStatus.checkoutForm,
@@ -6990,6 +7065,7 @@ class ThreeDs20Service {
6990
7065
  }
6991
7066
  if (threeDsStatus.status === ThreeDsStatusTypes.collectDfp) {
6992
7067
  this.dfpCollectService.collectDfpStatus(threeDsForm);
7068
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.threeDs2collectDfp, userBehaviourEventTypes.manual);
6993
7069
  }
6994
7070
  });
6995
7071
  }
@@ -6999,7 +7075,7 @@ class ThreeDs20Service {
6999
7075
  this.webSocketClient?.close();
7000
7076
  this.statusRequestSubscription?.unsubscribe();
7001
7077
  }
7002
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, deps: [{ token: StatusThreeDsService }, { token: NotifyDfpStatusService }, { token: WebSocketFactory }, { token: DfpCollectService }, { token: ReinsuranceCheckService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
7003
7079
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, providedIn: 'root' }); }
7004
7080
  }
7005
7081
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ThreeDs20Service, decorators: [{
@@ -7007,7 +7083,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7007
7083
  args: [{
7008
7084
  providedIn: 'root',
7009
7085
  }]
7010
- }], 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 }] });
7011
7087
 
7012
7088
  class ThreeDsService {
7013
7089
  constructor(threeDs20Service, nextActionService, checkStatusActionCreator, threeDsActionCreator) {
@@ -7137,6 +7213,7 @@ const isInitializeResponse = (value) => {
7137
7213
  class ApplePayWithShippingAddressStrategy extends BehaviourStrategy {
7138
7214
  constructor() {
7139
7215
  super();
7216
+ this.name = 'ApplePayWithShippingAddressStrategy';
7140
7217
  }
7141
7218
  isSuitable() {
7142
7219
  if (isInitializeResponse(this.paymentData)) {
@@ -7176,6 +7253,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7176
7253
  class GooglePayInstantFlowStrategy extends BehaviourStrategy {
7177
7254
  constructor() {
7178
7255
  super();
7256
+ this.name = 'GooglePayInstantFlowStrategy';
7179
7257
  }
7180
7258
  isSuitable() {
7181
7259
  if (!isInitializeResponse(this.paymentData)) {
@@ -7211,6 +7289,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7211
7289
  class GooglePayRegularFlowStrategy extends BehaviourStrategy {
7212
7290
  constructor() {
7213
7291
  super();
7292
+ this.name = 'GooglePayRegularFlowStrategy';
7214
7293
  }
7215
7294
  isSuitable() {
7216
7295
  if (!isInitializeResponse(this.paymentData)) {
@@ -7246,22 +7325,30 @@ const behaviourStrategies = [
7246
7325
  ];
7247
7326
 
7248
7327
  class PaymentBehaviourService {
7249
- constructor(behaviourStrategyTokens, injector) {
7328
+ constructor(behaviourStrategyTokens, userBehaviourAnalyticsService, injector) {
7250
7329
  this.behaviourStrategyTokens = behaviourStrategyTokens;
7330
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7251
7331
  this.injector = injector;
7252
7332
  }
7253
7333
  getApplicableBehaviourStrategies(paymentData, config) {
7254
7334
  const strategies = this.getBehaviourStrategies();
7255
- return strategies.filter((behaviourStrategy) => {
7335
+ const applicableStrategies = strategies.filter((behaviourStrategy) => {
7256
7336
  behaviourStrategy.setPaymentData(paymentData);
7257
7337
  behaviourStrategy.setPaymentConfig(config);
7258
7338
  return behaviourStrategy.isSuitable();
7259
7339
  });
7340
+ this.logApplicableStrategies(applicableStrategies);
7341
+ return applicableStrategies;
7260
7342
  }
7261
7343
  getBehaviourStrategies() {
7262
7344
  return this.behaviourStrategyTokens.map((behaviourStrategyToken) => this.injector.get(behaviourStrategyToken));
7263
7345
  }
7264
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, deps: [{ token: behaviourStrategiesToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
7265
7352
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService }); }
7266
7353
  }
7267
7354
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, decorators: [{
@@ -7269,7 +7356,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7269
7356
  }], ctorParameters: () => [{ type: undefined, decorators: [{
7270
7357
  type: Inject,
7271
7358
  args: [behaviourStrategiesToken]
7272
- }] }, { type: i0.Injector }] });
7359
+ }] }, { type: UserBehaviourAnalyticsService }, { type: i0.Injector }] });
7273
7360
 
7274
7361
  class PaymentService {
7275
7362
  get formFieldsStatus$() {
@@ -7284,7 +7371,7 @@ class PaymentService {
7284
7371
  get formResponseValue() {
7285
7372
  return this._formResponse$.getValue();
7286
7373
  }
7287
- 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) {
7288
7375
  this.loggerService = loggerService;
7289
7376
  this.initializeService = initializeService;
7290
7377
  this.submitService = submitService;
@@ -7304,11 +7391,13 @@ class PaymentService {
7304
7391
  this.printInstructionService = printInstructionService;
7305
7392
  this.paymentBehaviourService = paymentBehaviourService;
7306
7393
  this.translateService = translateService;
7394
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
7307
7395
  this.form = null;
7308
7396
  this.data = null;
7309
7397
  this.financeDetails = null;
7310
7398
  this.focusFieldName = null;
7311
7399
  this.fields = [];
7400
+ this.isSubmitAttempted = false;
7312
7401
  this.destroy$ = new Subject();
7313
7402
  this.formDestroy$ = new Subject();
7314
7403
  this._paymentForm$ = new BehaviorSubject(null);
@@ -7319,6 +7408,7 @@ class PaymentService {
7319
7408
  async initialize(config) {
7320
7409
  this.destroy$ = new Subject();
7321
7410
  this.formDestroy$ = new Subject();
7411
+ this.isSubmitAttempted = false;
7322
7412
  this.listenFinanceDetails();
7323
7413
  this.config = config;
7324
7414
  this.data = await this.initializeService.request(config);
@@ -7351,10 +7441,13 @@ class PaymentService {
7351
7441
  throw new Error('form is empty!');
7352
7442
  }
7353
7443
  if (!this.form.valid) {
7444
+ this.logSubmitAttempt();
7445
+ this.isSubmitAttempted = true;
7354
7446
  this.form.markAllAsTouched();
7355
7447
  this.emitFormFieldsStatus(this.form);
7356
7448
  return;
7357
7449
  }
7450
+ this.logSubmit();
7358
7451
  this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
7359
7452
  const submitResponse = await this.submitService.request(this.fields, this.form, this.config);
7360
7453
  this.handleSubmitWithErrors(submitResponse);
@@ -7362,7 +7455,7 @@ class PaymentService {
7362
7455
  this.initializeBehaviourStrategies();
7363
7456
  this.emitFormResponse(this.data);
7364
7457
  if (!this.isSavingMethodMode) {
7365
- this.emitFinanceDetails(submitResponse.summary);
7458
+ this.emitFinanceDetails(submitResponse.summary, false);
7366
7459
  }
7367
7460
  this.emitFormMessages(submitResponse.messages);
7368
7461
  // Handle 3ds flow
@@ -7389,7 +7482,7 @@ class PaymentService {
7389
7482
  this.data = submitResponse;
7390
7483
  this.emitFormResponse(this.data);
7391
7484
  if (!this.isSavingMethodMode) {
7392
- this.emitFinanceDetails(submitResponse.summary);
7485
+ this.emitFinanceDetails(submitResponse.summary, false);
7393
7486
  }
7394
7487
  this.emitFormMessages(submitResponse.messages);
7395
7488
  this.fields = this.getFields();
@@ -7613,8 +7706,8 @@ class PaymentService {
7613
7706
  this.destroy$.next();
7614
7707
  this.threeDsService.stopChecking();
7615
7708
  }
7616
- emitFinanceDetails(summary) {
7617
- this.financeDetailsService.emitWithSummary(summary);
7709
+ emitFinanceDetails(summary, needLogCart = true) {
7710
+ this.financeDetailsService.emitWithSummary(summary, needLogCart);
7618
7711
  }
7619
7712
  emitCreditCardState({ idCardType, cardBinCountry, }) {
7620
7713
  this.creditCardStateService.emit({ idCardType, cardBinCountry });
@@ -7760,7 +7853,20 @@ class PaymentService {
7760
7853
  }, new Map());
7761
7854
  updateAfterErrorRules.forEach((rule) => rule.apply(submitResponse, fieldsMap));
7762
7855
  }
7763
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, deps: [{ token: LoggerService }, { token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: InitializeNextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }, { token: CheckStatusActionCreator }, { token: PrintInstructionService }, { token: PaymentBehaviourService }, { token: i19.TranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
7764
7870
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, providedIn: 'root' }); }
7765
7871
  }
7766
7872
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, decorators: [{
@@ -7768,7 +7874,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7768
7874
  args: [{
7769
7875
  providedIn: 'root',
7770
7876
  }]
7771
- }], ctorParameters: () => [{ type: LoggerService }, { type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: InitializeNextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }, { type: PrintInstructionService }, { type: PaymentBehaviourService }, { type: i19.TranslateService }] });
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 }] });
7772
7878
 
7773
7879
  const euCountries = new Set([
7774
7880
  'AT',
@@ -8800,7 +8906,8 @@ class ApplePayCartService {
8800
8906
  get cartRecalculationRequest$() {
8801
8907
  return this.cartRecalculationRequest.asObservable();
8802
8908
  }
8803
- constructor(summaryFinanceDetailsAdapterService) {
8909
+ constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
8910
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8804
8911
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
8805
8912
  this.cartSuccessfulRecalculated = new Subject();
8806
8913
  this.cartErrorRecalculated = new Subject();
@@ -8818,6 +8925,10 @@ class ApplePayCartService {
8818
8925
  zip: parsedZip,
8819
8926
  country,
8820
8927
  });
8928
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
8929
+ dimension1: country,
8930
+ dimension2: parsedZip || '',
8931
+ });
8821
8932
  }
8822
8933
  buildShippingContactUpdate(paymentParams, updatedPrice) {
8823
8934
  return {
@@ -8841,6 +8952,7 @@ class ApplePayCartService {
8841
8952
  this.cartSuccessfulRecalculated.next(updatedPrice);
8842
8953
  }
8843
8954
  sendErrorRecalculatedCart(error) {
8955
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
8844
8956
  this.cartErrorRecalculated.next(error);
8845
8957
  }
8846
8958
  isZipCountry(country) {
@@ -8875,7 +8987,7 @@ class ApplePayCartService {
8875
8987
  getTotalAmount(finance) {
8876
8988
  return finance?.grand_total?.amount ?? finance?.total?.amount;
8877
8989
  }
8878
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
8879
8991
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
8880
8992
  }
8881
8993
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -8883,14 +8995,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8883
8995
  args: [{
8884
8996
  providedIn: 'root',
8885
8997
  }]
8886
- }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
8998
+ }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
8887
8999
 
8888
9000
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8889
- constructor(window, loggerService, applePayCartService) {
9001
+ constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
8890
9002
  super();
8891
9003
  this.window = window;
8892
9004
  this.loggerService = loggerService;
8893
9005
  this.applePayCartService = applePayCartService;
9006
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8894
9007
  this.paymentClient = null;
8895
9008
  }
8896
9009
  setClient(client) {
@@ -8908,14 +9021,18 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8908
9021
  const applePayRequest = this.paymentClient.createPaymentRequest(request);
8909
9022
  const session = new this.window.ApplePaySession(applePayVersion, applePayRequest);
8910
9023
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9024
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
8911
9025
  session.onshippingcontactselected = (event) => {
9026
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
8912
9027
  this.applePayCartService.cartSuccessfulRecalculated$
8913
9028
  .pipe(take(1))
8914
9029
  .subscribe((updatedPrice) => {
8915
9030
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9031
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
8916
9032
  session.completeShippingContactSelection(contactUpdate);
8917
9033
  });
8918
9034
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9035
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
8919
9036
  session.completeShippingContactSelection({
8920
9037
  errors: [error],
8921
9038
  newTotal: {
@@ -8928,6 +9045,10 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8928
9045
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
8929
9046
  };
8930
9047
  session.onvalidatemerchant = (event) => {
9048
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9049
+ value: event.validationURL,
9050
+ extraValue: params.totalLabel,
9051
+ });
8931
9052
  const validationParams = {
8932
9053
  validationURL: event.validationURL,
8933
9054
  displayName: params.totalLabel,
@@ -8942,12 +9063,14 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8942
9063
  session.completeMerchantValidation(merchantSession);
8943
9064
  })
8944
9065
  .catch((error) => {
9066
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
8945
9067
  console.error(ApplePayErrors.merchantValidationError, error);
8946
9068
  session.abort();
8947
9069
  applePayFinallyCallback();
8948
9070
  });
8949
9071
  };
8950
9072
  session.onpaymentauthorized = (event) => {
9073
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
8951
9074
  this.paymentClient
8952
9075
  ?.tokenize({ token: event.payment.token })
8953
9076
  .then((response) => {
@@ -8960,19 +9083,21 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8960
9083
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
8961
9084
  })
8962
9085
  .catch((error) => {
9086
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
8963
9087
  console.error('Apple Pay: Tokenization error', error);
8964
9088
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
8965
9089
  applePayFinallyCallback();
8966
9090
  });
8967
9091
  };
8968
9092
  session.oncancel = (event) => {
9093
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
8969
9094
  console.error(ApplePayErrors.cancelled, event);
8970
9095
  this.emitError(ApplePayErrors.cancelled);
8971
9096
  applePayFinallyCallback();
8972
9097
  };
8973
9098
  session.begin();
8974
9099
  }
8975
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
8976
9101
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler }); }
8977
9102
  }
8978
9103
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -8980,26 +9105,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8980
9105
  }], ctorParameters: () => [{ type: undefined, decorators: [{
8981
9106
  type: Inject,
8982
9107
  args: [windowToken]
8983
- }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9108
+ }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
8984
9109
 
8985
9110
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8986
- constructor(window, http, applePayCartService) {
9111
+ constructor(window, http, applePayCartService, userBehaviourAnalyticsService) {
8987
9112
  super();
8988
9113
  this.window = window;
8989
9114
  this.http = http;
8990
9115
  this.applePayCartService = applePayCartService;
9116
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
8991
9117
  }
8992
9118
  startSession(params, additionalParams, applePayFinallyCallback) {
8993
9119
  const request = this.buildPaymentRequest(params);
8994
9120
  const session = new this.window.ApplePaySession(applePayVersion, request);
8995
9121
  session.onshippingcontactselected = (event) => {
9122
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
8996
9123
  this.applePayCartService.cartSuccessfulRecalculated$
8997
9124
  .pipe(take(1))
8998
9125
  .subscribe((updatedPrice) => {
8999
9126
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9127
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
9000
9128
  session.completeShippingContactSelection(contactUpdate);
9001
9129
  });
9002
9130
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9131
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
9003
9132
  session.completeShippingContactSelection({
9004
9133
  errors: [error],
9005
9134
  newTotal: {
@@ -9012,6 +9141,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9012
9141
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9013
9142
  };
9014
9143
  session.onvalidatemerchant = (event) => {
9144
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9145
+ value: event.validationURL,
9146
+ extraValue: params.totalLabel,
9147
+ });
9015
9148
  const validationParams = {
9016
9149
  validationURL: event.validationURL,
9017
9150
  accountId: params.payInstanceAccountId,
@@ -9031,6 +9164,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9031
9164
  session.completeMerchantValidation(response.merchantSession);
9032
9165
  },
9033
9166
  error: (error) => {
9167
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9034
9168
  console.error(ApplePayErrors.merchantValidationError, error);
9035
9169
  session.abort();
9036
9170
  applePayFinallyCallback();
@@ -9038,6 +9172,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9038
9172
  });
9039
9173
  };
9040
9174
  session.onpaymentauthorized = (event) => {
9175
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9041
9176
  this.payment.next(JSON.stringify({
9042
9177
  token: event.payment.token ?? '',
9043
9178
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9047,13 +9182,14 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9047
9182
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9048
9183
  };
9049
9184
  session.oncancel = (event) => {
9185
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9050
9186
  console.error(ApplePayErrors.cancelled, event);
9051
9187
  this.emitError(ApplePayErrors.cancelled);
9052
9188
  applePayFinallyCallback();
9053
9189
  };
9054
9190
  session.begin();
9055
9191
  }
9056
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
9057
9193
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler }); }
9058
9194
  }
9059
9195
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9061,7 +9197,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9061
9197
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9062
9198
  type: Inject,
9063
9199
  args: [windowToken]
9064
- }] }, { type: i1.HttpClient }, { type: ApplePayCartService }] });
9200
+ }] }, { type: i1.HttpClient }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9065
9201
 
9066
9202
  class PaymentBehaviourModule {
9067
9203
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -9287,8 +9423,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9287
9423
  }] }] });
9288
9424
 
9289
9425
  class GooglePayCheckoutPaymentService {
9290
- constructor(paymentSystemProcessingService) {
9426
+ constructor(paymentSystemProcessingService, userBehaviourAnalyticsService) {
9291
9427
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9428
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9292
9429
  this.checkout = null;
9293
9430
  }
9294
9431
  preparePayment({ initParams, checkDeviceData, }) {
@@ -9328,6 +9465,7 @@ class GooglePayCheckoutPaymentService {
9328
9465
  return paymentDataRequest.allowedPaymentMethods;
9329
9466
  }
9330
9467
  handleSuccessfulPayment(response) {
9468
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleSuccessfulPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '' });
9331
9469
  if (!this.checkout)
9332
9470
  return;
9333
9471
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -9336,6 +9474,7 @@ class GooglePayCheckoutPaymentService {
9336
9474
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
9337
9475
  }
9338
9476
  handleFailedPayment(error) {
9477
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleFailedPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '' });
9339
9478
  if (!this.checkout)
9340
9479
  return;
9341
9480
  const statusCode = error?.statusCode;
@@ -9348,7 +9487,7 @@ class GooglePayCheckoutPaymentService {
9348
9487
  isCancelledStatus(statusCode) {
9349
9488
  return statusCode.toLowerCase() === 'canceled';
9350
9489
  }
9351
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
9352
9491
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
9353
9492
  }
9354
9493
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -9356,7 +9495,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9356
9495
  args: [{
9357
9496
  providedIn: 'root',
9358
9497
  }]
9359
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }] });
9498
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }] });
9360
9499
 
9361
9500
  class GooglePayInstantPaymentService {
9362
9501
  constructor(summaryFinanceDetailsAdapterService) {
@@ -9949,10 +10088,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9949
10088
  }], ctorParameters: () => [{ type: SecureApiClient }] });
9950
10089
 
9951
10090
  class ApplePayExternalWindowCommunicationService {
9952
- constructor(window, webSocketFactory, socketBridgeService) {
10091
+ constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
9953
10092
  this.window = window;
9954
10093
  this.webSocketFactory = webSocketFactory;
9955
10094
  this.socketBridgeService = socketBridgeService;
10095
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9956
10096
  }
9957
10097
  getWindowClose$() {
9958
10098
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -9977,6 +10117,7 @@ class ApplePayExternalWindowCommunicationService {
9977
10117
  return this.getEventSource(isRecalculateCartMessage);
9978
10118
  }
9979
10119
  async openWebSocketConnection(token) {
10120
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
9980
10121
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
9981
10122
  if (this.websocketClient) {
9982
10123
  this.websocketClient.close();
@@ -9985,6 +10126,7 @@ class ApplePayExternalWindowCommunicationService {
9985
10126
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
9986
10127
  }
9987
10128
  async sendMessageToAnotherWindow(command, payload) {
10129
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
9988
10130
  await this.socketBridgeService.publishMessage(command, payload);
9989
10131
  }
9990
10132
  getEventSource(eventHandler) {
@@ -9993,7 +10135,7 @@ class ApplePayExternalWindowCommunicationService {
9993
10135
  return JSON.parse(message);
9994
10136
  }), filter(eventHandler));
9995
10137
  }
9996
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
9997
10139
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
9998
10140
  }
9999
10141
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -10004,7 +10146,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
10004
10146
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10005
10147
  type: Inject,
10006
10148
  args: [windowToken]
10007
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10149
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10008
10150
 
10009
10151
  class ApplePayService {
10010
10152
  get paymentParameters() {
@@ -10047,7 +10189,7 @@ class ApplePayService {
10047
10189
  .getWindowReturnMessage$()
10048
10190
  .pipe(takeUntil(this.destroy$));
10049
10191
  }
10050
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10192
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10051
10193
  this.window = window;
10052
10194
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10053
10195
  this.braintreeHandler = braintreeHandler;
@@ -10056,6 +10198,7 @@ class ApplePayService {
10056
10198
  this.loggerService = loggerService;
10057
10199
  this.applePaySdkService = applePaySdkService;
10058
10200
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10201
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10059
10202
  this.settingsService = settingsService;
10060
10203
  this.payment = new Subject();
10061
10204
  this.error = new Subject();
@@ -10183,6 +10326,7 @@ class ApplePayService {
10183
10326
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
10184
10327
  }
10185
10328
  proceedCheckout(parameters, additionalParams) {
10329
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayAcquirer, 'manual', { value: parameters.acquirer });
10186
10330
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
10187
10331
  if (!sessionHandler) {
10188
10332
  console.error('Apple Pay: Unsupported acquirer:', parameters.acquirer);
@@ -10240,7 +10384,7 @@ class ApplePayService {
10240
10384
  this.applePayQrOpened.next();
10241
10385
  }
10242
10386
  }
10243
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: LoggerService }, { token: ApplePaySdkService }, { token: ApplePayExternalWindowCommunicationService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
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 }); }
10244
10388
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
10245
10389
  }
10246
10390
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
@@ -10251,7 +10395,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
10251
10395
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10252
10396
  type: Inject,
10253
10397
  args: [windowToken]
10254
- }] }, { 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 }] });
10255
10399
 
10256
10400
  /*
10257
10401
  * Public API Surface of core-library