@xsolla/payment-client-core 0.0.10 → 0.0.11

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 (53) hide show
  1. package/esm2020/lib/core/payment/actions/action-factory-value.interface.mjs +1 -1
  2. package/esm2020/lib/core/payment/actions/check-status/check-status.action.token.mjs +5 -2
  3. package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
  4. package/esm2020/lib/core/payment/actions/next-action.service.mjs +11 -10
  5. package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
  6. package/esm2020/lib/core/payment/actions/redirect/redirect.action.class.mjs +20 -0
  7. package/esm2020/lib/core/payment/actions/redirect/redirect.action.token.mjs +16 -0
  8. package/esm2020/lib/core/payment/actions/redirect/redirect.action.type.mjs +2 -0
  9. package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +2 -2
  10. package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.token.mjs +5 -2
  11. package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.token.mjs +2 -2
  12. package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +5 -7
  13. package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +9 -5
  14. package/esm2020/lib/core/payment/form/mask-config.interface.mjs +2 -0
  15. package/esm2020/lib/core/payment/form/masks-functions.map.mjs +7 -0
  16. package/esm2020/lib/core/payment/form/validators/convert.function.mjs +3 -2
  17. package/esm2020/lib/core/payment/form/validators/email-validator.mjs +3 -2
  18. package/esm2020/lib/core/payment/form/validators/errors-codes.enum.mjs +8 -0
  19. package/esm2020/lib/core/payment/form/validators/required-validator.mjs +3 -2
  20. package/esm2020/lib/core/payment/form/validators/validation-error.interface.mjs +1 -1
  21. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  22. package/esm2020/lib/core/payment/payment.service.mjs +23 -4
  23. package/esm2020/lib/core/payment/submit/response/is-submit-response.function.mjs +5 -0
  24. package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +1 -1
  25. package/esm2020/lib/core/payment/sync/sync.service.mjs +14 -2
  26. package/esm2020/lib/core-library.service.mjs +7 -2
  27. package/fesm2015/xsolla-payment-client-core.mjs +228 -139
  28. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  29. package/fesm2020/xsolla-payment-client-core.mjs +223 -136
  30. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  31. package/lib/core/payment/actions/action-factory-value.interface.d.ts +2 -1
  32. package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
  33. package/lib/core/payment/actions/next-action.service.d.ts +2 -2
  34. package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +9 -0
  35. package/lib/core/payment/actions/redirect/redirect.action.token.d.ts +4 -0
  36. package/lib/core/payment/actions/redirect/redirect.action.type.d.ts +17 -0
  37. package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -2
  38. package/lib/core/payment/form/mask-config.interface.d.ts +6 -0
  39. package/lib/core/payment/form/masks-functions.map.d.ts +3 -0
  40. package/lib/core/payment/form/validators/convert.function.d.ts +1 -1
  41. package/lib/core/payment/form/validators/errors-codes.enum.d.ts +6 -0
  42. package/lib/core/payment/form/validators/validation-error.interface.d.ts +1 -0
  43. package/lib/core/payment/payment.interface.d.ts +1 -2
  44. package/lib/core/payment/payment.service.d.ts +4 -5
  45. package/lib/core/payment/submit/response/is-submit-response.function.d.ts +2 -0
  46. package/lib/core/payment/sync/field-sync-state.interface.d.ts +2 -2
  47. package/lib/core/payment/sync/sync.service.d.ts +1 -0
  48. package/lib/core-library.service.d.ts +2 -0
  49. package/package.json +1 -1
  50. package/xsolla-payment-client-core-0.0.11.tgz +0 -0
  51. package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +0 -6
  52. package/lib/core/payment/actions/action-type-command.map.d.ts +0 -4
  53. package/xsolla-payment-client-core-0.0.10.tgz +0 -0
@@ -8,6 +8,13 @@ import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule }
8
8
  import { filter, map as map$1, catchError } from 'rxjs/operators';
9
9
  import * as i1$1 from '@angular/router';
10
10
 
11
+ const masksFunctionsMap = {
12
+ zip: () => {
13
+ const zipLength = 5;
14
+ return new Array(zipLength).fill('9').join('');
15
+ },
16
+ };
17
+
11
18
  class AppError extends Error {
12
19
  constructor(message) {
13
20
  super(message);
@@ -425,6 +432,114 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
425
432
  }] }, { type: SettingsService }, { type: SecureApiClient }];
426
433
  } });
427
434
 
435
+ var XpsCommand;
436
+ (function (XpsCommand) {
437
+ XpsCommand["form"] = "form";
438
+ XpsCommand["check"] = "check";
439
+ XpsCommand["status"] = "status";
440
+ XpsCommand["checkout"] = "checkout";
441
+ XpsCommand["account"] = "account";
442
+ XpsCommand["create"] = "create";
443
+ })(XpsCommand || (XpsCommand = {}));
444
+
445
+ var FieldNames;
446
+ (function (FieldNames) {
447
+ FieldNames["address1"] = "address1";
448
+ FieldNames["address2"] = "address2";
449
+ FieldNames["address"] = "address";
450
+ FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
451
+ FieldNames["allowSubscription"] = "allowSubscription";
452
+ FieldNames["apt"] = "apt";
453
+ FieldNames["availableCardTypes"] = "available_card_types";
454
+ FieldNames["bank"] = "bank";
455
+ FieldNames["birthDate"] = "birth_date";
456
+ FieldNames["cardMonth"] = "card_month";
457
+ FieldNames["cardYear"] = "card_year";
458
+ FieldNames["cardNumber"] = "card_number";
459
+ FieldNames["cardholdername"] = "cardholdername";
460
+ FieldNames["city"] = "city";
461
+ FieldNames["couponCode"] = "couponCode";
462
+ FieldNames["cpfName"] = "cpf_name";
463
+ FieldNames["cpfNumber"] = "cpf_number";
464
+ FieldNames["cvv"] = "cvv";
465
+ FieldNames["description"] = "description";
466
+ FieldNames["email"] = "email";
467
+ FieldNames["psEmail"] = "psEmail";
468
+ FieldNames["euCheck"] = "eu_check";
469
+ FieldNames["extraCvv"] = "extra_cvv";
470
+ FieldNames["extraCardNumber"] = "extra_card_number";
471
+ FieldNames["extraCardType"] = "extra_card_type";
472
+ FieldNames["fName"] = "f_name";
473
+ FieldNames["installments"] = "installments";
474
+ FieldNames["lName"] = "l_name";
475
+ FieldNames["needInstallments"] = "needInstallments";
476
+ FieldNames["personId"] = "person_id";
477
+ FieldNames["personIdAr"] = "person_id_ar";
478
+ FieldNames["personIdCo"] = "person_id_co";
479
+ FieldNames["phone"] = "phone";
480
+ FieldNames["purchaseDescription"] = "purchaseDescription";
481
+ FieldNames["recurrentType"] = "recurrent_type";
482
+ FieldNames["rockstarTaxes"] = "rockstar_taxes";
483
+ FieldNames["state"] = "state";
484
+ FieldNames["street"] = "street";
485
+ FieldNames["streetNumber"] = "street_number";
486
+ FieldNames["take2Taxes"] = "take2_taxes";
487
+ FieldNames["termsAndConditions"] = "termsAndConditions";
488
+ FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
489
+ FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
490
+ FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
491
+ FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
492
+ FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
493
+ FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
494
+ FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
495
+ FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
496
+ FieldNames["zip"] = "zip";
497
+ FieldNames["allowSave"] = "allowSave";
498
+ FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
499
+ FieldNames["tokenApplePay"] = "token_applepay";
500
+ FieldNames["fixInvoice"] = "fix_invoice";
501
+ FieldNames["fixPid"] = "fix_pid";
502
+ FieldNames["signature"] = "signature";
503
+ FieldNames["qr"] = "qr";
504
+ FieldNames["sum"] = "sum";
505
+ FieldNames["out"] = "out";
506
+ FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
507
+ })(FieldNames || (FieldNames = {}));
508
+
509
+ class SubmitResponse {
510
+ constructor(parameters, responseNumber = 0) {
511
+ var _a, _b, _c;
512
+ this.responseNumber = responseNumber;
513
+ /* Todo split into properties */
514
+ this.parameters = parameters;
515
+ this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
516
+ if (parameters.onlineBanking) {
517
+ this.onlineBanking = {
518
+ url: parameters.onlineBanking.value,
519
+ };
520
+ }
521
+ this.isNeedRedirect =
522
+ parameters.currentCommand === XpsCommand.account ||
523
+ (parameters.currentCommand === XpsCommand.checkout &&
524
+ Boolean(parameters.checkout));
525
+ this.buyData = parameters.buyData;
526
+ this.fixInvoice = (_a = this.fields.find((field) => field.name === FieldNames.fixInvoice)) === null || _a === void 0 ? void 0 : _a.value;
527
+ this.signature = (_b = this.fields.find((field) => field.name === FieldNames.signature)) === null || _b === void 0 ? void 0 : _b.value;
528
+ this.hasFatalErrors = (_c = parameters.textAll) === null || _c === void 0 ? void 0 : _c.fatal;
529
+ this.userSession = parameters.userSession;
530
+ this.pid = parameters.pid;
531
+ this.errors = parameters.errors;
532
+ this.summary = parameters.summary;
533
+ this.title = parameters.title;
534
+ this.currentCommand = parameters.currentCommand;
535
+ this.messages = parameters.messages;
536
+ }
537
+ }
538
+
539
+ const isSubmitResponse = (value) => {
540
+ return value instanceof SubmitResponse;
541
+ };
542
+
428
543
  class InitializeResponse {
429
544
  constructor(response) {
430
545
  this.paymentForm = null;
@@ -561,110 +676,6 @@ const submitRequestFactoryProvider = {
561
676
  useValue: (...args) => new SubmitRequest(...args),
562
677
  };
563
678
 
564
- var XpsCommand;
565
- (function (XpsCommand) {
566
- XpsCommand["form"] = "form";
567
- XpsCommand["check"] = "check";
568
- XpsCommand["status"] = "status";
569
- XpsCommand["checkout"] = "checkout";
570
- XpsCommand["account"] = "account";
571
- XpsCommand["create"] = "create";
572
- })(XpsCommand || (XpsCommand = {}));
573
-
574
- var FieldNames;
575
- (function (FieldNames) {
576
- FieldNames["address1"] = "address1";
577
- FieldNames["address2"] = "address2";
578
- FieldNames["address"] = "address";
579
- FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
580
- FieldNames["allowSubscription"] = "allowSubscription";
581
- FieldNames["apt"] = "apt";
582
- FieldNames["availableCardTypes"] = "available_card_types";
583
- FieldNames["bank"] = "bank";
584
- FieldNames["birthDate"] = "birth_date";
585
- FieldNames["cardMonth"] = "card_month";
586
- FieldNames["cardYear"] = "card_year";
587
- FieldNames["cardNumber"] = "card_number";
588
- FieldNames["cardholdername"] = "cardholdername";
589
- FieldNames["city"] = "city";
590
- FieldNames["couponCode"] = "couponCode";
591
- FieldNames["cpfName"] = "cpf_name";
592
- FieldNames["cpfNumber"] = "cpf_number";
593
- FieldNames["cvv"] = "cvv";
594
- FieldNames["description"] = "description";
595
- FieldNames["email"] = "email";
596
- FieldNames["psEmail"] = "psEmail";
597
- FieldNames["euCheck"] = "eu_check";
598
- FieldNames["extraCvv"] = "extra_cvv";
599
- FieldNames["extraCardNumber"] = "extra_card_number";
600
- FieldNames["extraCardType"] = "extra_card_type";
601
- FieldNames["fName"] = "f_name";
602
- FieldNames["installments"] = "installments";
603
- FieldNames["lName"] = "l_name";
604
- FieldNames["needInstallments"] = "needInstallments";
605
- FieldNames["personId"] = "person_id";
606
- FieldNames["personIdAr"] = "person_id_ar";
607
- FieldNames["personIdCo"] = "person_id_co";
608
- FieldNames["phone"] = "phone";
609
- FieldNames["purchaseDescription"] = "purchaseDescription";
610
- FieldNames["recurrentType"] = "recurrent_type";
611
- FieldNames["rockstarTaxes"] = "rockstar_taxes";
612
- FieldNames["state"] = "state";
613
- FieldNames["street"] = "street";
614
- FieldNames["streetNumber"] = "street_number";
615
- FieldNames["take2Taxes"] = "take2_taxes";
616
- FieldNames["termsAndConditions"] = "termsAndConditions";
617
- FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
618
- FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
619
- FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
620
- FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
621
- FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
622
- FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
623
- FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
624
- FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
625
- FieldNames["zip"] = "zip";
626
- FieldNames["allowSave"] = "allowSave";
627
- FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
628
- FieldNames["tokenApplePay"] = "token_applepay";
629
- FieldNames["fixInvoice"] = "fix_invoice";
630
- FieldNames["fixPid"] = "fix_pid";
631
- FieldNames["signature"] = "signature";
632
- FieldNames["qr"] = "qr";
633
- FieldNames["sum"] = "sum";
634
- FieldNames["out"] = "out";
635
- FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
636
- })(FieldNames || (FieldNames = {}));
637
-
638
- class SubmitResponse {
639
- constructor(parameters, responseNumber = 0) {
640
- var _a, _b, _c;
641
- this.responseNumber = responseNumber;
642
- /* Todo split into properties */
643
- this.parameters = parameters;
644
- this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
645
- if (parameters.onlineBanking) {
646
- this.onlineBanking = {
647
- url: parameters.onlineBanking.value,
648
- };
649
- }
650
- this.isNeedRedirect =
651
- parameters.currentCommand === XpsCommand.account ||
652
- (parameters.currentCommand === XpsCommand.checkout &&
653
- Boolean(parameters.checkout));
654
- this.buyData = parameters.buyData;
655
- this.fixInvoice = (_a = this.fields.find((field) => field.name === FieldNames.fixInvoice)) === null || _a === void 0 ? void 0 : _a.value;
656
- this.signature = (_b = this.fields.find((field) => field.name === FieldNames.signature)) === null || _b === void 0 ? void 0 : _b.value;
657
- this.hasFatalErrors = (_c = parameters.textAll) === null || _c === void 0 ? void 0 : _c.fatal;
658
- this.userSession = parameters.userSession;
659
- this.pid = parameters.pid;
660
- this.errors = parameters.errors;
661
- this.summary = parameters.summary;
662
- this.title = parameters.title;
663
- this.currentCommand = parameters.currentCommand;
664
- this.messages = parameters.messages;
665
- }
666
- }
667
-
668
679
  const submitResponseFactoryToken = new InjectionToken('SubmitResponse');
669
680
  const submitResponseFactoryProvider = {
670
681
  provide: submitResponseFactoryToken,
@@ -1021,7 +1032,10 @@ class SyncService extends EmitDataService {
1021
1032
  return Promise.resolve(null);
1022
1033
  }
1023
1034
  if (prevFieldState && value === prevFieldState.value) {
1024
- return Promise.resolve(prevFieldState.result);
1035
+ return Promise.resolve(prevFieldState.result).then((response) => {
1036
+ var _a;
1037
+ return (_a = response === null || response === void 0 ? void 0 : response.rewritableError) !== null && _a !== void 0 ? _a : null;
1038
+ });
1025
1039
  }
1026
1040
  const requestPromise = this.request(field);
1027
1041
  this.setPrevFieldSyncState(field, value, requestPromise);
@@ -1031,6 +1045,17 @@ class SyncService extends EmitDataService {
1031
1045
  });
1032
1046
  });
1033
1047
  }
1048
+ getSyncValidationErrors(field) {
1049
+ var _a;
1050
+ const control = this.form.get(field.name);
1051
+ if (!control) {
1052
+ return null;
1053
+ }
1054
+ const rewritableError = (_a = control.errors) === null || _a === void 0 ? void 0 : _a.rewritableError;
1055
+ return rewritableError
1056
+ ? { message: rewritableError.message, code: rewritableError.code }
1057
+ : null;
1058
+ }
1034
1059
  request(field) {
1035
1060
  return __awaiter(this, void 0, void 0, function* () {
1036
1061
  const requestParams = this.requestFactory({
@@ -1091,7 +1116,7 @@ class TextControlConfig extends ControlConfig {
1091
1116
  }
1092
1117
  }
1093
1118
 
1094
- function convert(validator, message) {
1119
+ function convert(validator, message, errorCode) {
1095
1120
  return (control) => {
1096
1121
  const errors = validator(control);
1097
1122
  if (!errors) {
@@ -1102,6 +1127,7 @@ function convert(validator, message) {
1102
1127
  error = typeof error === 'object' && error !== null ? error : {};
1103
1128
  const rewritableError = Object.assign({}, error);
1104
1129
  rewritableError.message = message;
1130
+ rewritableError.code = errorCode;
1105
1131
  if (error[firstErrorKey] != null) {
1106
1132
  rewritableError.value = error[firstErrorKey];
1107
1133
  }
@@ -1113,13 +1139,21 @@ function convert(validator, message) {
1113
1139
  };
1114
1140
  }
1115
1141
 
1142
+ var ErrorsCodes;
1143
+ (function (ErrorsCodes) {
1144
+ ErrorsCodes["minLength"] = "min-length";
1145
+ ErrorsCodes["maxLength"] = "max-length";
1146
+ ErrorsCodes["invalidValue"] = "invalid-value";
1147
+ ErrorsCodes["required"] = "required";
1148
+ })(ErrorsCodes || (ErrorsCodes = {}));
1149
+
1116
1150
  const emailRegexp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-line
1117
1151
  function emailValidator() {
1118
- return convert(Validators.pattern(emailRegexp), 'Enter a valid email');
1152
+ return convert(Validators.pattern(emailRegexp), 'Enter a valid email', ErrorsCodes.invalidValue);
1119
1153
  }
1120
1154
 
1121
1155
  function requiredValidator() {
1122
- return convert(Validators.required, 'Required');
1156
+ return convert(Validators.required, 'Required', ErrorsCodes.required);
1123
1157
  }
1124
1158
 
1125
1159
  class Converter {
@@ -1134,7 +1168,7 @@ class Converter {
1134
1168
  return config;
1135
1169
  }
1136
1170
  convertToFormControl(field) {
1137
- return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
1171
+ return new UntypedFormControl(this.getValue(field), this.getValidators(field));
1138
1172
  }
1139
1173
  getValidators(field) {
1140
1174
  const validators = [];
@@ -1148,14 +1182,11 @@ class Converter {
1148
1182
  const errorMessage = field.validation_error_msg
1149
1183
  ? field.validation_error_msg
1150
1184
  : 'Enter valid data';
1151
- validators.push(convert(Validators.pattern(pattern), errorMessage));
1185
+ validators.push(convert(Validators.pattern(pattern), errorMessage, ErrorsCodes.invalidValue));
1152
1186
  }
1153
1187
  }
1154
1188
  return validators;
1155
1189
  }
1156
- getAsyncValidators(field) {
1157
- return () => __awaiter(this, void 0, void 0, function* () { return this.syncService.validate(field); });
1158
- }
1159
1190
  createDefaultControlConfig(controlConfigClass, field) {
1160
1191
  const config = new controlConfigClass();
1161
1192
  this.copyCommonOptions(config, field);
@@ -1240,11 +1271,11 @@ class ZipConverter extends Converter {
1240
1271
  const validators = super
1241
1272
  .getValidators(field)
1242
1273
  .concat([
1243
- convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
1244
- convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
1274
+ convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`, ErrorsCodes.minLength),
1275
+ convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`, ErrorsCodes.maxLength),
1245
1276
  ]);
1246
1277
  if (this.isUsCountry) {
1247
- validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
1278
+ validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code', ErrorsCodes.invalidValue));
1248
1279
  }
1249
1280
  return validators;
1250
1281
  }
@@ -1253,12 +1284,14 @@ class ZipConverter extends Converter {
1253
1284
  config.icon = 'location';
1254
1285
  if (this.isUsCountry) {
1255
1286
  config.maskConfig = {
1256
- mask: () => new Array(this.usCountryLength).fill('9').join(''),
1257
1287
  guide: false,
1258
1288
  unmaskModelValue: true,
1259
1289
  showMask: true,
1260
1290
  };
1261
1291
  config.inputMode = 'numeric';
1292
+ if (masksFunctionsMap['zip']) {
1293
+ config.maskConfig.mask = masksFunctionsMap['zip'];
1294
+ }
1262
1295
  }
1263
1296
  else {
1264
1297
  config.maxLength = this.maxLength;
@@ -2372,7 +2405,7 @@ class ShowFieldsAction {
2372
2405
  messages: [],
2373
2406
  order: {},
2374
2407
  };
2375
- this.data.fields = submitResponse.fields;
2408
+ this.data.fields = submitResponse.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
2376
2409
  this.data.errors = submitResponse.errors;
2377
2410
  this.data.messages = submitResponse.messages;
2378
2411
  this.data.order = submitResponse.summary;
@@ -2384,7 +2417,9 @@ const showFieldsActionFactoryProvider = {
2384
2417
  provide: showFieldsActionFactoryToken,
2385
2418
  useValue: {
2386
2419
  factory: (...args) => new ShowFieldsAction(...args),
2387
- type: 'show_fields',
2420
+ isSuitable: (response) => {
2421
+ return response.currentCommand === XpsCommand.check;
2422
+ },
2388
2423
  },
2389
2424
  };
2390
2425
 
@@ -2410,7 +2445,9 @@ const checkStatusActionFactoryProvider = {
2410
2445
  provide: checkStatusActionFactoryToken,
2411
2446
  useValue: {
2412
2447
  factory: (...args) => new CheckStatusAction(...args),
2413
- type: 'check_status',
2448
+ isSuitable: (response) => {
2449
+ return response.currentCommand === XpsCommand.status;
2450
+ },
2414
2451
  },
2415
2452
  };
2416
2453
 
@@ -2419,7 +2456,40 @@ const statusUpdatedActionFactoryProvider = {
2419
2456
  provide: statusUpdatedActionFactoryToken,
2420
2457
  useValue: {
2421
2458
  factory: (...args) => new StatusUpdatedAction(...args),
2422
- type: 'status_updated',
2459
+ isSuitable: () => false,
2460
+ },
2461
+ };
2462
+
2463
+ class RedirectAction {
2464
+ constructor(submitResponse) {
2465
+ this.type = 'redirect';
2466
+ this.data = {
2467
+ fields: submitResponse.fields,
2468
+ errors: submitResponse.errors,
2469
+ messages: submitResponse.messages,
2470
+ order: submitResponse.summary,
2471
+ invoiceId: submitResponse.fixInvoice,
2472
+ redirect: this.getRedirect(submitResponse),
2473
+ };
2474
+ }
2475
+ getRedirect(submitResponse) {
2476
+ return {
2477
+ redirectUrl: submitResponse.parameters.checkout.action,
2478
+ data: submitResponse.parameters.checkout.data,
2479
+ };
2480
+ }
2481
+ }
2482
+
2483
+ const redirectActionFactoryToken = new InjectionToken('RedirectAction');
2484
+ const redirectActionFactoryProvider = {
2485
+ provide: redirectActionFactoryToken,
2486
+ useValue: {
2487
+ factory: (...args) => new RedirectAction(...args),
2488
+ isSuitable: (response) => {
2489
+ return (response.currentCommand === XpsCommand.account ||
2490
+ (response.currentCommand === XpsCommand.checkout &&
2491
+ Boolean(response.parameters.checkout)));
2492
+ },
2423
2493
  },
2424
2494
  };
2425
2495
 
@@ -2428,13 +2498,9 @@ const nextActions = [
2428
2498
  showFieldsActionFactoryProvider,
2429
2499
  checkStatusActionFactoryProvider,
2430
2500
  statusUpdatedActionFactoryProvider,
2501
+ redirectActionFactoryProvider,
2431
2502
  ];
2432
2503
 
2433
- const actionTypeCommandMap = {
2434
- [XpsCommand.check]: 'show_fields',
2435
- [XpsCommand.status]: 'check_status',
2436
- };
2437
-
2438
2504
  class NextActionService {
2439
2505
  get flowUpdates$() {
2440
2506
  return this.flowUpdatesSubject.asObservable();
@@ -2443,14 +2509,14 @@ class NextActionService {
2443
2509
  this.nextActionTokens = nextActionTokens;
2444
2510
  this.injector = injector;
2445
2511
  this.flowUpdatesSubject = new Subject();
2446
- this.nextActionsMap = new Map();
2447
- this.fillNextActionsMap();
2512
+ this.nextActionsList = [];
2513
+ this.fillNextActionsList();
2448
2514
  }
2449
2515
  getNextAction(submitResponse) {
2450
2516
  if (!submitResponse.currentCommand) {
2451
2517
  return null;
2452
2518
  }
2453
- const nextActionFactory = this.findNextAction(submitResponse.currentCommand);
2519
+ const nextActionFactory = this.findNextAction(submitResponse);
2454
2520
  if (nextActionFactory) {
2455
2521
  return nextActionFactory(submitResponse);
2456
2522
  }
@@ -2459,18 +2525,20 @@ class NextActionService {
2459
2525
  emitFlowUpdates(action) {
2460
2526
  this.flowUpdatesSubject.next(action);
2461
2527
  }
2462
- fillNextActionsMap() {
2528
+ fillNextActionsList() {
2463
2529
  this.nextActionTokens.forEach((nextAction) => {
2464
2530
  const item = this.injector.get(nextAction.provide);
2465
- this.nextActionsMap.set(item.type, item.factory);
2531
+ this.nextActionsList.push(item);
2466
2532
  });
2467
2533
  }
2468
- findNextAction(command) {
2469
- const actionType = actionTypeCommandMap[command];
2534
+ findNextAction(submitResponse) {
2535
+ const actionType = this.nextActionsList.find((nextAction) => {
2536
+ return nextAction.isSuitable(submitResponse);
2537
+ });
2470
2538
  if (!actionType) {
2471
2539
  return;
2472
2540
  }
2473
- return this.nextActionsMap.get(actionType);
2541
+ return actionType.factory;
2474
2542
  }
2475
2543
  }
2476
2544
  NextActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -2820,7 +2888,7 @@ class PaymentService {
2820
2888
  this.form = this.formService.createForm(this.fields);
2821
2889
  this.emitFinanceDetails((_a = this.data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary);
2822
2890
  this.setupSyncService(this.form, this.fields);
2823
- return this.fields;
2891
+ return this.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
2824
2892
  });
2825
2893
  }
2826
2894
  submit() {
@@ -2829,16 +2897,24 @@ class PaymentService {
2829
2897
  throw new Error('form is empty!');
2830
2898
  }
2831
2899
  const submitResponse = yield this.submitService.request(this.fields, this.form);
2900
+ this.data = submitResponse;
2832
2901
  this.emitFinanceDetails(submitResponse.summary);
2833
2902
  return this.nextActionService.getNextAction(submitResponse);
2834
2903
  });
2835
2904
  }
2836
2905
  getFields() {
2837
- var _a, _b, _c;
2838
- return (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.paymentForm) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : [];
2906
+ var _a, _b, _c, _d;
2907
+ if (this.data instanceof SubmitResponse) {
2908
+ return (_a = this.data.fields) !== null && _a !== void 0 ? _a : [];
2909
+ }
2910
+ return (_d = (_c = (_b = this.data) === null || _b === void 0 ? void 0 : _b.paymentForm) === null || _c === void 0 ? void 0 : _c.fields) !== null && _d !== void 0 ? _d : [];
2839
2911
  }
2840
2912
  validate(field) {
2841
2913
  return __awaiter(this, void 0, void 0, function* () {
2914
+ const syncErrors = this.syncService.getSyncValidationErrors(field);
2915
+ if (syncErrors) {
2916
+ return Promise.resolve(syncErrors);
2917
+ }
2842
2918
  return this.syncService.validate(field);
2843
2919
  });
2844
2920
  }
@@ -2848,8 +2924,17 @@ class PaymentService {
2848
2924
  getFinanceDetails() {
2849
2925
  return this.financeDetails;
2850
2926
  }
2851
- getStatus(params) {
2927
+ getStatus() {
2928
+ var _a, _b, _c, _d;
2852
2929
  return __awaiter(this, void 0, void 0, function* () {
2930
+ if (!isSubmitResponse(this.data)) {
2931
+ throw new Error('Should submit form first');
2932
+ }
2933
+ const params = {
2934
+ invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
2935
+ signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
2936
+ locale: (_d = (_c = this.data.fields.find((field) => field.name === 'locale')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'en',
2937
+ };
2853
2938
  return this.statusService.getStatus(Object.assign(Object.assign({}, params), { pid: this.config.paymentMethodId }));
2854
2939
  });
2855
2940
  }
@@ -3033,7 +3118,7 @@ class CoreLibraryService {
3033
3118
  validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
3034
3119
  getFinanceDetails: () => this.paymentService.getFinanceDetails(),
3035
3120
  runThreeDs: () => this.paymentService.runThreeDs(),
3036
- getStatus: (params) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.getStatus(params); }),
3121
+ getStatus: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.getStatus(); }),
3037
3122
  flowUpdates$: this.nextActionService.flowUpdates$,
3038
3123
  financeDetailsUpdates$: this.financeDetailsService.data$,
3039
3124
  form: {
@@ -3045,6 +3130,10 @@ class CoreLibraryService {
3045
3130
  getLegalComponentConfig() {
3046
3131
  return this.legalService.getLegalComponentConfig();
3047
3132
  }
3133
+ getFieldMask(field) {
3134
+ const sanitizedName = field.name.replace(/^fix_/i, '');
3135
+ return masksFunctionsMap[sanitizedName];
3136
+ }
3048
3137
  }
3049
3138
  CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
3050
3139
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });