@xsolla/payment-client-core 0.1.5 → 0.1.6
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/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 -19
- 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 -24
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +357 -24
- 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.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
|
@@ -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,21 +2398,251 @@ 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
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
2343
2623
|
const convertersMap = {
|
|
2344
|
-
zip: ZipConverter,
|
|
2345
|
-
email: EmailConverter,
|
|
2346
2624
|
card_number: CardNumberConverter,
|
|
2347
|
-
card_month:
|
|
2348
|
-
card_year:
|
|
2625
|
+
card_month: CardMonthConverter,
|
|
2626
|
+
card_year: CardYearConverter,
|
|
2349
2627
|
cvv: CvvConverter,
|
|
2350
2628
|
extra_cvv: CvvConverter,
|
|
2629
|
+
zip: ZipConverter,
|
|
2351
2630
|
cardholdername: CardholderNameConverter,
|
|
2352
2631
|
cpf_number: CpfNumberConverter,
|
|
2353
2632
|
cpf_name: CpfNameConverter,
|
|
2354
2633
|
birth_date: BirthDateConverter,
|
|
2355
|
-
street_number: StreetNumberConverter,
|
|
2356
2634
|
text: TextConverter,
|
|
2635
|
+
check: CheckboxConverter,
|
|
2636
|
+
select: SelectConverter,
|
|
2637
|
+
pin: PinConverter,
|
|
2638
|
+
radiogroup: RadioGroupConverter,
|
|
2639
|
+
email: EmailConverter,
|
|
2640
|
+
psEmail: EmailConverter,
|
|
2641
|
+
bazitemail: EmailConverter,
|
|
2642
|
+
street_number: StreetNumberConverter,
|
|
2643
|
+
sum: PricepointConverter,
|
|
2644
|
+
out: PricepointConverter,
|
|
2645
|
+
couponCode: CouponConverter,
|
|
2357
2646
|
};
|
|
2358
2647
|
|
|
2359
2648
|
class ControlConfigService {
|
|
@@ -2404,6 +2693,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2404
2693
|
class FormService {
|
|
2405
2694
|
constructor(controlConfigService) {
|
|
2406
2695
|
this.controlConfigService = controlConfigService;
|
|
2696
|
+
this.fieldFormStates = {};
|
|
2407
2697
|
}
|
|
2408
2698
|
createForm(fields) {
|
|
2409
2699
|
const controls = this.getVisibleFields(fields).reduce((result, field) => {
|
|
@@ -2415,6 +2705,21 @@ class FormService {
|
|
|
2415
2705
|
}, {});
|
|
2416
2706
|
return new UntypedFormGroup(controls);
|
|
2417
2707
|
}
|
|
2708
|
+
updateFieldFormState(form, fields, fieldName, formState) {
|
|
2709
|
+
var _a;
|
|
2710
|
+
const field = fields.find((fieldItem) => fieldItem.name === fieldName);
|
|
2711
|
+
if (!field) {
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
const converter = this.controlConfigService.getConverter(field);
|
|
2715
|
+
const control = form.controls[fieldName];
|
|
2716
|
+
if (!control) {
|
|
2717
|
+
return;
|
|
2718
|
+
}
|
|
2719
|
+
this.fieldFormStates[fieldName] = Object.assign(Object.assign({}, this.fieldFormStates[fieldName]), formState);
|
|
2720
|
+
control.setValidators((_a = converter === null || converter === void 0 ? void 0 : converter.getValidators(field, this.fieldFormStates[fieldName])) !== null && _a !== void 0 ? _a : []);
|
|
2721
|
+
control.updateValueAndValidity();
|
|
2722
|
+
}
|
|
2418
2723
|
getVisibleFields(fields) {
|
|
2419
2724
|
return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
|
|
2420
2725
|
}
|
|
@@ -4377,6 +4682,11 @@ class PaymentService {
|
|
|
4377
4682
|
getFinanceDetails() {
|
|
4378
4683
|
return this.financeDetails;
|
|
4379
4684
|
}
|
|
4685
|
+
updateFieldFormState(fieldName, formState) {
|
|
4686
|
+
if (this.form) {
|
|
4687
|
+
this.formService.updateFieldFormState(this.form, this.fields, fieldName, formState);
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4380
4690
|
getStatus() {
|
|
4381
4691
|
var _a, _b, _c, _d;
|
|
4382
4692
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -4643,6 +4953,7 @@ class CoreLibraryService {
|
|
|
4643
4953
|
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
4644
4954
|
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
4645
4955
|
changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
|
|
4956
|
+
updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
|
|
4646
4957
|
},
|
|
4647
4958
|
};
|
|
4648
4959
|
}
|
|
@@ -4747,17 +5058,28 @@ FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
|
|
|
4747
5058
|
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
4748
5059
|
FormService,
|
|
4749
5060
|
ControlConfigService,
|
|
4750
|
-
ZipConverter,
|
|
4751
|
-
EmailConverter,
|
|
4752
5061
|
CardNumberConverter,
|
|
4753
|
-
|
|
5062
|
+
CardMonthConverter,
|
|
5063
|
+
CardYearConverter,
|
|
5064
|
+
CvvConverter,
|
|
4754
5065
|
CvvConverter,
|
|
5066
|
+
ZipConverter,
|
|
4755
5067
|
CardholderNameConverter,
|
|
4756
5068
|
CpfNumberConverter,
|
|
4757
5069
|
CpfNameConverter,
|
|
4758
5070
|
BirthDateConverter,
|
|
4759
|
-
StreetNumberConverter,
|
|
4760
5071
|
TextConverter,
|
|
5072
|
+
CheckboxConverter,
|
|
5073
|
+
SelectConverter,
|
|
5074
|
+
PinConverter,
|
|
5075
|
+
RadioGroupConverter,
|
|
5076
|
+
EmailConverter,
|
|
5077
|
+
EmailConverter,
|
|
5078
|
+
EmailConverter,
|
|
5079
|
+
StreetNumberConverter,
|
|
5080
|
+
PricepointConverter,
|
|
5081
|
+
PricepointConverter,
|
|
5082
|
+
CouponConverter,
|
|
4761
5083
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4762
5084
|
], imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
4763
5085
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
@@ -4767,17 +5089,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4767
5089
|
providers: [
|
|
4768
5090
|
FormService,
|
|
4769
5091
|
ControlConfigService,
|
|
4770
|
-
ZipConverter,
|
|
4771
|
-
EmailConverter,
|
|
4772
5092
|
CardNumberConverter,
|
|
4773
|
-
|
|
5093
|
+
CardMonthConverter,
|
|
5094
|
+
CardYearConverter,
|
|
5095
|
+
CvvConverter,
|
|
4774
5096
|
CvvConverter,
|
|
5097
|
+
ZipConverter,
|
|
4775
5098
|
CardholderNameConverter,
|
|
4776
5099
|
CpfNumberConverter,
|
|
4777
5100
|
CpfNameConverter,
|
|
4778
5101
|
BirthDateConverter,
|
|
4779
|
-
StreetNumberConverter,
|
|
4780
5102
|
TextConverter,
|
|
5103
|
+
CheckboxConverter,
|
|
5104
|
+
SelectConverter,
|
|
5105
|
+
PinConverter,
|
|
5106
|
+
RadioGroupConverter,
|
|
5107
|
+
EmailConverter,
|
|
5108
|
+
EmailConverter,
|
|
5109
|
+
EmailConverter,
|
|
5110
|
+
StreetNumberConverter,
|
|
5111
|
+
PricepointConverter,
|
|
5112
|
+
PricepointConverter,
|
|
5113
|
+
CouponConverter,
|
|
4781
5114
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4782
5115
|
],
|
|
4783
5116
|
}]
|