@xsolla/payment-client-core 0.1.13 → 0.1.14-test10

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 (46) hide show
  1. package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.class.mjs +17 -7
  2. package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.type.mjs +1 -1
  3. package/esm2020/lib/core/payment/config/config.service.mjs +12 -6
  4. package/esm2020/lib/core/payment/form-messages/form-messages.service.mjs +26 -0
  5. package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
  6. package/esm2020/lib/core/payment/initialize/initialize.service.mjs +8 -3
  7. package/esm2020/lib/core/payment/payment-config.interface.mjs +1 -1
  8. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  9. package/esm2020/lib/core/payment/payment.service.mjs +22 -5
  10. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.mjs +2 -0
  11. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +44 -0
  12. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.mjs +2 -0
  13. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.mjs +6 -0
  14. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +71 -0
  15. package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +1 -1
  16. package/esm2020/lib/core/payment/status/status-request/status-search-param.enum.mjs +2 -1
  17. package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +8 -1
  18. package/esm2020/lib/core/payment/status/status.service.mjs +13 -4
  19. package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
  20. package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +5 -4
  21. package/esm2020/lib/core-library.service.mjs +8 -5
  22. package/fesm2015/xsolla-payment-client-core.mjs +346 -156
  23. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  24. package/fesm2020/xsolla-payment-client-core.mjs +338 -152
  25. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  26. package/lib/core/payment/actions/status-updated/status-updated.action.class.d.ts +3 -1
  27. package/lib/core/payment/actions/status-updated/status-updated.action.type.d.ts +3 -0
  28. package/lib/core/payment/form-messages/form-messages.service.d.ts +11 -0
  29. package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +4 -0
  30. package/lib/core/payment/payment-config.interface.d.ts +3 -0
  31. package/lib/core/payment/payment.interface.d.ts +1 -0
  32. package/lib/core/payment/payment.service.d.ts +5 -1
  33. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.d.ts +6 -0
  34. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.d.ts +16 -0
  35. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.d.ts +7 -0
  36. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.d.ts +4 -0
  37. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +22 -0
  38. package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +1 -0
  39. package/lib/core/payment/status/status-request/status-search-param.enum.d.ts +2 -1
  40. package/lib/core/payment/status/status.service.d.ts +3 -1
  41. package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +2 -0
  42. package/lib/core/payment-methods/payment-methods.service.d.ts +1 -1
  43. package/lib/core-library.service.d.ts +4 -2
  44. package/package.json +1 -1
  45. package/xsolla-payment-client-core-0.1.14-test10.tgz +0 -0
  46. package/xsolla-payment-client-core-0.1.13.tgz +0 -0
@@ -5,7 +5,7 @@ import * as i1 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
6
6
  import JSEncrypt from 'jsencrypt';
7
7
  import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
8
- import { filter, map as map$1, catchError } from 'rxjs/operators';
8
+ import { filter, map as map$1, tap, catchError } from 'rxjs/operators';
9
9
  import * as i1$1 from '@angular/router';
10
10
  import { CommonModule } from '@angular/common';
11
11
 
@@ -238,18 +238,19 @@ class PaymentMethodsService {
238
238
  this.apiRoute = 'remained_payment_methods';
239
239
  this.cache = new Map();
240
240
  }
241
- async getList() {
242
- const response = await this.request();
241
+ async getList(isSaveMethodMode) {
242
+ const response = await this.request(isSaveMethodMode);
243
243
  return response.remained;
244
244
  }
245
245
  async getQuickMethods() {
246
246
  const response = await this.request();
247
247
  return response.especial;
248
248
  }
249
- async request() {
249
+ async request(isSaveMethodMode) {
250
250
  const requestParams = {
251
251
  access_token: this.settingsService.token,
252
252
  country: this.countryService.getCountry(),
253
+ save_payment_account_only: isSaveMethodMode ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
253
254
  };
254
255
  const cacheKey = JSON.stringify(requestParams);
255
256
  if (!this.cache.has(cacheKey)) {
@@ -453,13 +454,19 @@ class PaymentConfigService {
453
454
  }
454
455
  return {
455
456
  ...config,
456
- returnUrl: this.enrichReturnUrl(config.returnUrl),
457
+ returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod)
457
458
  };
458
459
  }
459
- enrichReturnUrl(returnUrl) {
460
- return this.urlService.addSearchParams(returnUrl, {
461
- token: this.settingsService.token,
460
+ enrichReturnUrl(returnUrl, savePaymentMethod) {
461
+ let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
462
+ token: this.settingsService.token
462
463
  });
464
+ if (savePaymentMethod) {
465
+ enrichedUrl = this.urlService.addSearchParams(returnUrl, {
466
+ isSavePaymentAccount: "1" /* XpsBoolean.true */
467
+ });
468
+ }
469
+ return enrichedUrl;
463
470
  }
464
471
  }
465
472
  PaymentConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, deps: [{ token: UrlService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -467,7 +474,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
467
474
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
468
475
  type: Injectable,
469
476
  args: [{
470
- providedIn: 'root',
477
+ providedIn: 'root'
471
478
  }]
472
479
  }], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
473
480
 
@@ -781,15 +788,143 @@ const checkStatusActionFactoryProvider = {
781
788
  },
782
789
  };
783
790
 
791
+ class TerminalError extends AppError {
792
+ constructor(message, code) {
793
+ super(message);
794
+ this.code = code;
795
+ }
796
+ }
797
+
798
+ var StatusGroups;
799
+ (function (StatusGroups) {
800
+ StatusGroups["troubled"] = "troubled";
801
+ StatusGroups["done"] = "done";
802
+ StatusGroups["invoice"] = "invoice";
803
+ })(StatusGroups || (StatusGroups = {}));
804
+
805
+ var StatusEnum;
806
+ (function (StatusEnum) {
807
+ StatusEnum["created"] = "created";
808
+ StatusEnum["awaiting"] = "awaiting";
809
+ StatusEnum["processing"] = "processing";
810
+ StatusEnum["authorized"] = "authorized";
811
+ StatusEnum["held"] = "held";
812
+ StatusEnum["done"] = "done";
813
+ StatusEnum["error"] = "error";
814
+ StatusEnum["canceled"] = "canceled";
815
+ })(StatusEnum || (StatusEnum = {}));
816
+
817
+ class StatusResponse {
818
+ constructor(parameters) {
819
+ if (parameters.errors?.[0]) {
820
+ this.error = {
821
+ code: parameters.errors[0].code.toString(),
822
+ message: parameters.errors[0].message,
823
+ };
824
+ }
825
+ if (!parameters.status) {
826
+ throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
827
+ }
828
+ this.status = {
829
+ statusState: parameters.status.statusData.stateText,
830
+ email: parameters.status.statusData.email,
831
+ webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
832
+ webSocketChannelName: parameters.status.statusData.webSocketChannelName,
833
+ webSocketClientType: parameters.status.statusData.webSocketClientType,
834
+ financeInfo: parameters.status.text.info,
835
+ discount: parameters.status.text.info.discount
836
+ ? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
837
+ : null,
838
+ isCancelUser: parameters.status.isCancelUser,
839
+ postMessageStatus: parameters.status.isCancelUser
840
+ ? StatusGroups.troubled
841
+ : parameters.status.group,
842
+ virtualCurrencyAmount: parameters.status.statusData.out,
843
+ backUrlSettings: {
844
+ backUrl: parameters.status.text.backurl,
845
+ backUrlAction: parameters.status.text.backurl_action,
846
+ backUrlCaption: parameters.status.text.backurl_caption,
847
+ returnRegion: parameters.status.return_region,
848
+ },
849
+ additionalBackButton: this.getAdditionalBackButton(parameters.status),
850
+ group: parameters.status.group,
851
+ needToCheck: parameters.status.needToCheck,
852
+ autoRedirect: parameters.status.autoredirect,
853
+ statusMessage: parameters.status.text.state,
854
+ userId: parameters.status.statusData.v1,
855
+ invoice: parameters.status.statusData.invoice,
856
+ pid: parameters.status.statusData.pid,
857
+ projectAmount: this.getProjectAmount(parameters.status),
858
+ titleClass: parameters.status.title_class,
859
+ paymentCountryIso: parameters.status.statusData.payment_country_iso,
860
+ order: parameters.status.text.order,
861
+ };
862
+ if (parameters.form) {
863
+ this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
864
+ }
865
+ if (this.status.statusState === StatusEnum.done ||
866
+ this.status.statusState === StatusEnum.authorized) {
867
+ this.status.isSuccess = true;
868
+ }
869
+ if (this.status.statusState === StatusEnum.canceled ||
870
+ this.status.isCancelUser) {
871
+ this.status.isCanceled = true;
872
+ }
873
+ }
874
+ getUserReturnStatus(form) {
875
+ const value = form['fix_userReturnStatus']?.value;
876
+ if (value === 'undefined')
877
+ return undefined;
878
+ return value;
879
+ }
880
+ getProjectAmount(status) {
881
+ if (!status.statusData.projectAmount) {
882
+ return;
883
+ }
884
+ const [amount, currency] = status.statusData.projectAmount.split(' ');
885
+ return {
886
+ amount,
887
+ currency,
888
+ };
889
+ }
890
+ getAdditionalBackButton(status) {
891
+ if (!status.text.is_additional_back_url_enabled) {
892
+ return {
893
+ link: '',
894
+ action: '',
895
+ label: '',
896
+ region: '',
897
+ isEnabled: false,
898
+ };
899
+ }
900
+ return {
901
+ link: status.text.additional_back_url_link ?? '',
902
+ action: status.text.additional_back_url_action ?? '',
903
+ label: status.text.additional_back_url_label ?? '',
904
+ region: status.additional_button_return_region ?? '',
905
+ isEnabled: status.text.is_additional_back_url_enabled,
906
+ };
907
+ }
908
+ }
909
+
784
910
  class StatusUpdatedAction {
785
- constructor(statusResponse) {
911
+ constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
786
912
  this.type = 'status_updated';
913
+ let status;
914
+ if (statusResponse instanceof StatusResponse) {
915
+ status = statusResponse.status;
916
+ }
917
+ else {
918
+ status = statusResponse;
919
+ }
787
920
  this.data = {
788
- statusState: statusResponse.status.statusState,
789
- invoice: statusResponse.status.invoice,
790
- isSuccess: statusResponse.status.isSuccess,
791
- isCanceled: statusResponse.status.isCanceled,
792
- group: statusResponse.status.group,
921
+ statusState: status.statusState,
922
+ invoice: status.invoice,
923
+ isSuccess: status.isSuccess,
924
+ isCanceled: status.isCanceled,
925
+ group: status.group,
926
+ isSavePaymentMethodMode,
927
+ savePaymentMethodStatus
793
928
  };
794
929
  }
795
930
  }
@@ -1431,6 +1566,11 @@ class InitializeService {
1431
1566
  refer: this.ps4ReferId,
1432
1567
  country: this.countryService.getCountry(),
1433
1568
  returnUrl: config.returnUrl,
1569
+ paymentWithSavedMethod: config.paymentWithSavedMethod === true
1570
+ ? "1" /* XpsBoolean.true */
1571
+ : "0" /* XpsBoolean.false */,
1572
+ saved_method_id: config.savedMethodId,
1573
+ save_payment_account_only: !!config.savePaymentMethod ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
1434
1574
  };
1435
1575
  return this.xpsApiService
1436
1576
  .directPaymentRequest(requestParams)
@@ -1462,7 +1602,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
1462
1602
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
1463
1603
  type: Injectable,
1464
1604
  args: [{
1465
- providedIn: 'root',
1605
+ providedIn: 'root'
1466
1606
  }]
1467
1607
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1468
1608
  type: Inject,
@@ -2820,6 +2960,7 @@ var StatusSearchParam;
2820
2960
  StatusSearchParam["testPs"] = "fix_testPs";
2821
2961
  StatusSearchParam["testXsolla"] = "fix_testXsolla";
2822
2962
  StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
2963
+ StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
2823
2964
  })(StatusSearchParam || (StatusSearchParam = {}));
2824
2965
 
2825
2966
  const requiredStatusSearchParams = [
@@ -2899,15 +3040,15 @@ const statusSearchParamsMap = new Map([
2899
3040
  converter: numberConverter,
2900
3041
  },
2901
3042
  ],
3043
+ [
3044
+ StatusSearchParam.isSavePaymentAccount,
3045
+ {
3046
+ key: 'isSavePaymentAccount',
3047
+ converter: numberConverter,
3048
+ },
3049
+ ],
2902
3050
  ]);
2903
3051
 
2904
- class TerminalError extends AppError {
2905
- constructor(message, code) {
2906
- super(message);
2907
- this.code = code;
2908
- }
2909
- }
2910
-
2911
3052
  class XpsApiPart {
2912
3053
  constructor() {
2913
3054
  this.response = new BehaviorSubject(null);
@@ -2951,118 +3092,6 @@ const statusRequestFactoryProvider = {
2951
3092
  useValue: (...args) => new StatusRequest(...args),
2952
3093
  };
2953
3094
 
2954
- var StatusGroups;
2955
- (function (StatusGroups) {
2956
- StatusGroups["troubled"] = "troubled";
2957
- StatusGroups["done"] = "done";
2958
- StatusGroups["invoice"] = "invoice";
2959
- })(StatusGroups || (StatusGroups = {}));
2960
-
2961
- var StatusEnum;
2962
- (function (StatusEnum) {
2963
- StatusEnum["created"] = "created";
2964
- StatusEnum["awaiting"] = "awaiting";
2965
- StatusEnum["processing"] = "processing";
2966
- StatusEnum["authorized"] = "authorized";
2967
- StatusEnum["held"] = "held";
2968
- StatusEnum["done"] = "done";
2969
- StatusEnum["error"] = "error";
2970
- StatusEnum["canceled"] = "canceled";
2971
- })(StatusEnum || (StatusEnum = {}));
2972
-
2973
- class StatusResponse {
2974
- constructor(parameters) {
2975
- if (parameters.errors?.[0]) {
2976
- this.error = {
2977
- code: parameters.errors[0].code.toString(),
2978
- message: parameters.errors[0].message,
2979
- };
2980
- }
2981
- if (!parameters.status) {
2982
- throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
2983
- }
2984
- this.status = {
2985
- statusState: parameters.status.statusData.stateText,
2986
- email: parameters.status.statusData.email,
2987
- webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
2988
- webSocketChannelName: parameters.status.statusData.webSocketChannelName,
2989
- webSocketClientType: parameters.status.statusData.webSocketClientType,
2990
- financeInfo: parameters.status.text.info,
2991
- discount: parameters.status.text.info.discount
2992
- ? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
2993
- : null,
2994
- isCancelUser: parameters.status.isCancelUser,
2995
- postMessageStatus: parameters.status.isCancelUser
2996
- ? StatusGroups.troubled
2997
- : parameters.status.group,
2998
- virtualCurrencyAmount: parameters.status.statusData.out,
2999
- backUrlSettings: {
3000
- backUrl: parameters.status.text.backurl,
3001
- backUrlAction: parameters.status.text.backurl_action,
3002
- backUrlCaption: parameters.status.text.backurl_caption,
3003
- returnRegion: parameters.status.return_region,
3004
- },
3005
- additionalBackButton: this.getAdditionalBackButton(parameters.status),
3006
- group: parameters.status.group,
3007
- needToCheck: parameters.status.needToCheck,
3008
- autoRedirect: parameters.status.autoredirect,
3009
- statusMessage: parameters.status.text.state,
3010
- userId: parameters.status.statusData.v1,
3011
- invoice: parameters.status.statusData.invoice,
3012
- pid: parameters.status.statusData.pid,
3013
- projectAmount: this.getProjectAmount(parameters.status),
3014
- titleClass: parameters.status.title_class,
3015
- paymentCountryIso: parameters.status.statusData.payment_country_iso,
3016
- order: parameters.status.text.order,
3017
- };
3018
- if (parameters.form) {
3019
- this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
3020
- }
3021
- if (this.status.statusState === StatusEnum.done ||
3022
- this.status.statusState === StatusEnum.authorized) {
3023
- this.status.isSuccess = true;
3024
- }
3025
- if (this.status.statusState === StatusEnum.canceled ||
3026
- this.status.isCancelUser) {
3027
- this.status.isCanceled = true;
3028
- }
3029
- }
3030
- getUserReturnStatus(form) {
3031
- const value = form['fix_userReturnStatus']?.value;
3032
- if (value === 'undefined')
3033
- return undefined;
3034
- return value;
3035
- }
3036
- getProjectAmount(status) {
3037
- if (!status.statusData.projectAmount) {
3038
- return;
3039
- }
3040
- const [amount, currency] = status.statusData.projectAmount.split(' ');
3041
- return {
3042
- amount,
3043
- currency,
3044
- };
3045
- }
3046
- getAdditionalBackButton(status) {
3047
- if (!status.text.is_additional_back_url_enabled) {
3048
- return {
3049
- link: '',
3050
- action: '',
3051
- label: '',
3052
- region: '',
3053
- isEnabled: false,
3054
- };
3055
- }
3056
- return {
3057
- link: status.text.additional_back_url_link ?? '',
3058
- action: status.text.additional_back_url_action ?? '',
3059
- label: status.text.additional_back_url_label ?? '',
3060
- region: status.additional_button_return_region ?? '',
3061
- isEnabled: status.text.is_additional_back_url_enabled,
3062
- };
3063
- }
3064
- }
3065
-
3066
3095
  const statusResponseFactoryToken = new InjectionToken('StatusResponse');
3067
3096
  const statusResponseFactoryProvider = {
3068
3097
  provide: statusResponseFactoryToken,
@@ -4539,15 +4568,137 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
4539
4568
  }]
4540
4569
  }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
4541
4570
 
4571
+ var TitleClass;
4572
+ (function (TitleClass) {
4573
+ TitleClass["done"] = "done";
4574
+ TitleClass["cancel"] = "cancel";
4575
+ TitleClass["cancelUser"] = "canceluser";
4576
+ })(TitleClass || (TitleClass = {}));
4577
+
4578
+ var SavePaymentMethodStatus;
4579
+ (function (SavePaymentMethodStatus) {
4580
+ SavePaymentMethodStatus["success"] = "success";
4581
+ SavePaymentMethodStatus["failed"] = "failed";
4582
+ })(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
4583
+
4584
+ class XpsResponseError extends AppError {
4585
+ constructor(message) {
4586
+ super('XPS response failed' + (message ? `: "${message}".` : '.'));
4587
+ }
4588
+ }
4589
+
4590
+ class SavedPaymentAccountChangesService {
4591
+ constructor(settingsService, secureApi) {
4592
+ this.settingsService = settingsService;
4593
+ this.secureApi = secureApi;
4594
+ this.apiRoute = 'savedmethods/newaccountinfo';
4595
+ this.response = new Subject();
4596
+ }
4597
+ get response$() {
4598
+ return this.response.asObservable();
4599
+ }
4600
+ async request(invoice) {
4601
+ const requestParameters = {
4602
+ access_token: this.settingsService.token,
4603
+ invoice_id: invoice,
4604
+ };
4605
+ return lastValueFrom(this.secureApi
4606
+ .post(this.apiRoute, new URLSearchParams(requestParameters), {
4607
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
4608
+ responseType: 'json',
4609
+ })
4610
+ .pipe(tap((value) => {
4611
+ this.response.next(value);
4612
+ }))).catch((error) => {
4613
+ throw new XpsResponseError(error.message);
4614
+ });
4615
+ }
4616
+ }
4617
+ SavedPaymentAccountChangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, deps: [{ token: SettingsService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
4618
+ SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
4619
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
4620
+ type: Injectable,
4621
+ args: [{
4622
+ providedIn: 'root'
4623
+ }]
4624
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
4625
+
4626
+ class SavePaymentMethodStatusService {
4627
+ constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
4628
+ this.statusRequestService = statusRequestService;
4629
+ this.listenStatusService = listenStatusService;
4630
+ this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
4631
+ this.nextActionService = nextActionService;
4632
+ }
4633
+ async getStatus(params) {
4634
+ this.statusRequestService.setRequestParams(params);
4635
+ this.startWaitingStatusUpdates(params.invoice);
4636
+ this.statusRequestService.request();
4637
+ const statusResponse = await firstValueFrom(this.statusRequestService.response$);
4638
+ if (!this.savePaymentMethodStatus) {
4639
+ statusResponse.status.statusState = StatusEnum.processing;
4640
+ }
4641
+ return statusResponse.status;
4642
+ }
4643
+ startWaitingStatusUpdates(invoice) {
4644
+ this.listenStatusService.listen(invoice);
4645
+ this.listenStatusSubscription = this.listenStatusService.statusUpdated$
4646
+ .subscribe(({ statusResponse }) => {
4647
+ if (statusResponse.status) {
4648
+ this.loadNewPaymentAccountData(statusResponse.status);
4649
+ }
4650
+ });
4651
+ }
4652
+ loadNewPaymentAccountData(status) {
4653
+ if (!status.invoice) {
4654
+ return;
4655
+ }
4656
+ void this.savedPaymentAccountChangesService
4657
+ .request(status.invoice)
4658
+ .then((accountChanges) => {
4659
+ if (accountChanges) {
4660
+ this.handleSavingStatus(status, accountChanges.new_account);
4661
+ }
4662
+ });
4663
+ }
4664
+ handleSavingStatus(status, account) {
4665
+ this.listenStatusService.stopListening();
4666
+ this.listenStatusSubscription.unsubscribe();
4667
+ const updatingIsProcessing = status?.titleClass !== TitleClass.cancel && status?.titleClass !== TitleClass.cancelUser && !account;
4668
+ if (updatingIsProcessing) {
4669
+ return;
4670
+ }
4671
+ const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4672
+ const isSavePaymentMethod = true;
4673
+ this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4674
+ this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4675
+ }
4676
+ }
4677
+ SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
4678
+ SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
4679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4680
+ type: Injectable,
4681
+ args: [{
4682
+ providedIn: 'root'
4683
+ }]
4684
+ }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
4685
+
4542
4686
  class StatusService {
4543
- constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
4687
+ constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
4544
4688
  this.urlService = urlService;
4545
4689
  this.statusRequestService = statusRequestService;
4546
4690
  this.financeDetailsService = financeDetailsService;
4547
4691
  this.listenStatusService = listenStatusService;
4548
4692
  this.nextActionService = nextActionService;
4693
+ this.savePaymentMethodStatusService = savePaymentMethodStatusService;
4549
4694
  }
4550
4695
  async getStatus(params) {
4696
+ // todo: если params.savePaymentMethod, то надо выполнить логику для
4697
+ // account status
4698
+ const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
4699
+ if (isSavePaymentMethodMode) {
4700
+ return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
4701
+ }
4551
4702
  this.statusRequestService.setRequestParams(params);
4552
4703
  this.startWaitingStatusUpdates(params.invoice);
4553
4704
  this.statusRequestService.request();
@@ -4557,6 +4708,7 @@ class StatusService {
4557
4708
  }
4558
4709
  async getStatusWithUrlSearchParams(url) {
4559
4710
  const searchParams = this.getRequestParamsFromUrl(url);
4711
+ console.log('searchParams', searchParams);
4560
4712
  if (!searchParams) {
4561
4713
  throw new Error('No required search params to get status');
4562
4714
  }
@@ -4584,14 +4736,14 @@ class StatusService {
4584
4736
  });
4585
4737
  }
4586
4738
  }
4587
- StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
4739
+ StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4588
4740
  StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
4589
4741
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
4590
4742
  type: Injectable,
4591
4743
  args: [{
4592
4744
  providedIn: 'root',
4593
4745
  }]
4594
- }], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
4746
+ }], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
4595
4747
 
4596
4748
  class CreditCardStateService extends EmitDataService {
4597
4749
  }
@@ -4616,12 +4768,6 @@ var ThreeDsStatusTypes;
4616
4768
  ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
4617
4769
  })(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
4618
4770
 
4619
- class XpsResponseError extends AppError {
4620
- constructor(message) {
4621
- super('XPS response failed' + (message ? `: "${message}".` : '.'));
4622
- }
4623
- }
4624
-
4625
4771
  class StatusThreeDsRequest {
4626
4772
  constructor(token, threeDsId) {
4627
4773
  this.access_token = token;
@@ -5023,11 +5169,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5023
5169
  }]
5024
5170
  }], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
5025
5171
 
5172
+ class FormMessagesService extends EmitDataService {
5173
+ constructor(unescapeHtmlPipe) {
5174
+ super();
5175
+ this.unescapeHtmlPipe = unescapeHtmlPipe;
5176
+ }
5177
+ emitOnResponse(messages) {
5178
+ if (!messages) {
5179
+ return;
5180
+ }
5181
+ const mapInfoMessages = (infoMessage) => this.unescapeHtmlPipe.transform(infoMessage.message);
5182
+ super.emit(messages.map(mapInfoMessages));
5183
+ }
5184
+ }
5185
+ FormMessagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, deps: [{ token: UnescapeHtmlPipe }], target: i0.ɵɵFactoryTarget.Injectable });
5186
+ FormMessagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, providedIn: 'root' });
5187
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, decorators: [{
5188
+ type: Injectable,
5189
+ args: [{
5190
+ providedIn: 'root',
5191
+ }]
5192
+ }], ctorParameters: function () { return [{ type: UnescapeHtmlPipe }]; } });
5193
+
5026
5194
  class PaymentService {
5027
5195
  get formFieldsStatus$() {
5028
5196
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
5029
5197
  }
5030
- constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
5198
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService) {
5031
5199
  this.initializeService = initializeService;
5032
5200
  this.submitService = submitService;
5033
5201
  this.syncService = syncService;
@@ -5038,6 +5206,7 @@ class PaymentService {
5038
5206
  this.nextActionService = nextActionService;
5039
5207
  this.controlConfigService = controlConfigService;
5040
5208
  this.threeDsService = threeDsService;
5209
+ this.formMessagesService = formMessagesService;
5041
5210
  this.form = null;
5042
5211
  this.data = null;
5043
5212
  this.financeDetails = null;
@@ -5046,6 +5215,7 @@ class PaymentService {
5046
5215
  this.destroy$ = new Subject();
5047
5216
  this.formDestroy$ = new Subject();
5048
5217
  this.formFieldsStatusSubject = new BehaviorSubject(null);
5218
+ this.isSavingMethodMode = false;
5049
5219
  }
5050
5220
  async initialize(config) {
5051
5221
  this.destroy$ = new Subject();
@@ -5059,6 +5229,7 @@ class PaymentService {
5059
5229
  this.listenFormStatusChanges(this.form);
5060
5230
  this.emitFinanceDetails(this.data.paymentForm?.summary);
5061
5231
  this.emitFormFieldsStatus(this.form);
5232
+ this.emitFormMessages(this.data.paymentForm?.messages);
5062
5233
  return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
5063
5234
  }
5064
5235
  async submit() {
@@ -5070,9 +5241,15 @@ class PaymentService {
5070
5241
  this.emitFormFieldsStatus(this.form);
5071
5242
  return;
5072
5243
  }
5244
+ console.log('this.fields', this.fields);
5245
+ console.log('this.form', this.form);
5246
+ this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5073
5247
  const submitResponse = await this.submitService.request(this.fields, this.form);
5074
5248
  this.data = submitResponse;
5075
- this.emitFinanceDetails(submitResponse.summary);
5249
+ if (!this.isSavingMethodMode) {
5250
+ this.emitFinanceDetails(submitResponse.summary);
5251
+ }
5252
+ this.emitFormMessages(submitResponse.messages);
5076
5253
  // Handle 3ds flow
5077
5254
  if (submitResponse.currentCommand === XpsCommand.create) {
5078
5255
  this.runThreeDs();
@@ -5120,7 +5297,10 @@ class PaymentService {
5120
5297
  signature: this.data.signature ?? '',
5121
5298
  locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
5122
5299
  'en',
5300
+ isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
5123
5301
  };
5302
+ console.log('this.data', this.data);
5303
+ console.log('getStatus', params);
5124
5304
  return this.statusService.getStatus(params);
5125
5305
  }
5126
5306
  getFieldConfig(field) {
@@ -5178,12 +5358,16 @@ class PaymentService {
5178
5358
  });
5179
5359
  this.formFieldsStatusSubject.next(formFieldsStatus);
5180
5360
  }
5361
+ emitFormMessages(messages) {
5362
+ this.formMessagesService.emitOnResponse(messages);
5363
+ }
5181
5364
  setupSyncService(form, fields) {
5182
5365
  this.syncService.setup(form, fields);
5183
5366
  this.syncService.data$
5184
5367
  .pipe(takeUntil(this.destroy$))
5185
5368
  .subscribe((response) => {
5186
5369
  this.emitFinanceDetails(response.summary);
5370
+ this.emitFormMessages(response.messages);
5187
5371
  });
5188
5372
  this.syncService.fieldAsyncValidation$
5189
5373
  .pipe(takeUntil(this.destroy$))
@@ -5205,14 +5389,14 @@ class PaymentService {
5205
5389
  .subscribe(() => this.emitFormFieldsStatus(form));
5206
5390
  }
5207
5391
  }
5208
- 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: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }], target: i0.ɵɵFactoryTarget.Injectable });
5392
+ 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: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }], target: i0.ɵɵFactoryTarget.Injectable });
5209
5393
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
5210
5394
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
5211
5395
  type: Injectable,
5212
5396
  args: [{
5213
5397
  providedIn: 'root',
5214
5398
  }]
5215
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
5399
+ }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }]; } });
5216
5400
 
5217
5401
  class RefundPolicyService {
5218
5402
  constructor(settingsService) {
@@ -5317,7 +5501,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5317
5501
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
5318
5502
 
5319
5503
  class CoreLibraryService {
5320
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
5504
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService) {
5321
5505
  this.settingsService = settingsService;
5322
5506
  this.countryService = countryService;
5323
5507
  this.paymentMethodsService = paymentMethodsService;
@@ -5332,8 +5516,9 @@ class CoreLibraryService {
5332
5516
  this.nextActionService = nextActionService;
5333
5517
  this.creditCardService = creditCardService;
5334
5518
  this.creditCardStateService = creditCardStateService;
5519
+ this.formMessagesService = formMessagesService;
5335
5520
  this.paymentMethods = {
5336
- getList: async () => this.paymentMethodsService.getList(),
5521
+ getList: async (isSaveMethodMode) => this.paymentMethodsService.getList(isSaveMethodMode),
5337
5522
  getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
5338
5523
  getSavedMethods: async () => this.savedMethodsService.getList(),
5339
5524
  getUserBalance: async () => this.userBalanceService.getUserBalance(),
@@ -5369,6 +5554,7 @@ class CoreLibraryService {
5369
5554
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
5370
5555
  changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
5371
5556
  updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
5557
+ formMessages$: this.formMessagesService.data$,
5372
5558
  },
5373
5559
  };
5374
5560
  }
@@ -5399,14 +5585,14 @@ class CoreLibraryService {
5399
5585
  return this.userBalanceService.getUserBalanceValue();
5400
5586
  }
5401
5587
  }
5402
- 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: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }], target: i0.ɵɵFactoryTarget.Injectable });
5588
+ 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: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }], target: i0.ɵɵFactoryTarget.Injectable });
5403
5589
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
5404
5590
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
5405
5591
  type: Injectable,
5406
5592
  args: [{
5407
5593
  providedIn: 'root',
5408
5594
  }]
5409
- }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }]; } });
5595
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }, { type: FormMessagesService }]; } });
5410
5596
 
5411
5597
  class HttpError extends AppError {
5412
5598
  constructor(error, req) {