@xsolla/payment-client-core 0.5.0 → 0.5.2

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 (26) hide show
  1. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +17 -9
  2. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +20 -10
  3. package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +19 -8
  4. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +40 -15
  5. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +32 -13
  6. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.mjs +8 -1
  7. package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +14 -8
  8. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +21 -9
  9. package/esm2022/lib/core/user-behaviour-analytics/event-builder/event-builder.service.mjs +2 -1
  10. package/esm2022/lib/core/user-behaviour-analytics/event-builder/user-behaviour-event.interface.mjs +1 -1
  11. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.mjs +1 -1
  12. package/esm2022/lib/version.mjs +2 -2
  13. package/fesm2022/xsolla-payment-client-core.mjs +154 -55
  14. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  15. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +4 -3
  16. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +4 -3
  17. package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +4 -3
  18. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +1 -3
  19. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +1 -3
  20. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.d.ts +4 -0
  21. package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +4 -3
  22. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +5 -3
  23. package/lib/core/user-behaviour-analytics/event-builder/user-behaviour-event.interface.d.ts +1 -0
  24. package/lib/core/user-behaviour-analytics/user-behaviour-analytics.interface.d.ts +12 -0
  25. package/lib/version.d.ts +1 -1
  26. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Inject, Injectable, isDevMode, Pipe, NgModule } from '@angular/core';
3
- import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, take, of, interval, throwError, share } from 'rxjs';
3
+ import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, take, of, interval, throwError, share, merge } from 'rxjs';
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
6
6
  import { UntypedFormGroup, Validators, UntypedFormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
@@ -13,7 +13,7 @@ import { CommonModule } from '@angular/common';
13
13
  import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/naming-convention
16
- const PAYMENT_CLIENT_CORE_VERSION = '0.5.0';
16
+ const PAYMENT_CLIENT_CORE_VERSION = '0.5.2';
17
17
 
18
18
  class TranslateHelper {
19
19
  static init(service) {
@@ -2575,6 +2575,7 @@ class EventBuilderService {
2575
2575
  timezone: this.getTimezone(options.date),
2576
2576
  session_id: this.settingsService.unsafeUtilsResponse?.user?.session_id ?? null,
2577
2577
  referrer_url: this.window?.document?.referrer,
2578
+ ancestor_origins: this.convertToEventParameterType(Array.from(this.window?.location?.ancestorOrigins ?? []), EventParameterType.stringArray),
2578
2579
  project_id: this.convertToEventParameterType(this.settingsService.unsafeUtilsResponse?.project?.id, EventParameterType.int),
2579
2580
  payment_country: this.convertToEventParameterType(options.invoice?.payment_country ??
2580
2581
  this.settingsService.unsafeUtilsResponse?.user?.country?.value, EventParameterType.string),
@@ -9476,6 +9477,7 @@ class ApplePaySessionHandlerAbstract {
9476
9477
  constructor() {
9477
9478
  this.payment = new Subject();
9478
9479
  this._errorSubject = new Subject();
9480
+ this._analyticsEventSubject = new Subject();
9479
9481
  }
9480
9482
  get error$() {
9481
9483
  return this._errorSubject.asObservable();
@@ -9483,9 +9485,15 @@ class ApplePaySessionHandlerAbstract {
9483
9485
  get payment$() {
9484
9486
  return this.payment.asObservable();
9485
9487
  }
9488
+ get analyticsEvent$() {
9489
+ return this._analyticsEventSubject.asObservable();
9490
+ }
9486
9491
  emitError(error) {
9487
9492
  this._errorSubject.next(error);
9488
9493
  }
9494
+ emitAnalyticsEvent(event) {
9495
+ this._analyticsEventSubject.next(event);
9496
+ }
9489
9497
  buildPaymentRequest(params) {
9490
9498
  return {
9491
9499
  total: {
@@ -9512,12 +9520,15 @@ class ApplePayCartService {
9512
9520
  get cartRecalculationRequest$() {
9513
9521
  return this.cartRecalculationRequest.asObservable();
9514
9522
  }
9515
- constructor(userBehaviourAnalyticsService, summaryFinanceDetailsAdapterService) {
9516
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9523
+ get analyticsEvent$() {
9524
+ return this.analyticsEvent.asObservable();
9525
+ }
9526
+ constructor(summaryFinanceDetailsAdapterService) {
9517
9527
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
9518
9528
  this.cartSuccessfulRecalculated = new Subject();
9519
9529
  this.cartErrorRecalculated = new Subject();
9520
9530
  this.cartRecalculationRequest = new Subject();
9531
+ this.analyticsEvent = new Subject();
9521
9532
  }
9522
9533
  recalculateCartTaxes(shippingContact) {
9523
9534
  const zip = shippingContact.postalCode;
@@ -9531,7 +9542,9 @@ class ApplePayCartService {
9531
9542
  zip: parsedZip,
9532
9543
  country,
9533
9544
  });
9534
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartTaxes, 'manual', {
9545
+ this.analyticsEvent.next({
9546
+ eventName: UserBehaviourEventName.applePayRecalculateCartTaxes,
9547
+ eventType: userBehaviourEventTypes.manual,
9535
9548
  dimension1: country,
9536
9549
  dimension2: parsedZip || '',
9537
9550
  });
@@ -9558,7 +9571,10 @@ class ApplePayCartService {
9558
9571
  this.cartSuccessfulRecalculated.next(updatedPrice);
9559
9572
  }
9560
9573
  sendErrorRecalculatedCart(error) {
9561
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayRecalculateCartError, 'manual');
9574
+ this.analyticsEvent.next({
9575
+ eventName: UserBehaviourEventName.applePayRecalculateCartError,
9576
+ eventType: userBehaviourEventTypes.manual,
9577
+ });
9562
9578
  this.cartErrorRecalculated.next(error);
9563
9579
  }
9564
9580
  isZipCountry(country) {
@@ -9593,7 +9609,7 @@ class ApplePayCartService {
9593
9609
  getTotalAmount(finance) {
9594
9610
  return finance?.grand_total?.amount ?? finance?.total?.amount;
9595
9611
  }
9596
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, deps: [{ token: UserBehaviourAnalyticsService }, { token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9612
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9597
9613
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
9598
9614
  }
9599
9615
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayCartService, decorators: [{
@@ -9601,15 +9617,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9601
9617
  args: [{
9602
9618
  providedIn: 'root',
9603
9619
  }]
9604
- }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }, { type: SummaryFinanceDetailsAdapterService }] });
9620
+ }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9605
9621
 
9606
9622
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9607
- constructor(window, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9623
+ constructor(window, loggerService, applePayCartService) {
9608
9624
  super();
9609
9625
  this.window = window;
9610
9626
  this.loggerService = loggerService;
9611
9627
  this.applePayCartService = applePayCartService;
9612
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9613
9628
  this.paymentClient = null;
9614
9629
  }
9615
9630
  setClient(client) {
@@ -9639,18 +9654,30 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9639
9654
  if (!session)
9640
9655
  return;
9641
9656
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
9642
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
9657
+ this.emitAnalyticsEvent({
9658
+ eventName: UserBehaviourEventName.applePayBraintreeStartSession,
9659
+ eventType: userBehaviourEventTypes.manual,
9660
+ });
9643
9661
  session.onshippingcontactselected = (event) => {
9644
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeSelectShipping, 'manual');
9662
+ this.emitAnalyticsEvent({
9663
+ eventName: UserBehaviourEventName.applePayBraintreeSelectShipping,
9664
+ eventType: userBehaviourEventTypes.manual,
9665
+ });
9645
9666
  this.applePayCartService.cartSuccessfulRecalculated$
9646
9667
  .pipe(take(1))
9647
9668
  .subscribe((updatedPrice) => {
9648
9669
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9649
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated, 'manual');
9670
+ this.emitAnalyticsEvent({
9671
+ eventName: UserBehaviourEventName.applePayBraintreeCartSuccessfulRecalculated,
9672
+ eventType: userBehaviourEventTypes.manual,
9673
+ });
9650
9674
  session.completeShippingContactSelection(contactUpdate);
9651
9675
  });
9652
9676
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9653
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeCartErrorRecalculated, 'manual');
9677
+ this.emitAnalyticsEvent({
9678
+ eventName: UserBehaviourEventName.applePayBraintreeCartErrorRecalculated,
9679
+ eventType: userBehaviourEventTypes.manual,
9680
+ });
9654
9681
  session.completeShippingContactSelection({
9655
9682
  errors: [error],
9656
9683
  newTotal: {
@@ -9663,7 +9690,9 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9663
9690
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9664
9691
  };
9665
9692
  session.onvalidatemerchant = (event) => {
9666
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchant, 'manual', {
9693
+ this.emitAnalyticsEvent({
9694
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchant,
9695
+ eventType: userBehaviourEventTypes.manual,
9667
9696
  value: event.validationURL,
9668
9697
  extraValue: params.totalLabel,
9669
9698
  });
@@ -9681,14 +9710,20 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9681
9710
  session.completeMerchantValidation(merchantSession);
9682
9711
  })
9683
9712
  .catch((error) => {
9684
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeValidateMerchantError, 'manual');
9713
+ this.emitAnalyticsEvent({
9714
+ eventName: UserBehaviourEventName.applePayBraintreeValidateMerchantError,
9715
+ eventType: userBehaviourEventTypes.manual,
9716
+ });
9685
9717
  console.error(ApplePayErrors.merchantValidationError, error);
9686
9718
  session.abort();
9687
9719
  applePayFinallyCallback();
9688
9720
  });
9689
9721
  };
9690
9722
  session.onpaymentauthorized = (event) => {
9691
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentAuthorized, 'manual');
9723
+ this.emitAnalyticsEvent({
9724
+ eventName: UserBehaviourEventName.applePayBraintreePaymentAuthorized,
9725
+ eventType: userBehaviourEventTypes.manual,
9726
+ });
9692
9727
  this.paymentClient
9693
9728
  ?.tokenize({ token: event.payment.token })
9694
9729
  .then((response) => {
@@ -9701,21 +9736,27 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
9701
9736
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9702
9737
  })
9703
9738
  .catch((error) => {
9704
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentTokenizationError, 'manual');
9739
+ this.emitAnalyticsEvent({
9740
+ eventName: UserBehaviourEventName.applePayBraintreePaymentTokenizationError,
9741
+ eventType: userBehaviourEventTypes.manual,
9742
+ });
9705
9743
  console.error('Apple Pay: Tokenization error', error);
9706
9744
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
9707
9745
  applePayFinallyCallback();
9708
9746
  });
9709
9747
  };
9710
9748
  session.oncancel = (event) => {
9711
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreePaymentCancel, 'manual');
9749
+ this.emitAnalyticsEvent({
9750
+ eventName: UserBehaviourEventName.applePayBraintreePaymentCancel,
9751
+ eventType: userBehaviourEventTypes.manual,
9752
+ });
9712
9753
  console.error(ApplePayErrors.cancelled, event);
9713
9754
  this.emitError(ApplePayErrors.cancelled);
9714
9755
  applePayFinallyCallback();
9715
9756
  };
9716
9757
  session.begin();
9717
9758
  }
9718
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9759
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9719
9760
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler }); }
9720
9761
  }
9721
9762
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -9723,16 +9764,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9723
9764
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9724
9765
  type: Inject,
9725
9766
  args: [windowToken]
9726
- }] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9767
+ }] }, { type: LoggerService }, { type: ApplePayCartService }] });
9727
9768
 
9728
9769
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9729
- constructor(window, http, loggerService, applePayCartService, userBehaviourAnalyticsService) {
9770
+ constructor(window, http, loggerService, applePayCartService) {
9730
9771
  super();
9731
9772
  this.window = window;
9732
9773
  this.http = http;
9733
9774
  this.loggerService = loggerService;
9734
9775
  this.applePayCartService = applePayCartService;
9735
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9736
9776
  }
9737
9777
  startSession(params, additionalParams, applePayFinallyCallback) {
9738
9778
  const request = this.buildPaymentRequest(params);
@@ -9750,16 +9790,25 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9750
9790
  if (!session)
9751
9791
  return;
9752
9792
  session.onshippingcontactselected = (event) => {
9753
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
9793
+ this.emitAnalyticsEvent({
9794
+ eventName: UserBehaviourEventName.applePayCheckoutSelectShipping,
9795
+ eventType: userBehaviourEventTypes.manual,
9796
+ });
9754
9797
  this.applePayCartService.cartSuccessfulRecalculated$
9755
9798
  .pipe(take(1))
9756
9799
  .subscribe((updatedPrice) => {
9757
9800
  const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
9758
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated, 'manual');
9801
+ this.emitAnalyticsEvent({
9802
+ eventName: UserBehaviourEventName.applePayCheckoutCartSuccessfulRecalculated,
9803
+ eventType: userBehaviourEventTypes.manual,
9804
+ });
9759
9805
  session.completeShippingContactSelection(contactUpdate);
9760
9806
  });
9761
9807
  this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
9762
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutCartErrorRecalculated, 'manual');
9808
+ this.emitAnalyticsEvent({
9809
+ eventName: UserBehaviourEventName.applePayCheckoutCartErrorRecalculated,
9810
+ eventType: userBehaviourEventTypes.manual,
9811
+ });
9763
9812
  session.completeShippingContactSelection({
9764
9813
  errors: [error],
9765
9814
  newTotal: {
@@ -9772,7 +9821,9 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9772
9821
  this.applePayCartService.recalculateCartTaxes(event.shippingContact);
9773
9822
  };
9774
9823
  session.onvalidatemerchant = (event) => {
9775
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchant, 'manual', {
9824
+ this.emitAnalyticsEvent({
9825
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchant,
9826
+ eventType: userBehaviourEventTypes.manual,
9776
9827
  value: event.validationURL,
9777
9828
  extraValue: params.totalLabel,
9778
9829
  });
@@ -9795,7 +9846,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9795
9846
  session.completeMerchantValidation(response.merchantSession);
9796
9847
  },
9797
9848
  error: (error) => {
9798
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutValidateMerchantError, 'manual');
9849
+ this.emitAnalyticsEvent({
9850
+ eventName: UserBehaviourEventName.applePayCheckoutValidateMerchantError,
9851
+ eventType: userBehaviourEventTypes.manual,
9852
+ });
9799
9853
  console.error(ApplePayErrors.merchantValidationError, error);
9800
9854
  session.abort();
9801
9855
  applePayFinallyCallback();
@@ -9803,7 +9857,10 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9803
9857
  });
9804
9858
  };
9805
9859
  session.onpaymentauthorized = (event) => {
9806
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentAuthorized, 'manual');
9860
+ this.emitAnalyticsEvent({
9861
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentAuthorized,
9862
+ eventType: userBehaviourEventTypes.manual,
9863
+ });
9807
9864
  this.payment.next(JSON.stringify({
9808
9865
  token: event.payment.token ?? '',
9809
9866
  email: event.payment.billingContact?.emailAddress ?? null,
@@ -9813,14 +9870,17 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
9813
9870
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
9814
9871
  };
9815
9872
  session.oncancel = (event) => {
9816
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutPaymentCancel, 'manual');
9873
+ this.emitAnalyticsEvent({
9874
+ eventName: UserBehaviourEventName.applePayCheckoutPaymentCancel,
9875
+ eventType: userBehaviourEventTypes.manual,
9876
+ });
9817
9877
  console.error(ApplePayErrors.cancelled, event);
9818
9878
  this.emitError(ApplePayErrors.cancelled);
9819
9879
  applePayFinallyCallback();
9820
9880
  };
9821
9881
  session.begin();
9822
9882
  }
9823
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9883
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: LoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9824
9884
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler }); }
9825
9885
  }
9826
9886
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -9828,7 +9888,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9828
9888
  }], ctorParameters: () => [{ type: undefined, decorators: [{
9829
9889
  type: Inject,
9830
9890
  args: [windowToken]
9831
- }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
9891
+ }] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }] });
9832
9892
 
9833
9893
  class PaymentBehaviourModule {
9834
9894
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
@@ -10054,11 +10114,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10054
10114
  }] }] });
10055
10115
 
10056
10116
  class GooglePayCheckoutPaymentService {
10057
- constructor(paymentSystemProcessingService, userBehaviourAnalyticsService, loggerService) {
10117
+ constructor(paymentSystemProcessingService, loggerService) {
10058
10118
  this.paymentSystemProcessingService = paymentSystemProcessingService;
10059
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10060
10119
  this.loggerService = loggerService;
10061
10120
  this.checkout = null;
10121
+ this.analyticsEvent = new Subject();
10122
+ }
10123
+ get analyticsEvent$() {
10124
+ return this.analyticsEvent.asObservable();
10062
10125
  }
10063
10126
  preparePayment({ initParams, checkDeviceData, }) {
10064
10127
  if (!initParams || !checkDeviceData.base64checkoutData) {
@@ -10103,7 +10166,11 @@ class GooglePayCheckoutPaymentService {
10103
10166
  return paymentDataRequest.allowedPaymentMethods;
10104
10167
  }
10105
10168
  handleSuccessfulPayment(response) {
10106
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleSuccessfulPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '' });
10169
+ this.analyticsEvent.next({
10170
+ eventName: UserBehaviourEventName.googlePayHandleSuccessfulPayment,
10171
+ eventType: userBehaviourEventTypes.manual,
10172
+ value: this.checkout?.request?.form?.fields?.returnSuccessUrl ?? '',
10173
+ });
10107
10174
  if (!this.checkout)
10108
10175
  return;
10109
10176
  let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
@@ -10112,7 +10179,11 @@ class GooglePayCheckoutPaymentService {
10112
10179
  this.paymentSystemProcessingService.emitStatusUrl(returnUrl);
10113
10180
  }
10114
10181
  handleFailedPayment(error) {
10115
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.googlePayHandleFailedPayment, 'manual', { value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '' });
10182
+ this.analyticsEvent.next({
10183
+ eventName: UserBehaviourEventName.googlePayHandleFailedPayment,
10184
+ eventType: userBehaviourEventTypes.manual,
10185
+ value: this.checkout?.request?.form?.fields?.returnFailUrl ?? '',
10186
+ });
10116
10187
  if (!this.checkout)
10117
10188
  return;
10118
10189
  const statusCode = error?.statusCode;
@@ -10125,7 +10196,7 @@ class GooglePayCheckoutPaymentService {
10125
10196
  isCancelledStatus(statusCode) {
10126
10197
  return statusCode.toLowerCase() === 'canceled';
10127
10198
  }
10128
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: UserBehaviourAnalyticsService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10199
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10129
10200
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
10130
10201
  }
10131
10202
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -10133,7 +10204,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10133
10204
  args: [{
10134
10205
  providedIn: 'root',
10135
10206
  }]
10136
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }, { type: LoggerService }] });
10207
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: LoggerService }] });
10137
10208
 
10138
10209
  class GooglePayInstantPaymentService {
10139
10210
  constructor(summaryFinanceDetailsAdapterService, loggerService) {
@@ -10267,19 +10338,19 @@ class GooglePayService {
10267
10338
  get googlePaymentClientWasInitialized() {
10268
10339
  return !!this.googlePaymentClient;
10269
10340
  }
10270
- constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector, userBehaviourAnalyticsService) {
10341
+ constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector) {
10271
10342
  this.window = window;
10272
10343
  this.loggerService = loggerService;
10273
10344
  this.paymentSystemProcessingService = paymentSystemProcessingService;
10274
10345
  this.googlePayCheckoutPaymentService = googlePayCheckoutPaymentService;
10275
10346
  this.googlePayInstantPaymentService = googlePayInstantPaymentService;
10276
10347
  this.injector = injector;
10277
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10278
10348
  this.googlePayScriptUrl = 'https://pay.google.com/gp/p/js/pay.js';
10279
10349
  this.readyToPay = new BehaviorSubject(null);
10280
10350
  this.paymentWindowIsReady = new Subject();
10281
10351
  this.paymentWindowIsClose = new Subject();
10282
10352
  this.error = new Subject();
10353
+ this.analyticsEvent = new Subject();
10283
10354
  this.paymentInProgress = false;
10284
10355
  this.googlePaymentClient = null;
10285
10356
  this.paymentService = null;
@@ -10296,6 +10367,9 @@ class GooglePayService {
10296
10367
  get error$() {
10297
10368
  return this.error.asObservable();
10298
10369
  }
10370
+ get analyticsEvent$() {
10371
+ return merge(this.analyticsEvent.asObservable(), this.googlePayCheckoutPaymentService.analyticsEvent$);
10372
+ }
10299
10373
  isReadyToPay() {
10300
10374
  return this.readyToPay.getValue();
10301
10375
  }
@@ -10368,7 +10442,11 @@ class GooglePayService {
10368
10442
  return Promise.resolve(null);
10369
10443
  }
10370
10444
  if (this.initParams.isInstantPayFlow) {
10371
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowOpen, userBehaviourEventTypes.open, { instanceId: googlePay });
10445
+ this.analyticsEvent.next({
10446
+ eventName: UserBehaviourEventName.sysInstantFlowOpen,
10447
+ eventType: userBehaviourEventTypes.open,
10448
+ instanceId: googlePay,
10449
+ });
10372
10450
  }
10373
10451
  const paymentDataRequest = this.paymentService.getPaymentRequest();
10374
10452
  if (!paymentDataRequest) {
@@ -10516,7 +10594,7 @@ class GooglePayService {
10516
10594
  }
10517
10595
  return allowedLocales.find((locale) => locale === userLocale) ?? 'en';
10518
10596
  }
10519
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10597
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
10520
10598
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, providedIn: 'root' }); }
10521
10599
  }
10522
10600
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, decorators: [{
@@ -10527,7 +10605,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10527
10605
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10528
10606
  type: Inject,
10529
10607
  args: [windowToken]
10530
- }] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }, { type: UserBehaviourAnalyticsService }] });
10608
+ }] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }] });
10531
10609
 
10532
10610
  var ApplePayIntegrationType;
10533
10611
  (function (ApplePayIntegrationType) {
@@ -10774,11 +10852,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10774
10852
  }], ctorParameters: () => [{ type: SecureApiClient }] });
10775
10853
 
10776
10854
  class ApplePayExternalWindowCommunicationService {
10777
- constructor(window, webSocketFactory, socketBridgeService, userBehaviourAnalyticsService) {
10855
+ constructor(window, webSocketFactory, socketBridgeService) {
10778
10856
  this.window = window;
10779
10857
  this.webSocketFactory = webSocketFactory;
10780
10858
  this.socketBridgeService = socketBridgeService;
10781
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10859
+ this.analyticsEvent = new Subject();
10860
+ }
10861
+ get analyticsEvent$() {
10862
+ return this.analyticsEvent.asObservable();
10782
10863
  }
10783
10864
  getWindowClose$() {
10784
10865
  const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
@@ -10803,7 +10884,10 @@ class ApplePayExternalWindowCommunicationService {
10803
10884
  return this.getEventSource(isRecalculateCartMessage);
10804
10885
  }
10805
10886
  async openWebSocketConnection(token) {
10806
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayOpenWebSocketConnection, 'manual');
10887
+ this.analyticsEvent.next({
10888
+ eventName: UserBehaviourEventName.applePayOpenWebSocketConnection,
10889
+ eventType: userBehaviourEventTypes.manual,
10890
+ });
10807
10891
  const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
10808
10892
  if (this.websocketClient) {
10809
10893
  this.websocketClient.close();
@@ -10812,7 +10896,11 @@ class ApplePayExternalWindowCommunicationService {
10812
10896
  await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
10813
10897
  }
10814
10898
  async sendMessageToAnotherWindow(command, payload) {
10815
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePaySendMessageToAnotherWindow, 'manual', { value: command });
10899
+ this.analyticsEvent.next({
10900
+ eventName: UserBehaviourEventName.applePaySendMessageToAnotherWindow,
10901
+ eventType: userBehaviourEventTypes.manual,
10902
+ value: command,
10903
+ });
10816
10904
  await this.socketBridgeService.publishMessage(command, payload);
10817
10905
  }
10818
10906
  getEventSource(eventHandler) {
@@ -10821,7 +10909,7 @@ class ApplePayExternalWindowCommunicationService {
10821
10909
  return JSON.parse(message);
10822
10910
  }), filter(eventHandler));
10823
10911
  }
10824
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10912
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10825
10913
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
10826
10914
  }
10827
10915
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
@@ -10832,7 +10920,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10832
10920
  }], ctorParameters: () => [{ type: undefined, decorators: [{
10833
10921
  type: Inject,
10834
10922
  args: [windowToken]
10835
- }] }, { type: WebSocketFactory }, { type: SocketBridgeService }, { type: UserBehaviourAnalyticsService }] });
10923
+ }] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
10836
10924
 
10837
10925
  class ApplePayService {
10838
10926
  get paymentParameters() {
@@ -10848,6 +10936,9 @@ class ApplePayService {
10848
10936
  get applePayQrOpened$() {
10849
10937
  return this.applePayQrOpened.asObservable();
10850
10938
  }
10939
+ get analyticsEvent$() {
10940
+ return merge(this.analyticsEvent.asObservable(), this.braintreeHandler.analyticsEvent$, this.checkoutHandler.analyticsEvent$, this.externalWindowCommunicationService.analyticsEvent$);
10941
+ }
10851
10942
  /* istanbul ignore next */
10852
10943
  get windowClosing$() {
10853
10944
  return this.applePaySdkService.windowClosing$;
@@ -10875,7 +10966,7 @@ class ApplePayService {
10875
10966
  .getWindowReturnMessage$()
10876
10967
  .pipe(takeUntil(this.destroy$));
10877
10968
  }
10878
- constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, userBehaviourAnalyticsService, settingsService) {
10969
+ constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, loggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
10879
10970
  this.window = window;
10880
10971
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
10881
10972
  this.braintreeHandler = braintreeHandler;
@@ -10884,12 +10975,12 @@ class ApplePayService {
10884
10975
  this.loggerService = loggerService;
10885
10976
  this.applePaySdkService = applePaySdkService;
10886
10977
  this.externalWindowCommunicationService = externalWindowCommunicationService;
10887
- this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
10888
10978
  this.settingsService = settingsService;
10889
10979
  this.payment = new Subject();
10890
10980
  this.error = new Subject();
10891
10981
  this.integrationType = new Subject();
10892
10982
  this.applePayQrOpened = new Subject();
10983
+ this.analyticsEvent = new Subject();
10893
10984
  this.destroy$ = new Subject();
10894
10985
  this.paymentClient = null;
10895
10986
  this.applePayParams = null;
@@ -11012,9 +11103,17 @@ class ApplePayService {
11012
11103
  this.applePayParams = this.appleParamsBuilder.updateParams(this.applePayParams, summary);
11013
11104
  }
11014
11105
  proceedCheckout(parameters, additionalParams) {
11015
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayAcquirer, 'manual', { value: parameters.acquirer });
11106
+ this.analyticsEvent.next({
11107
+ eventName: UserBehaviourEventName.applePayAcquirer,
11108
+ eventType: userBehaviourEventTypes.manual,
11109
+ value: parameters.acquirer,
11110
+ });
11016
11111
  if (additionalParams.isApplePayInstantFlowEnabled) {
11017
- this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowOpen, userBehaviourEventTypes.open, { instanceId: applePayId });
11112
+ this.analyticsEvent.next({
11113
+ eventName: UserBehaviourEventName.sysInstantFlowOpen,
11114
+ eventType: userBehaviourEventTypes.open,
11115
+ instanceId: applePayId,
11116
+ });
11018
11117
  }
11019
11118
  const sessionHandler = this.getSessionHandler(parameters.acquirer);
11020
11119
  if (!sessionHandler) {
@@ -11073,7 +11172,7 @@ class ApplePayService {
11073
11172
  this.applePayQrOpened.next();
11074
11173
  }
11075
11174
  }
11076
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", 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 }); }
11175
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", 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 }); }
11077
11176
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
11078
11177
  }
11079
11178
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayService, decorators: [{
@@ -11084,7 +11183,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11084
11183
  }], ctorParameters: () => [{ type: undefined, decorators: [{
11085
11184
  type: Inject,
11086
11185
  args: [windowToken]
11087
- }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: UserBehaviourAnalyticsService }, { type: SettingsService }] });
11186
+ }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
11088
11187
 
11089
11188
  /*
11090
11189
  * Public API Surface of core-library