@xsolla/payment-client-core 0.0.2 → 0.0.3-1
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.
- package/esm2020/lib/core/boolean-number.enum.mjs +5 -5
- package/esm2020/lib/core/country/country.service.mjs +26 -26
- package/esm2020/lib/core/deep-readonly.type.mjs +1 -1
- package/esm2020/lib/core/exceptions-handling/errors/api-error.interface.mjs +1 -1
- package/esm2020/lib/core/exceptions-handling/errors/app-error.class.mjs +5 -5
- package/esm2020/lib/core/exceptions-handling/errors/http-error.class.mjs +39 -39
- package/esm2020/lib/core/exceptions-handling/errors/response-error.class.mjs +6 -6
- package/esm2020/lib/core/exceptions-handling/http-interceptor/http-error-data.interface.mjs +1 -1
- package/esm2020/lib/core/exceptions-handling/http-interceptor/http-error-response-data.interface.mjs +1 -1
- package/esm2020/lib/core/exceptions-handling/http-interceptor/http-exceptions.interceptor.mjs +21 -21
- package/esm2020/lib/core/extended-window.interface.mjs +1 -1
- package/esm2020/lib/core/http/secure-api/api-url.const.mjs +2 -2
- package/esm2020/lib/core/http/secure-api/options.interface.mjs +1 -1
- package/esm2020/lib/core/http/secure-api/secure-api.service.mjs +54 -54
- package/esm2020/lib/core/legal/legal.component.config.mjs +2 -0
- package/esm2020/lib/core/legal/legal.service.mjs +30 -0
- package/esm2020/lib/core/legal/refund-policy.service.mjs +30 -0
- package/esm2020/lib/core/payment-methods/payment-method-api.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-method.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods-api.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods-response.class.mjs +25 -25
- package/esm2020/lib/core/payment-methods/payment-methods-response.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods-response.token.mjs +7 -7
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +57 -57
- package/esm2020/lib/core/saved-methods/saved-method-api.interface.mjs +2 -0
- package/esm2020/lib/core/saved-methods/saved-method.interface.mjs +2 -0
- package/esm2020/lib/core/saved-methods/saved-methods-request-params.interface.mjs +2 -0
- package/esm2020/lib/core/saved-methods/saved-methods-response.class.mjs +24 -0
- package/esm2020/lib/core/saved-methods/saved-methods-response.interface.mjs +2 -0
- package/esm2020/lib/core/saved-methods/saved-methods-response.token.mjs +8 -0
- package/esm2020/lib/core/saved-methods/saved-methods.service.mjs +53 -0
- package/esm2020/lib/core/settings/auto-redirect-on-status.mjs +13 -13
- package/esm2020/lib/core/settings/balance.interface.mjs +1 -1
- package/esm2020/lib/core/settings/bonus.interface.mjs +1 -1
- package/esm2020/lib/core/settings/configuration.interface.mjs +1 -1
- package/esm2020/lib/core/settings/empty-utils-response.error.mjs +6 -6
- package/esm2020/lib/core/settings/header-type.enum.mjs +5 -5
- package/esm2020/lib/core/settings/offer.interface.mjs +1 -1
- package/esm2020/lib/core/settings/project.interface.mjs +1 -1
- package/esm2020/lib/core/settings/purchase.interface.mjs +1 -1
- package/esm2020/lib/core/settings/settings-mode.enum.mjs +4 -4
- package/esm2020/lib/core/settings/settings.interface.mjs +1 -1
- package/esm2020/lib/core/settings/settings.service.mjs +84 -84
- package/esm2020/lib/core/settings/status-back-show.mjs +15 -15
- package/esm2020/lib/core/settings/tracking-info.interface.mjs +1 -1
- package/esm2020/lib/core/settings/user.interface.mjs +1 -1
- package/esm2020/lib/core/settings/utils-response.interface.mjs +1 -1
- package/esm2020/lib/core/user-balance/user-balance-api.interface.mjs +2 -0
- package/esm2020/lib/core/user-balance/user-balance-request-params.interface.mjs +2 -0
- package/esm2020/lib/core/user-balance/user-balance-response.class.mjs +8 -0
- package/esm2020/lib/core/user-balance/user-balance-response.token.mjs +8 -0
- package/esm2020/lib/core/user-balance/user-balance.service.mjs +50 -0
- package/esm2020/lib/core/window.token.mjs +2 -2
- package/esm2020/lib/core-library.module.mjs +41 -35
- package/esm2020/lib/core-library.service.mjs +42 -31
- package/esm2020/public-api.mjs +7 -6
- package/esm2020/xsolla-payment-client-core.mjs +4 -4
- package/fesm2015/xsolla-payment-client-core.mjs +567 -358
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +540 -345
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/lib/core/boolean-number.enum.d.ts +4 -4
- package/lib/core/country/country.service.d.ts +12 -12
- package/lib/core/deep-readonly.type.d.ts +3 -3
- package/lib/core/exceptions-handling/errors/api-error.interface.d.ts +4 -4
- package/lib/core/exceptions-handling/errors/app-error.class.d.ts +3 -3
- package/lib/core/exceptions-handling/errors/http-error.class.d.ts +10 -10
- package/lib/core/exceptions-handling/errors/response-error.class.d.ts +4 -4
- package/lib/core/exceptions-handling/http-interceptor/http-error-data.interface.d.ts +20 -20
- package/lib/core/exceptions-handling/http-interceptor/http-error-response-data.interface.d.ts +7 -7
- package/lib/core/exceptions-handling/http-interceptor/http-exceptions.interceptor.d.ts +11 -11
- package/lib/core/extended-window.interface.d.ts +1 -1
- package/lib/core/http/secure-api/api-url.const.d.ts +2 -2
- package/lib/core/http/secure-api/options.interface.d.ts +14 -14
- package/lib/core/http/secure-api/secure-api.service.d.ts +20 -20
- package/lib/core/legal/legal.component.config.d.ts +5 -0
- package/lib/core/legal/legal.service.d.ts +14 -0
- package/lib/core/legal/refund-policy.service.d.ts +11 -0
- package/lib/core/payment-methods/payment-method-api.interface.d.ts +11 -11
- package/lib/core/payment-methods/payment-method.interface.d.ts +11 -11
- package/lib/core/payment-methods/payment-methods-api.interface.d.ts +10 -10
- package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +4 -4
- package/lib/core/payment-methods/payment-methods-response.class.d.ts +13 -13
- package/lib/core/payment-methods/payment-methods-response.interface.d.ts +4 -4
- package/lib/core/payment-methods/payment-methods-response.token.d.ts +7 -7
- package/lib/core/payment-methods/payment-methods.service.d.ts +20 -20
- package/lib/core/saved-methods/saved-method-api.interface.d.ts +22 -0
- package/lib/core/saved-methods/saved-method.interface.d.ts +21 -0
- package/lib/core/saved-methods/saved-methods-request-params.interface.d.ts +3 -0
- package/lib/core/saved-methods/saved-methods-response.class.d.ts +7 -0
- package/lib/core/saved-methods/saved-methods-response.interface.d.ts +4 -0
- package/lib/core/saved-methods/saved-methods-response.token.d.ts +7 -0
- package/lib/core/saved-methods/saved-methods.service.d.ts +19 -0
- package/lib/core/settings/auto-redirect-on-status.d.ts +12 -12
- package/lib/core/settings/balance.interface.d.ts +4 -4
- package/lib/core/settings/bonus.interface.d.ts +10 -10
- package/lib/core/settings/configuration.interface.d.ts +5 -5
- package/lib/core/settings/empty-utils-response.error.d.ts +4 -4
- package/lib/core/settings/header-type.enum.d.ts +4 -4
- package/lib/core/settings/offer.interface.d.ts +6 -6
- package/lib/core/settings/project.interface.d.ts +32 -32
- package/lib/core/settings/purchase.interface.d.ts +47 -47
- package/lib/core/settings/settings-mode.enum.d.ts +3 -3
- package/lib/core/settings/settings.interface.d.ts +45 -45
- package/lib/core/settings/settings.service.d.ts +30 -30
- package/lib/core/settings/status-back-show.d.ts +14 -14
- package/lib/core/settings/tracking-info.interface.d.ts +5 -5
- package/lib/core/settings/user.interface.d.ts +23 -23
- package/lib/core/settings/utils-response.interface.d.ts +16 -16
- package/lib/core/user-balance/user-balance-api.interface.d.ts +4 -0
- package/lib/core/user-balance/user-balance-request-params.interface.d.ts +3 -0
- package/lib/core/user-balance/user-balance-response.class.d.ts +6 -0
- package/lib/core/user-balance/user-balance-response.token.d.ts +7 -0
- package/lib/core/user-balance/user-balance.service.d.ts +17 -0
- package/lib/core/window.token.d.ts +3 -3
- package/lib/core-library.module.d.ts +7 -7
- package/lib/core-library.service.d.ts +32 -20
- package/package.json +1 -1
- package/public-api.d.ts +3 -2
- package/xsolla-payment-client-core-0.0.3-1.tgz +0 -0
- package/xsolla-payment-client-core-0.0.2.tgz +0 -0
|
@@ -6,384 +6,579 @@ 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
214
|
}
|
|
215
215
|
|
|
216
|
-
const paymentMethodsResponseFactoryToken = new InjectionToken('PaymentMethodsResponse');
|
|
217
|
-
const paymentMethodsResponseFactoryProvider = {
|
|
218
|
-
provide: paymentMethodsResponseFactoryToken,
|
|
219
|
-
useValue: (...args) => new PaymentMethodsResponse(...args),
|
|
216
|
+
const paymentMethodsResponseFactoryToken = new InjectionToken('PaymentMethodsResponse');
|
|
217
|
+
const paymentMethodsResponseFactoryProvider = {
|
|
218
|
+
provide: paymentMethodsResponseFactoryToken,
|
|
219
|
+
useValue: (...args) => new PaymentMethodsResponse(...args),
|
|
220
220
|
};
|
|
221
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]
|
|
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
269
|
}] }, { type: SettingsService }, { type: CountryService }, { type: SecureApiClient }]; } });
|
|
270
270
|
|
|
271
|
-
class
|
|
272
|
-
constructor(
|
|
273
|
-
this.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const savedMethodsResponseFactoryToken = new InjectionToken('SavedMethodsResponse');
|
|
296
|
+
const savedMethodsResponseFactoryProvider = {
|
|
297
|
+
provide: savedMethodsResponseFactoryToken,
|
|
298
|
+
useValue: (...args) => new SavedMethodsResponse(...args),
|
|
299
|
+
};
|
|
296
300
|
|
|
297
|
-
class
|
|
298
|
-
constructor(
|
|
299
|
-
|
|
300
|
-
this.
|
|
301
|
-
this.
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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]
|
|
343
|
+
}] }, { type: SettingsService }, { type: CountryService }, { type: SecureApiClient }]; } });
|
|
344
|
+
|
|
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
|
+
}
|
|
334
351
|
}
|
|
335
352
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
353
|
+
const userBalanceResponseFactoryToken = new InjectionToken('UserBalanceResponse');
|
|
354
|
+
const userBalanceResponseFactoryProvider = {
|
|
355
|
+
provide: userBalanceResponseFactoryToken,
|
|
356
|
+
useValue: (...args) => new UserBalanceResponse(...args),
|
|
357
|
+
};
|
|
358
|
+
|
|
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
|
+
}
|
|
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 }]; } });
|
|
400
|
+
|
|
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 LegalService {
|
|
429
|
+
get isJapanUser() {
|
|
430
|
+
return this.settingsService.user?.local === 'ja';
|
|
431
|
+
}
|
|
432
|
+
constructor(settingsService, refundPolicyService) {
|
|
433
|
+
this.settingsService = settingsService;
|
|
434
|
+
this.refundPolicyService = refundPolicyService;
|
|
435
|
+
this.sctlPolicyUrl = 'https://xsolla.com/sctl';
|
|
436
|
+
}
|
|
437
|
+
getLegalComponentConfig() {
|
|
438
|
+
return {
|
|
439
|
+
isJapanUser: this.isJapanUser,
|
|
440
|
+
refundPolicyUrl: this.refundPolicyService.url,
|
|
441
|
+
sctlPolicyUrl: this.sctlPolicyUrl,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
LegalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, deps: [{ token: SettingsService }, { token: RefundPolicyService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
446
|
+
LegalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, providedIn: 'root' });
|
|
447
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: LegalService, decorators: [{
|
|
448
|
+
type: Injectable,
|
|
449
|
+
args: [{
|
|
450
|
+
providedIn: 'root',
|
|
451
|
+
}]
|
|
452
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }]; } });
|
|
453
|
+
|
|
454
|
+
class CoreLibraryService {
|
|
455
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, legalService) {
|
|
456
|
+
this.settingsService = settingsService;
|
|
457
|
+
this.countryService = countryService;
|
|
458
|
+
this.paymentMethodsService = paymentMethodsService;
|
|
459
|
+
this.savedMethodsService = savedMethodsService;
|
|
460
|
+
this.userBalanceService = userBalanceService;
|
|
461
|
+
this.legalService = legalService;
|
|
462
|
+
this.paymentMethods = {
|
|
463
|
+
getList: async () => this.paymentMethodsService.getList(),
|
|
464
|
+
getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
|
|
465
|
+
getSavedMethods: async () => this.savedMethodsService.getList(),
|
|
466
|
+
getUserBalance: async () => this.userBalanceService.getUserBalance(),
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
async init(configuration) {
|
|
470
|
+
return this.settingsService.init(configuration);
|
|
471
|
+
}
|
|
472
|
+
setCountry(country) {
|
|
473
|
+
this.countryService.setCountry(country);
|
|
474
|
+
}
|
|
475
|
+
getLegalComponentConfig() {
|
|
476
|
+
return this.legalService.getLegalComponentConfig();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
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 });
|
|
480
|
+
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
481
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
482
|
+
type: Injectable,
|
|
483
|
+
args: [{
|
|
484
|
+
providedIn: 'root',
|
|
485
|
+
}]
|
|
486
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: LegalService }]; } });
|
|
487
|
+
|
|
488
|
+
class HttpError extends AppError {
|
|
489
|
+
constructor(error, req) {
|
|
490
|
+
super(error.message);
|
|
491
|
+
this.RESTRICTED_KEYS_REGEXP = new RegExp('.*(card_number|number|cvv|cvn|month|year|cardholdername|client_data|dfp|password).*', 'i');
|
|
492
|
+
this.httpErrorData = {
|
|
493
|
+
request: {
|
|
494
|
+
url: req.url,
|
|
495
|
+
method: req.method,
|
|
496
|
+
headers: req.headers,
|
|
497
|
+
},
|
|
498
|
+
response: {
|
|
499
|
+
status: error.status,
|
|
500
|
+
headers: error.headers,
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
if (req.body) {
|
|
504
|
+
this.httpErrorData.request.data = this.cleanPersonalData(req.body);
|
|
505
|
+
}
|
|
506
|
+
if (error.statusText) {
|
|
507
|
+
const errorData = error.error;
|
|
508
|
+
this.httpErrorData.response.data = {
|
|
509
|
+
statusText: error.statusText,
|
|
510
|
+
errors: errorData?.errors ?? [],
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
getHttpErrorData() {
|
|
515
|
+
return this.httpErrorData;
|
|
516
|
+
}
|
|
517
|
+
cleanPersonalData(data) {
|
|
518
|
+
return Object.entries(data).reduce((acc, [key, val]) => {
|
|
519
|
+
return {
|
|
520
|
+
...acc,
|
|
521
|
+
[key]: this.RESTRICTED_KEYS_REGEXP.test(key) ? '***' : val,
|
|
522
|
+
};
|
|
523
|
+
}, {});
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
class HttpExceptionsInterceptor {
|
|
528
|
+
constructor(router) {
|
|
529
|
+
this.router = router;
|
|
530
|
+
}
|
|
531
|
+
intercept(req, next) {
|
|
532
|
+
return next.handle(req).pipe(catchError((error) => {
|
|
533
|
+
return throwError(() => new HttpError(error, req));
|
|
534
|
+
}));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
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 });
|
|
538
|
+
HttpExceptionsInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor });
|
|
539
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: HttpExceptionsInterceptor, decorators: [{
|
|
540
|
+
type: Injectable
|
|
350
541
|
}], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
|
|
351
542
|
|
|
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
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
543
|
+
class CoreLibraryModule {
|
|
544
|
+
}
|
|
545
|
+
CoreLibraryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
546
|
+
CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule] });
|
|
547
|
+
CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, providers: [
|
|
548
|
+
{
|
|
549
|
+
provide: HTTP_INTERCEPTORS,
|
|
550
|
+
useClass: HttpExceptionsInterceptor,
|
|
551
|
+
multi: true,
|
|
552
|
+
},
|
|
553
|
+
{ provide: windowToken, useValue: window },
|
|
554
|
+
paymentMethodsResponseFactoryProvider,
|
|
555
|
+
savedMethodsResponseFactoryProvider,
|
|
556
|
+
userBalanceResponseFactoryProvider,
|
|
557
|
+
], imports: [HttpClientModule] });
|
|
558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
|
|
559
|
+
type: NgModule,
|
|
560
|
+
args: [{
|
|
561
|
+
imports: [HttpClientModule],
|
|
562
|
+
providers: [
|
|
563
|
+
{
|
|
564
|
+
provide: HTTP_INTERCEPTORS,
|
|
565
|
+
useClass: HttpExceptionsInterceptor,
|
|
566
|
+
multi: true,
|
|
567
|
+
},
|
|
568
|
+
{ provide: windowToken, useValue: window },
|
|
569
|
+
paymentMethodsResponseFactoryProvider,
|
|
570
|
+
savedMethodsResponseFactoryProvider,
|
|
571
|
+
userBalanceResponseFactoryProvider,
|
|
572
|
+
],
|
|
573
|
+
}]
|
|
379
574
|
}] });
|
|
380
575
|
|
|
381
|
-
/*
|
|
382
|
-
* Public API Surface of core-library
|
|
576
|
+
/*
|
|
577
|
+
* Public API Surface of core-library
|
|
383
578
|
*/
|
|
384
579
|
|
|
385
|
-
/**
|
|
386
|
-
* Generated bundle index. Do not edit.
|
|
580
|
+
/**
|
|
581
|
+
* Generated bundle index. Do not edit.
|
|
387
582
|
*/
|
|
388
583
|
|
|
389
584
|
export { CoreLibraryModule, CoreLibraryService };
|