@xsolla/payment-client-core 0.1.14-test18 → 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 -419
  15. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  16. package/fesm2020/xsolla-payment-client-core.mjs +142 -410
  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 -191
  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 -29
  40. package/xsolla-payment-client-core-0.1.14-test18.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,263 +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
- }
4747
- getStatus(params) {
4748
- return __awaiter(this, void 0, void 0, function* () {
4749
- this.statusRequestService.setRequestParams(params);
4750
- this.statusRequestService.request();
4751
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4752
- statusResponse.status.isSavePaymentAccount = true;
4753
- const accountData = yield this.getPaymentAccountData(params.invoice);
4754
- if (this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) || this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4755
- return statusResponse.status;
4756
- }
4757
- this.checkStatus(params);
4758
- statusResponse.status.isSavePaymentAccount = true;
4759
- statusResponse.status.statusState = StatusEnum.processing;
4760
- return statusResponse.status;
4761
- });
4762
- }
4763
- checkStatus(params) {
4764
- this.startWaitingStatusUpdates(params.invoice);
4765
- this.statusRequestService.request();
4766
- }
4767
- getStatusOld(params) {
4768
- return __awaiter(this, void 0, void 0, function* () {
4769
- console.log('getStatus', params);
4770
- this.statusRequestService.setRequestParams(params);
4771
- // this.startWaitingStatusUpdates(params.invoice);
4772
- this.statusRequestService.request();
4773
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4774
- this.checkStatusService.setRequestParams(params.invoice);
4775
- this.checkStatusService.request();
4776
- const checkStatusResponse = yield firstValueFrom(this.checkStatusService.response$);
4777
- if (!checkStatusResponse.final) {
4778
- this.startWaitingStatusUpdates(params.invoice);
4779
- statusResponse.status.isSavePaymentAccount = true;
4780
- statusResponse.status.statusState = StatusEnum.processing;
4781
- return statusResponse.status;
4782
- }
4783
- // todo: get account
4784
- const accountData = yield this.getPaymentAccountData(params.invoice);
4785
- if (!this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) && !this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4786
- // todo is proccessing
4787
- this.startWaitingStatusUpdates(params.invoice);
4788
- statusResponse.status.statusState = StatusEnum.processing;
4789
- }
4790
- statusResponse.status.isSavePaymentAccount = true;
4791
- return statusResponse.status;
4792
- // this.listenStatusService.listen(params.invoice);
4793
- // this.statusRequestService.request();
4794
- // const paramsCheck = {
4795
- // section: 'getstatus',
4796
- // action: 'getstatus',
4797
- // // invoice: params.invoice,
4798
- // ...params,
4799
- // access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
4800
- // };
4801
- // // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
4802
- // // console.log('requestPromise', check);
4803
- // // todo: get account
4804
- // // const accountData = await this.getPaymentAccountData(params.invoice);
4805
- // // this.startWaitingStatusUpdates(params.invoice);
4806
- // // this.listenStatusService.statusUpdated$
4807
- // this.startWaitingStatusUpdates(params.invoice);
4808
- // this.statusRequestService.request();
4809
- // this.checkStatusService.setRequestParams(params.invoice);
4810
- // this.checkStatusService.request();
4811
- // this.checkStatusService.response$.subscribe((resp) => {
4812
- // console.log('checkSt', resp);
4813
- // });
4814
- // const statusResponse = await firstValueFrom(
4815
- // this.statusRequestService.response$
4816
- // );
4817
- // const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
4818
- // const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
4819
- // if (!accountData) {
4820
- // this.startWaitingStatusUpdates(params.invoice);
4821
- // statusResponse.status.statusState = StatusEnum.processing;
4822
- // }
4823
- // if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4824
- // // todo is proccessing
4825
- //
4826
- // // this.startWaitingStatusUpdates(params.invoice);
4827
- // statusResponse.status.statusState = StatusEnum.processing;
4828
- // }
4829
- // statusResponse.status.isSavePaymentAccount = true;
4830
- // return statusResponse.status;
4831
- // return null;
4832
- // if (!this.savePaymentMethodStatus) {
4833
- // statusResponse.status.statusState = StatusEnum.processing;
4834
- // }
4835
- // statusResponse.status.isSavePaymentAccount = true;
4836
- // return statusResponse.status;
4837
- });
4838
- }
4839
- savingFailedOrCancel(status) {
4840
- return (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancel || (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancelUser;
4841
- }
4842
- savingSuccessful(accountData, status, checkStatus) {
4843
- 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)));
4844
- }
4845
- getPaymentAccountData(invoice) {
4846
- return this.savedPaymentAccountChangesService
4847
- .request(invoice);
4848
- // .then((accountChanges: SavedPaymentAccountChanges) => {
4849
- // if (accountChanges) {
4850
- // this.handleSavingStatus(status, accountChanges.new_account);
4851
- // }
4852
- // });
4853
- }
4854
- startWaitingStatusUpdates(invoice) {
4855
- if (this.listenStatusSubscription) {
4856
- this.listenStatusSubscription.unsubscribe();
4857
- this.listenStatusService.stopListening();
4858
- }
4859
- // debugger
4860
- this.listenStatusService.listen(invoice);
4861
- this.listenStatusSubscription = this.listenStatusService.statusUpdated$
4862
- .subscribe((statusSettings) => {
4863
- // this.checkStatusService.response$.subscribe((res) => {
4864
- // if (res.final) {
4865
- // if (statusSettings?.statusResponse.status) {
4866
- // this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
4867
- // }
4868
- // }
4869
- // });
4870
- void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
4871
- if (checkStatusResponse.final && (statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status)) {
4872
- this.loadNewPaymentAccountData(statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status, checkStatusResponse);
4873
- }
4874
- });
4875
- // this.checkStatusService.request();
4876
- // const checkStatusResponse = await firstValueFrom(
4877
- // this.checkStatusService.response$
4878
- // );
4879
- });
4880
- // this.statusRequestService.request();
4881
- }
4882
- loadNewPaymentAccountData(status, checkStatus) {
4883
- if (!status.invoice) {
4884
- return;
4885
- }
4886
- void this.savedPaymentAccountChangesService
4887
- .request(status.invoice)
4888
- .then((accountChanges) => {
4889
- if (accountChanges) {
4890
- this.handleSavingStatus(status, accountChanges, checkStatus);
4891
- }
4892
- });
4893
- }
4894
- handleSavingStatus(status, account, checkStatus) {
4895
- // const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
4896
- //
4897
- // const savingSuccessful = status?.titleClass === TitleClass.done && account;
4898
- if (this.savingSuccessful(account, status, checkStatus)) {
4899
- this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
4900
- }
4901
- else {
4902
- this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
4903
- }
4904
- this.listenStatusService.stopListening();
4905
- this.listenStatusSubscription.unsubscribe();
4906
- // const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4907
- const isSavePaymentMethod = true;
4908
- // this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4909
- console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
4910
- this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4911
- }
4912
- }
4913
- 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 });
4914
- SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
4915
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4916
- type: Injectable,
4917
- args: [{
4918
- providedIn: 'root'
4919
- }]
4920
- }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
4921
-
4922
4659
  class StatusService {
4923
- constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
4660
+ constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
4924
4661
  this.urlService = urlService;
4925
4662
  this.statusRequestService = statusRequestService;
4926
4663
  this.financeDetailsService = financeDetailsService;
4927
4664
  this.listenStatusService = listenStatusService;
4928
4665
  this.nextActionService = nextActionService;
4929
- this.savePaymentMethodStatusService = savePaymentMethodStatusService;
4930
4666
  }
4931
4667
  getStatus(params) {
4932
4668
  return __awaiter(this, void 0, void 0, function* () {
4933
- // todo: если params.savePaymentMethod, то надо выполнить логику для
4934
- // account status
4935
- const isSavePaymentMethodMode = !!(params === null || params === void 0 ? void 0 : params.isSavePaymentAccount);
4936
- if (isSavePaymentMethodMode) {
4937
- return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
4938
- }
4939
4669
  this.statusRequestService.setRequestParams(params);
4940
4670
  this.startWaitingStatusUpdates(params.invoice);
4941
4671
  this.statusRequestService.request();
@@ -4947,7 +4677,6 @@ class StatusService {
4947
4677
  getStatusWithUrlSearchParams(url) {
4948
4678
  return __awaiter(this, void 0, void 0, function* () {
4949
4679
  const searchParams = this.getRequestParamsFromUrl(url);
4950
- console.log('searchParams', searchParams);
4951
4680
  if (!searchParams) {
4952
4681
  throw new Error('No required search params to get status');
4953
4682
  }
@@ -4976,14 +4705,14 @@ class StatusService {
4976
4705
  });
4977
4706
  }
4978
4707
  }
4979
- 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 });
4980
4709
  StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
4981
4710
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
4982
4711
  type: Injectable,
4983
4712
  args: [{
4984
4713
  providedIn: 'root',
4985
4714
  }]
4986
- }], 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 }]; } });
4987
4716
 
4988
4717
  class CreditCardStateService extends EmitDataService {
4989
4718
  }
@@ -5008,6 +4737,12 @@ var ThreeDsStatusTypes;
5008
4737
  ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
5009
4738
  })(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
5010
4739
 
4740
+ class XpsResponseError extends AppError {
4741
+ constructor(message) {
4742
+ super('XPS response failed' + (message ? `: "${message}".` : '.'));
4743
+ }
4744
+ }
4745
+
5011
4746
  class StatusThreeDsRequest {
5012
4747
  constructor(token, threeDsId) {
5013
4748
  this.access_token = token;
@@ -5470,7 +5205,6 @@ class PaymentService {
5470
5205
  this.destroy$ = new Subject();
5471
5206
  this.formDestroy$ = new Subject();
5472
5207
  this.formFieldsStatusSubject = new BehaviorSubject(null);
5473
- this.isSavingMethodMode = false;
5474
5208
  }
5475
5209
  initialize(config) {
5476
5210
  var _a, _b;
@@ -5500,14 +5234,9 @@ class PaymentService {
5500
5234
  this.emitFormFieldsStatus(this.form);
5501
5235
  return;
5502
5236
  }
5503
- console.log('this.fields', this.fields);
5504
- console.log('this.form', this.form);
5505
- this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5506
5237
  const submitResponse = yield this.submitService.request(this.fields, this.form);
5507
5238
  this.data = submitResponse;
5508
- if (!this.isSavingMethodMode) {
5509
- this.emitFinanceDetails(submitResponse.summary);
5510
- }
5239
+ this.emitFinanceDetails(submitResponse.summary);
5511
5240
  this.emitFormMessages(submitResponse.messages);
5512
5241
  // Handle 3ds flow
5513
5242
  if (submitResponse.currentCommand === XpsCommand.create) {
@@ -5561,10 +5290,7 @@ class PaymentService {
5561
5290
  invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
5562
5291
  signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
5563
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',
5564
- isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
5565
5293
  };
5566
- console.log('this.data', this.data);
5567
- console.log('getStatus', params);
5568
5294
  return this.statusService.getStatus(params);
5569
5295
  });
5570
5296
  }