@xsolla/payment-client-core 0.1.14-test19 → 0.1.14-test2

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 (40) hide show
  1. package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.class.mjs +7 -17
  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 +6 -12
  4. package/esm2020/lib/core/payment/initialize/initialize.service.mjs +3 -3
  5. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  6. package/esm2020/lib/core/payment/payment.service.mjs +2 -11
  7. package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +1 -1
  8. package/esm2020/lib/core/payment/status/status-request/status-search-param.enum.mjs +1 -2
  9. package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +1 -8
  10. package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
  11. package/esm2020/lib/core/payment/status/status.service.mjs +4 -13
  12. package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +1 -1
  13. package/esm2020/lib/core-library.service.mjs +1 -1
  14. package/fesm2015/xsolla-payment-client-core.mjs +145 -426
  15. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  16. package/fesm2020/xsolla-payment-client-core.mjs +142 -417
  17. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  18. package/lib/core/payment/actions/status-updated/status-updated.action.class.d.ts +1 -3
  19. package/lib/core/payment/actions/status-updated/status-updated.action.type.d.ts +0 -3
  20. package/lib/core/payment/payment.interface.d.ts +1 -1
  21. package/lib/core/payment/payment.service.d.ts +1 -2
  22. package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +0 -1
  23. package/lib/core/payment/status/status-request/status-search-param.enum.d.ts +1 -2
  24. package/lib/core/payment/status/status.interface.d.ts +0 -1
  25. package/lib/core/payment/status/status.service.d.ts +3 -5
  26. package/lib/core/payment-methods/payment-methods.service.d.ts +1 -1
  27. package/lib/core-library.service.d.ts +2 -2
  28. package/package.json +1 -1
  29. package/xsolla-payment-client-core-0.1.14-test2.tgz +0 -0
  30. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.mjs +0 -2
  31. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +0 -44
  32. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.mjs +0 -2
  33. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.mjs +0 -6
  34. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +0 -198
  35. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.d.ts +0 -6
  36. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.d.ts +0 -16
  37. package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.d.ts +0 -7
  38. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.d.ts +0 -4
  39. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +0 -30
  40. package/xsolla-payment-client-core-0.1.14-test19.tgz +0 -0
@@ -6,7 +6,7 @@ import * as i1 from '@angular/common/http';
6
6
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
7
7
  import JSEncrypt from 'jsencrypt';
8
8
  import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
9
- import { filter, map as map$1, tap, catchError } from 'rxjs/operators';
9
+ import { filter, map as map$1, catchError } from 'rxjs/operators';
10
10
  import * as i1$1 from '@angular/router';
11
11
  import { CommonModule } from '@angular/common';
12
12
 
@@ -479,18 +479,12 @@ class PaymentConfigService {
479
479
  if (!config.returnUrl) {
480
480
  throw new Error('URL is not provided in payment config');
481
481
  }
482
- return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod) });
482
+ return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl) });
483
483
  }
484
- enrichReturnUrl(returnUrl, savePaymentMethod) {
485
- let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
486
- token: this.settingsService.token
484
+ enrichReturnUrl(returnUrl) {
485
+ return this.urlService.addSearchParams(returnUrl, {
486
+ token: this.settingsService.token,
487
487
  });
488
- if (savePaymentMethod) {
489
- enrichedUrl = this.urlService.addSearchParams(returnUrl, {
490
- isSavePaymentAccount: "1" /* XpsBoolean.true */
491
- });
492
- }
493
- return enrichedUrl;
494
488
  }
495
489
  }
496
490
  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 });
@@ -498,7 +492,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
498
492
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
499
493
  type: Injectable,
500
494
  args: [{
501
- providedIn: 'root'
495
+ providedIn: 'root',
502
496
  }]
503
497
  }], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
504
498
 
@@ -812,146 +806,15 @@ const checkStatusActionFactoryProvider = {
812
806
  },
813
807
  };
814
808
 
815
- class TerminalError extends AppError {
816
- constructor(message, code) {
817
- super(message);
818
- this.code = code;
819
- }
820
- }
821
-
822
- var StatusGroups;
823
- (function (StatusGroups) {
824
- StatusGroups["troubled"] = "troubled";
825
- StatusGroups["done"] = "done";
826
- StatusGroups["invoice"] = "invoice";
827
- })(StatusGroups || (StatusGroups = {}));
828
-
829
- var StatusEnum;
830
- (function (StatusEnum) {
831
- StatusEnum["created"] = "created";
832
- StatusEnum["awaiting"] = "awaiting";
833
- StatusEnum["processing"] = "processing";
834
- StatusEnum["authorized"] = "authorized";
835
- StatusEnum["held"] = "held";
836
- StatusEnum["done"] = "done";
837
- StatusEnum["error"] = "error";
838
- StatusEnum["canceled"] = "canceled";
839
- })(StatusEnum || (StatusEnum = {}));
840
-
841
- class StatusResponse {
842
- constructor(parameters) {
843
- var _a, _b, _c, _d, _e, _f, _g;
844
- if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
845
- this.error = {
846
- code: parameters.errors[0].code.toString(),
847
- message: parameters.errors[0].message,
848
- };
849
- }
850
- if (!parameters.status) {
851
- throw new TerminalError((_c = (_b = this.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_e = (_d = this.error) === null || _d === void 0 ? void 0 : _d.code.toString()) !== null && _e !== void 0 ? _e : '');
852
- }
853
- this.status = {
854
- statusState: parameters.status.statusData.stateText,
855
- email: parameters.status.statusData.email,
856
- webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
857
- webSocketChannelName: parameters.status.statusData.webSocketChannelName,
858
- webSocketClientType: parameters.status.statusData.webSocketClientType,
859
- financeInfo: parameters.status.text.info,
860
- discount: parameters.status.text.info.discount
861
- ? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
862
- : null,
863
- isCancelUser: parameters.status.isCancelUser,
864
- postMessageStatus: parameters.status.isCancelUser
865
- ? StatusGroups.troubled
866
- : parameters.status.group,
867
- virtualCurrencyAmount: parameters.status.statusData.out,
868
- backUrlSettings: {
869
- backUrl: parameters.status.text.backurl,
870
- backUrlAction: parameters.status.text.backurl_action,
871
- backUrlCaption: parameters.status.text.backurl_caption,
872
- returnRegion: parameters.status.return_region,
873
- },
874
- additionalBackButton: this.getAdditionalBackButton(parameters.status),
875
- group: parameters.status.group,
876
- needToCheck: parameters.status.needToCheck,
877
- autoRedirect: parameters.status.autoredirect,
878
- statusMessage: parameters.status.text.state,
879
- userId: parameters.status.statusData.v1,
880
- invoice: parameters.status.statusData.invoice,
881
- pid: parameters.status.statusData.pid,
882
- projectAmount: this.getProjectAmount(parameters.status),
883
- titleClass: parameters.status.title_class,
884
- paymentCountryIso: parameters.status.statusData.payment_country_iso,
885
- order: parameters.status.text.order,
886
- };
887
- if (parameters.form) {
888
- this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
889
- }
890
- if (this.status.statusState === StatusEnum.done ||
891
- this.status.statusState === StatusEnum.authorized) {
892
- this.status.isSuccess = true;
893
- }
894
- if (this.status.statusState === StatusEnum.canceled ||
895
- this.status.isCancelUser) {
896
- this.status.isCanceled = true;
897
- }
898
- }
899
- getUserReturnStatus(form) {
900
- var _a;
901
- const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
902
- if (value === 'undefined')
903
- return undefined;
904
- return value;
905
- }
906
- getProjectAmount(status) {
907
- if (!status.statusData.projectAmount) {
908
- return;
909
- }
910
- const [amount, currency] = status.statusData.projectAmount.split(' ');
911
- return {
912
- amount,
913
- currency,
914
- };
915
- }
916
- getAdditionalBackButton(status) {
917
- var _a, _b, _c, _d;
918
- if (!status.text.is_additional_back_url_enabled) {
919
- return {
920
- link: '',
921
- action: '',
922
- label: '',
923
- region: '',
924
- isEnabled: false,
925
- };
926
- }
927
- return {
928
- link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
929
- action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
930
- label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
931
- region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
932
- isEnabled: status.text.is_additional_back_url_enabled,
933
- };
934
- }
935
- }
936
-
937
809
  class StatusUpdatedAction {
938
- constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
810
+ constructor(statusResponse) {
939
811
  this.type = 'status_updated';
940
- let status;
941
- if (statusResponse instanceof StatusResponse) {
942
- status = statusResponse.status;
943
- }
944
- else {
945
- status = statusResponse;
946
- }
947
812
  this.data = {
948
- statusState: status.statusState,
949
- invoice: status.invoice,
950
- isSuccess: status.isSuccess,
951
- isCanceled: status.isCanceled,
952
- group: status.group,
953
- isSavePaymentMethodMode,
954
- savePaymentMethodStatus
813
+ statusState: statusResponse.status.statusState,
814
+ invoice: statusResponse.status.invoice,
815
+ isSuccess: statusResponse.status.isSuccess,
816
+ isCanceled: statusResponse.status.isCanceled,
817
+ group: statusResponse.status.group,
955
818
  };
956
819
  }
957
820
  }
@@ -1630,7 +1493,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
1630
1493
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
1631
1494
  type: Injectable,
1632
1495
  args: [{
1633
- providedIn: 'root'
1496
+ providedIn: 'root',
1634
1497
  }]
1635
1498
  }], ctorParameters: function () {
1636
1499
  return [{ type: undefined, decorators: [{
@@ -3018,7 +2881,6 @@ var StatusSearchParam;
3018
2881
  StatusSearchParam["testPs"] = "fix_testPs";
3019
2882
  StatusSearchParam["testXsolla"] = "fix_testXsolla";
3020
2883
  StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
3021
- StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
3022
2884
  })(StatusSearchParam || (StatusSearchParam = {}));
3023
2885
 
3024
2886
  const requiredStatusSearchParams = [
@@ -3098,15 +2960,15 @@ const statusSearchParamsMap = new Map([
3098
2960
  converter: numberConverter,
3099
2961
  },
3100
2962
  ],
3101
- [
3102
- StatusSearchParam.isSavePaymentAccount,
3103
- {
3104
- key: 'isSavePaymentAccount',
3105
- converter: numberConverter,
3106
- },
3107
- ],
3108
2963
  ]);
3109
2964
 
2965
+ class TerminalError extends AppError {
2966
+ constructor(message, code) {
2967
+ super(message);
2968
+ this.code = code;
2969
+ }
2970
+ }
2971
+
3110
2972
  class XpsApiPart {
3111
2973
  constructor() {
3112
2974
  this.response = new BehaviorSubject(null);
@@ -3150,6 +3012,121 @@ const statusRequestFactoryProvider = {
3150
3012
  useValue: (...args) => new StatusRequest(...args),
3151
3013
  };
3152
3014
 
3015
+ var StatusGroups;
3016
+ (function (StatusGroups) {
3017
+ StatusGroups["troubled"] = "troubled";
3018
+ StatusGroups["done"] = "done";
3019
+ StatusGroups["invoice"] = "invoice";
3020
+ })(StatusGroups || (StatusGroups = {}));
3021
+
3022
+ var StatusEnum;
3023
+ (function (StatusEnum) {
3024
+ StatusEnum["created"] = "created";
3025
+ StatusEnum["awaiting"] = "awaiting";
3026
+ StatusEnum["processing"] = "processing";
3027
+ StatusEnum["authorized"] = "authorized";
3028
+ StatusEnum["held"] = "held";
3029
+ StatusEnum["done"] = "done";
3030
+ StatusEnum["error"] = "error";
3031
+ StatusEnum["canceled"] = "canceled";
3032
+ })(StatusEnum || (StatusEnum = {}));
3033
+
3034
+ class StatusResponse {
3035
+ constructor(parameters) {
3036
+ var _a, _b, _c, _d, _e, _f, _g;
3037
+ if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
3038
+ this.error = {
3039
+ code: parameters.errors[0].code.toString(),
3040
+ message: parameters.errors[0].message,
3041
+ };
3042
+ }
3043
+ if (!parameters.status) {
3044
+ throw new TerminalError((_c = (_b = this.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_e = (_d = this.error) === null || _d === void 0 ? void 0 : _d.code.toString()) !== null && _e !== void 0 ? _e : '');
3045
+ }
3046
+ this.status = {
3047
+ statusState: parameters.status.statusData.stateText,
3048
+ email: parameters.status.statusData.email,
3049
+ webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
3050
+ webSocketChannelName: parameters.status.statusData.webSocketChannelName,
3051
+ webSocketClientType: parameters.status.statusData.webSocketClientType,
3052
+ financeInfo: parameters.status.text.info,
3053
+ discount: parameters.status.text.info.discount
3054
+ ? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
3055
+ : null,
3056
+ isCancelUser: parameters.status.isCancelUser,
3057
+ postMessageStatus: parameters.status.isCancelUser
3058
+ ? StatusGroups.troubled
3059
+ : parameters.status.group,
3060
+ virtualCurrencyAmount: parameters.status.statusData.out,
3061
+ backUrlSettings: {
3062
+ backUrl: parameters.status.text.backurl,
3063
+ backUrlAction: parameters.status.text.backurl_action,
3064
+ backUrlCaption: parameters.status.text.backurl_caption,
3065
+ returnRegion: parameters.status.return_region,
3066
+ },
3067
+ additionalBackButton: this.getAdditionalBackButton(parameters.status),
3068
+ group: parameters.status.group,
3069
+ needToCheck: parameters.status.needToCheck,
3070
+ autoRedirect: parameters.status.autoredirect,
3071
+ statusMessage: parameters.status.text.state,
3072
+ userId: parameters.status.statusData.v1,
3073
+ invoice: parameters.status.statusData.invoice,
3074
+ pid: parameters.status.statusData.pid,
3075
+ projectAmount: this.getProjectAmount(parameters.status),
3076
+ titleClass: parameters.status.title_class,
3077
+ paymentCountryIso: parameters.status.statusData.payment_country_iso,
3078
+ order: parameters.status.text.order,
3079
+ };
3080
+ if (parameters.form) {
3081
+ this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
3082
+ }
3083
+ if (this.status.statusState === StatusEnum.done ||
3084
+ this.status.statusState === StatusEnum.authorized) {
3085
+ this.status.isSuccess = true;
3086
+ }
3087
+ if (this.status.statusState === StatusEnum.canceled ||
3088
+ this.status.isCancelUser) {
3089
+ this.status.isCanceled = true;
3090
+ }
3091
+ }
3092
+ getUserReturnStatus(form) {
3093
+ var _a;
3094
+ const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
3095
+ if (value === 'undefined')
3096
+ return undefined;
3097
+ return value;
3098
+ }
3099
+ getProjectAmount(status) {
3100
+ if (!status.statusData.projectAmount) {
3101
+ return;
3102
+ }
3103
+ const [amount, currency] = status.statusData.projectAmount.split(' ');
3104
+ return {
3105
+ amount,
3106
+ currency,
3107
+ };
3108
+ }
3109
+ getAdditionalBackButton(status) {
3110
+ var _a, _b, _c, _d;
3111
+ if (!status.text.is_additional_back_url_enabled) {
3112
+ return {
3113
+ link: '',
3114
+ action: '',
3115
+ label: '',
3116
+ region: '',
3117
+ isEnabled: false,
3118
+ };
3119
+ }
3120
+ return {
3121
+ link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
3122
+ action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
3123
+ label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
3124
+ region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
3125
+ isEnabled: status.text.is_additional_back_url_enabled,
3126
+ };
3127
+ }
3128
+ }
3129
+
3153
3130
  const statusResponseFactoryToken = new InjectionToken('StatusResponse');
3154
3131
  const statusResponseFactoryProvider = {
3155
3132
  provide: statusResponseFactoryToken,
@@ -4679,270 +4656,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
4679
4656
  }]
4680
4657
  }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
4681
4658
 
4682
- var TitleClass;
4683
- (function (TitleClass) {
4684
- TitleClass["done"] = "done";
4685
- TitleClass["cancel"] = "cancel";
4686
- TitleClass["cancelUser"] = "canceluser";
4687
- })(TitleClass || (TitleClass = {}));
4688
-
4689
- var SavePaymentMethodStatus;
4690
- (function (SavePaymentMethodStatus) {
4691
- SavePaymentMethodStatus["success"] = "success";
4692
- SavePaymentMethodStatus["failed"] = "failed";
4693
- })(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
4694
-
4695
- class XpsResponseError extends AppError {
4696
- constructor(message) {
4697
- super('XPS response failed' + (message ? `: "${message}".` : '.'));
4698
- }
4699
- }
4700
-
4701
- class SavedPaymentAccountChangesService {
4702
- constructor(settingsService, secureApi) {
4703
- this.settingsService = settingsService;
4704
- this.secureApi = secureApi;
4705
- this.apiRoute = 'savedmethods/newaccountinfo';
4706
- this.response = new Subject();
4707
- }
4708
- get response$() {
4709
- return this.response.asObservable();
4710
- }
4711
- request(invoice) {
4712
- return __awaiter(this, void 0, void 0, function* () {
4713
- const requestParameters = {
4714
- access_token: this.settingsService.token,
4715
- invoice_id: invoice,
4716
- };
4717
- return lastValueFrom(this.secureApi
4718
- .post(this.apiRoute, new URLSearchParams(requestParameters), {
4719
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
4720
- responseType: 'json',
4721
- })
4722
- .pipe(tap((value) => {
4723
- this.response.next(value);
4724
- }))).catch((error) => {
4725
- throw new XpsResponseError(error.message);
4726
- });
4727
- });
4728
- }
4729
- }
4730
- 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 });
4731
- SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
4732
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
4733
- type: Injectable,
4734
- args: [{
4735
- providedIn: 'root'
4736
- }]
4737
- }], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
4738
-
4739
- class SavePaymentMethodStatusService {
4740
- constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
4741
- this.statusRequestService = statusRequestService;
4742
- this.listenStatusService = listenStatusService;
4743
- this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
4744
- this.nextActionService = nextActionService;
4745
- this.checkStatusService = checkStatusService;
4746
- this.statusChecked = false;
4747
- }
4748
- getStatus(params) {
4749
- return __awaiter(this, void 0, void 0, function* () {
4750
- this.statusRequestService.setRequestParams(params);
4751
- this.statusRequestService.request();
4752
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4753
- statusResponse.status.isSavePaymentAccount = true;
4754
- const accountData = yield this.getPaymentAccountData(params.invoice);
4755
- if (this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) || this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4756
- return statusResponse.status;
4757
- }
4758
- if (!this.statusChecked) {
4759
- this.checkStatus(params);
4760
- statusResponse.status.statusState = StatusEnum.processing;
4761
- return statusResponse.status;
4762
- }
4763
- statusResponse.status.statusState = StatusEnum.error;
4764
- return statusResponse.status;
4765
- });
4766
- }
4767
- checkStatus(params) {
4768
- if (!this.statusChecked) {
4769
- this.statusChecked = true;
4770
- }
4771
- this.startWaitingStatusUpdates(params.invoice);
4772
- this.statusRequestService.request();
4773
- }
4774
- getStatusOld(params) {
4775
- return __awaiter(this, void 0, void 0, function* () {
4776
- console.log('getStatus', params);
4777
- this.statusRequestService.setRequestParams(params);
4778
- // this.startWaitingStatusUpdates(params.invoice);
4779
- this.statusRequestService.request();
4780
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4781
- this.checkStatusService.setRequestParams(params.invoice);
4782
- this.checkStatusService.request();
4783
- const checkStatusResponse = yield firstValueFrom(this.checkStatusService.response$);
4784
- if (!checkStatusResponse.final) {
4785
- this.startWaitingStatusUpdates(params.invoice);
4786
- statusResponse.status.isSavePaymentAccount = true;
4787
- statusResponse.status.statusState = StatusEnum.processing;
4788
- return statusResponse.status;
4789
- }
4790
- // todo: get account
4791
- const accountData = yield this.getPaymentAccountData(params.invoice);
4792
- if (!this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) && !this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4793
- // todo is proccessing
4794
- this.startWaitingStatusUpdates(params.invoice);
4795
- statusResponse.status.statusState = StatusEnum.processing;
4796
- }
4797
- statusResponse.status.isSavePaymentAccount = true;
4798
- return statusResponse.status;
4799
- // this.listenStatusService.listen(params.invoice);
4800
- // this.statusRequestService.request();
4801
- // const paramsCheck = {
4802
- // section: 'getstatus',
4803
- // action: 'getstatus',
4804
- // // invoice: params.invoice,
4805
- // ...params,
4806
- // access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
4807
- // };
4808
- // // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
4809
- // // console.log('requestPromise', check);
4810
- // // todo: get account
4811
- // // const accountData = await this.getPaymentAccountData(params.invoice);
4812
- // // this.startWaitingStatusUpdates(params.invoice);
4813
- // // this.listenStatusService.statusUpdated$
4814
- // this.startWaitingStatusUpdates(params.invoice);
4815
- // this.statusRequestService.request();
4816
- // this.checkStatusService.setRequestParams(params.invoice);
4817
- // this.checkStatusService.request();
4818
- // this.checkStatusService.response$.subscribe((resp) => {
4819
- // console.log('checkSt', resp);
4820
- // });
4821
- // const statusResponse = await firstValueFrom(
4822
- // this.statusRequestService.response$
4823
- // );
4824
- // const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
4825
- // const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
4826
- // if (!accountData) {
4827
- // this.startWaitingStatusUpdates(params.invoice);
4828
- // statusResponse.status.statusState = StatusEnum.processing;
4829
- // }
4830
- // if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4831
- // // todo is proccessing
4832
- //
4833
- // // this.startWaitingStatusUpdates(params.invoice);
4834
- // statusResponse.status.statusState = StatusEnum.processing;
4835
- // }
4836
- // statusResponse.status.isSavePaymentAccount = true;
4837
- // return statusResponse.status;
4838
- // return null;
4839
- // if (!this.savePaymentMethodStatus) {
4840
- // statusResponse.status.statusState = StatusEnum.processing;
4841
- // }
4842
- // statusResponse.status.isSavePaymentAccount = true;
4843
- // return statusResponse.status;
4844
- });
4845
- }
4846
- savingFailedOrCancel(status) {
4847
- return (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancel || (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancelUser;
4848
- }
4849
- savingSuccessful(accountData, status, checkStatus) {
4850
- return !!((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.done && ((accountData === null || accountData === void 0 ? void 0 : accountData.new_account) || (checkStatus === null || checkStatus === void 0 ? void 0 : checkStatus.isPaymentAccountAttached)));
4851
- }
4852
- getPaymentAccountData(invoice) {
4853
- return this.savedPaymentAccountChangesService
4854
- .request(invoice);
4855
- // .then((accountChanges: SavedPaymentAccountChanges) => {
4856
- // if (accountChanges) {
4857
- // this.handleSavingStatus(status, accountChanges.new_account);
4858
- // }
4859
- // });
4860
- }
4861
- startWaitingStatusUpdates(invoice) {
4862
- if (this.listenStatusSubscription) {
4863
- this.listenStatusSubscription.unsubscribe();
4864
- this.listenStatusService.stopListening();
4865
- }
4866
- // debugger
4867
- this.listenStatusService.listen(invoice);
4868
- this.listenStatusSubscription = this.listenStatusService.statusUpdated$
4869
- .subscribe((statusSettings) => {
4870
- // this.checkStatusService.response$.subscribe((res) => {
4871
- // if (res.final) {
4872
- // if (statusSettings?.statusResponse.status) {
4873
- // this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
4874
- // }
4875
- // }
4876
- // });
4877
- void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
4878
- if (checkStatusResponse.final && (statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status)) {
4879
- this.loadNewPaymentAccountData(statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status, checkStatusResponse);
4880
- }
4881
- });
4882
- // this.checkStatusService.request();
4883
- // const checkStatusResponse = await firstValueFrom(
4884
- // this.checkStatusService.response$
4885
- // );
4886
- });
4887
- // this.statusRequestService.request();
4888
- }
4889
- loadNewPaymentAccountData(status, checkStatus) {
4890
- if (!status.invoice) {
4891
- return;
4892
- }
4893
- void this.savedPaymentAccountChangesService
4894
- .request(status.invoice)
4895
- .then((accountChanges) => {
4896
- if (accountChanges) {
4897
- this.handleSavingStatus(status, accountChanges, checkStatus);
4898
- }
4899
- });
4900
- }
4901
- handleSavingStatus(status, account, checkStatus) {
4902
- // const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
4903
- //
4904
- // const savingSuccessful = status?.titleClass === TitleClass.done && account;
4905
- if (this.savingSuccessful(account, status, checkStatus)) {
4906
- this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
4907
- }
4908
- else {
4909
- this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
4910
- }
4911
- this.listenStatusService.stopListening();
4912
- this.listenStatusSubscription.unsubscribe();
4913
- // const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4914
- const isSavePaymentMethod = true;
4915
- // this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4916
- console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
4917
- this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4918
- }
4919
- }
4920
- 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 }, { token: CheckStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4921
- SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
4922
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4923
- type: Injectable,
4924
- args: [{
4925
- providedIn: 'root'
4926
- }]
4927
- }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
4928
-
4929
4659
  class StatusService {
4930
- constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
4660
+ constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
4931
4661
  this.urlService = urlService;
4932
4662
  this.statusRequestService = statusRequestService;
4933
4663
  this.financeDetailsService = financeDetailsService;
4934
4664
  this.listenStatusService = listenStatusService;
4935
4665
  this.nextActionService = nextActionService;
4936
- this.savePaymentMethodStatusService = savePaymentMethodStatusService;
4937
4666
  }
4938
4667
  getStatus(params) {
4939
4668
  return __awaiter(this, void 0, void 0, function* () {
4940
- // todo: если params.savePaymentMethod, то надо выполнить логику для
4941
- // account status
4942
- const isSavePaymentMethodMode = !!(params === null || params === void 0 ? void 0 : params.isSavePaymentAccount);
4943
- if (isSavePaymentMethodMode) {
4944
- return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
4945
- }
4946
4669
  this.statusRequestService.setRequestParams(params);
4947
4670
  this.startWaitingStatusUpdates(params.invoice);
4948
4671
  this.statusRequestService.request();
@@ -4954,7 +4677,6 @@ class StatusService {
4954
4677
  getStatusWithUrlSearchParams(url) {
4955
4678
  return __awaiter(this, void 0, void 0, function* () {
4956
4679
  const searchParams = this.getRequestParamsFromUrl(url);
4957
- console.log('searchParams', searchParams);
4958
4680
  if (!searchParams) {
4959
4681
  throw new Error('No required search params to get status');
4960
4682
  }
@@ -4983,14 +4705,14 @@ class StatusService {
4983
4705
  });
4984
4706
  }
4985
4707
  }
4986
- 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 });
4708
+ 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 });
4987
4709
  StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
4988
4710
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
4989
4711
  type: Injectable,
4990
4712
  args: [{
4991
4713
  providedIn: 'root',
4992
4714
  }]
4993
- }], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
4715
+ }], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
4994
4716
 
4995
4717
  class CreditCardStateService extends EmitDataService {
4996
4718
  }
@@ -5015,6 +4737,12 @@ var ThreeDsStatusTypes;
5015
4737
  ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
5016
4738
  })(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
5017
4739
 
4740
+ class XpsResponseError extends AppError {
4741
+ constructor(message) {
4742
+ super('XPS response failed' + (message ? `: "${message}".` : '.'));
4743
+ }
4744
+ }
4745
+
5018
4746
  class StatusThreeDsRequest {
5019
4747
  constructor(token, threeDsId) {
5020
4748
  this.access_token = token;
@@ -5477,7 +5205,6 @@ class PaymentService {
5477
5205
  this.destroy$ = new Subject();
5478
5206
  this.formDestroy$ = new Subject();
5479
5207
  this.formFieldsStatusSubject = new BehaviorSubject(null);
5480
- this.isSavingMethodMode = false;
5481
5208
  }
5482
5209
  initialize(config) {
5483
5210
  var _a, _b;
@@ -5507,14 +5234,9 @@ class PaymentService {
5507
5234
  this.emitFormFieldsStatus(this.form);
5508
5235
  return;
5509
5236
  }
5510
- console.log('this.fields', this.fields);
5511
- console.log('this.form', this.form);
5512
- this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5513
5237
  const submitResponse = yield this.submitService.request(this.fields, this.form);
5514
5238
  this.data = submitResponse;
5515
- if (!this.isSavingMethodMode) {
5516
- this.emitFinanceDetails(submitResponse.summary);
5517
- }
5239
+ this.emitFinanceDetails(submitResponse.summary);
5518
5240
  this.emitFormMessages(submitResponse.messages);
5519
5241
  // Handle 3ds flow
5520
5242
  if (submitResponse.currentCommand === XpsCommand.create) {
@@ -5568,10 +5290,7 @@ class PaymentService {
5568
5290
  invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
5569
5291
  signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
5570
5292
  locale: (_d = (_c = this.data.fields.find((field) => field.name === 'locale')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'en',
5571
- isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
5572
5293
  };
5573
- console.log('this.data', this.data);
5574
- console.log('getStatus', params);
5575
5294
  return this.statusService.getStatus(params);
5576
5295
  });
5577
5296
  }