@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.
Files changed (111) hide show
  1. package/esm2020/lib/core/payment/form/controls/card-number/card-number-control.config.mjs +10 -0
  2. package/esm2020/lib/core/payment/form/controls/checkbox/checkbox-control.config.mjs +10 -0
  3. package/esm2020/lib/core/payment/form/controls/coupon/coupon-control.config.mjs +8 -0
  4. package/esm2020/lib/core/payment/form/controls/radio-control/radio-control.config.mjs +9 -0
  5. package/esm2020/lib/core/payment/form/controls/radio-control/radio-option.interface.mjs +2 -0
  6. package/esm2020/lib/core/payment/form/controls/search-select/search-select-control.config.mjs +8 -0
  7. package/esm2020/lib/core/payment/form/controls/search-select/search-select-option.interface.mjs +2 -0
  8. package/esm2020/lib/core/payment/form/controls/search-select/select-option.interface.mjs +2 -0
  9. package/esm2020/lib/core/payment/form/converters/birth-date/birth-date.converter.mjs +38 -0
  10. package/esm2020/lib/core/payment/form/converters/card-month/card-month.converter.mjs +38 -0
  11. package/esm2020/lib/core/payment/form/converters/card-number/card-number.converter.mjs +45 -0
  12. package/esm2020/lib/core/payment/form/converters/card-year/card-year.converter.mjs +38 -0
  13. package/esm2020/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.mjs +25 -0
  14. package/esm2020/lib/core/payment/form/converters/checkbox/checkbox.converter.mjs +34 -0
  15. package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +4 -3
  16. package/esm2020/lib/core/payment/form/converters/converters-map.mjs +32 -16
  17. package/esm2020/lib/core/payment/form/converters/coupon/coupon.converter.mjs +25 -0
  18. package/esm2020/lib/core/payment/form/converters/cpf-name/cpf-name-regex.variable.mjs +2 -0
  19. package/esm2020/lib/core/payment/form/converters/cpf-name/cpf-name.converter.mjs +34 -0
  20. package/esm2020/lib/core/payment/form/converters/cpf-number/cpf-number.converter.mjs +31 -0
  21. package/esm2020/lib/core/payment/form/converters/cvv/cvv-form-state.interface.mjs +2 -0
  22. package/esm2020/lib/core/payment/form/converters/cvv/cvv.converter.mjs +72 -0
  23. package/esm2020/lib/core/payment/form/converters/email/email.converter.mjs +29 -0
  24. package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +2 -2
  25. package/esm2020/lib/core/payment/form/converters/pin/pin.converter.mjs +19 -0
  26. package/esm2020/lib/core/payment/form/converters/pricepoint/pricepoint.converter.mjs +32 -0
  27. package/esm2020/lib/core/payment/form/converters/radio-group/radio-group.converter.mjs +21 -0
  28. package/esm2020/lib/core/payment/form/converters/select/select.converter.mjs +21 -0
  29. package/esm2020/lib/core/payment/form/converters/street-number/street-number.converter.mjs +2 -2
  30. package/esm2020/lib/core/payment/form/converters/text/text.converter.mjs +19 -0
  31. package/esm2020/lib/core/payment/form/converters/zip/zip.converter.mjs +67 -0
  32. package/esm2020/lib/core/payment/form/field-form-states.interface.mjs +2 -0
  33. package/esm2020/lib/core/payment/form/form.module.mjs +48 -17
  34. package/esm2020/lib/core/payment/form/form.service.mjs +19 -1
  35. package/esm2020/lib/core/payment/form/validators/birth-date/birth-date.validator.mjs +37 -0
  36. package/esm2020/lib/core/payment/form/validators/card-month/card-month.validator.mjs +37 -0
  37. package/esm2020/lib/core/payment/form/validators/card-year/card-year.validator.mjs +34 -0
  38. package/esm2020/lib/core/payment/form/validators/coupon/coupon-validator.mjs +6 -0
  39. package/esm2020/lib/core/payment/form/validators/credit-card-length/credit-card-min-length.validator.mjs +32 -0
  40. package/esm2020/lib/core/payment/form/validators/email/email-validator.mjs +7 -0
  41. package/esm2020/lib/core/payment/form/validators/required/required.validator.mjs +6 -0
  42. package/esm2020/lib/core/payment/form/validators/restricted-value/restricted-value.validator.mjs +6 -0
  43. package/esm2020/lib/core/payment/form/validators/validators.module.mjs +2 -2
  44. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  45. package/esm2020/lib/core/payment/payment.service.mjs +6 -1
  46. package/esm2020/lib/core-library.service.mjs +2 -1
  47. package/fesm2015/xsolla-payment-client-core.mjs +357 -22
  48. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  49. package/fesm2020/xsolla-payment-client-core.mjs +357 -22
  50. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  51. package/lib/core/payment/form/controls/{card-number-control.config.d.ts → card-number/card-number-control.config.d.ts} +2 -2
  52. package/lib/core/payment/form/controls/checkbox/checkbox-control.config.d.ts +6 -0
  53. package/lib/core/payment/form/controls/coupon/coupon-control.config.d.ts +8 -0
  54. package/lib/core/payment/form/controls/radio-control/radio-control.config.d.ts +6 -0
  55. package/lib/core/payment/form/controls/radio-control/radio-option.interface.d.ts +5 -0
  56. package/lib/core/payment/form/controls/search-select/search-select-control.config.d.ts +11 -0
  57. package/lib/core/payment/form/controls/search-select/search-select-option.interface.d.ts +19 -0
  58. package/lib/core/payment/form/controls/search-select/select-option.interface.d.ts +13 -0
  59. package/lib/core/payment/form/converters/{birth-date.converter.d.ts → birth-date/birth-date.converter.d.ts} +4 -4
  60. package/lib/core/payment/form/converters/card-month/card-month.converter.d.ts +16 -0
  61. package/lib/core/payment/form/converters/{card-number.converter.d.ts → card-number/card-number.converter.d.ts} +6 -6
  62. package/lib/core/payment/form/converters/card-year/card-year.converter.d.ts +16 -0
  63. package/lib/core/payment/form/converters/{cardholder-name.converter.d.ts → cardholder-name/cardholder-name.converter.d.ts} +4 -4
  64. package/lib/core/payment/form/converters/checkbox/checkbox.converter.d.ts +16 -0
  65. package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -1
  66. package/lib/core/payment/form/converters/coupon/coupon.converter.d.ts +13 -0
  67. package/lib/core/payment/form/converters/{cpf-name.converter.d.ts → cpf-name/cpf-name.converter.d.ts} +4 -4
  68. package/lib/core/payment/form/converters/{cpf-number.converter.d.ts → cpf-number/cpf-number.converter.d.ts} +4 -4
  69. package/lib/core/payment/form/converters/cvv/cvv-form-state.interface.d.ts +3 -0
  70. package/lib/core/payment/form/converters/{cvv.converter.d.ts → cvv/cvv.converter.d.ts} +8 -7
  71. package/lib/core/payment/form/converters/{email.converter.d.ts → email/email.converter.d.ts} +5 -5
  72. package/lib/core/payment/form/converters/pin/pin.converter.d.ts +11 -0
  73. package/lib/core/payment/form/converters/pricepoint/pricepoint.converter.d.ts +14 -0
  74. package/lib/core/payment/form/converters/radio-group/radio-group.converter.d.ts +11 -0
  75. package/lib/core/payment/form/converters/select/select.converter.d.ts +11 -0
  76. package/lib/core/payment/form/converters/{text.converter.d.ts → text/text.converter.d.ts} +4 -4
  77. package/lib/core/payment/form/converters/{zip.converter.d.ts → zip/zip.converter.d.ts} +5 -5
  78. package/lib/core/payment/form/field-form-states.interface.d.ts +4 -0
  79. package/lib/core/payment/form/form.service.d.ts +4 -0
  80. package/lib/core/payment/form/validators/card-month/card-month.validator.d.ts +5 -0
  81. package/lib/core/payment/form/validators/card-year/card-year.validator.d.ts +5 -0
  82. package/lib/core/payment/form/validators/coupon/coupon-validator.d.ts +2 -0
  83. 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
  84. package/lib/core/payment/form/validators/{email-validator.d.ts → email/email-validator.d.ts} +1 -1
  85. package/lib/core/payment/form/validators/{restricted-value.validator.d.ts → restricted-value/restricted-value.validator.d.ts} +1 -1
  86. package/lib/core/payment/payment.interface.d.ts +2 -0
  87. package/lib/core/payment/payment.service.d.ts +2 -0
  88. package/package.json +1 -1
  89. package/xsolla-payment-client-core-0.1.6-1.tgz +0 -0
  90. package/esm2020/lib/core/payment/form/controls/card-number-control.config.mjs +0 -10
  91. package/esm2020/lib/core/payment/form/converters/birth-date.converter.mjs +0 -38
  92. package/esm2020/lib/core/payment/form/converters/card-expiration.converter.mjs +0 -36
  93. package/esm2020/lib/core/payment/form/converters/card-number.converter.mjs +0 -45
  94. package/esm2020/lib/core/payment/form/converters/cardholder-name.converter.mjs +0 -25
  95. package/esm2020/lib/core/payment/form/converters/cpf-name-regex.variable.mjs +0 -2
  96. package/esm2020/lib/core/payment/form/converters/cpf-name.converter.mjs +0 -34
  97. package/esm2020/lib/core/payment/form/converters/cpf-number.converter.mjs +0 -31
  98. package/esm2020/lib/core/payment/form/converters/cvv.converter.mjs +0 -50
  99. package/esm2020/lib/core/payment/form/converters/email.converter.mjs +0 -29
  100. package/esm2020/lib/core/payment/form/converters/text.converter.mjs +0 -19
  101. package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +0 -67
  102. package/esm2020/lib/core/payment/form/validators/birth-date.validator.mjs +0 -37
  103. package/esm2020/lib/core/payment/form/validators/credit-card-min-length.validator.mjs +0 -32
  104. package/esm2020/lib/core/payment/form/validators/email-validator.mjs +0 -7
  105. package/esm2020/lib/core/payment/form/validators/required-validator.mjs +0 -6
  106. package/esm2020/lib/core/payment/form/validators/restricted-value.validator.mjs +0 -6
  107. package/lib/core/payment/form/converters/card-expiration.converter.d.ts +0 -16
  108. package/xsolla-payment-client-core-0.1.5-4.tgz +0 -0
  109. /package/lib/core/payment/form/converters/{cpf-name-regex.variable.d.ts → cpf-name/cpf-name-regex.variable.d.ts} +0 -0
  110. /package/lib/core/payment/form/validators/{birth-date.validator.d.ts → birth-date/birth-date.validator.d.ts} +0 -0
  111. /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
- getValidators(field) {
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
- class CardExpirationConverter extends Converter {
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.title = 'date';
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
- CardExpirationConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2058
- CardExpirationConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter });
2059
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, decorators: [{
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
- return [];
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,6 +2337,226 @@ 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
+
2282
2560
  function phoneValidator() {
2283
2561
  return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
2284
2562
  }
@@ -2328,19 +2606,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2328
2606
 
2329
2607
  const convertersMapToken = new InjectionToken('ConvertersTokensMap');
2330
2608
  const convertersMap = {
2331
- zip: ZipConverter,
2332
- email: EmailConverter,
2333
2609
  card_number: CardNumberConverter,
2334
- card_month: CardExpirationConverter,
2335
- card_year: CardExpirationConverter,
2610
+ card_month: CardMonthConverter,
2611
+ card_year: CardYearConverter,
2336
2612
  cvv: CvvConverter,
2337
2613
  extra_cvv: CvvConverter,
2614
+ zip: ZipConverter,
2338
2615
  cardholdername: CardholderNameConverter,
2339
2616
  cpf_number: CpfNumberConverter,
2340
2617
  cpf_name: CpfNameConverter,
2341
2618
  birth_date: BirthDateConverter,
2342
- street_number: StreetNumberConverter,
2343
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,
2344
2631
  phone: PhoneConverter,
2345
2632
  };
2346
2633
 
@@ -2390,6 +2677,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2390
2677
  class FormService {
2391
2678
  constructor(controlConfigService) {
2392
2679
  this.controlConfigService = controlConfigService;
2680
+ this.fieldFormStates = {};
2393
2681
  }
2394
2682
  createForm(fields) {
2395
2683
  const controls = this.getVisibleFields(fields).reduce((result, field) => {
@@ -2401,6 +2689,23 @@ class FormService {
2401
2689
  }, {});
2402
2690
  return new UntypedFormGroup(controls);
2403
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
+ }
2404
2709
  getVisibleFields(fields) {
2405
2710
  return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
2406
2711
  }
@@ -4289,6 +4594,11 @@ class PaymentService {
4289
4594
  getFinanceDetails() {
4290
4595
  return this.financeDetails;
4291
4596
  }
4597
+ updateFieldFormState(fieldName, formState) {
4598
+ if (this.form) {
4599
+ this.formService.updateFieldFormState(this.form, this.fields, fieldName, formState);
4600
+ }
4601
+ }
4292
4602
  async getStatus() {
4293
4603
  if (!isSubmitResponse(this.data)) {
4294
4604
  throw new Error('Should submit form first');
@@ -4547,6 +4857,7 @@ class CoreLibraryService {
4547
4857
  getControlConfig: (field) => this.paymentService.getFieldConfig(field),
4548
4858
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
4549
4859
  changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
4860
+ updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
4550
4861
  },
4551
4862
  };
4552
4863
  }
@@ -4653,16 +4964,28 @@ FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15
4653
4964
  FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
4654
4965
  FormService,
4655
4966
  ControlConfigService,
4656
- ZipConverter,
4657
- EmailConverter,
4658
4967
  CardNumberConverter,
4659
- CardExpirationConverter,
4968
+ CardMonthConverter,
4969
+ CardYearConverter,
4660
4970
  CvvConverter,
4971
+ CvvConverter,
4972
+ ZipConverter,
4661
4973
  CardholderNameConverter,
4662
4974
  CpfNumberConverter,
4663
4975
  CpfNameConverter,
4664
4976
  BirthDateConverter,
4977
+ TextConverter,
4978
+ CheckboxConverter,
4979
+ SelectConverter,
4980
+ PinConverter,
4981
+ RadioGroupConverter,
4982
+ EmailConverter,
4983
+ EmailConverter,
4984
+ EmailConverter,
4665
4985
  StreetNumberConverter,
4986
+ PricepointConverter,
4987
+ PricepointConverter,
4988
+ CouponConverter,
4666
4989
  TextConverter,
4667
4990
  PhoneConverter,
4668
4991
  { provide: convertersMapToken, useValue: convertersMap },
@@ -4674,16 +4997,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
4674
4997
  providers: [
4675
4998
  FormService,
4676
4999
  ControlConfigService,
4677
- ZipConverter,
4678
- EmailConverter,
4679
5000
  CardNumberConverter,
4680
- CardExpirationConverter,
5001
+ CardMonthConverter,
5002
+ CardYearConverter,
5003
+ CvvConverter,
4681
5004
  CvvConverter,
5005
+ ZipConverter,
4682
5006
  CardholderNameConverter,
4683
5007
  CpfNumberConverter,
4684
5008
  CpfNameConverter,
4685
5009
  BirthDateConverter,
5010
+ TextConverter,
5011
+ CheckboxConverter,
5012
+ SelectConverter,
5013
+ PinConverter,
5014
+ RadioGroupConverter,
5015
+ EmailConverter,
5016
+ EmailConverter,
5017
+ EmailConverter,
4686
5018
  StreetNumberConverter,
5019
+ PricepointConverter,
5020
+ PricepointConverter,
5021
+ CouponConverter,
4687
5022
  TextConverter,
4688
5023
  PhoneConverter,
4689
5024
  { provide: convertersMapToken, useValue: convertersMap },