@xsolla/payment-client-core 0.0.2 → 0.0.3-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/esm2020/lib/core/boolean-number.enum.mjs +5 -5
  2. package/esm2020/lib/core/country/country.service.mjs +26 -26
  3. package/esm2020/lib/core/deep-readonly.type.mjs +1 -1
  4. package/esm2020/lib/core/exceptions-handling/errors/api-error.interface.mjs +1 -1
  5. package/esm2020/lib/core/exceptions-handling/errors/app-error.class.mjs +5 -5
  6. package/esm2020/lib/core/exceptions-handling/errors/http-error.class.mjs +39 -39
  7. package/esm2020/lib/core/exceptions-handling/errors/response-error.class.mjs +6 -6
  8. package/esm2020/lib/core/exceptions-handling/http-interceptor/http-error-data.interface.mjs +1 -1
  9. package/esm2020/lib/core/exceptions-handling/http-interceptor/http-error-response-data.interface.mjs +1 -1
  10. package/esm2020/lib/core/exceptions-handling/http-interceptor/http-exceptions.interceptor.mjs +21 -21
  11. package/esm2020/lib/core/extended-window.interface.mjs +1 -1
  12. package/esm2020/lib/core/http/secure-api/api-url.const.mjs +2 -2
  13. package/esm2020/lib/core/http/secure-api/options.interface.mjs +1 -1
  14. package/esm2020/lib/core/http/secure-api/secure-api.service.mjs +54 -54
  15. package/esm2020/lib/core/legal/disclaimer.service.mjs +16 -0
  16. package/esm2020/lib/core/legal/legal.component.config.mjs +2 -0
  17. package/esm2020/lib/core/legal/legal.service.mjs +39 -0
  18. package/esm2020/lib/core/legal/refund-policy.service.mjs +30 -0
  19. package/esm2020/lib/core/legal/secure-connection.service.mjs +31 -0
  20. package/esm2020/lib/core/payment-methods/payment-method-api.interface.mjs +1 -1
  21. package/esm2020/lib/core/payment-methods/payment-method.interface.mjs +1 -1
  22. package/esm2020/lib/core/payment-methods/payment-methods-api.interface.mjs +1 -1
  23. package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
  24. package/esm2020/lib/core/payment-methods/payment-methods-response.class.mjs +25 -25
  25. package/esm2020/lib/core/payment-methods/payment-methods-response.interface.mjs +1 -1
  26. package/esm2020/lib/core/payment-methods/payment-methods-response.token.mjs +7 -7
  27. package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +57 -57
  28. package/esm2020/lib/core/saved-methods/saved-method-api.interface.mjs +2 -0
  29. package/esm2020/lib/core/saved-methods/saved-method.interface.mjs +2 -0
  30. package/esm2020/lib/core/saved-methods/saved-methods-request-params.interface.mjs +2 -0
  31. package/esm2020/lib/core/saved-methods/saved-methods-response.class.mjs +24 -0
  32. package/esm2020/lib/core/saved-methods/saved-methods-response.interface.mjs +2 -0
  33. package/esm2020/lib/core/saved-methods/saved-methods-response.token.mjs +8 -0
  34. package/esm2020/lib/core/saved-methods/saved-methods.service.mjs +53 -0
  35. package/esm2020/lib/core/settings/auto-redirect-on-status.mjs +13 -13
  36. package/esm2020/lib/core/settings/balance.interface.mjs +1 -1
  37. package/esm2020/lib/core/settings/bonus.interface.mjs +1 -1
  38. package/esm2020/lib/core/settings/configuration.interface.mjs +1 -1
  39. package/esm2020/lib/core/settings/empty-utils-response.error.mjs +6 -6
  40. package/esm2020/lib/core/settings/header-type.enum.mjs +5 -5
  41. package/esm2020/lib/core/settings/offer.interface.mjs +1 -1
  42. package/esm2020/lib/core/settings/project.interface.mjs +1 -1
  43. package/esm2020/lib/core/settings/purchase.interface.mjs +1 -1
  44. package/esm2020/lib/core/settings/settings-mode.enum.mjs +4 -4
  45. package/esm2020/lib/core/settings/settings.interface.mjs +1 -1
  46. package/esm2020/lib/core/settings/settings.service.mjs +84 -84
  47. package/esm2020/lib/core/settings/status-back-show.mjs +15 -15
  48. package/esm2020/lib/core/settings/tracking-info.interface.mjs +1 -1
  49. package/esm2020/lib/core/settings/user.interface.mjs +1 -1
  50. package/esm2020/lib/core/settings/utils-response.interface.mjs +1 -1
  51. package/esm2020/lib/core/user-balance/user-balance-api.interface.mjs +2 -0
  52. package/esm2020/lib/core/user-balance/user-balance-request-params.interface.mjs +2 -0
  53. package/esm2020/lib/core/user-balance/user-balance-response.class.mjs +8 -0
  54. package/esm2020/lib/core/user-balance/user-balance-response.token.mjs +8 -0
  55. package/esm2020/lib/core/user-balance/user-balance.service.mjs +50 -0
  56. package/esm2020/lib/core/window.token.mjs +2 -2
  57. package/esm2020/lib/core-library.module.mjs +41 -35
  58. package/esm2020/lib/core-library.service.mjs +42 -31
  59. package/esm2020/public-api.mjs +7 -6
  60. package/esm2020/xsolla-payment-client-core.mjs +4 -4
  61. package/fesm2015/xsolla-payment-client-core.mjs +618 -358
  62. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  63. package/fesm2020/xsolla-payment-client-core.mjs +589 -345
  64. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  65. package/index.d.ts +5 -5
  66. package/lib/core/boolean-number.enum.d.ts +4 -4
  67. package/lib/core/country/country.service.d.ts +12 -12
  68. package/lib/core/deep-readonly.type.d.ts +3 -3
  69. package/lib/core/exceptions-handling/errors/api-error.interface.d.ts +4 -4
  70. package/lib/core/exceptions-handling/errors/app-error.class.d.ts +3 -3
  71. package/lib/core/exceptions-handling/errors/http-error.class.d.ts +10 -10
  72. package/lib/core/exceptions-handling/errors/response-error.class.d.ts +4 -4
  73. package/lib/core/exceptions-handling/http-interceptor/http-error-data.interface.d.ts +20 -20
  74. package/lib/core/exceptions-handling/http-interceptor/http-error-response-data.interface.d.ts +7 -7
  75. package/lib/core/exceptions-handling/http-interceptor/http-exceptions.interceptor.d.ts +11 -11
  76. package/lib/core/extended-window.interface.d.ts +1 -1
  77. package/lib/core/http/secure-api/api-url.const.d.ts +2 -2
  78. package/lib/core/http/secure-api/options.interface.d.ts +14 -14
  79. package/lib/core/http/secure-api/secure-api.service.d.ts +20 -20
  80. package/lib/core/legal/disclaimer.service.d.ts +6 -0
  81. package/lib/core/legal/legal.component.config.d.ts +10 -0
  82. package/lib/core/legal/legal.service.d.ts +18 -0
  83. package/lib/core/legal/refund-policy.service.d.ts +11 -0
  84. package/lib/core/legal/secure-connection.service.d.ts +13 -0
  85. package/lib/core/payment-methods/payment-method-api.interface.d.ts +11 -11
  86. package/lib/core/payment-methods/payment-method.interface.d.ts +11 -11
  87. package/lib/core/payment-methods/payment-methods-api.interface.d.ts +10 -10
  88. package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +4 -4
  89. package/lib/core/payment-methods/payment-methods-response.class.d.ts +13 -13
  90. package/lib/core/payment-methods/payment-methods-response.interface.d.ts +4 -4
  91. package/lib/core/payment-methods/payment-methods-response.token.d.ts +7 -7
  92. package/lib/core/payment-methods/payment-methods.service.d.ts +20 -20
  93. package/lib/core/saved-methods/saved-method-api.interface.d.ts +22 -0
  94. package/lib/core/saved-methods/saved-method.interface.d.ts +21 -0
  95. package/lib/core/saved-methods/saved-methods-request-params.interface.d.ts +3 -0
  96. package/lib/core/saved-methods/saved-methods-response.class.d.ts +7 -0
  97. package/lib/core/saved-methods/saved-methods-response.interface.d.ts +4 -0
  98. package/lib/core/saved-methods/saved-methods-response.token.d.ts +7 -0
  99. package/lib/core/saved-methods/saved-methods.service.d.ts +19 -0
  100. package/lib/core/settings/auto-redirect-on-status.d.ts +12 -12
  101. package/lib/core/settings/balance.interface.d.ts +4 -4
  102. package/lib/core/settings/bonus.interface.d.ts +10 -10
  103. package/lib/core/settings/configuration.interface.d.ts +5 -5
  104. package/lib/core/settings/empty-utils-response.error.d.ts +4 -4
  105. package/lib/core/settings/header-type.enum.d.ts +4 -4
  106. package/lib/core/settings/offer.interface.d.ts +6 -6
  107. package/lib/core/settings/project.interface.d.ts +32 -32
  108. package/lib/core/settings/purchase.interface.d.ts +47 -47
  109. package/lib/core/settings/settings-mode.enum.d.ts +3 -3
  110. package/lib/core/settings/settings.interface.d.ts +45 -45
  111. package/lib/core/settings/settings.service.d.ts +30 -30
  112. package/lib/core/settings/status-back-show.d.ts +14 -14
  113. package/lib/core/settings/tracking-info.interface.d.ts +5 -5
  114. package/lib/core/settings/user.interface.d.ts +23 -23
  115. package/lib/core/settings/utils-response.interface.d.ts +16 -16
  116. package/lib/core/user-balance/user-balance-api.interface.d.ts +4 -0
  117. package/lib/core/user-balance/user-balance-request-params.interface.d.ts +3 -0
  118. package/lib/core/user-balance/user-balance-response.class.d.ts +6 -0
  119. package/lib/core/user-balance/user-balance-response.token.d.ts +7 -0
  120. package/lib/core/user-balance/user-balance.service.d.ts +17 -0
  121. package/lib/core/window.token.d.ts +3 -3
  122. package/lib/core-library.module.d.ts +7 -7
  123. package/lib/core-library.service.d.ts +32 -20
  124. package/package.json +1 -1
  125. package/public-api.d.ts +3 -2
  126. package/xsolla-payment-client-core-0.0.3-2.tgz +0 -0
  127. package/xsolla-payment-client-core-0.0.2.tgz +0 -0
@@ -6,384 +6,628 @@ import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@a
6
6
  import { catchError } from 'rxjs/operators';
7
7
  import * as i1$1 from '@angular/router';
8
8
 
9
- class AppError extends Error {
10
- constructor(message) {
11
- super(message);
12
- }
9
+ class AppError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ }
13
13
  }
14
14
 
15
- class EmptyUtilsResponseError extends AppError {
16
- constructor() {
17
- super('Utils response is empty or not requested. Check your token.');
18
- }
15
+ class EmptyUtilsResponseError extends AppError {
16
+ constructor() {
17
+ super('Utils response is empty or not requested. Check your token.');
18
+ }
19
19
  }
20
20
 
21
21
  const windowToken = new InjectionToken('window');
22
22
 
23
- const defaultApiUrl = 'https://secure.xsolla.com/paystation2/api/';
23
+ const defaultApiUrl = 'https://secure.xsolla.com/paystation2/api/';
24
24
  const sandboxApiUrl = 'https://sandbox-secure.xsolla.com/paystation2/api/';
25
25
 
26
- class SecureApiClient {
27
- constructor(httpClient, window) {
28
- this.httpClient = httpClient;
29
- this.window = window;
30
- this.isSandboxMode = false;
31
- }
32
- setSandboxMode(isSandboxMode) {
33
- this.isSandboxMode = isSandboxMode;
34
- }
35
- get(url, options) {
36
- return this.httpClient.get(`${this.baseUrl}${url}`, options);
37
- }
38
- post(url, body, options) {
39
- return this.httpClient.post(`${this.baseUrl}${url}`, body, options);
40
- }
41
- patch(url, body, options) {
42
- return this.httpClient.patch(`${this.baseUrl}${url}`, body, options);
43
- }
44
- put(url, body, options) {
45
- return this.httpClient.put(`${this.baseUrl}${url}`, body, options);
46
- }
47
- delete(url, options) {
48
- return this.httpClient.delete(`${this.baseUrl}${url}`, options);
49
- }
50
- get baseUrl() {
51
- let predefinedBaseUrl = null;
52
- try {
53
- predefinedBaseUrl = this.window.localStorage.getItem('devApiUrl');
54
- }
55
- catch (e) {
56
- console.warn('localStorage is not available');
57
- }
58
- if (predefinedBaseUrl) {
59
- return predefinedBaseUrl;
60
- }
61
- return this.isSandboxMode ? sandboxApiUrl : defaultApiUrl;
62
- }
63
- }
64
- SecureApiClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, deps: [{ token: i1.HttpClient }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
65
- SecureApiClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, providedIn: 'root' });
66
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, decorators: [{
67
- type: Injectable,
68
- args: [{
69
- providedIn: 'root',
70
- }]
71
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
72
- type: Inject,
73
- args: [windowToken]
26
+ class SecureApiClient {
27
+ constructor(httpClient, window) {
28
+ this.httpClient = httpClient;
29
+ this.window = window;
30
+ this.isSandboxMode = false;
31
+ }
32
+ setSandboxMode(isSandboxMode) {
33
+ this.isSandboxMode = isSandboxMode;
34
+ }
35
+ get(url, options) {
36
+ return this.httpClient.get(`${this.baseUrl}${url}`, options);
37
+ }
38
+ post(url, body, options) {
39
+ return this.httpClient.post(`${this.baseUrl}${url}`, body, options);
40
+ }
41
+ patch(url, body, options) {
42
+ return this.httpClient.patch(`${this.baseUrl}${url}`, body, options);
43
+ }
44
+ put(url, body, options) {
45
+ return this.httpClient.put(`${this.baseUrl}${url}`, body, options);
46
+ }
47
+ delete(url, options) {
48
+ return this.httpClient.delete(`${this.baseUrl}${url}`, options);
49
+ }
50
+ get baseUrl() {
51
+ let predefinedBaseUrl = null;
52
+ try {
53
+ predefinedBaseUrl = this.window.localStorage.getItem('devApiUrl');
54
+ }
55
+ catch (e) {
56
+ console.warn('localStorage is not available');
57
+ }
58
+ if (predefinedBaseUrl) {
59
+ return predefinedBaseUrl;
60
+ }
61
+ return this.isSandboxMode ? sandboxApiUrl : defaultApiUrl;
62
+ }
63
+ }
64
+ SecureApiClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, deps: [{ token: i1.HttpClient }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
65
+ SecureApiClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, providedIn: 'root' });
66
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureApiClient, decorators: [{
67
+ type: Injectable,
68
+ args: [{
69
+ providedIn: 'root',
70
+ }]
71
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
72
+ type: Inject,
73
+ args: [windowToken]
74
74
  }] }]; } });
75
75
 
76
- class SettingsService {
77
- get project() {
78
- if (!this.response) {
79
- throw new EmptyUtilsResponseError();
80
- }
81
- return this.response.project;
82
- }
83
- get purchase() {
84
- if (!this.response) {
85
- throw new EmptyUtilsResponseError();
86
- }
87
- return this.response.purchase;
88
- }
89
- get settings() {
90
- if (!this.response) {
91
- throw new EmptyUtilsResponseError();
92
- }
93
- if (this.response?.purchase_external_id) {
94
- return {
95
- ...this.response.settings,
96
- purchase_external_id: this.response.purchase_external_id,
97
- };
98
- }
99
- return this.response?.settings;
100
- }
101
- get user() {
102
- if (!this.response) {
103
- throw new EmptyUtilsResponseError();
104
- }
105
- return this.response.user;
106
- }
107
- get utilsResponse() {
108
- if (!this.response) {
109
- throw new EmptyUtilsResponseError();
110
- }
111
- return this.response;
112
- }
113
- get isEmpty() {
114
- return !this.response;
115
- }
116
- get token() {
117
- return this._token;
118
- }
119
- get hasResponse() {
120
- return !!this.response;
121
- }
122
- constructor(secureApi) {
123
- this.secureApi = secureApi;
124
- this.isInitialized = false;
125
- this._token = '';
126
- this.sandboxMode = false;
127
- }
128
- async init(configuration) {
129
- if (!configuration.token) {
130
- return Promise.reject('token is missing');
131
- }
132
- this._token = configuration.token;
133
- this.sandboxMode = !!configuration.sandbox;
134
- await this.sendRequest(this.token);
135
- this.isInitialized = true;
136
- }
137
- isSandboxMode() {
138
- return this.sandboxMode;
139
- }
140
- async sendRequest(token) {
141
- const params = new HttpParams().set('access_token', token);
142
- this.secureApi.setSandboxMode(this.isSandboxMode());
143
- this.response = await firstValueFrom(this.secureApi.get('utils', { params }));
144
- }
145
- }
146
- SettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, deps: [{ token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
147
- SettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, providedIn: 'root' });
148
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, decorators: [{
149
- type: Injectable,
150
- args: [{
151
- providedIn: 'root',
152
- }]
76
+ class SettingsService {
77
+ get project() {
78
+ if (!this.response) {
79
+ throw new EmptyUtilsResponseError();
80
+ }
81
+ return this.response.project;
82
+ }
83
+ get purchase() {
84
+ if (!this.response) {
85
+ throw new EmptyUtilsResponseError();
86
+ }
87
+ return this.response.purchase;
88
+ }
89
+ get settings() {
90
+ if (!this.response) {
91
+ throw new EmptyUtilsResponseError();
92
+ }
93
+ if (this.response?.purchase_external_id) {
94
+ return {
95
+ ...this.response.settings,
96
+ purchase_external_id: this.response.purchase_external_id,
97
+ };
98
+ }
99
+ return this.response?.settings;
100
+ }
101
+ get user() {
102
+ if (!this.response) {
103
+ throw new EmptyUtilsResponseError();
104
+ }
105
+ return this.response.user;
106
+ }
107
+ get utilsResponse() {
108
+ if (!this.response) {
109
+ throw new EmptyUtilsResponseError();
110
+ }
111
+ return this.response;
112
+ }
113
+ get isEmpty() {
114
+ return !this.response;
115
+ }
116
+ get token() {
117
+ return this._token;
118
+ }
119
+ get hasResponse() {
120
+ return !!this.response;
121
+ }
122
+ constructor(secureApi) {
123
+ this.secureApi = secureApi;
124
+ this.isInitialized = false;
125
+ this._token = '';
126
+ this.sandboxMode = false;
127
+ }
128
+ async init(configuration) {
129
+ if (!configuration.token) {
130
+ return Promise.reject('token is missing');
131
+ }
132
+ this._token = configuration.token;
133
+ this.sandboxMode = !!configuration.sandbox;
134
+ await this.sendRequest(this.token);
135
+ this.isInitialized = true;
136
+ }
137
+ isSandboxMode() {
138
+ return this.sandboxMode;
139
+ }
140
+ async sendRequest(token) {
141
+ const params = new HttpParams().set('access_token', token);
142
+ this.secureApi.setSandboxMode(this.isSandboxMode());
143
+ this.response = await firstValueFrom(this.secureApi.get('utils', { params }));
144
+ }
145
+ }
146
+ SettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, deps: [{ token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
147
+ SettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, providedIn: 'root' });
148
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SettingsService, decorators: [{
149
+ type: Injectable,
150
+ args: [{
151
+ providedIn: 'root',
152
+ }]
153
153
  }], ctorParameters: function () { return [{ type: SecureApiClient }]; } });
154
154
 
155
- class CountryService {
156
- constructor(settingsService) {
157
- this.settingsService = settingsService;
158
- this.userDefinedCountry = null;
159
- }
160
- setCountry(country) {
161
- this.userDefinedCountry = country;
162
- }
163
- getCountry() {
164
- return this.userDefinedCountry ?? this.getTokenCountry();
165
- }
166
- getTokenCountry() {
167
- return this.settingsService.user.country.value;
168
- }
169
- }
170
- CountryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
171
- CountryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, providedIn: 'root' });
172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, decorators: [{
173
- type: Injectable,
174
- args: [{
175
- providedIn: 'root',
176
- }]
155
+ class CountryService {
156
+ constructor(settingsService) {
157
+ this.settingsService = settingsService;
158
+ this.userDefinedCountry = null;
159
+ }
160
+ setCountry(country) {
161
+ this.userDefinedCountry = country;
162
+ }
163
+ getCountry() {
164
+ return this.userDefinedCountry ?? this.getTokenCountry();
165
+ }
166
+ getTokenCountry() {
167
+ return this.settingsService.user.country.value;
168
+ }
169
+ }
170
+ CountryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
171
+ CountryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, providedIn: 'root' });
172
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CountryService, decorators: [{
173
+ type: Injectable,
174
+ args: [{
175
+ providedIn: 'root',
176
+ }]
177
177
  }], ctorParameters: function () { return [{ type: SettingsService }]; } });
178
178
 
179
- class ResponseError extends AppError {
180
- constructor(message) {
181
- super('Response failed' + (message ? `: "${message}".` : '.'));
182
- }
179
+ class ResponseError extends AppError {
180
+ constructor(message) {
181
+ super('Response failed' + (message ? `: "${message}".` : '.'));
182
+ }
183
183
  }
184
184
 
185
- var BooleanNumber;
186
- (function (BooleanNumber) {
187
- BooleanNumber[BooleanNumber["false"] = 0] = "false";
188
- BooleanNumber[BooleanNumber["true"] = 1] = "true";
185
+ var BooleanNumber;
186
+ (function (BooleanNumber) {
187
+ BooleanNumber[BooleanNumber["false"] = 0] = "false";
188
+ BooleanNumber[BooleanNumber["true"] = 1] = "true";
189
189
  })(BooleanNumber || (BooleanNumber = {}));
190
190
 
191
- class PaymentMethodsResponse {
192
- constructor(paymentMethods) {
193
- this.especial = paymentMethods.especial.map((method) => this.mapPaymentMethod(method));
194
- this.top = paymentMethods.top.map((method) => this.mapPaymentMethod(method));
195
- this.remained = paymentMethods.remained.map((method) => this.mapPaymentMethod(method));
196
- this.remainedCount = {
197
- total: paymentMethods.remained_count.total,
198
- visible: paymentMethods.remained_count.visible,
199
- };
200
- }
201
- mapPaymentMethod(method) {
202
- return {
203
- id: method.id,
204
- rank: method.rank,
205
- name: method.name,
206
- aliases: method.aliases,
207
- categories: method.cat,
208
- isVisible: method.is_visible,
209
- recommended: method.recommended === BooleanNumber.true,
210
- enabledSaveAccount: method.enabled_save_account,
211
- iconName: method.switch_icon_name,
212
- };
213
- }
191
+ class PaymentMethodsResponse {
192
+ constructor(paymentMethods) {
193
+ this.especial = paymentMethods.especial.map((method) => this.mapPaymentMethod(method));
194
+ this.top = paymentMethods.top.map((method) => this.mapPaymentMethod(method));
195
+ this.remained = paymentMethods.remained.map((method) => this.mapPaymentMethod(method));
196
+ this.remainedCount = {
197
+ total: paymentMethods.remained_count.total,
198
+ visible: paymentMethods.remained_count.visible,
199
+ };
200
+ }
201
+ mapPaymentMethod(method) {
202
+ return {
203
+ id: method.id,
204
+ rank: method.rank,
205
+ name: method.name,
206
+ aliases: method.aliases,
207
+ categories: method.cat,
208
+ isVisible: method.is_visible,
209
+ recommended: method.recommended === BooleanNumber.true,
210
+ enabledSaveAccount: method.enabled_save_account,
211
+ iconName: method.switch_icon_name,
212
+ };
213
+ }
214
+ }
215
+
216
+ const paymentMethodsResponseFactoryToken = new InjectionToken('PaymentMethodsResponse');
217
+ const paymentMethodsResponseFactoryProvider = {
218
+ provide: paymentMethodsResponseFactoryToken,
219
+ useValue: (...args) => new PaymentMethodsResponse(...args),
220
+ };
221
+
222
+ class PaymentMethodsService {
223
+ constructor(responseFactory, settingsService, countryService, secureApi) {
224
+ this.responseFactory = responseFactory;
225
+ this.settingsService = settingsService;
226
+ this.countryService = countryService;
227
+ this.secureApi = secureApi;
228
+ this.apiRoute = 'remained_payment_methods';
229
+ this.cache = new Map();
230
+ }
231
+ async getList() {
232
+ const response = await this.request();
233
+ return response.remained;
234
+ }
235
+ async getQuickMethods() {
236
+ const response = await this.request();
237
+ return response.especial;
238
+ }
239
+ async request() {
240
+ const requestParams = {
241
+ access_token: this.settingsService.token,
242
+ country: this.countryService.getCountry(),
243
+ };
244
+ const cacheKey = JSON.stringify(requestParams);
245
+ if (!this.cache.has(cacheKey)) {
246
+ this.cache.set(cacheKey, lastValueFrom(this.secureApi
247
+ .post(this.apiRoute, new URLSearchParams({ ...requestParams }), {
248
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
249
+ responseType: 'json',
250
+ })
251
+ .pipe(map((response) => this.responseFactory(response.payment_methods)))).catch((error) => {
252
+ throw new ResponseError(error.message);
253
+ }));
254
+ }
255
+ // @ts-expect-error the map already has the cache with key
256
+ return this.cache.get(cacheKey);
257
+ }
258
+ }
259
+ PaymentMethodsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, deps: [{ token: paymentMethodsResponseFactoryToken }, { token: SettingsService }, { token: CountryService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
260
+ PaymentMethodsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, providedIn: 'root' });
261
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, decorators: [{
262
+ type: Injectable,
263
+ args: [{
264
+ providedIn: 'root',
265
+ }]
266
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
267
+ type: Inject,
268
+ args: [paymentMethodsResponseFactoryToken]
269
+ }] }, { type: SettingsService }, { type: CountryService }, { type: SecureApiClient }]; } });
270
+
271
+ class SavedMethodsResponse {
272
+ constructor(savedMethods) {
273
+ this.list = savedMethods.list.map((method) => this.mapSavedMethod(method));
274
+ }
275
+ mapSavedMethod(method) {
276
+ return {
277
+ currency: method.currency,
278
+ form: method.form,
279
+ id: method.id,
280
+ isSelected: method.isSelected,
281
+ isBabkaPay: method.is_babka_pay,
282
+ name: method.name,
283
+ pid: method.pid,
284
+ psName: method.psName,
285
+ recurrentType: method.recurrent_type,
286
+ replaced: method.replaced,
287
+ type: method.type,
288
+ cardExpiryDate: method.card_expiry_date,
289
+ iconName: method.switch_icon_name,
290
+ partner: method.partner,
291
+ };
292
+ }
214
293
  }
215
294
 
216
- const paymentMethodsResponseFactoryToken = new InjectionToken('PaymentMethodsResponse');
217
- const paymentMethodsResponseFactoryProvider = {
218
- provide: paymentMethodsResponseFactoryToken,
219
- useValue: (...args) => new PaymentMethodsResponse(...args),
295
+ const savedMethodsResponseFactoryToken = new InjectionToken('SavedMethodsResponse');
296
+ const savedMethodsResponseFactoryProvider = {
297
+ provide: savedMethodsResponseFactoryToken,
298
+ useValue: (...args) => new SavedMethodsResponse(...args),
220
299
  };
221
300
 
222
- class PaymentMethodsService {
223
- constructor(responseFactory, settingsService, countryService, secureApi) {
224
- this.responseFactory = responseFactory;
225
- this.settingsService = settingsService;
226
- this.countryService = countryService;
227
- this.secureApi = secureApi;
228
- this.apiRoute = 'remained_payment_methods';
229
- this.cache = new Map();
230
- }
231
- async getList() {
232
- const response = await this.request();
233
- return response.remained;
234
- }
235
- async getQuickMethods() {
236
- const response = await this.request();
237
- return response.especial;
238
- }
239
- async request() {
240
- const requestParams = {
241
- access_token: this.settingsService.token,
242
- country: this.countryService.getCountry(),
243
- };
244
- const cacheKey = JSON.stringify(requestParams);
245
- if (!this.cache.has(cacheKey)) {
246
- this.cache.set(cacheKey, lastValueFrom(this.secureApi
247
- .post(this.apiRoute, new URLSearchParams({ ...requestParams }), {
248
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
249
- responseType: 'json',
250
- })
251
- .pipe(map((response) => this.responseFactory(response.payment_methods)))).catch((error) => {
252
- throw new ResponseError(error.message);
253
- }));
254
- }
255
- // @ts-expect-error the map already has the cache with key
256
- return this.cache.get(cacheKey);
257
- }
258
- }
259
- PaymentMethodsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, deps: [{ token: paymentMethodsResponseFactoryToken }, { token: SettingsService }, { token: CountryService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
260
- PaymentMethodsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, providedIn: 'root' });
261
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, decorators: [{
262
- type: Injectable,
263
- args: [{
264
- providedIn: 'root',
265
- }]
266
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
267
- type: Inject,
268
- args: [paymentMethodsResponseFactoryToken]
301
+ class SavedMethodsService {
302
+ constructor(responseFactory, settingsService, countryService, secureApi) {
303
+ this.responseFactory = responseFactory;
304
+ this.settingsService = settingsService;
305
+ this.countryService = countryService;
306
+ this.secureApi = secureApi;
307
+ this.apiRoute = 'savedmethods';
308
+ this.cache = new Map();
309
+ }
310
+ async getList() {
311
+ const response = await this.request();
312
+ return response.list;
313
+ }
314
+ async request() {
315
+ const requestParams = {
316
+ access_token: this.settingsService.token,
317
+ };
318
+ const cacheKey = JSON.stringify(requestParams);
319
+ if (!this.cache.has(cacheKey)) {
320
+ this.cache.set(cacheKey, lastValueFrom(this.secureApi
321
+ .post(this.apiRoute, new URLSearchParams({ ...requestParams }), {
322
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
323
+ responseType: 'json',
324
+ })
325
+ .pipe(map((response) => this.responseFactory(response)))).catch((error) => {
326
+ throw new ResponseError(error.message);
327
+ }));
328
+ }
329
+ // @ts-expect-error the map already has the cache with key
330
+ return this.cache.get(cacheKey);
331
+ }
332
+ }
333
+ SavedMethodsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedMethodsService, deps: [{ token: savedMethodsResponseFactoryToken }, { token: SettingsService }, { token: CountryService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
334
+ SavedMethodsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedMethodsService, providedIn: 'root' });
335
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedMethodsService, decorators: [{
336
+ type: Injectable,
337
+ args: [{
338
+ providedIn: 'root',
339
+ }]
340
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
341
+ type: Inject,
342
+ args: [savedMethodsResponseFactoryToken]
269
343
  }] }, { type: SettingsService }, { type: CountryService }, { type: SecureApiClient }]; } });
270
344
 
271
- class CoreLibraryService {
272
- constructor(settingsService, countryService, paymentMethodsService) {
273
- this.settingsService = settingsService;
274
- this.countryService = countryService;
275
- this.paymentMethodsService = paymentMethodsService;
276
- this.paymentMethods = {
277
- getList: async () => this.paymentMethodsService.getList(),
278
- getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
279
- };
280
- }
281
- async init(configuration) {
282
- return this.settingsService.init(configuration);
283
- }
284
- setCountry(country) {
285
- this.countryService.setCountry(country);
286
- }
287
- }
288
- CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }], target: i0.ɵɵFactoryTarget.Injectable });
289
- CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
290
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
291
- type: Injectable,
292
- args: [{
293
- providedIn: 'root',
294
- }]
295
- }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }]; } });
345
+ class UserBalanceResponse {
346
+ constructor(userBalance) {
347
+ this.isEnoughUserBalance = userBalance.is_enough_user_balance ?? false;
348
+ this.isEnoughUserRecurrentBalance =
349
+ userBalance.is_enough_user_recurrent_balance ?? false;
350
+ }
351
+ }
352
+
353
+ const userBalanceResponseFactoryToken = new InjectionToken('UserBalanceResponse');
354
+ const userBalanceResponseFactoryProvider = {
355
+ provide: userBalanceResponseFactoryToken,
356
+ useValue: (...args) => new UserBalanceResponse(...args),
357
+ };
296
358
 
297
- class HttpError extends AppError {
298
- constructor(error, req) {
299
- super(error.message);
300
- this.RESTRICTED_KEYS_REGEXP = new RegExp('.*(card_number|number|cvv|cvn|month|year|cardholdername|client_data|dfp|password).*', 'i');
301
- this.httpErrorData = {
302
- request: {
303
- url: req.url,
304
- method: req.method,
305
- headers: req.headers,
306
- },
307
- response: {
308
- status: error.status,
309
- headers: error.headers,
310
- },
311
- };
312
- if (req.body) {
313
- this.httpErrorData.request.data = this.cleanPersonalData(req.body);
314
- }
315
- if (error.statusText) {
316
- const errorData = error.error;
317
- this.httpErrorData.response.data = {
318
- statusText: error.statusText,
319
- errors: errorData?.errors ?? [],
320
- };
321
- }
322
- }
323
- getHttpErrorData() {
324
- return this.httpErrorData;
325
- }
326
- cleanPersonalData(data) {
327
- return Object.entries(data).reduce((acc, [key, val]) => {
328
- return {
329
- ...acc,
330
- [key]: this.RESTRICTED_KEYS_REGEXP.test(key) ? '***' : val,
331
- };
332
- }, {});
333
- }
359
+ class UserBalanceService {
360
+ constructor(responseFactory, settingsService, secureApi) {
361
+ this.responseFactory = responseFactory;
362
+ this.settingsService = settingsService;
363
+ this.secureApi = secureApi;
364
+ this.apiRoute = 'balance/sufficiency';
365
+ this.cache = new Map();
366
+ }
367
+ async getUserBalance() {
368
+ return this.request();
369
+ }
370
+ async request() {
371
+ const requestParams = {
372
+ access_token: this.settingsService.token,
373
+ };
374
+ const cacheKey = JSON.stringify(requestParams);
375
+ if (!this.cache.has(cacheKey)) {
376
+ this.cache.set(cacheKey, lastValueFrom(this.secureApi
377
+ .post(this.apiRoute, new URLSearchParams({ ...requestParams }), {
378
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
379
+ responseType: 'json',
380
+ })
381
+ .pipe(map((response) => this.responseFactory(response)))).catch((error) => {
382
+ throw new ResponseError(error.message);
383
+ }));
384
+ }
385
+ // @ts-expect-error the map already has the cache with key
386
+ return this.cache.get(cacheKey);
387
+ }
334
388
  }
389
+ UserBalanceService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserBalanceService, deps: [{ token: userBalanceResponseFactoryToken }, { token: SettingsService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
390
+ UserBalanceService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserBalanceService, providedIn: 'root' });
391
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserBalanceService, decorators: [{
392
+ type: Injectable,
393
+ args: [{
394
+ providedIn: 'root',
395
+ }]
396
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
397
+ type: Inject,
398
+ args: [userBalanceResponseFactoryToken]
399
+ }] }, { type: SettingsService }, { type: SecureApiClient }]; } });
335
400
 
336
- class HttpExceptionsInterceptor {
337
- constructor(router) {
338
- this.router = router;
339
- }
340
- intercept(req, next) {
341
- return next.handle(req).pipe(catchError((error) => {
342
- return throwError(() => new HttpError(error, req));
343
- }));
344
- }
345
- }
346
- HttpExceptionsInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
347
- HttpExceptionsInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor });
348
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor, decorators: [{
349
- type: Injectable
401
+ class RefundPolicyService {
402
+ constructor(settingsService) {
403
+ this.settingsService = settingsService;
404
+ this.defaultVersionId = 2;
405
+ this.defaultUrl = 'https://xsolla.com/refund-policy-ps';
406
+ }
407
+ get url() {
408
+ if (!this.settingsService.token) {
409
+ return 'https://xsolla.com/refundpolicy/en-us';
410
+ }
411
+ const language = this.settingsService.user.local ?? 'en';
412
+ const versionId = this.settingsService.project.refundPolicySettings?.policy_version_id ??
413
+ this.defaultVersionId;
414
+ const countryIso = this.settingsService.user.country.value ?? '';
415
+ const projectId = this.settingsService.project.id;
416
+ return `${this.defaultUrl}?policy_version_id=${versionId}&language=${language}&country=${countryIso}&project_id=${projectId}`;
417
+ }
418
+ }
419
+ RefundPolicyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RefundPolicyService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
420
+ RefundPolicyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RefundPolicyService, providedIn: 'root' });
421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RefundPolicyService, decorators: [{
422
+ type: Injectable,
423
+ args: [{
424
+ providedIn: 'root',
425
+ }]
426
+ }], ctorParameters: function () { return [{ type: SettingsService }]; } });
427
+
428
+ class SecureConnectionService {
429
+ get isWhiteLabel() {
430
+ return !!this.settingsService.settings?.white_label;
431
+ }
432
+ get secureConnectionUrl() {
433
+ this.setSecureConnectionUrl();
434
+ return this._secureConnectionUrl;
435
+ }
436
+ constructor(settingsService) {
437
+ this.settingsService = settingsService;
438
+ this.secureConnectionApi = 'https://verify.xsolla.com/?url=';
439
+ }
440
+ setSecureConnectionUrl() {
441
+ const projectUrl = this.settingsService.project?.projectUrl;
442
+ if (projectUrl) {
443
+ this._secureConnectionUrl = `${this.secureConnectionApi}${encodeURIComponent(projectUrl)}`;
444
+ }
445
+ }
446
+ }
447
+ SecureConnectionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureConnectionService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
448
+ SecureConnectionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureConnectionService, providedIn: 'root' });
449
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SecureConnectionService, decorators: [{
450
+ type: Injectable,
451
+ args: [{
452
+ providedIn: 'root'
453
+ }]
454
+ }], ctorParameters: function () { return [{ type: SettingsService }]; } });
455
+
456
+ class DisclaimerService {
457
+ get disclaimer() {
458
+ return 'disclaimer';
459
+ }
460
+ }
461
+ DisclaimerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DisclaimerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
462
+ DisclaimerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DisclaimerService, providedIn: 'root' });
463
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DisclaimerService, decorators: [{
464
+ type: Injectable,
465
+ args: [{
466
+ providedIn: 'root'
467
+ }]
468
+ }] });
469
+
470
+ class LegalService {
471
+ get isJapanUser() {
472
+ return this.settingsService.user?.local === 'ja';
473
+ }
474
+ constructor(settingsService, refundPolicyService, secureConnectionService, disclaimerService) {
475
+ this.settingsService = settingsService;
476
+ this.refundPolicyService = refundPolicyService;
477
+ this.secureConnectionService = secureConnectionService;
478
+ this.disclaimerService = disclaimerService;
479
+ this.sctlPolicyUrl = 'https://xsolla.com/sctl';
480
+ }
481
+ getLegalComponentConfig() {
482
+ return {
483
+ isJapanUser: this.isJapanUser,
484
+ refundPolicyUrl: this.refundPolicyService.url,
485
+ sctlPolicyUrl: this.sctlPolicyUrl,
486
+ secureConnection: {
487
+ secureConnectionUrl: this.secureConnectionService.secureConnectionUrl,
488
+ isWhiteLabel: this.secureConnectionService.isWhiteLabel,
489
+ },
490
+ disclaimer: this.disclaimerService.disclaimer
491
+ };
492
+ }
493
+ }
494
+ LegalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, deps: [{ token: SettingsService }, { token: RefundPolicyService }, { token: SecureConnectionService }, { token: DisclaimerService }], target: i0.ɵɵFactoryTarget.Injectable });
495
+ LegalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, providedIn: 'root' });
496
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, decorators: [{
497
+ type: Injectable,
498
+ args: [{
499
+ providedIn: 'root',
500
+ }]
501
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
502
+
503
+ class CoreLibraryService {
504
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, legalService) {
505
+ this.settingsService = settingsService;
506
+ this.countryService = countryService;
507
+ this.paymentMethodsService = paymentMethodsService;
508
+ this.savedMethodsService = savedMethodsService;
509
+ this.userBalanceService = userBalanceService;
510
+ this.legalService = legalService;
511
+ this.paymentMethods = {
512
+ getList: async () => this.paymentMethodsService.getList(),
513
+ getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
514
+ getSavedMethods: async () => this.savedMethodsService.getList(),
515
+ getUserBalance: async () => this.userBalanceService.getUserBalance(),
516
+ };
517
+ }
518
+ async init(configuration) {
519
+ return this.settingsService.init(configuration);
520
+ }
521
+ setCountry(country) {
522
+ this.countryService.setCountry(country);
523
+ }
524
+ getLegalComponentConfig() {
525
+ return this.legalService.getLegalComponentConfig();
526
+ }
527
+ }
528
+ 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: LegalService }], target: i0.ɵɵFactoryTarget.Injectable });
529
+ CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
530
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
531
+ type: Injectable,
532
+ args: [{
533
+ providedIn: 'root',
534
+ }]
535
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: LegalService }]; } });
536
+
537
+ class HttpError extends AppError {
538
+ constructor(error, req) {
539
+ super(error.message);
540
+ this.RESTRICTED_KEYS_REGEXP = new RegExp('.*(card_number|number|cvv|cvn|month|year|cardholdername|client_data|dfp|password).*', 'i');
541
+ this.httpErrorData = {
542
+ request: {
543
+ url: req.url,
544
+ method: req.method,
545
+ headers: req.headers,
546
+ },
547
+ response: {
548
+ status: error.status,
549
+ headers: error.headers,
550
+ },
551
+ };
552
+ if (req.body) {
553
+ this.httpErrorData.request.data = this.cleanPersonalData(req.body);
554
+ }
555
+ if (error.statusText) {
556
+ const errorData = error.error;
557
+ this.httpErrorData.response.data = {
558
+ statusText: error.statusText,
559
+ errors: errorData?.errors ?? [],
560
+ };
561
+ }
562
+ }
563
+ getHttpErrorData() {
564
+ return this.httpErrorData;
565
+ }
566
+ cleanPersonalData(data) {
567
+ return Object.entries(data).reduce((acc, [key, val]) => {
568
+ return {
569
+ ...acc,
570
+ [key]: this.RESTRICTED_KEYS_REGEXP.test(key) ? '***' : val,
571
+ };
572
+ }, {});
573
+ }
574
+ }
575
+
576
+ class HttpExceptionsInterceptor {
577
+ constructor(router) {
578
+ this.router = router;
579
+ }
580
+ intercept(req, next) {
581
+ return next.handle(req).pipe(catchError((error) => {
582
+ return throwError(() => new HttpError(error, req));
583
+ }));
584
+ }
585
+ }
586
+ HttpExceptionsInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
587
+ HttpExceptionsInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor });
588
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor, decorators: [{
589
+ type: Injectable
350
590
  }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
351
591
 
352
- class CoreLibraryModule {
353
- }
354
- CoreLibraryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
355
- CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule] });
356
- CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, providers: [
357
- {
358
- provide: HTTP_INTERCEPTORS,
359
- useClass: HttpExceptionsInterceptor,
360
- multi: true,
361
- },
362
- { provide: windowToken, useValue: window },
363
- paymentMethodsResponseFactoryProvider,
364
- ], imports: [HttpClientModule] });
365
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
366
- type: NgModule,
367
- args: [{
368
- imports: [HttpClientModule],
369
- providers: [
370
- {
371
- provide: HTTP_INTERCEPTORS,
372
- useClass: HttpExceptionsInterceptor,
373
- multi: true,
374
- },
375
- { provide: windowToken, useValue: window },
376
- paymentMethodsResponseFactoryProvider,
377
- ],
378
- }]
592
+ class CoreLibraryModule {
593
+ }
594
+ CoreLibraryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
595
+ CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule] });
596
+ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, providers: [
597
+ {
598
+ provide: HTTP_INTERCEPTORS,
599
+ useClass: HttpExceptionsInterceptor,
600
+ multi: true,
601
+ },
602
+ { provide: windowToken, useValue: window },
603
+ paymentMethodsResponseFactoryProvider,
604
+ savedMethodsResponseFactoryProvider,
605
+ userBalanceResponseFactoryProvider,
606
+ ], imports: [HttpClientModule] });
607
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
608
+ type: NgModule,
609
+ args: [{
610
+ imports: [HttpClientModule],
611
+ providers: [
612
+ {
613
+ provide: HTTP_INTERCEPTORS,
614
+ useClass: HttpExceptionsInterceptor,
615
+ multi: true,
616
+ },
617
+ { provide: windowToken, useValue: window },
618
+ paymentMethodsResponseFactoryProvider,
619
+ savedMethodsResponseFactoryProvider,
620
+ userBalanceResponseFactoryProvider,
621
+ ],
622
+ }]
379
623
  }] });
380
624
 
381
- /*
382
- * Public API Surface of core-library
625
+ /*
626
+ * Public API Surface of core-library
383
627
  */
384
628
 
385
- /**
386
- * Generated bundle index. Do not edit.
629
+ /**
630
+ * Generated bundle index. Do not edit.
387
631
  */
388
632
 
389
633
  export { CoreLibraryModule, CoreLibraryService };