@xsolla/payment-client-core 0.1.17 → 0.1.19
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/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status.service.mjs +2 -2
- package/esm2020/lib/core/payment/sync/sync.service.mjs +34 -10
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +12 -1
- package/esm2020/lib/core-library.service.mjs +2 -1
- package/fesm2015/xsolla-payment-client-core.mjs +49 -11
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +46 -10
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/payment.interface.d.ts +2 -1
- package/lib/core/payment/sync/sync.service.d.ts +3 -1
- package/lib/core/payment-methods/payment-methods.service.d.ts +2 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.19.tgz +0 -0
- package/xsolla-payment-client-core-0.1.17.tgz +0 -0
|
@@ -240,6 +240,9 @@ class PaymentMethodsService {
|
|
|
240
240
|
}
|
|
241
241
|
async getList(isSaveMethodMode) {
|
|
242
242
|
const response = await this.request(isSaveMethodMode);
|
|
243
|
+
if (this.isFixedPaymentMethod) {
|
|
244
|
+
return this.filterMethodsByFixedPaymentMethod(response.remained);
|
|
245
|
+
}
|
|
243
246
|
return response.remained;
|
|
244
247
|
}
|
|
245
248
|
async getQuickMethods() {
|
|
@@ -268,6 +271,14 @@ class PaymentMethodsService {
|
|
|
268
271
|
// @ts-expect-error the map already has the cache with key
|
|
269
272
|
return this.cache.get(cacheKey);
|
|
270
273
|
}
|
|
274
|
+
filterMethodsByFixedPaymentMethod(methods) {
|
|
275
|
+
const fixedPid = this.settingsService.purchase?.payment_system?.id;
|
|
276
|
+
const paymentMethod = methods.find((method) => method.id === fixedPid);
|
|
277
|
+
return paymentMethod ? [paymentMethod] : [];
|
|
278
|
+
}
|
|
279
|
+
get isFixedPaymentMethod() {
|
|
280
|
+
return !!this.settingsService.purchase?.payment_system?.id;
|
|
281
|
+
}
|
|
271
282
|
}
|
|
272
283
|
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 });
|
|
273
284
|
PaymentMethodsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentMethodsService, providedIn: 'root' });
|
|
@@ -1859,6 +1870,7 @@ class SyncService extends EmitDataService {
|
|
|
1859
1870
|
this.prevFieldSyncStates = {};
|
|
1860
1871
|
this.form = new UntypedFormGroup({});
|
|
1861
1872
|
this.fields = [];
|
|
1873
|
+
this.fieldSyncTimers = {};
|
|
1862
1874
|
this.fieldAsyncValidation = new Subject();
|
|
1863
1875
|
}
|
|
1864
1876
|
get fieldAsyncValidation$() {
|
|
@@ -1874,7 +1886,7 @@ class SyncService extends EmitDataService {
|
|
|
1874
1886
|
this.form = new UntypedFormGroup({});
|
|
1875
1887
|
this.fields = [];
|
|
1876
1888
|
}
|
|
1877
|
-
async validate(field) {
|
|
1889
|
+
async validate(field, delay = Number('750')) {
|
|
1878
1890
|
if (!this.isReadyField(field)) {
|
|
1879
1891
|
return Promise.resolve(null);
|
|
1880
1892
|
}
|
|
@@ -1890,15 +1902,31 @@ class SyncService extends EmitDataService {
|
|
|
1890
1902
|
return response?.error ?? null;
|
|
1891
1903
|
});
|
|
1892
1904
|
}
|
|
1893
|
-
const
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1905
|
+
const updateFieldState = async () => {
|
|
1906
|
+
const requestPromise = this.request(field);
|
|
1907
|
+
this.setPrevFieldSyncState(field, value, requestPromise);
|
|
1908
|
+
return requestPromise.then((response) => {
|
|
1909
|
+
this.fieldAsyncValidation.next({
|
|
1910
|
+
value,
|
|
1911
|
+
field,
|
|
1912
|
+
response,
|
|
1913
|
+
});
|
|
1914
|
+
return response.error ?? null;
|
|
1900
1915
|
});
|
|
1901
|
-
|
|
1916
|
+
};
|
|
1917
|
+
return new Promise((resolve) => {
|
|
1918
|
+
if (delay) {
|
|
1919
|
+
const timerId = setTimeout(() => {
|
|
1920
|
+
if (value !== control?.value) {
|
|
1921
|
+
return resolve(null);
|
|
1922
|
+
}
|
|
1923
|
+
void updateFieldState().then((errors) => resolve(errors));
|
|
1924
|
+
}, delay);
|
|
1925
|
+
this.resetFieldSyncTimer(field, Number(timerId));
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
void updateFieldState().then((errors) => resolve(errors));
|
|
1929
|
+
}
|
|
1902
1930
|
});
|
|
1903
1931
|
}
|
|
1904
1932
|
getSyncValidationErrors(field) {
|
|
@@ -1939,6 +1967,13 @@ class SyncService extends EmitDataService {
|
|
|
1939
1967
|
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(formErrors));
|
|
1940
1968
|
}
|
|
1941
1969
|
}
|
|
1970
|
+
resetFieldSyncTimer(field, timerId) {
|
|
1971
|
+
const prevTimerId = this.fieldSyncTimers[field.name];
|
|
1972
|
+
if (prevTimerId) {
|
|
1973
|
+
clearTimeout(prevTimerId);
|
|
1974
|
+
}
|
|
1975
|
+
this.fieldSyncTimers[field.name] = timerId;
|
|
1976
|
+
}
|
|
1942
1977
|
}
|
|
1943
1978
|
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1944
1979
|
SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
|
|
@@ -4742,7 +4777,7 @@ class StatusService {
|
|
|
4742
4777
|
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4743
4778
|
}
|
|
4744
4779
|
async getStatus(params) {
|
|
4745
|
-
const isSavePaymentMethodMode =
|
|
4780
|
+
const isSavePaymentMethodMode = params?.isSavePaymentAccount === "1" /* XpsBoolean.true */;
|
|
4746
4781
|
if (isSavePaymentMethodMode) {
|
|
4747
4782
|
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4748
4783
|
}
|
|
@@ -5637,6 +5672,7 @@ class CoreLibraryService {
|
|
|
5637
5672
|
changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
|
|
5638
5673
|
updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
|
|
5639
5674
|
formMessages$: this.formMessagesService.data$,
|
|
5675
|
+
getFormStatus: () => this.paymentService.form?.status,
|
|
5640
5676
|
},
|
|
5641
5677
|
};
|
|
5642
5678
|
}
|