@xsolla/payment-client-core 0.0.9 → 0.0.10-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 (53) hide show
  1. package/esm2020/lib/core/payment/emit-data.service.abstract.mjs +11 -0
  2. package/esm2020/lib/core/payment/finance-details/cart-item.interface.mjs +2 -0
  3. package/esm2020/lib/core/payment/finance-details/cart-line.interface.mjs +2 -0
  4. package/esm2020/lib/core/payment/finance-details/cart-pricing.interface.mjs +2 -0
  5. package/esm2020/lib/core/payment/finance-details/default-image-patterns.const.mjs +10 -0
  6. package/esm2020/lib/core/payment/finance-details/finance-details-response.token.mjs +8 -0
  7. package/esm2020/lib/core/payment/finance-details/finance-details.class.mjs +214 -0
  8. package/esm2020/lib/core/payment/finance-details/finance-details.service.mjs +25 -0
  9. package/esm2020/lib/core/payment/finance-details/price.helpers.mjs +15 -0
  10. package/esm2020/lib/core/payment/finance-details/price.interface.mjs +2 -0
  11. package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +2 -5
  12. package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +3 -3
  13. package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
  14. package/esm2020/lib/core/payment/initialize/initialize.service.mjs +4 -1
  15. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  16. package/esm2020/lib/core/payment/payment.service.mjs +42 -8
  17. package/esm2020/lib/core/payment/sync/sync.service.mjs +18 -3
  18. package/esm2020/lib/core/payment/xps-finance.interface.mjs +2 -0
  19. package/esm2020/lib/core/payment/xps-purchase.interface.mjs +2 -0
  20. package/esm2020/lib/core/payment/xps-response.interface.mjs +1 -1
  21. package/esm2020/lib/core/payment/xps-summary.interface.mjs +2 -0
  22. package/esm2020/lib/core-library.module.mjs +4 -1
  23. package/esm2020/lib/core-library.service.mjs +9 -6
  24. package/fesm2015/xsolla-payment-client-core.mjs +353 -17
  25. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  26. package/fesm2020/xsolla-payment-client-core.mjs +341 -17
  27. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  28. package/lib/core/payment/emit-data.service.abstract.d.ts +7 -0
  29. package/lib/core/payment/finance-details/cart-item.interface.d.ts +13 -0
  30. package/lib/core/payment/finance-details/cart-line.interface.d.ts +8 -0
  31. package/lib/core/payment/finance-details/cart-pricing.interface.d.ts +10 -0
  32. package/lib/core/payment/finance-details/default-image-patterns.const.d.ts +6 -0
  33. package/lib/core/payment/finance-details/finance-details-response.token.d.ts +7 -0
  34. package/lib/core/payment/finance-details/finance-details.class.d.ts +25 -0
  35. package/lib/core/payment/finance-details/finance-details.service.d.ts +12 -0
  36. package/lib/core/payment/finance-details/price.helpers.d.ts +6 -0
  37. package/lib/core/payment/finance-details/price.interface.d.ts +4 -0
  38. package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -2
  39. package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -0
  40. package/lib/core/payment/initialize/initialize.service.d.ts +1 -0
  41. package/lib/core/payment/payment.interface.d.ts +3 -2
  42. package/lib/core/payment/payment.service.d.ts +11 -3
  43. package/lib/core/payment/sync/sync.service.d.ts +6 -2
  44. package/lib/core/payment/xps-finance.interface.d.ts +57 -0
  45. package/lib/core/payment/xps-purchase.interface.d.ts +15 -0
  46. package/lib/core/payment/xps-response.interface.d.ts +2 -74
  47. package/lib/core/payment/xps-summary.interface.d.ts +6 -0
  48. package/lib/core-library.service.d.ts +3 -1
  49. package/package.json +1 -1
  50. package/xsolla-payment-client-core-0.0.10-2.tgz +0 -0
  51. package/esm2020/lib/core/payment/finance-details.interface.mjs +0 -2
  52. package/lib/core/payment/finance-details.interface.d.ts +0 -2
  53. package/xsolla-payment-client-core-0.0.9.tgz +0 -0
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
3
- import { firstValueFrom, lastValueFrom, map, BehaviorSubject, Subject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
3
+ import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
6
6
  import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
@@ -454,11 +454,14 @@ class InitializeService {
454
454
  this.settingsService = settingsService;
455
455
  this.countryService = countryService;
456
456
  this.apiRoute = 'directpayment';
457
+ // TODO PAYMENTS-15743: replace with new refer id for headless core
458
+ this.ps4ReferId = '22';
457
459
  }
458
460
  async request(config) {
459
461
  const requestParams = {
460
462
  access_token: this.settingsService.token,
461
463
  pid: String(config.paymentMethodId),
464
+ refer: this.ps4ReferId,
462
465
  country: this.countryService.getCountry(),
463
466
  returnUrl: config.returnUrl,
464
467
  };
@@ -856,6 +859,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
856
859
  args: [submitResponseFactoryToken]
857
860
  }] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: SecureApiClient }]; } });
858
861
 
862
+ class EmitDataService {
863
+ constructor() {
864
+ this.dataSubject = new Subject();
865
+ this.data$ = this.dataSubject.asObservable();
866
+ }
867
+ emit(data) {
868
+ this.dataSubject.next(data);
869
+ }
870
+ }
871
+
859
872
  class XpsRequest {
860
873
  addXpsParameters(parameters) {
861
874
  for (const key in parameters) {
@@ -920,8 +933,9 @@ const syncResponseFactoryProvider = {
920
933
  useValue: (...args) => new SyncResponse(...args),
921
934
  };
922
935
 
923
- class SyncService {
936
+ class SyncService extends EmitDataService {
924
937
  constructor(requestFactory, responseFactory, secureApi, settingsService) {
938
+ super();
925
939
  this.requestFactory = requestFactory;
926
940
  this.responseFactory = responseFactory;
927
941
  this.secureApi = secureApi;
@@ -945,6 +959,7 @@ class SyncService {
945
959
  if (!this.isReadyField(field)) {
946
960
  return Promise.resolve(null);
947
961
  }
962
+ debugger;
948
963
  const control = this.form.get(field.name);
949
964
  const value = control?.value;
950
965
  const prevFieldState = this.getPrevFieldSyncState(field);
@@ -953,14 +968,25 @@ class SyncService {
953
968
  return Promise.resolve(null);
954
969
  }
955
970
  if (prevFieldState && value === prevFieldState.value) {
956
- return Promise.resolve(prevFieldState.result);
971
+ return Promise.resolve(prevFieldState.result).then((response) => {
972
+ return response?.rewritableError ?? null;
973
+ });
957
974
  }
958
975
  const requestPromise = this.request(field);
959
976
  this.setPrevFieldSyncState(field, value, requestPromise);
960
977
  return requestPromise.then((response) => {
978
+ debugger;
961
979
  return response.rewritableError ?? null;
962
980
  });
963
981
  }
982
+ getSyncValidationErrors(field) {
983
+ const control = this.form.get(field.name);
984
+ if (!control) {
985
+ return null;
986
+ }
987
+ const rewritableError = control.errors?.rewritableError;
988
+ return rewritableError ? { message: rewritableError.message } : null;
989
+ }
964
990
  async request(field) {
965
991
  const requestParams = this.requestFactory({
966
992
  token: this.settingsService.token,
@@ -972,6 +998,7 @@ class SyncService {
972
998
  headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
973
999
  responseType: 'json',
974
1000
  })).then((response) => {
1001
+ this.emit(response);
975
1002
  return this.responseFactory(field, response);
976
1003
  });
977
1004
  }
@@ -1058,7 +1085,7 @@ class Converter {
1058
1085
  return config;
1059
1086
  }
1060
1087
  convertToFormControl(field) {
1061
- return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
1088
+ return new UntypedFormControl(this.getValue(field), this.getValidators(field));
1062
1089
  }
1063
1090
  getValidators(field) {
1064
1091
  const validators = [];
@@ -1077,9 +1104,6 @@ class Converter {
1077
1104
  }
1078
1105
  return validators;
1079
1106
  }
1080
- getAsyncValidators(field) {
1081
- return async () => this.syncService.validate(field);
1082
- }
1083
1107
  createDefaultControlConfig(controlConfigClass, field) {
1084
1108
  const config = new controlConfigClass();
1085
1109
  this.copyCommonOptions(config, field);
@@ -1164,8 +1188,8 @@ class ZipConverter extends Converter {
1164
1188
  const validators = super
1165
1189
  .getValidators(field)
1166
1190
  .concat([
1167
- convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
1168
- convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
1191
+ convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
1192
+ convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`),
1169
1193
  ]);
1170
1194
  if (this.isUsCountry) {
1171
1195
  validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
@@ -2401,25 +2425,295 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2401
2425
  }]
2402
2426
  }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
2403
2427
 
2428
+ /**
2429
+ * default image for purchase item is set on Publisher Account side.
2430
+ * for purchase checkout items the image url is converted into base64 string.
2431
+ * to determine default image fixed templates are used
2432
+ */
2433
+ const defaultImagePatterns = [
2434
+ /^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
2435
+ /virtual_item_default_image/,
2436
+ ];
2437
+
2438
+ function extractMoneyCurrency(money, allowZero = true) {
2439
+ return {
2440
+ amount: money?.amount ?? (allowZero ? 0 : null),
2441
+ currency: money?.currency ?? '',
2442
+ };
2443
+ }
2444
+ function createPriceOrUndefined(amount, currency) {
2445
+ return amount !== undefined && amount !== null
2446
+ ? {
2447
+ amount,
2448
+ currency,
2449
+ }
2450
+ : undefined;
2451
+ }
2452
+
2453
+ class FinanceDetails {
2454
+ get shouldShowZeroIndirectTaxRate() {
2455
+ return !!(this.finance?.vat?.visible || this.finance?.vat_user?.visible);
2456
+ }
2457
+ get isSalesTaxes() {
2458
+ return !!(this.finance?.sales_tax?.amount || this.finance?.sales_tax_user?.amount);
2459
+ }
2460
+ constructor(parameters) {
2461
+ this.purchase = parameters.purchase;
2462
+ this.finance = parameters.finance;
2463
+ }
2464
+ getFormattedPurchaseForCart() {
2465
+ const checkouts = this.purchase.checkout_items?.map((item) => {
2466
+ return {
2467
+ imgSrc: item.image_url,
2468
+ hasDefaultImg: this.isDefaultImage(item.image_url),
2469
+ title: item.name,
2470
+ price: extractMoneyCurrency(item, false),
2471
+ priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
2472
+ quantity: item.quantity,
2473
+ description: item.description,
2474
+ tax: this.getTaxForItem(item.indirect_tax_rate),
2475
+ isBonus: item.is_bonus,
2476
+ };
2477
+ });
2478
+ const virtualCurrencies = this.purchase.virtual_currency?.map((item) => {
2479
+ return {
2480
+ imgSrc: item.image_url,
2481
+ hasDefaultImg: this.isDefaultImage(item.image_url),
2482
+ title: `${item.quantity} ${item.name}`,
2483
+ price: extractMoneyCurrency(item),
2484
+ description: item.description,
2485
+ isBonus: item.is_bonus,
2486
+ };
2487
+ });
2488
+ const virtualItems = this.purchase.virtual_items?.map((item) => {
2489
+ return {
2490
+ imgSrc: item.image_url,
2491
+ hasDefaultImg: this.isDefaultImage(item.image_url),
2492
+ title: item.name,
2493
+ price: extractMoneyCurrency(item),
2494
+ description: item.description,
2495
+ quantity: item.quantity,
2496
+ isBonus: item.is_bonus,
2497
+ };
2498
+ });
2499
+ let checkoutArray = undefined;
2500
+ if (this.purchase.checkout) {
2501
+ checkoutArray = [
2502
+ {
2503
+ title: this.purchase.checkout.description
2504
+ ? this.purchase.checkout.description
2505
+ : 'In-game purchase',
2506
+ price: extractMoneyCurrency(this.purchase.checkout),
2507
+ isBonus: this.purchase.checkout.is_bonus ?? false,
2508
+ },
2509
+ ];
2510
+ }
2511
+ return [
2512
+ ...(checkouts ?? []),
2513
+ ...(virtualCurrencies ?? []),
2514
+ ...(virtualItems ?? []),
2515
+ ...(checkoutArray ?? []),
2516
+ ];
2517
+ }
2518
+ getFormattedPricingForCart() {
2519
+ // subtotal details fields
2520
+ const subtotalDetailsSorting = [
2521
+ {
2522
+ key: 'discount',
2523
+ title: 'Discount',
2524
+ },
2525
+ {
2526
+ key: 'fee',
2527
+ title: 'Payment system fee',
2528
+ },
2529
+ {
2530
+ key: 'user_balance',
2531
+ title: 'Balance',
2532
+ },
2533
+ ];
2534
+ return {
2535
+ subtotal: {
2536
+ title: 'Subtotal',
2537
+ money: createPriceOrUndefined(this.finance.sub_total.amount, this.finance.sub_total.currency),
2538
+ },
2539
+ subtotalPayment: {
2540
+ title: '',
2541
+ money: createPriceOrUndefined(this.finance.sub_total.payment_amount, this.finance.sub_total.payment_currency),
2542
+ },
2543
+ total: {
2544
+ title: 'Total',
2545
+ money: extractMoneyCurrency(this.finance.total),
2546
+ },
2547
+ totalDetails: this.getTaxesForTotalDetails(),
2548
+ subtotalDetails: [
2549
+ ...subtotalDetailsSorting.map((sorting) => {
2550
+ const field = this.finance[sorting.key];
2551
+ if (field) {
2552
+ return {
2553
+ ...sorting,
2554
+ money: {
2555
+ amount: sorting.key === 'discount' && field.amount
2556
+ ? -field.amount
2557
+ : field.amount,
2558
+ currency: field.currency,
2559
+ },
2560
+ };
2561
+ }
2562
+ return sorting;
2563
+ }),
2564
+ ...this.getTaxesForSubtotalDetails(),
2565
+ ],
2566
+ };
2567
+ }
2568
+ getPaymentCountry() {
2569
+ return this.finance?.payment_country.iso;
2570
+ }
2571
+ getTaxForItem(indirectTaxRate) {
2572
+ if (indirectTaxRate ||
2573
+ (this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
2574
+ if (this.isSalesTaxes) {
2575
+ return {
2576
+ content: `Sales tax ${indirectTaxRate}%`,
2577
+ };
2578
+ }
2579
+ if (this.isIndia()) {
2580
+ return {
2581
+ content: `GST ${indirectTaxRate}%`,
2582
+ };
2583
+ }
2584
+ if (this.isGhana()) {
2585
+ return {
2586
+ content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
2587
+ };
2588
+ }
2589
+ return {
2590
+ content: `VAT ${indirectTaxRate}%`,
2591
+ };
2592
+ }
2593
+ return null;
2594
+ }
2595
+ getTaxesForSubtotalDetails() {
2596
+ const ret = [];
2597
+ // subtotal. VAT %p
2598
+ if (this.finance.vat_user &&
2599
+ (this.finance?.vat_user?.amount ?? this.finance?.vat_user?.visible)) {
2600
+ ret.push({
2601
+ key: 'vat_user',
2602
+ title: this.getVatLabelForSubtotalDetails(),
2603
+ money: extractMoneyCurrency(this.finance.vat_user),
2604
+ });
2605
+ }
2606
+ if (this.finance.sales_tax_user?.amount) {
2607
+ ret.push({
2608
+ key: 'sales_tax_user',
2609
+ title: 'Sales tax',
2610
+ money: extractMoneyCurrency(this.finance.sales_tax_user),
2611
+ });
2612
+ }
2613
+ return ret;
2614
+ }
2615
+ getVatLabelForSubtotalDetails() {
2616
+ if (this.isIndia()) {
2617
+ return `GST ${this.finance.vat_user?.percent ?? ''}%`;
2618
+ }
2619
+ if (this.isGhana()) {
2620
+ return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
2621
+ }
2622
+ return `VAT ${this.finance.vat_user?.percent ?? ''}%`;
2623
+ }
2624
+ getTaxesForTotalDetails() {
2625
+ const ret = [];
2626
+ // for totalDetails. VAT
2627
+ if ((this.finance?.vat?.amount || this.finance?.vat?.visible) &&
2628
+ !this.finance?.vat_user?.amount) {
2629
+ ret.push({
2630
+ key: 'vat',
2631
+ title: this.getVatLabelForTotalDetails(),
2632
+ money: extractMoneyCurrency(this.finance.vat),
2633
+ });
2634
+ }
2635
+ if (this.finance?.sales_tax?.amount &&
2636
+ !this.finance?.sales_tax_user?.amount) {
2637
+ ret.push({
2638
+ key: 'sales_tax',
2639
+ title: 'Sales tax included',
2640
+ money: extractMoneyCurrency(this.finance.sales_tax),
2641
+ });
2642
+ }
2643
+ return ret;
2644
+ }
2645
+ getVatLabelForTotalDetails() {
2646
+ if (this.isIndia()) {
2647
+ return `Including ${this.finance.vat.percent}% GST`;
2648
+ }
2649
+ if (this.isGhana()) {
2650
+ return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
2651
+ }
2652
+ return `Including ${this.finance.vat.percent}% VAT`;
2653
+ }
2654
+ isIndia() {
2655
+ return this.finance?.payment_country.iso === 'IN';
2656
+ }
2657
+ isGhana() {
2658
+ return this.finance?.payment_country.iso === 'GH';
2659
+ }
2660
+ isDefaultImage(url) {
2661
+ return defaultImagePatterns.some((regex) => regex.test(url));
2662
+ }
2663
+ }
2664
+
2665
+ const financeDetailsResponseFactoryToken = new InjectionToken('FinanceDetails');
2666
+ const financeDetailsResponseFactoryProvider = {
2667
+ provide: financeDetailsResponseFactoryToken,
2668
+ useValue: (...args) => new FinanceDetails(...args),
2669
+ };
2670
+
2671
+ class FinanceDetailsService extends EmitDataService {
2672
+ constructor(responseFactory) {
2673
+ super();
2674
+ this.responseFactory = responseFactory;
2675
+ }
2676
+ emit(summary) {
2677
+ if (summary) {
2678
+ super.emit(this.responseFactory(summary));
2679
+ }
2680
+ }
2681
+ }
2682
+ FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: financeDetailsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
2683
+ FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
2684
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
2685
+ type: Injectable,
2686
+ args: [{ providedIn: 'root' }]
2687
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2688
+ type: Inject,
2689
+ args: [financeDetailsResponseFactoryToken]
2690
+ }] }]; } });
2691
+
2404
2692
  class PaymentService {
2405
- constructor(initializeService, submitService, syncService, formService, statusService, nextActionService, controlConfigService) {
2693
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, nextActionService, controlConfigService) {
2406
2694
  this.initializeService = initializeService;
2407
2695
  this.submitService = submitService;
2408
2696
  this.syncService = syncService;
2409
2697
  this.formService = formService;
2410
2698
  this.statusService = statusService;
2699
+ this.financeDetailsService = financeDetailsService;
2411
2700
  this.nextActionService = nextActionService;
2412
2701
  this.controlConfigService = controlConfigService;
2413
2702
  this.form = null;
2414
2703
  this.data = null;
2704
+ this.financeDetails = null;
2415
2705
  this.fields = [];
2706
+ this.destroy$ = new Subject();
2416
2707
  }
2417
2708
  async initialize(config) {
2709
+ this.destroy$ = new Subject();
2710
+ this.listenFinanceDetails();
2418
2711
  this.config = config;
2419
2712
  this.data = await this.initializeService.request(config);
2420
2713
  this.fields = this.getFields();
2421
2714
  this.form = this.formService.createForm(this.fields);
2422
- this.syncService.setup(this.form, this.fields);
2715
+ this.emitFinanceDetails(this.data.paymentForm?.summary);
2716
+ this.setupSyncService(this.form, this.fields);
2423
2717
  return this.fields;
2424
2718
  }
2425
2719
  async submit() {
@@ -2427,19 +2721,24 @@ class PaymentService {
2427
2721
  throw new Error('form is empty!');
2428
2722
  }
2429
2723
  const submitResponse = await this.submitService.request(this.fields, this.form);
2724
+ this.emitFinanceDetails(submitResponse.summary);
2430
2725
  return this.nextActionService.getNextAction(submitResponse);
2431
2726
  }
2432
2727
  getFields() {
2433
2728
  return this.data?.paymentForm?.fields ?? [];
2434
2729
  }
2435
2730
  async validate(field) {
2731
+ const syncErrors = this.syncService.getSyncValidationErrors(field);
2732
+ if (syncErrors) {
2733
+ return Promise.resolve(syncErrors);
2734
+ }
2436
2735
  return this.syncService.validate(field);
2437
2736
  }
2438
2737
  runThreeDs() {
2439
2738
  throw new Error('Method not implemented.');
2440
2739
  }
2441
2740
  getFinanceDetails() {
2442
- throw new Error('Method not implemented.');
2741
+ return this.financeDetails;
2443
2742
  }
2444
2743
  async getStatus(params) {
2445
2744
  return this.statusService.getStatus({
@@ -2454,15 +2753,36 @@ class PaymentService {
2454
2753
  const formControl = this.form?.get(name);
2455
2754
  formControl?.setValue(value);
2456
2755
  }
2756
+ destroy() {
2757
+ this.data = null;
2758
+ this.financeDetails = null;
2759
+ this.form = null;
2760
+ this.fields = [];
2761
+ this.destroy$.next();
2762
+ }
2763
+ emitFinanceDetails(summary) {
2764
+ this.financeDetailsService.emit(summary);
2765
+ }
2766
+ setupSyncService(form, fields) {
2767
+ this.syncService.setup(form, fields);
2768
+ this.syncService.data$
2769
+ .pipe(takeUntil(this.destroy$))
2770
+ .subscribe((response) => this.emitFinanceDetails(response.summary));
2771
+ }
2772
+ listenFinanceDetails() {
2773
+ this.financeDetailsService.data$
2774
+ .pipe(takeUntil(this.destroy$))
2775
+ .subscribe((financeDetails) => (this.financeDetails = financeDetails));
2776
+ }
2457
2777
  }
2458
- PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
2778
+ PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
2459
2779
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
2460
2780
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
2461
2781
  type: Injectable,
2462
2782
  args: [{
2463
2783
  providedIn: 'root',
2464
2784
  }]
2465
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }, { type: ControlConfigService }]; } });
2785
+ }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: NextActionService }, { type: ControlConfigService }]; } });
2466
2786
 
2467
2787
  class RefundPolicyService {
2468
2788
  constructor(settingsService) {
@@ -2567,7 +2887,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2567
2887
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
2568
2888
 
2569
2889
  class CoreLibraryService {
2570
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, legalService, nextActionService) {
2890
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
2571
2891
  this.settingsService = settingsService;
2572
2892
  this.countryService = countryService;
2573
2893
  this.paymentMethodsService = paymentMethodsService;
@@ -2575,6 +2895,7 @@ class CoreLibraryService {
2575
2895
  this.userBalanceService = userBalanceService;
2576
2896
  this.paymentService = paymentService;
2577
2897
  this.deviceFingerPrintService = deviceFingerPrintService;
2898
+ this.financeDetailsService = financeDetailsService;
2578
2899
  this.legalService = legalService;
2579
2900
  this.nextActionService = nextActionService;
2580
2901
  this.paymentMethods = {
@@ -2601,6 +2922,7 @@ class CoreLibraryService {
2601
2922
  runThreeDs: () => this.paymentService.runThreeDs(),
2602
2923
  getStatus: async (params) => this.paymentService.getStatus(params),
2603
2924
  flowUpdates$: this.nextActionService.flowUpdates$,
2925
+ financeDetailsUpdates$: this.financeDetailsService.data$,
2604
2926
  form: {
2605
2927
  getControlConfig: (field) => this.paymentService.getFieldConfig(field),
2606
2928
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
@@ -2611,14 +2933,14 @@ class CoreLibraryService {
2611
2933
  return this.legalService.getLegalComponentConfig();
2612
2934
  }
2613
2935
  }
2614
- CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
2936
+ CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
2615
2937
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
2616
2938
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
2617
2939
  type: Injectable,
2618
2940
  args: [{
2619
2941
  providedIn: 'root',
2620
2942
  }]
2621
- }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: LegalService }, { type: NextActionService }]; } });
2943
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
2622
2944
 
2623
2945
  class HttpError extends AppError {
2624
2946
  constructor(error, req) {
@@ -2723,6 +3045,7 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
2723
3045
  statusResponseFactoryProvider,
2724
3046
  checkStatusRequestFactoryProvider,
2725
3047
  checkStatusResponseFactoryProvider,
3048
+ financeDetailsResponseFactoryProvider,
2726
3049
  {
2727
3050
  provide: nextActionsToken,
2728
3051
  useValue: nextActions,
@@ -2752,6 +3075,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2752
3075
  statusResponseFactoryProvider,
2753
3076
  checkStatusRequestFactoryProvider,
2754
3077
  checkStatusResponseFactoryProvider,
3078
+ financeDetailsResponseFactoryProvider,
2755
3079
  {
2756
3080
  provide: nextActionsToken,
2757
3081
  useValue: nextActions,