@xsolla/payment-client-core 0.1.5-4 → 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/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 +32 -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 +2 -2
- 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 +48 -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/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 +2 -1
- package/fesm2015/xsolla-payment-client-core.mjs +357 -22
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +357 -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/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/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/{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/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-4.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
|
@@ -1822,7 +1822,8 @@ class Converter {
|
|
|
1822
1822
|
convertToFormControl(field) {
|
|
1823
1823
|
return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
|
|
1824
1824
|
}
|
|
1825
|
-
|
|
1825
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1826
|
+
getValidators(field, formState) {
|
|
1826
1827
|
const validators = [];
|
|
1827
1828
|
if (field.isMandatory === "1" /* XpsBoolean.true */) {
|
|
1828
1829
|
validators.push(convertedRequiredValidator());
|
|
@@ -2087,12 +2088,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2087
2088
|
type: Injectable
|
|
2088
2089
|
}], ctorParameters: function () { return [{ type: SyncService }, { type: CreditCardMinLengthValidator }, { type: CreditCardMinLengthValidator }]; } });
|
|
2089
2090
|
|
|
2090
|
-
|
|
2091
|
+
const maxMonths = 12;
|
|
2092
|
+
const getMinMonth = (parsedYear) => {
|
|
2093
|
+
let minMonth = 1;
|
|
2094
|
+
const year = parsedYear ? Number('20' + parsedYear) : null;
|
|
2095
|
+
const today = new Date();
|
|
2096
|
+
minMonth = year === today.getFullYear() ? today.getMonth() + 1 : 1;
|
|
2097
|
+
return minMonth;
|
|
2098
|
+
};
|
|
2099
|
+
const sendErrMessage$1 = (fn) => ({
|
|
2100
|
+
cardMonthExpiration: {
|
|
2101
|
+
message: fn,
|
|
2102
|
+
},
|
|
2103
|
+
});
|
|
2104
|
+
function cardMonthValidator(formState) {
|
|
2105
|
+
return (control) => {
|
|
2106
|
+
var _a;
|
|
2107
|
+
const { value } = control;
|
|
2108
|
+
if (typeof value !== 'string')
|
|
2109
|
+
return null;
|
|
2110
|
+
const minMonth = getMinMonth((_a = formState === null || formState === void 0 ? void 0 : formState.cardYearValue) !== null && _a !== void 0 ? _a : null);
|
|
2111
|
+
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
2112
|
+
const fieldCommonLength = 2;
|
|
2113
|
+
if (value.length !== fieldCommonLength) {
|
|
2114
|
+
return sendErrMessage$1(`Enter ${fieldCommonLength} characters`);
|
|
2115
|
+
}
|
|
2116
|
+
if (!twoDigitsRegex.test(value)) {
|
|
2117
|
+
return sendErrMessage$1(`Enter a valid expiration month`);
|
|
2118
|
+
}
|
|
2119
|
+
if (Number(value) < minMonth) {
|
|
2120
|
+
return sendErrMessage$1(`Enter a month greater than or equal to ${minMonth}`);
|
|
2121
|
+
}
|
|
2122
|
+
if (Number(value) > maxMonths) {
|
|
2123
|
+
return sendErrMessage$1(`Enter a month less than or equal to ${maxMonths}`);
|
|
2124
|
+
}
|
|
2125
|
+
return null;
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
class CardMonthConverter extends Converter {
|
|
2091
2130
|
constructor(syncService) {
|
|
2092
2131
|
super(syncService);
|
|
2093
2132
|
}
|
|
2094
|
-
getValidators() {
|
|
2095
|
-
return [];
|
|
2133
|
+
getValidators(field, formState) {
|
|
2134
|
+
return super.getValidators(field).concat([cardMonthValidator(formState)]);
|
|
2096
2135
|
}
|
|
2097
2136
|
createControlConfig(field, formState) {
|
|
2098
2137
|
var _a;
|
|
@@ -2102,20 +2141,21 @@ class CardExpirationConverter extends Converter {
|
|
|
2102
2141
|
guide: false,
|
|
2103
2142
|
};
|
|
2104
2143
|
config.inputMode = 'numeric';
|
|
2105
|
-
config.
|
|
2144
|
+
config.placeholder = `MM`;
|
|
2145
|
+
config.title = `MM`;
|
|
2106
2146
|
config.disabled = (_a = formState === null || formState === void 0 ? void 0 : formState.disabled) !== null && _a !== void 0 ? _a : false;
|
|
2107
2147
|
return config;
|
|
2108
2148
|
}
|
|
2109
2149
|
getAutocomplete() {
|
|
2110
|
-
return 'cc-exp';
|
|
2150
|
+
return 'cc-exp-month';
|
|
2111
2151
|
}
|
|
2112
2152
|
getDataType() {
|
|
2113
2153
|
return 'text';
|
|
2114
2154
|
}
|
|
2115
2155
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type:
|
|
2156
|
+
CardMonthConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2157
|
+
CardMonthConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter });
|
|
2158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardMonthConverter, decorators: [{
|
|
2119
2159
|
type: Injectable
|
|
2120
2160
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2121
2161
|
|
|
@@ -2125,8 +2165,27 @@ class CvvConverter extends Converter {
|
|
|
2125
2165
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
2126
2166
|
this.maxFieldLength = 4;
|
|
2127
2167
|
}
|
|
2128
|
-
getValidators() {
|
|
2129
|
-
|
|
2168
|
+
getValidators(field, formState) {
|
|
2169
|
+
const validators = super.getValidators(field);
|
|
2170
|
+
const activeCardType = formState ? formState.activeCardType : null;
|
|
2171
|
+
const getPatternValidator = (pattern) => convert(Validators.pattern(pattern), `Enter a valid CVV/CVC`);
|
|
2172
|
+
switch (activeCardType) {
|
|
2173
|
+
case CreditCardTypes.AMERICAN_EXPRESS: {
|
|
2174
|
+
this.maxFieldLength = 4;
|
|
2175
|
+
validators.push(getPatternValidator(/^\d{4}$/));
|
|
2176
|
+
break;
|
|
2177
|
+
}
|
|
2178
|
+
case CreditCardTypes.MAESTRO: {
|
|
2179
|
+
this.maxFieldLength = 3;
|
|
2180
|
+
validators.push(getPatternValidator(/^\d{0,3}$/));
|
|
2181
|
+
break;
|
|
2182
|
+
}
|
|
2183
|
+
default: {
|
|
2184
|
+
this.maxFieldLength = 3;
|
|
2185
|
+
validators.push(getPatternValidator(/^\d{3}$/));
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
return validators;
|
|
2130
2189
|
}
|
|
2131
2190
|
createControlConfig(field, formState) {
|
|
2132
2191
|
var _a;
|
|
@@ -2339,6 +2398,227 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2339
2398
|
type: Injectable
|
|
2340
2399
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2341
2400
|
|
|
2401
|
+
class CheckboxControlConfig extends ControlConfig {
|
|
2402
|
+
constructor() {
|
|
2403
|
+
super(...arguments);
|
|
2404
|
+
this.controlType = 'checkbox';
|
|
2405
|
+
this.checkedValue = true; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2406
|
+
this.uncheckedValue = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
class CheckboxConverter extends Converter {
|
|
2411
|
+
constructor(syncService) {
|
|
2412
|
+
super(syncService);
|
|
2413
|
+
this.checkedValue = "1" /* XpsBoolean.true */;
|
|
2414
|
+
this.uncheckedValue = "0" /* XpsBoolean.false */;
|
|
2415
|
+
}
|
|
2416
|
+
getValidators(field) {
|
|
2417
|
+
const validators = [];
|
|
2418
|
+
if (field.isMandatory === this.checkedValue) {
|
|
2419
|
+
validators.push(convert(restrictedValueValidator(this.uncheckedValue), 'validation_message_required_checkbox'));
|
|
2420
|
+
}
|
|
2421
|
+
return validators;
|
|
2422
|
+
}
|
|
2423
|
+
createControlConfig(field) {
|
|
2424
|
+
const config = this.createDefaultControlConfig(CheckboxControlConfig, field);
|
|
2425
|
+
config.placeholder = config.title;
|
|
2426
|
+
config.checkedValue = this.checkedValue;
|
|
2427
|
+
config.uncheckedValue = this.uncheckedValue;
|
|
2428
|
+
return config;
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
CheckboxConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2432
|
+
CheckboxConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter });
|
|
2433
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckboxConverter, decorators: [{
|
|
2434
|
+
type: Injectable
|
|
2435
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2436
|
+
|
|
2437
|
+
class SearchSelectControlConfig extends ControlConfig {
|
|
2438
|
+
constructor() {
|
|
2439
|
+
super(...arguments);
|
|
2440
|
+
this.controlType = 'search-select';
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
class SelectConverter extends Converter {
|
|
2445
|
+
constructor(syncService) {
|
|
2446
|
+
super(syncService);
|
|
2447
|
+
}
|
|
2448
|
+
createControlConfig(field) {
|
|
2449
|
+
const config = this.createDefaultControlConfig(SearchSelectControlConfig, field);
|
|
2450
|
+
config.options = field.options;
|
|
2451
|
+
return config;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
SelectConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2455
|
+
SelectConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter });
|
|
2456
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SelectConverter, decorators: [{
|
|
2457
|
+
type: Injectable
|
|
2458
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2459
|
+
|
|
2460
|
+
class PinConverter extends Converter {
|
|
2461
|
+
constructor(syncService) {
|
|
2462
|
+
super(syncService);
|
|
2463
|
+
}
|
|
2464
|
+
createControlConfig(field) {
|
|
2465
|
+
return this.createDefaultControlConfig(TextControlConfig, field);
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
PinConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2469
|
+
PinConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter });
|
|
2470
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PinConverter, decorators: [{
|
|
2471
|
+
type: Injectable
|
|
2472
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2473
|
+
|
|
2474
|
+
class RadioControlConfig extends ControlConfig {
|
|
2475
|
+
constructor() {
|
|
2476
|
+
super(...arguments);
|
|
2477
|
+
this.controlType = 'radio';
|
|
2478
|
+
this.options = [];
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
class RadioGroupConverter extends Converter {
|
|
2483
|
+
constructor(syncService) {
|
|
2484
|
+
super(syncService);
|
|
2485
|
+
}
|
|
2486
|
+
createControlConfig(field) {
|
|
2487
|
+
const config = this.createDefaultControlConfig(RadioControlConfig, field);
|
|
2488
|
+
config.options = field.options;
|
|
2489
|
+
return config;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
RadioGroupConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2493
|
+
RadioGroupConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter });
|
|
2494
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RadioGroupConverter, decorators: [{
|
|
2495
|
+
type: Injectable
|
|
2496
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2497
|
+
|
|
2498
|
+
class PricepointConverter extends Converter {
|
|
2499
|
+
constructor(syncService) {
|
|
2500
|
+
super(syncService);
|
|
2501
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
2502
|
+
this.maxFieldLength = 30;
|
|
2503
|
+
}
|
|
2504
|
+
getValidators(field) {
|
|
2505
|
+
return super.getValidators(field);
|
|
2506
|
+
}
|
|
2507
|
+
createControlConfig(field) {
|
|
2508
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2509
|
+
config.maskConfig = {
|
|
2510
|
+
mask: () => new Array(this.maxFieldLength).fill('9').join(``),
|
|
2511
|
+
unmaskModelValue: false,
|
|
2512
|
+
guide: false,
|
|
2513
|
+
};
|
|
2514
|
+
config.placeholder = field.title;
|
|
2515
|
+
config.inputMode = 'numeric';
|
|
2516
|
+
return config;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
PricepointConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2520
|
+
PricepointConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter });
|
|
2521
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PricepointConverter, decorators: [{
|
|
2522
|
+
type: Injectable
|
|
2523
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2524
|
+
|
|
2525
|
+
class CouponControlConfig extends ControlConfig {
|
|
2526
|
+
constructor() {
|
|
2527
|
+
super(...arguments);
|
|
2528
|
+
this.controlType = 'coupon';
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
function couponValidator(message = `Enter a valid promo code`) {
|
|
2533
|
+
return convert(Validators.pattern(/^[0-9a-z_-]+$/i), message);
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
class CouponConverter extends Converter {
|
|
2537
|
+
constructor(syncService) {
|
|
2538
|
+
super(syncService);
|
|
2539
|
+
}
|
|
2540
|
+
getValidators() {
|
|
2541
|
+
return [couponValidator()];
|
|
2542
|
+
}
|
|
2543
|
+
createControlConfig(field) {
|
|
2544
|
+
const config = this.createDefaultControlConfig(CouponControlConfig, field);
|
|
2545
|
+
config.placeholder = `Enter promo code`;
|
|
2546
|
+
return config;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
CouponConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2550
|
+
CouponConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter });
|
|
2551
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CouponConverter, decorators: [{
|
|
2552
|
+
type: Injectable
|
|
2553
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2554
|
+
|
|
2555
|
+
const sendErrMessage = (fn) => ({
|
|
2556
|
+
cardYearExpiration: {
|
|
2557
|
+
message: fn,
|
|
2558
|
+
},
|
|
2559
|
+
});
|
|
2560
|
+
const getLastCharactersInYear = (str = new Date().getFullYear().toString()) => {
|
|
2561
|
+
// for getting last characters in year; need to check in future
|
|
2562
|
+
return str.slice(str.length - 2);
|
|
2563
|
+
};
|
|
2564
|
+
// Карта выдается максимум на 50 лет
|
|
2565
|
+
const maxYearsCount = 50;
|
|
2566
|
+
function cardYearValidator(control) {
|
|
2567
|
+
const { value } = control;
|
|
2568
|
+
if (typeof value !== 'string')
|
|
2569
|
+
return null;
|
|
2570
|
+
const minYear = parseInt(getLastCharactersInYear(), 10);
|
|
2571
|
+
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
2572
|
+
const fieldCommonLength = 2;
|
|
2573
|
+
if (value.length !== fieldCommonLength) {
|
|
2574
|
+
return sendErrMessage(`Enter ${fieldCommonLength} characters`);
|
|
2575
|
+
}
|
|
2576
|
+
if (!twoDigitsRegex.test(value)) {
|
|
2577
|
+
return sendErrMessage(`Enter a valid expiration year`);
|
|
2578
|
+
}
|
|
2579
|
+
if (Number(value) < minYear) {
|
|
2580
|
+
return sendErrMessage(`Enter a year greater than or equal to ${minYear}`);
|
|
2581
|
+
}
|
|
2582
|
+
const maxValidYear = minYear + maxYearsCount;
|
|
2583
|
+
if (Number(value) > maxValidYear) {
|
|
2584
|
+
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}`);
|
|
2585
|
+
}
|
|
2586
|
+
return null;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
class CardYearConverter extends Converter {
|
|
2590
|
+
constructor(syncService) {
|
|
2591
|
+
super(syncService);
|
|
2592
|
+
}
|
|
2593
|
+
getValidators(field) {
|
|
2594
|
+
return super.getValidators(field).concat([cardYearValidator]);
|
|
2595
|
+
}
|
|
2596
|
+
createControlConfig(field, formState) {
|
|
2597
|
+
var _a;
|
|
2598
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2599
|
+
config.maskConfig = {
|
|
2600
|
+
mask: '99',
|
|
2601
|
+
guide: false,
|
|
2602
|
+
};
|
|
2603
|
+
config.inputMode = 'numeric';
|
|
2604
|
+
config.placeholder = `YY`;
|
|
2605
|
+
config.title = `YY`;
|
|
2606
|
+
config.disabled = (_a = formState === null || formState === void 0 ? void 0 : formState.disabled) !== null && _a !== void 0 ? _a : false;
|
|
2607
|
+
return config;
|
|
2608
|
+
}
|
|
2609
|
+
getAutocomplete() {
|
|
2610
|
+
return 'cc-exp-year';
|
|
2611
|
+
}
|
|
2612
|
+
getDataType() {
|
|
2613
|
+
return 'text';
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
CardYearConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2617
|
+
CardYearConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter });
|
|
2618
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardYearConverter, decorators: [{
|
|
2619
|
+
type: Injectable
|
|
2620
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2621
|
+
|
|
2342
2622
|
function phoneValidator() {
|
|
2343
2623
|
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
|
|
2344
2624
|
}
|
|
@@ -2388,19 +2668,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2388
2668
|
|
|
2389
2669
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
2390
2670
|
const convertersMap = {
|
|
2391
|
-
zip: ZipConverter,
|
|
2392
|
-
email: EmailConverter,
|
|
2393
2671
|
card_number: CardNumberConverter,
|
|
2394
|
-
card_month:
|
|
2395
|
-
card_year:
|
|
2672
|
+
card_month: CardMonthConverter,
|
|
2673
|
+
card_year: CardYearConverter,
|
|
2396
2674
|
cvv: CvvConverter,
|
|
2397
2675
|
extra_cvv: CvvConverter,
|
|
2676
|
+
zip: ZipConverter,
|
|
2398
2677
|
cardholdername: CardholderNameConverter,
|
|
2399
2678
|
cpf_number: CpfNumberConverter,
|
|
2400
2679
|
cpf_name: CpfNameConverter,
|
|
2401
2680
|
birth_date: BirthDateConverter,
|
|
2402
|
-
street_number: StreetNumberConverter,
|
|
2403
2681
|
text: TextConverter,
|
|
2682
|
+
check: CheckboxConverter,
|
|
2683
|
+
select: SelectConverter,
|
|
2684
|
+
pin: PinConverter,
|
|
2685
|
+
radiogroup: RadioGroupConverter,
|
|
2686
|
+
email: EmailConverter,
|
|
2687
|
+
psEmail: EmailConverter,
|
|
2688
|
+
bazitemail: EmailConverter,
|
|
2689
|
+
street_number: StreetNumberConverter,
|
|
2690
|
+
sum: PricepointConverter,
|
|
2691
|
+
out: PricepointConverter,
|
|
2692
|
+
couponCode: CouponConverter,
|
|
2404
2693
|
phone: PhoneConverter,
|
|
2405
2694
|
};
|
|
2406
2695
|
|
|
@@ -2452,6 +2741,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2452
2741
|
class FormService {
|
|
2453
2742
|
constructor(controlConfigService) {
|
|
2454
2743
|
this.controlConfigService = controlConfigService;
|
|
2744
|
+
this.fieldFormStates = {};
|
|
2455
2745
|
}
|
|
2456
2746
|
createForm(fields) {
|
|
2457
2747
|
const controls = this.getVisibleFields(fields).reduce((result, field) => {
|
|
@@ -2463,6 +2753,21 @@ class FormService {
|
|
|
2463
2753
|
}, {});
|
|
2464
2754
|
return new UntypedFormGroup(controls);
|
|
2465
2755
|
}
|
|
2756
|
+
updateFieldFormState(form, fields, fieldName, formState) {
|
|
2757
|
+
var _a;
|
|
2758
|
+
const field = fields.find((fieldItem) => fieldItem.name === fieldName);
|
|
2759
|
+
if (!field) {
|
|
2760
|
+
return;
|
|
2761
|
+
}
|
|
2762
|
+
const converter = this.controlConfigService.getConverter(field);
|
|
2763
|
+
const control = form.controls[fieldName];
|
|
2764
|
+
if (!control) {
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
this.fieldFormStates[fieldName] = Object.assign(Object.assign({}, this.fieldFormStates[fieldName]), formState);
|
|
2768
|
+
control.setValidators((_a = converter === null || converter === void 0 ? void 0 : converter.getValidators(field, this.fieldFormStates[fieldName])) !== null && _a !== void 0 ? _a : []);
|
|
2769
|
+
control.updateValueAndValidity();
|
|
2770
|
+
}
|
|
2466
2771
|
getVisibleFields(fields) {
|
|
2467
2772
|
return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
|
|
2468
2773
|
}
|
|
@@ -4425,6 +4730,11 @@ class PaymentService {
|
|
|
4425
4730
|
getFinanceDetails() {
|
|
4426
4731
|
return this.financeDetails;
|
|
4427
4732
|
}
|
|
4733
|
+
updateFieldFormState(fieldName, formState) {
|
|
4734
|
+
if (this.form) {
|
|
4735
|
+
this.formService.updateFieldFormState(this.form, this.fields, fieldName, formState);
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4428
4738
|
getStatus() {
|
|
4429
4739
|
var _a, _b, _c, _d;
|
|
4430
4740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -4694,6 +5004,7 @@ class CoreLibraryService {
|
|
|
4694
5004
|
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
4695
5005
|
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
4696
5006
|
changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
|
|
5007
|
+
updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
|
|
4697
5008
|
},
|
|
4698
5009
|
};
|
|
4699
5010
|
}
|
|
@@ -4798,16 +5109,28 @@ FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
|
|
|
4798
5109
|
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
4799
5110
|
FormService,
|
|
4800
5111
|
ControlConfigService,
|
|
4801
|
-
ZipConverter,
|
|
4802
|
-
EmailConverter,
|
|
4803
5112
|
CardNumberConverter,
|
|
4804
|
-
|
|
5113
|
+
CardMonthConverter,
|
|
5114
|
+
CardYearConverter,
|
|
4805
5115
|
CvvConverter,
|
|
5116
|
+
CvvConverter,
|
|
5117
|
+
ZipConverter,
|
|
4806
5118
|
CardholderNameConverter,
|
|
4807
5119
|
CpfNumberConverter,
|
|
4808
5120
|
CpfNameConverter,
|
|
4809
5121
|
BirthDateConverter,
|
|
5122
|
+
TextConverter,
|
|
5123
|
+
CheckboxConverter,
|
|
5124
|
+
SelectConverter,
|
|
5125
|
+
PinConverter,
|
|
5126
|
+
RadioGroupConverter,
|
|
5127
|
+
EmailConverter,
|
|
5128
|
+
EmailConverter,
|
|
5129
|
+
EmailConverter,
|
|
4810
5130
|
StreetNumberConverter,
|
|
5131
|
+
PricepointConverter,
|
|
5132
|
+
PricepointConverter,
|
|
5133
|
+
CouponConverter,
|
|
4811
5134
|
TextConverter,
|
|
4812
5135
|
PhoneConverter,
|
|
4813
5136
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
@@ -4819,16 +5142,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4819
5142
|
providers: [
|
|
4820
5143
|
FormService,
|
|
4821
5144
|
ControlConfigService,
|
|
4822
|
-
ZipConverter,
|
|
4823
|
-
EmailConverter,
|
|
4824
5145
|
CardNumberConverter,
|
|
4825
|
-
|
|
5146
|
+
CardMonthConverter,
|
|
5147
|
+
CardYearConverter,
|
|
5148
|
+
CvvConverter,
|
|
4826
5149
|
CvvConverter,
|
|
5150
|
+
ZipConverter,
|
|
4827
5151
|
CardholderNameConverter,
|
|
4828
5152
|
CpfNumberConverter,
|
|
4829
5153
|
CpfNameConverter,
|
|
4830
5154
|
BirthDateConverter,
|
|
5155
|
+
TextConverter,
|
|
5156
|
+
CheckboxConverter,
|
|
5157
|
+
SelectConverter,
|
|
5158
|
+
PinConverter,
|
|
5159
|
+
RadioGroupConverter,
|
|
5160
|
+
EmailConverter,
|
|
5161
|
+
EmailConverter,
|
|
5162
|
+
EmailConverter,
|
|
4831
5163
|
StreetNumberConverter,
|
|
5164
|
+
PricepointConverter,
|
|
5165
|
+
PricepointConverter,
|
|
5166
|
+
CouponConverter,
|
|
4832
5167
|
TextConverter,
|
|
4833
5168
|
PhoneConverter,
|
|
4834
5169
|
{ provide: convertersMapToken, useValue: convertersMap },
|