@xsolla/payment-client-core 0.1.5 → 0.1.6-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/payment/form/controls/card-number/card-number-control.config.mjs +10 -0
- package/esm2020/lib/core/payment/form/controls/checkbox/checkbox-control.config.mjs +10 -0
- package/esm2020/lib/core/payment/form/controls/coupon/coupon-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/controls/phone-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/controls/radio-control/radio-control.config.mjs +9 -0
- package/esm2020/lib/core/payment/form/controls/radio-control/radio-option.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/controls/search-select/search-select-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/controls/search-select/search-select-option.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/controls/search-select/select-option.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/birth-date/birth-date.converter.mjs +38 -0
- package/esm2020/lib/core/payment/form/converters/card-month/card-month.converter.mjs +38 -0
- package/esm2020/lib/core/payment/form/converters/card-number/card-number.converter.mjs +45 -0
- package/esm2020/lib/core/payment/form/converters/card-year/card-year.converter.mjs +38 -0
- package/esm2020/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.mjs +25 -0
- package/esm2020/lib/core/payment/form/converters/checkbox/checkbox.converter.mjs +34 -0
- package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +4 -3
- package/esm2020/lib/core/payment/form/converters/converters-map.mjs +34 -16
- package/esm2020/lib/core/payment/form/converters/coupon/coupon.converter.mjs +25 -0
- package/esm2020/lib/core/payment/form/converters/cpf-name/cpf-name-regex.variable.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/cpf-name/cpf-name.converter.mjs +34 -0
- package/esm2020/lib/core/payment/form/converters/cpf-number/cpf-number.converter.mjs +31 -0
- package/esm2020/lib/core/payment/form/converters/cvv/cvv-form-state.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/cvv/cvv.converter.mjs +72 -0
- package/esm2020/lib/core/payment/form/converters/email/email.converter.mjs +29 -0
- package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +37 -0
- package/esm2020/lib/core/payment/form/converters/pin/pin.converter.mjs +19 -0
- package/esm2020/lib/core/payment/form/converters/pricepoint/pricepoint.converter.mjs +32 -0
- package/esm2020/lib/core/payment/form/converters/radio-group/radio-group.converter.mjs +21 -0
- package/esm2020/lib/core/payment/form/converters/select/select.converter.mjs +21 -0
- package/esm2020/lib/core/payment/form/converters/street-number/street-number.converter.mjs +2 -2
- package/esm2020/lib/core/payment/form/converters/text/text.converter.mjs +19 -0
- package/esm2020/lib/core/payment/form/converters/zip/zip.converter.mjs +67 -0
- package/esm2020/lib/core/payment/form/field-form-states.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/form.module.mjs +51 -17
- package/esm2020/lib/core/payment/form/form.service.mjs +19 -1
- package/esm2020/lib/core/payment/form/validators/birth-date/birth-date.validator.mjs +37 -0
- package/esm2020/lib/core/payment/form/validators/card-month/card-month.validator.mjs +37 -0
- package/esm2020/lib/core/payment/form/validators/card-year/card-year.validator.mjs +34 -0
- package/esm2020/lib/core/payment/form/validators/coupon/coupon-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/credit-card-length/credit-card-min-length.validator.mjs +32 -0
- package/esm2020/lib/core/payment/form/validators/email/email-validator.mjs +7 -0
- package/esm2020/lib/core/payment/form/validators/max-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/min-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/phone-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/required/required.validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/restricted-value/restricted-value.validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/validators.module.mjs +2 -2
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +6 -1
- package/esm2020/lib/core-library.service.mjs +5 -1
- package/fesm2015/xsolla-payment-client-core.mjs +410 -22
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +410 -22
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/controls/{card-number-control.config.d.ts → card-number/card-number-control.config.d.ts} +2 -2
- package/lib/core/payment/form/controls/checkbox/checkbox-control.config.d.ts +6 -0
- package/lib/core/payment/form/controls/coupon/coupon-control.config.d.ts +8 -0
- package/lib/core/payment/form/controls/phone-control.config.d.ts +6 -0
- package/lib/core/payment/form/controls/radio-control/radio-control.config.d.ts +6 -0
- package/lib/core/payment/form/controls/radio-control/radio-option.interface.d.ts +5 -0
- package/lib/core/payment/form/controls/search-select/search-select-control.config.d.ts +11 -0
- package/lib/core/payment/form/controls/search-select/search-select-option.interface.d.ts +19 -0
- package/lib/core/payment/form/controls/search-select/select-option.interface.d.ts +13 -0
- package/lib/core/payment/form/converters/{birth-date.converter.d.ts → birth-date/birth-date.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/card-month/card-month.converter.d.ts +16 -0
- package/lib/core/payment/form/converters/{card-number.converter.d.ts → card-number/card-number.converter.d.ts} +6 -6
- package/lib/core/payment/form/converters/card-year/card-year.converter.d.ts +16 -0
- package/lib/core/payment/form/converters/{cardholder-name.converter.d.ts → cardholder-name/cardholder-name.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/checkbox/checkbox.converter.d.ts +16 -0
- package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -1
- package/lib/core/payment/form/converters/coupon/coupon.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/{cpf-name.converter.d.ts → cpf-name/cpf-name.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/{cpf-number.converter.d.ts → cpf-number/cpf-number.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/cvv/cvv-form-state.interface.d.ts +3 -0
- package/lib/core/payment/form/converters/{cvv.converter.d.ts → cvv/cvv.converter.d.ts} +8 -7
- package/lib/core/payment/form/converters/{email.converter.d.ts → email/email.converter.d.ts} +5 -5
- package/lib/core/payment/form/converters/phone.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/pin/pin.converter.d.ts +11 -0
- package/lib/core/payment/form/converters/pricepoint/pricepoint.converter.d.ts +14 -0
- package/lib/core/payment/form/converters/radio-group/radio-group.converter.d.ts +11 -0
- package/lib/core/payment/form/converters/select/select.converter.d.ts +11 -0
- package/lib/core/payment/form/converters/{text.converter.d.ts → text/text.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/{zip.converter.d.ts → zip/zip.converter.d.ts} +5 -5
- package/lib/core/payment/form/field-form-states.interface.d.ts +4 -0
- package/lib/core/payment/form/form.service.d.ts +4 -0
- package/lib/core/payment/form/validators/card-month/card-month.validator.d.ts +5 -0
- package/lib/core/payment/form/validators/card-year/card-year.validator.d.ts +5 -0
- package/lib/core/payment/form/validators/coupon/coupon-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/{credit-card-min-length.validator.d.ts → credit-card-length/credit-card-min-length.validator.d.ts} +1 -1
- package/lib/core/payment/form/validators/{email-validator.d.ts → email/email-validator.d.ts} +1 -1
- package/lib/core/payment/form/validators/max-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/min-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/phone-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/{restricted-value.validator.d.ts → restricted-value/restricted-value.validator.d.ts} +1 -1
- package/lib/core/payment/payment.interface.d.ts +2 -0
- package/lib/core/payment/payment.service.d.ts +2 -0
- package/lib/core-library.service.d.ts +1 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.6-1.tgz +0 -0
- package/esm2020/lib/core/payment/form/controls/card-number-control.config.mjs +0 -10
- package/esm2020/lib/core/payment/form/converters/birth-date.converter.mjs +0 -38
- package/esm2020/lib/core/payment/form/converters/card-expiration.converter.mjs +0 -36
- package/esm2020/lib/core/payment/form/converters/card-number.converter.mjs +0 -45
- package/esm2020/lib/core/payment/form/converters/cardholder-name.converter.mjs +0 -25
- package/esm2020/lib/core/payment/form/converters/cpf-name-regex.variable.mjs +0 -2
- package/esm2020/lib/core/payment/form/converters/cpf-name.converter.mjs +0 -34
- package/esm2020/lib/core/payment/form/converters/cpf-number.converter.mjs +0 -31
- package/esm2020/lib/core/payment/form/converters/cvv.converter.mjs +0 -50
- package/esm2020/lib/core/payment/form/converters/email.converter.mjs +0 -29
- package/esm2020/lib/core/payment/form/converters/text.converter.mjs +0 -19
- package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +0 -67
- package/esm2020/lib/core/payment/form/validators/birth-date.validator.mjs +0 -37
- package/esm2020/lib/core/payment/form/validators/credit-card-min-length.validator.mjs +0 -32
- package/esm2020/lib/core/payment/form/validators/email-validator.mjs +0 -7
- package/esm2020/lib/core/payment/form/validators/required-validator.mjs +0 -6
- package/esm2020/lib/core/payment/form/validators/restricted-value.validator.mjs +0 -6
- package/lib/core/payment/form/converters/card-expiration.converter.d.ts +0 -16
- package/xsolla-payment-client-core-0.1.5.tgz +0 -0
- /package/lib/core/payment/form/converters/{cpf-name-regex.variable.d.ts → cpf-name/cpf-name-regex.variable.d.ts} +0 -0
- /package/lib/core/payment/form/validators/{birth-date.validator.d.ts → birth-date/birth-date.validator.d.ts} +0 -0
- /package/lib/core/payment/form/validators/{required-validator.d.ts → required/required.validator.d.ts} +0 -0
|
@@ -1765,7 +1765,8 @@ class Converter {
|
|
|
1765
1765
|
convertToFormControl(field) {
|
|
1766
1766
|
return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
|
|
1767
1767
|
}
|
|
1768
|
-
|
|
1768
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1769
|
+
getValidators(field, formState) {
|
|
1769
1770
|
const validators = [];
|
|
1770
1771
|
if (field.isMandatory === "1" /* XpsBoolean.true */) {
|
|
1771
1772
|
validators.push(convertedRequiredValidator());
|
|
@@ -2029,12 +2030,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2029
2030
|
type: Injectable
|
|
2030
2031
|
}], ctorParameters: function () { return [{ type: SyncService }, { type: CreditCardMinLengthValidator }, { type: CreditCardMinLengthValidator }]; } });
|
|
2031
2032
|
|
|
2032
|
-
|
|
2033
|
+
const maxMonths = 12;
|
|
2034
|
+
const getMinMonth = (parsedYear) => {
|
|
2035
|
+
let minMonth = 1;
|
|
2036
|
+
const year = parsedYear ? Number('20' + parsedYear) : null;
|
|
2037
|
+
const today = new Date();
|
|
2038
|
+
minMonth = year === today.getFullYear() ? today.getMonth() + 1 : 1;
|
|
2039
|
+
return minMonth;
|
|
2040
|
+
};
|
|
2041
|
+
const sendErrMessage$1 = (fn) => ({
|
|
2042
|
+
cardMonthExpiration: {
|
|
2043
|
+
message: fn,
|
|
2044
|
+
},
|
|
2045
|
+
});
|
|
2046
|
+
function cardMonthValidator(formState) {
|
|
2047
|
+
return (control) => {
|
|
2048
|
+
const { value } = control;
|
|
2049
|
+
if (typeof value !== 'string')
|
|
2050
|
+
return null;
|
|
2051
|
+
const minMonth = getMinMonth(formState?.cardYearValue ?? null);
|
|
2052
|
+
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
2053
|
+
const fieldCommonLength = 2;
|
|
2054
|
+
if (value.length !== fieldCommonLength) {
|
|
2055
|
+
return sendErrMessage$1(`Enter ${fieldCommonLength} characters`);
|
|
2056
|
+
}
|
|
2057
|
+
if (!twoDigitsRegex.test(value)) {
|
|
2058
|
+
return sendErrMessage$1(`Enter a valid expiration month`);
|
|
2059
|
+
}
|
|
2060
|
+
if (Number(value) < minMonth) {
|
|
2061
|
+
return sendErrMessage$1(`Enter a month greater than or equal to ${minMonth}`);
|
|
2062
|
+
}
|
|
2063
|
+
if (Number(value) > maxMonths) {
|
|
2064
|
+
return sendErrMessage$1(`Enter a month less than or equal to ${maxMonths}`);
|
|
2065
|
+
}
|
|
2066
|
+
return null;
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
class CardMonthConverter extends Converter {
|
|
2033
2071
|
constructor(syncService) {
|
|
2034
2072
|
super(syncService);
|
|
2035
2073
|
}
|
|
2036
|
-
getValidators() {
|
|
2037
|
-
return [];
|
|
2074
|
+
getValidators(field, formState) {
|
|
2075
|
+
return super.getValidators(field).concat([cardMonthValidator(formState)]);
|
|
2038
2076
|
}
|
|
2039
2077
|
createControlConfig(field, formState) {
|
|
2040
2078
|
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
@@ -2043,20 +2081,21 @@ class CardExpirationConverter extends Converter {
|
|
|
2043
2081
|
guide: false,
|
|
2044
2082
|
};
|
|
2045
2083
|
config.inputMode = 'numeric';
|
|
2046
|
-
config.
|
|
2084
|
+
config.placeholder = `MM`;
|
|
2085
|
+
config.title = `MM`;
|
|
2047
2086
|
config.disabled = formState?.disabled ?? false;
|
|
2048
2087
|
return config;
|
|
2049
2088
|
}
|
|
2050
2089
|
getAutocomplete() {
|
|
2051
|
-
return 'cc-exp';
|
|
2090
|
+
return 'cc-exp-month';
|
|
2052
2091
|
}
|
|
2053
2092
|
getDataType() {
|
|
2054
2093
|
return 'text';
|
|
2055
2094
|
}
|
|
2056
2095
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type:
|
|
2096
|
+
CardMonthConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2097
|
+
CardMonthConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter });
|
|
2098
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter, decorators: [{
|
|
2060
2099
|
type: Injectable
|
|
2061
2100
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2062
2101
|
|
|
@@ -2066,8 +2105,27 @@ class CvvConverter extends Converter {
|
|
|
2066
2105
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
2067
2106
|
this.maxFieldLength = 4;
|
|
2068
2107
|
}
|
|
2069
|
-
getValidators() {
|
|
2070
|
-
|
|
2108
|
+
getValidators(field, formState) {
|
|
2109
|
+
const validators = super.getValidators(field);
|
|
2110
|
+
const activeCardType = formState ? formState.activeCardType : null;
|
|
2111
|
+
const getPatternValidator = (pattern) => convert(Validators.pattern(pattern), `Enter a valid CVV/CVC`);
|
|
2112
|
+
switch (activeCardType) {
|
|
2113
|
+
case CreditCardTypes.AMERICAN_EXPRESS: {
|
|
2114
|
+
this.maxFieldLength = 4;
|
|
2115
|
+
validators.push(getPatternValidator(/^\d{4}$/));
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2118
|
+
case CreditCardTypes.MAESTRO: {
|
|
2119
|
+
this.maxFieldLength = 3;
|
|
2120
|
+
validators.push(getPatternValidator(/^\d{0,3}$/));
|
|
2121
|
+
break;
|
|
2122
|
+
}
|
|
2123
|
+
default: {
|
|
2124
|
+
this.maxFieldLength = 3;
|
|
2125
|
+
validators.push(getPatternValidator(/^\d{3}$/));
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return validators;
|
|
2071
2129
|
}
|
|
2072
2130
|
createControlConfig(field, formState) {
|
|
2073
2131
|
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
@@ -2279,21 +2337,298 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2279
2337
|
type: Injectable
|
|
2280
2338
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2281
2339
|
|
|
2340
|
+
class CheckboxControlConfig extends ControlConfig {
|
|
2341
|
+
constructor() {
|
|
2342
|
+
super(...arguments);
|
|
2343
|
+
this.controlType = 'checkbox';
|
|
2344
|
+
this.checkedValue = true; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2345
|
+
this.uncheckedValue = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
class CheckboxConverter extends Converter {
|
|
2350
|
+
constructor(syncService) {
|
|
2351
|
+
super(syncService);
|
|
2352
|
+
this.checkedValue = "1" /* XpsBoolean.true */;
|
|
2353
|
+
this.uncheckedValue = "0" /* XpsBoolean.false */;
|
|
2354
|
+
}
|
|
2355
|
+
getValidators(field) {
|
|
2356
|
+
const validators = [];
|
|
2357
|
+
if (field.isMandatory === this.checkedValue) {
|
|
2358
|
+
validators.push(convert(restrictedValueValidator(this.uncheckedValue), 'validation_message_required_checkbox'));
|
|
2359
|
+
}
|
|
2360
|
+
return validators;
|
|
2361
|
+
}
|
|
2362
|
+
createControlConfig(field) {
|
|
2363
|
+
const config = this.createDefaultControlConfig(CheckboxControlConfig, field);
|
|
2364
|
+
config.placeholder = config.title;
|
|
2365
|
+
config.checkedValue = this.checkedValue;
|
|
2366
|
+
config.uncheckedValue = this.uncheckedValue;
|
|
2367
|
+
return config;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
CheckboxConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2371
|
+
CheckboxConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter });
|
|
2372
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter, decorators: [{
|
|
2373
|
+
type: Injectable
|
|
2374
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2375
|
+
|
|
2376
|
+
class SearchSelectControlConfig extends ControlConfig {
|
|
2377
|
+
constructor() {
|
|
2378
|
+
super(...arguments);
|
|
2379
|
+
this.controlType = 'search-select';
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
class SelectConverter extends Converter {
|
|
2384
|
+
constructor(syncService) {
|
|
2385
|
+
super(syncService);
|
|
2386
|
+
}
|
|
2387
|
+
createControlConfig(field) {
|
|
2388
|
+
const config = this.createDefaultControlConfig(SearchSelectControlConfig, field);
|
|
2389
|
+
config.options = field.options;
|
|
2390
|
+
return config;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
SelectConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2394
|
+
SelectConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter });
|
|
2395
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter, decorators: [{
|
|
2396
|
+
type: Injectable
|
|
2397
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2398
|
+
|
|
2399
|
+
class PinConverter extends Converter {
|
|
2400
|
+
constructor(syncService) {
|
|
2401
|
+
super(syncService);
|
|
2402
|
+
}
|
|
2403
|
+
createControlConfig(field) {
|
|
2404
|
+
return this.createDefaultControlConfig(TextControlConfig, field);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
PinConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2408
|
+
PinConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter });
|
|
2409
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter, decorators: [{
|
|
2410
|
+
type: Injectable
|
|
2411
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2412
|
+
|
|
2413
|
+
class RadioControlConfig extends ControlConfig {
|
|
2414
|
+
constructor() {
|
|
2415
|
+
super(...arguments);
|
|
2416
|
+
this.controlType = 'radio';
|
|
2417
|
+
this.options = [];
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
class RadioGroupConverter extends Converter {
|
|
2422
|
+
constructor(syncService) {
|
|
2423
|
+
super(syncService);
|
|
2424
|
+
}
|
|
2425
|
+
createControlConfig(field) {
|
|
2426
|
+
const config = this.createDefaultControlConfig(RadioControlConfig, field);
|
|
2427
|
+
config.options = field.options;
|
|
2428
|
+
return config;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
RadioGroupConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2432
|
+
RadioGroupConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter });
|
|
2433
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter, decorators: [{
|
|
2434
|
+
type: Injectable
|
|
2435
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2436
|
+
|
|
2437
|
+
class PricepointConverter extends Converter {
|
|
2438
|
+
constructor(syncService) {
|
|
2439
|
+
super(syncService);
|
|
2440
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
2441
|
+
this.maxFieldLength = 30;
|
|
2442
|
+
}
|
|
2443
|
+
getValidators(field) {
|
|
2444
|
+
return super.getValidators(field);
|
|
2445
|
+
}
|
|
2446
|
+
createControlConfig(field) {
|
|
2447
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2448
|
+
config.maskConfig = {
|
|
2449
|
+
mask: () => new Array(this.maxFieldLength).fill('9').join(``),
|
|
2450
|
+
unmaskModelValue: false,
|
|
2451
|
+
guide: false,
|
|
2452
|
+
};
|
|
2453
|
+
config.placeholder = field.title;
|
|
2454
|
+
config.inputMode = 'numeric';
|
|
2455
|
+
return config;
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
PricepointConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2459
|
+
PricepointConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter });
|
|
2460
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter, decorators: [{
|
|
2461
|
+
type: Injectable
|
|
2462
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2463
|
+
|
|
2464
|
+
class CouponControlConfig extends ControlConfig {
|
|
2465
|
+
constructor() {
|
|
2466
|
+
super(...arguments);
|
|
2467
|
+
this.controlType = 'coupon';
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
function couponValidator(message = `Enter a valid promo code`) {
|
|
2472
|
+
return convert(Validators.pattern(/^[0-9a-z_-]+$/i), message);
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
class CouponConverter extends Converter {
|
|
2476
|
+
constructor(syncService) {
|
|
2477
|
+
super(syncService);
|
|
2478
|
+
}
|
|
2479
|
+
getValidators() {
|
|
2480
|
+
return [couponValidator()];
|
|
2481
|
+
}
|
|
2482
|
+
createControlConfig(field) {
|
|
2483
|
+
const config = this.createDefaultControlConfig(CouponControlConfig, field);
|
|
2484
|
+
config.placeholder = `Enter promo code`;
|
|
2485
|
+
return config;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
CouponConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2489
|
+
CouponConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter });
|
|
2490
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter, decorators: [{
|
|
2491
|
+
type: Injectable
|
|
2492
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2493
|
+
|
|
2494
|
+
const sendErrMessage = (fn) => ({
|
|
2495
|
+
cardYearExpiration: {
|
|
2496
|
+
message: fn,
|
|
2497
|
+
},
|
|
2498
|
+
});
|
|
2499
|
+
const getLastCharactersInYear = (str = new Date().getFullYear().toString()) => {
|
|
2500
|
+
// for getting last characters in year; need to check in future
|
|
2501
|
+
return str.slice(str.length - 2);
|
|
2502
|
+
};
|
|
2503
|
+
// Карта выдается максимум на 50 лет
|
|
2504
|
+
const maxYearsCount = 50;
|
|
2505
|
+
function cardYearValidator(control) {
|
|
2506
|
+
const { value } = control;
|
|
2507
|
+
if (typeof value !== 'string')
|
|
2508
|
+
return null;
|
|
2509
|
+
const minYear = parseInt(getLastCharactersInYear(), 10);
|
|
2510
|
+
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
2511
|
+
const fieldCommonLength = 2;
|
|
2512
|
+
if (value.length !== fieldCommonLength) {
|
|
2513
|
+
return sendErrMessage(`Enter ${fieldCommonLength} characters`);
|
|
2514
|
+
}
|
|
2515
|
+
if (!twoDigitsRegex.test(value)) {
|
|
2516
|
+
return sendErrMessage(`Enter a valid expiration year`);
|
|
2517
|
+
}
|
|
2518
|
+
if (Number(value) < minYear) {
|
|
2519
|
+
return sendErrMessage(`Enter a year greater than or equal to ${minYear}`);
|
|
2520
|
+
}
|
|
2521
|
+
const maxValidYear = minYear + maxYearsCount;
|
|
2522
|
+
if (Number(value) > maxValidYear) {
|
|
2523
|
+
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}`);
|
|
2524
|
+
}
|
|
2525
|
+
return null;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
class CardYearConverter extends Converter {
|
|
2529
|
+
constructor(syncService) {
|
|
2530
|
+
super(syncService);
|
|
2531
|
+
}
|
|
2532
|
+
getValidators(field) {
|
|
2533
|
+
return super.getValidators(field).concat([cardYearValidator]);
|
|
2534
|
+
}
|
|
2535
|
+
createControlConfig(field, formState) {
|
|
2536
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2537
|
+
config.maskConfig = {
|
|
2538
|
+
mask: '99',
|
|
2539
|
+
guide: false,
|
|
2540
|
+
};
|
|
2541
|
+
config.inputMode = 'numeric';
|
|
2542
|
+
config.placeholder = `YY`;
|
|
2543
|
+
config.title = `YY`;
|
|
2544
|
+
config.disabled = formState?.disabled ?? false;
|
|
2545
|
+
return config;
|
|
2546
|
+
}
|
|
2547
|
+
getAutocomplete() {
|
|
2548
|
+
return 'cc-exp-year';
|
|
2549
|
+
}
|
|
2550
|
+
getDataType() {
|
|
2551
|
+
return 'text';
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
CardYearConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2555
|
+
CardYearConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter });
|
|
2556
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter, decorators: [{
|
|
2557
|
+
type: Injectable
|
|
2558
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2559
|
+
|
|
2560
|
+
function phoneValidator() {
|
|
2561
|
+
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
function minLengthValidator(minLength) {
|
|
2565
|
+
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
function maxLengthValidator(maxLength) {
|
|
2569
|
+
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
class PhoneControlConfig extends ControlConfig {
|
|
2573
|
+
constructor() {
|
|
2574
|
+
super(...arguments);
|
|
2575
|
+
this.controlType = 'phone';
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
class PhoneConverter extends Converter {
|
|
2580
|
+
constructor(syncService) {
|
|
2581
|
+
super(syncService);
|
|
2582
|
+
}
|
|
2583
|
+
getValidators(field) {
|
|
2584
|
+
const minLength = 10;
|
|
2585
|
+
const maxLength = 15;
|
|
2586
|
+
return super
|
|
2587
|
+
.getValidators(field)
|
|
2588
|
+
.concat([
|
|
2589
|
+
convertedRequiredValidator(),
|
|
2590
|
+
phoneValidator(),
|
|
2591
|
+
minLengthValidator(minLength),
|
|
2592
|
+
maxLengthValidator(maxLength),
|
|
2593
|
+
]);
|
|
2594
|
+
}
|
|
2595
|
+
createControlConfig(field) {
|
|
2596
|
+
const config = this.createDefaultControlConfig(PhoneControlConfig, field);
|
|
2597
|
+
config.inputMode = 'numeric';
|
|
2598
|
+
return config;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
PhoneConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2602
|
+
PhoneConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter });
|
|
2603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, decorators: [{
|
|
2604
|
+
type: Injectable
|
|
2605
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2606
|
+
|
|
2282
2607
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
2283
2608
|
const convertersMap = {
|
|
2284
|
-
zip: ZipConverter,
|
|
2285
|
-
email: EmailConverter,
|
|
2286
2609
|
card_number: CardNumberConverter,
|
|
2287
|
-
card_month:
|
|
2288
|
-
card_year:
|
|
2610
|
+
card_month: CardMonthConverter,
|
|
2611
|
+
card_year: CardYearConverter,
|
|
2289
2612
|
cvv: CvvConverter,
|
|
2290
2613
|
extra_cvv: CvvConverter,
|
|
2614
|
+
zip: ZipConverter,
|
|
2291
2615
|
cardholdername: CardholderNameConverter,
|
|
2292
2616
|
cpf_number: CpfNumberConverter,
|
|
2293
2617
|
cpf_name: CpfNameConverter,
|
|
2294
2618
|
birth_date: BirthDateConverter,
|
|
2295
|
-
street_number: StreetNumberConverter,
|
|
2296
2619
|
text: TextConverter,
|
|
2620
|
+
check: CheckboxConverter,
|
|
2621
|
+
select: SelectConverter,
|
|
2622
|
+
pin: PinConverter,
|
|
2623
|
+
radiogroup: RadioGroupConverter,
|
|
2624
|
+
email: EmailConverter,
|
|
2625
|
+
psEmail: EmailConverter,
|
|
2626
|
+
bazitemail: EmailConverter,
|
|
2627
|
+
street_number: StreetNumberConverter,
|
|
2628
|
+
sum: PricepointConverter,
|
|
2629
|
+
out: PricepointConverter,
|
|
2630
|
+
couponCode: CouponConverter,
|
|
2631
|
+
phone: PhoneConverter,
|
|
2297
2632
|
};
|
|
2298
2633
|
|
|
2299
2634
|
class ControlConfigService {
|
|
@@ -2342,6 +2677,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2342
2677
|
class FormService {
|
|
2343
2678
|
constructor(controlConfigService) {
|
|
2344
2679
|
this.controlConfigService = controlConfigService;
|
|
2680
|
+
this.fieldFormStates = {};
|
|
2345
2681
|
}
|
|
2346
2682
|
createForm(fields) {
|
|
2347
2683
|
const controls = this.getVisibleFields(fields).reduce((result, field) => {
|
|
@@ -2353,6 +2689,23 @@ class FormService {
|
|
|
2353
2689
|
}, {});
|
|
2354
2690
|
return new UntypedFormGroup(controls);
|
|
2355
2691
|
}
|
|
2692
|
+
updateFieldFormState(form, fields, fieldName, formState) {
|
|
2693
|
+
const field = fields.find((fieldItem) => fieldItem.name === fieldName);
|
|
2694
|
+
if (!field) {
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
const converter = this.controlConfigService.getConverter(field);
|
|
2698
|
+
const control = form.controls[fieldName];
|
|
2699
|
+
if (!control) {
|
|
2700
|
+
return;
|
|
2701
|
+
}
|
|
2702
|
+
this.fieldFormStates[fieldName] = {
|
|
2703
|
+
...this.fieldFormStates[fieldName],
|
|
2704
|
+
...formState,
|
|
2705
|
+
};
|
|
2706
|
+
control.setValidators(converter?.getValidators(field, this.fieldFormStates[fieldName]) ?? []);
|
|
2707
|
+
control.updateValueAndValidity();
|
|
2708
|
+
}
|
|
2356
2709
|
getVisibleFields(fields) {
|
|
2357
2710
|
return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
|
|
2358
2711
|
}
|
|
@@ -4241,6 +4594,11 @@ class PaymentService {
|
|
|
4241
4594
|
getFinanceDetails() {
|
|
4242
4595
|
return this.financeDetails;
|
|
4243
4596
|
}
|
|
4597
|
+
updateFieldFormState(fieldName, formState) {
|
|
4598
|
+
if (this.form) {
|
|
4599
|
+
this.formService.updateFieldFormState(this.form, this.fields, fieldName, formState);
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4244
4602
|
async getStatus() {
|
|
4245
4603
|
if (!isSubmitResponse(this.data)) {
|
|
4246
4604
|
throw new Error('Should submit form first');
|
|
@@ -4479,6 +4837,9 @@ class CoreLibraryService {
|
|
|
4479
4837
|
setCountry(country) {
|
|
4480
4838
|
this.countryService.setCountry(country);
|
|
4481
4839
|
}
|
|
4840
|
+
getCountry() {
|
|
4841
|
+
return this.countryService.getCountry();
|
|
4842
|
+
}
|
|
4482
4843
|
createPayment(config) {
|
|
4483
4844
|
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
4484
4845
|
return {
|
|
@@ -4496,6 +4857,7 @@ class CoreLibraryService {
|
|
|
4496
4857
|
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
4497
4858
|
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
4498
4859
|
changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
|
|
4860
|
+
updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
|
|
4499
4861
|
},
|
|
4500
4862
|
};
|
|
4501
4863
|
}
|
|
@@ -4602,17 +4964,30 @@ FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
|
|
|
4602
4964
|
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
4603
4965
|
FormService,
|
|
4604
4966
|
ControlConfigService,
|
|
4605
|
-
ZipConverter,
|
|
4606
|
-
EmailConverter,
|
|
4607
4967
|
CardNumberConverter,
|
|
4608
|
-
|
|
4968
|
+
CardMonthConverter,
|
|
4969
|
+
CardYearConverter,
|
|
4970
|
+
CvvConverter,
|
|
4609
4971
|
CvvConverter,
|
|
4972
|
+
ZipConverter,
|
|
4610
4973
|
CardholderNameConverter,
|
|
4611
4974
|
CpfNumberConverter,
|
|
4612
4975
|
CpfNameConverter,
|
|
4613
4976
|
BirthDateConverter,
|
|
4977
|
+
TextConverter,
|
|
4978
|
+
CheckboxConverter,
|
|
4979
|
+
SelectConverter,
|
|
4980
|
+
PinConverter,
|
|
4981
|
+
RadioGroupConverter,
|
|
4982
|
+
EmailConverter,
|
|
4983
|
+
EmailConverter,
|
|
4984
|
+
EmailConverter,
|
|
4614
4985
|
StreetNumberConverter,
|
|
4986
|
+
PricepointConverter,
|
|
4987
|
+
PricepointConverter,
|
|
4988
|
+
CouponConverter,
|
|
4615
4989
|
TextConverter,
|
|
4990
|
+
PhoneConverter,
|
|
4616
4991
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4617
4992
|
], imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
4618
4993
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
@@ -4622,17 +4997,30 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4622
4997
|
providers: [
|
|
4623
4998
|
FormService,
|
|
4624
4999
|
ControlConfigService,
|
|
4625
|
-
ZipConverter,
|
|
4626
|
-
EmailConverter,
|
|
4627
5000
|
CardNumberConverter,
|
|
4628
|
-
|
|
5001
|
+
CardMonthConverter,
|
|
5002
|
+
CardYearConverter,
|
|
4629
5003
|
CvvConverter,
|
|
5004
|
+
CvvConverter,
|
|
5005
|
+
ZipConverter,
|
|
4630
5006
|
CardholderNameConverter,
|
|
4631
5007
|
CpfNumberConverter,
|
|
4632
5008
|
CpfNameConverter,
|
|
4633
5009
|
BirthDateConverter,
|
|
5010
|
+
TextConverter,
|
|
5011
|
+
CheckboxConverter,
|
|
5012
|
+
SelectConverter,
|
|
5013
|
+
PinConverter,
|
|
5014
|
+
RadioGroupConverter,
|
|
5015
|
+
EmailConverter,
|
|
5016
|
+
EmailConverter,
|
|
5017
|
+
EmailConverter,
|
|
4634
5018
|
StreetNumberConverter,
|
|
5019
|
+
PricepointConverter,
|
|
5020
|
+
PricepointConverter,
|
|
5021
|
+
CouponConverter,
|
|
4635
5022
|
TextConverter,
|
|
5023
|
+
PhoneConverter,
|
|
4636
5024
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4637
5025
|
],
|
|
4638
5026
|
}]
|