@xsolla/payment-client-core 0.0.10-6 → 0.0.10
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/form/converters/converter.abstract.mjs +5 -2
- package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +4 -17
- package/esm2020/lib/core/payment/payment.service.mjs +1 -5
- package/esm2020/lib/core/payment/sync/sync.service.mjs +2 -12
- package/esm2020/lib/core-library.service.mjs +1 -6
- package/fesm2015/xsolla-payment-client-core.mjs +8 -41
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +8 -39
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/converters/converter.abstract.d.ts +2 -1
- package/lib/core/payment/sync/sync.service.d.ts +0 -1
- package/lib/core-library.service.d.ts +0 -2
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.10.tgz +0 -0
- package/esm2020/lib/core/payment/form/masks-functions.map.mjs +0 -4
- package/lib/core/payment/form/masks-functions.map.d.ts +0 -3
- package/xsolla-payment-client-core-0.0.10-6.tgz +0 -0
|
@@ -7,10 +7,6 @@ import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule }
|
|
|
7
7
|
import { filter, map as map$1, catchError } from 'rxjs/operators';
|
|
8
8
|
import * as i1$1 from '@angular/router';
|
|
9
9
|
|
|
10
|
-
const masksFunctionsMap = {
|
|
11
|
-
zip: () => new Array(5).fill('9').join(''),
|
|
12
|
-
};
|
|
13
|
-
|
|
14
10
|
class AppError extends Error {
|
|
15
11
|
constructor(message) {
|
|
16
12
|
super(message);
|
|
@@ -971,9 +967,7 @@ class SyncService extends EmitDataService {
|
|
|
971
967
|
return Promise.resolve(null);
|
|
972
968
|
}
|
|
973
969
|
if (prevFieldState && value === prevFieldState.value) {
|
|
974
|
-
return Promise.resolve(prevFieldState.result)
|
|
975
|
-
return response?.rewritableError ?? null;
|
|
976
|
-
});
|
|
970
|
+
return Promise.resolve(prevFieldState.result);
|
|
977
971
|
}
|
|
978
972
|
const requestPromise = this.request(field);
|
|
979
973
|
this.setPrevFieldSyncState(field, value, requestPromise);
|
|
@@ -981,14 +975,6 @@ class SyncService extends EmitDataService {
|
|
|
981
975
|
return response.rewritableError ?? null;
|
|
982
976
|
});
|
|
983
977
|
}
|
|
984
|
-
getSyncValidationErrors(field) {
|
|
985
|
-
const control = this.form.get(field.name);
|
|
986
|
-
if (!control) {
|
|
987
|
-
return null;
|
|
988
|
-
}
|
|
989
|
-
const rewritableError = control.errors?.rewritableError;
|
|
990
|
-
return rewritableError ? { message: rewritableError.message } : null;
|
|
991
|
-
}
|
|
992
978
|
async request(field) {
|
|
993
979
|
const requestParams = this.requestFactory({
|
|
994
980
|
token: this.settingsService.token,
|
|
@@ -1087,7 +1073,7 @@ class Converter {
|
|
|
1087
1073
|
return config;
|
|
1088
1074
|
}
|
|
1089
1075
|
convertToFormControl(field) {
|
|
1090
|
-
return new UntypedFormControl(this.getValue(field), this.getValidators(field));
|
|
1076
|
+
return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
|
|
1091
1077
|
}
|
|
1092
1078
|
getValidators(field) {
|
|
1093
1079
|
const validators = [];
|
|
@@ -1106,6 +1092,9 @@ class Converter {
|
|
|
1106
1092
|
}
|
|
1107
1093
|
return validators;
|
|
1108
1094
|
}
|
|
1095
|
+
getAsyncValidators(field) {
|
|
1096
|
+
return async () => this.syncService.validate(field);
|
|
1097
|
+
}
|
|
1109
1098
|
createDefaultControlConfig(controlConfigClass, field) {
|
|
1110
1099
|
const config = new controlConfigClass();
|
|
1111
1100
|
this.copyCommonOptions(config, field);
|
|
@@ -1190,8 +1179,8 @@ class ZipConverter extends Converter {
|
|
|
1190
1179
|
const validators = super
|
|
1191
1180
|
.getValidators(field)
|
|
1192
1181
|
.concat([
|
|
1193
|
-
convert(Validators.minLength(minLength),
|
|
1194
|
-
convert(Validators.maxLength(maxLength),
|
|
1182
|
+
convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
|
|
1183
|
+
convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
|
|
1195
1184
|
]);
|
|
1196
1185
|
if (this.isUsCountry) {
|
|
1197
1186
|
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
|
|
@@ -1203,24 +1192,12 @@ class ZipConverter extends Converter {
|
|
|
1203
1192
|
config.icon = 'location';
|
|
1204
1193
|
if (this.isUsCountry) {
|
|
1205
1194
|
config.maskConfig = {
|
|
1206
|
-
|
|
1207
|
-
// mask: () => new Array(5).fill('9').join(''),
|
|
1208
|
-
// mask: function() { return new Array(5).fill('9').join('') },
|
|
1209
|
-
// mask: MasksFunctionsMap['zip'],
|
|
1210
|
-
// mask: function mask() {
|
|
1211
|
-
// const length = this.usCountryLength;
|
|
1212
|
-
// return function() {
|
|
1213
|
-
// return new Array(length).fill('9').join('');
|
|
1214
|
-
// }
|
|
1215
|
-
// },
|
|
1195
|
+
mask: () => new Array(this.usCountryLength).fill('9').join(''),
|
|
1216
1196
|
guide: false,
|
|
1217
1197
|
unmaskModelValue: true,
|
|
1218
1198
|
showMask: true,
|
|
1219
1199
|
};
|
|
1220
1200
|
config.inputMode = 'numeric';
|
|
1221
|
-
if (masksFunctionsMap['zip']) {
|
|
1222
|
-
config.maskConfig.mask = masksFunctionsMap['zip'];
|
|
1223
|
-
}
|
|
1224
1201
|
}
|
|
1225
1202
|
else {
|
|
1226
1203
|
config.maxLength = this.maxLength;
|
|
@@ -2742,10 +2719,6 @@ class PaymentService {
|
|
|
2742
2719
|
return this.data?.paymentForm?.fields ?? [];
|
|
2743
2720
|
}
|
|
2744
2721
|
async validate(field) {
|
|
2745
|
-
const syncErrors = this.syncService.getSyncValidationErrors(field);
|
|
2746
|
-
if (syncErrors) {
|
|
2747
|
-
return Promise.resolve(syncErrors);
|
|
2748
|
-
}
|
|
2749
2722
|
return this.syncService.validate(field);
|
|
2750
2723
|
}
|
|
2751
2724
|
runThreeDs() {
|
|
@@ -2946,10 +2919,6 @@ class CoreLibraryService {
|
|
|
2946
2919
|
getLegalComponentConfig() {
|
|
2947
2920
|
return this.legalService.getLegalComponentConfig();
|
|
2948
2921
|
}
|
|
2949
|
-
getFieldMask(field) {
|
|
2950
|
-
const sanitizedName = field.name.replace(/^fix_/i, '');
|
|
2951
|
-
return masksFunctionsMap[sanitizedName];
|
|
2952
|
-
}
|
|
2953
2922
|
}
|
|
2954
2923
|
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: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2955
2924
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|