@xsolla/payment-client-core 0.0.10 → 0.0.12

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 (65) 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/finance-details/cart-item.interface.mjs +1 -1
  13. package/esm2020/lib/core/payment/finance-details/cart-line.interface.mjs +1 -1
  14. package/esm2020/lib/core/payment/finance-details/{cart-pricing.interface.mjs → cart-summary.interface.mjs} +1 -1
  15. package/esm2020/lib/core/payment/finance-details/finance-details.class.mjs +35 -12
  16. package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +5 -7
  17. package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +9 -5
  18. package/esm2020/lib/core/payment/form/mask-config.interface.mjs +2 -0
  19. package/esm2020/lib/core/payment/form/masks-functions.map.mjs +7 -0
  20. package/esm2020/lib/core/payment/form/validators/convert.function.mjs +3 -2
  21. package/esm2020/lib/core/payment/form/validators/email-validator.mjs +3 -2
  22. package/esm2020/lib/core/payment/form/validators/errors-codes.enum.mjs +8 -0
  23. package/esm2020/lib/core/payment/form/validators/required-validator.mjs +3 -2
  24. package/esm2020/lib/core/payment/form/validators/validation-error.interface.mjs +1 -1
  25. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  26. package/esm2020/lib/core/payment/payment.service.mjs +23 -4
  27. package/esm2020/lib/core/payment/submit/response/is-submit-response.function.mjs +5 -0
  28. package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +1 -1
  29. package/esm2020/lib/core/payment/sync/sync.service.mjs +14 -2
  30. package/esm2020/lib/core/payment/xps-purchase.interface.mjs +1 -1
  31. package/esm2020/lib/core-library.service.mjs +7 -2
  32. package/fesm2015/xsolla-payment-client-core.mjs +266 -152
  33. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  34. package/fesm2020/xsolla-payment-client-core.mjs +257 -147
  35. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  36. package/lib/core/payment/actions/action-factory-value.interface.d.ts +2 -1
  37. package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
  38. package/lib/core/payment/actions/next-action.service.d.ts +2 -2
  39. package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +9 -0
  40. package/lib/core/payment/actions/redirect/redirect.action.token.d.ts +4 -0
  41. package/lib/core/payment/actions/redirect/redirect.action.type.d.ts +17 -0
  42. package/lib/core/payment/finance-details/cart-item.interface.d.ts +1 -0
  43. package/lib/core/payment/finance-details/cart-line.interface.d.ts +1 -0
  44. package/lib/core/payment/finance-details/finance-details.class.d.ts +8 -4
  45. package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -2
  46. package/lib/core/payment/form/mask-config.interface.d.ts +6 -0
  47. package/lib/core/payment/form/masks-functions.map.d.ts +3 -0
  48. package/lib/core/payment/form/validators/convert.function.d.ts +1 -1
  49. package/lib/core/payment/form/validators/errors-codes.enum.d.ts +6 -0
  50. package/lib/core/payment/form/validators/validation-error.interface.d.ts +1 -0
  51. package/lib/core/payment/payment.interface.d.ts +1 -2
  52. package/lib/core/payment/payment.service.d.ts +4 -5
  53. package/lib/core/payment/submit/response/is-submit-response.function.d.ts +2 -0
  54. package/lib/core/payment/sync/field-sync-state.interface.d.ts +2 -2
  55. package/lib/core/payment/sync/sync.service.d.ts +1 -0
  56. package/lib/core/payment/xps-purchase.interface.d.ts +0 -2
  57. package/lib/core-library.service.d.ts +2 -0
  58. package/package.json +1 -1
  59. package/xsolla-payment-client-core-0.0.12.tgz +0 -0
  60. package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +0 -6
  61. package/esm2020/lib/core/payment/xps-subscription-item.interface.mjs +0 -2
  62. package/lib/core/payment/actions/action-type-command.map.d.ts +0 -4
  63. package/lib/core/payment/xps-subscription-item.interface.d.ts +0 -20
  64. package/xsolla-payment-client-core-0.0.10.tgz +0 -0
  65. /package/lib/core/payment/finance-details/{cart-pricing.interface.d.ts → cart-summary.interface.d.ts} +0 -0
@@ -7,6 +7,13 @@ import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule }
7
7
  import { filter, map as map$1, catchError } from 'rxjs/operators';
8
8
  import * as i1$1 from '@angular/router';
9
9
 
10
+ const masksFunctionsMap = {
11
+ zip: () => {
12
+ const zipLength = 5;
13
+ return new Array(zipLength).fill('9').join('');
14
+ },
15
+ };
16
+
10
17
  class AppError extends Error {
11
18
  constructor(message) {
12
19
  super(message);
@@ -398,6 +405,113 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
398
405
  args: [userBalanceResponseFactoryToken]
399
406
  }] }, { type: SettingsService }, { type: SecureApiClient }]; } });
400
407
 
408
+ var XpsCommand;
409
+ (function (XpsCommand) {
410
+ XpsCommand["form"] = "form";
411
+ XpsCommand["check"] = "check";
412
+ XpsCommand["status"] = "status";
413
+ XpsCommand["checkout"] = "checkout";
414
+ XpsCommand["account"] = "account";
415
+ XpsCommand["create"] = "create";
416
+ })(XpsCommand || (XpsCommand = {}));
417
+
418
+ var FieldNames;
419
+ (function (FieldNames) {
420
+ FieldNames["address1"] = "address1";
421
+ FieldNames["address2"] = "address2";
422
+ FieldNames["address"] = "address";
423
+ FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
424
+ FieldNames["allowSubscription"] = "allowSubscription";
425
+ FieldNames["apt"] = "apt";
426
+ FieldNames["availableCardTypes"] = "available_card_types";
427
+ FieldNames["bank"] = "bank";
428
+ FieldNames["birthDate"] = "birth_date";
429
+ FieldNames["cardMonth"] = "card_month";
430
+ FieldNames["cardYear"] = "card_year";
431
+ FieldNames["cardNumber"] = "card_number";
432
+ FieldNames["cardholdername"] = "cardholdername";
433
+ FieldNames["city"] = "city";
434
+ FieldNames["couponCode"] = "couponCode";
435
+ FieldNames["cpfName"] = "cpf_name";
436
+ FieldNames["cpfNumber"] = "cpf_number";
437
+ FieldNames["cvv"] = "cvv";
438
+ FieldNames["description"] = "description";
439
+ FieldNames["email"] = "email";
440
+ FieldNames["psEmail"] = "psEmail";
441
+ FieldNames["euCheck"] = "eu_check";
442
+ FieldNames["extraCvv"] = "extra_cvv";
443
+ FieldNames["extraCardNumber"] = "extra_card_number";
444
+ FieldNames["extraCardType"] = "extra_card_type";
445
+ FieldNames["fName"] = "f_name";
446
+ FieldNames["installments"] = "installments";
447
+ FieldNames["lName"] = "l_name";
448
+ FieldNames["needInstallments"] = "needInstallments";
449
+ FieldNames["personId"] = "person_id";
450
+ FieldNames["personIdAr"] = "person_id_ar";
451
+ FieldNames["personIdCo"] = "person_id_co";
452
+ FieldNames["phone"] = "phone";
453
+ FieldNames["purchaseDescription"] = "purchaseDescription";
454
+ FieldNames["recurrentType"] = "recurrent_type";
455
+ FieldNames["rockstarTaxes"] = "rockstar_taxes";
456
+ FieldNames["state"] = "state";
457
+ FieldNames["street"] = "street";
458
+ FieldNames["streetNumber"] = "street_number";
459
+ FieldNames["take2Taxes"] = "take2_taxes";
460
+ FieldNames["termsAndConditions"] = "termsAndConditions";
461
+ FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
462
+ FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
463
+ FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
464
+ FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
465
+ FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
466
+ FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
467
+ FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
468
+ FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
469
+ FieldNames["zip"] = "zip";
470
+ FieldNames["allowSave"] = "allowSave";
471
+ FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
472
+ FieldNames["tokenApplePay"] = "token_applepay";
473
+ FieldNames["fixInvoice"] = "fix_invoice";
474
+ FieldNames["fixPid"] = "fix_pid";
475
+ FieldNames["signature"] = "signature";
476
+ FieldNames["qr"] = "qr";
477
+ FieldNames["sum"] = "sum";
478
+ FieldNames["out"] = "out";
479
+ FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
480
+ })(FieldNames || (FieldNames = {}));
481
+
482
+ class SubmitResponse {
483
+ constructor(parameters, responseNumber = 0) {
484
+ this.responseNumber = responseNumber;
485
+ /* Todo split into properties */
486
+ this.parameters = parameters;
487
+ this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
488
+ if (parameters.onlineBanking) {
489
+ this.onlineBanking = {
490
+ url: parameters.onlineBanking.value,
491
+ };
492
+ }
493
+ this.isNeedRedirect =
494
+ parameters.currentCommand === XpsCommand.account ||
495
+ (parameters.currentCommand === XpsCommand.checkout &&
496
+ Boolean(parameters.checkout));
497
+ this.buyData = parameters.buyData;
498
+ this.fixInvoice = this.fields.find((field) => field.name === FieldNames.fixInvoice)?.value;
499
+ this.signature = this.fields.find((field) => field.name === FieldNames.signature)?.value;
500
+ this.hasFatalErrors = parameters.textAll?.fatal;
501
+ this.userSession = parameters.userSession;
502
+ this.pid = parameters.pid;
503
+ this.errors = parameters.errors;
504
+ this.summary = parameters.summary;
505
+ this.title = parameters.title;
506
+ this.currentCommand = parameters.currentCommand;
507
+ this.messages = parameters.messages;
508
+ }
509
+ }
510
+
511
+ const isSubmitResponse = (value) => {
512
+ return value instanceof SubmitResponse;
513
+ };
514
+
401
515
  class InitializeResponse {
402
516
  constructor(response) {
403
517
  this.paymentForm = null;
@@ -529,109 +643,6 @@ const submitRequestFactoryProvider = {
529
643
  useValue: (...args) => new SubmitRequest(...args),
530
644
  };
531
645
 
532
- var XpsCommand;
533
- (function (XpsCommand) {
534
- XpsCommand["form"] = "form";
535
- XpsCommand["check"] = "check";
536
- XpsCommand["status"] = "status";
537
- XpsCommand["checkout"] = "checkout";
538
- XpsCommand["account"] = "account";
539
- XpsCommand["create"] = "create";
540
- })(XpsCommand || (XpsCommand = {}));
541
-
542
- var FieldNames;
543
- (function (FieldNames) {
544
- FieldNames["address1"] = "address1";
545
- FieldNames["address2"] = "address2";
546
- FieldNames["address"] = "address";
547
- FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
548
- FieldNames["allowSubscription"] = "allowSubscription";
549
- FieldNames["apt"] = "apt";
550
- FieldNames["availableCardTypes"] = "available_card_types";
551
- FieldNames["bank"] = "bank";
552
- FieldNames["birthDate"] = "birth_date";
553
- FieldNames["cardMonth"] = "card_month";
554
- FieldNames["cardYear"] = "card_year";
555
- FieldNames["cardNumber"] = "card_number";
556
- FieldNames["cardholdername"] = "cardholdername";
557
- FieldNames["city"] = "city";
558
- FieldNames["couponCode"] = "couponCode";
559
- FieldNames["cpfName"] = "cpf_name";
560
- FieldNames["cpfNumber"] = "cpf_number";
561
- FieldNames["cvv"] = "cvv";
562
- FieldNames["description"] = "description";
563
- FieldNames["email"] = "email";
564
- FieldNames["psEmail"] = "psEmail";
565
- FieldNames["euCheck"] = "eu_check";
566
- FieldNames["extraCvv"] = "extra_cvv";
567
- FieldNames["extraCardNumber"] = "extra_card_number";
568
- FieldNames["extraCardType"] = "extra_card_type";
569
- FieldNames["fName"] = "f_name";
570
- FieldNames["installments"] = "installments";
571
- FieldNames["lName"] = "l_name";
572
- FieldNames["needInstallments"] = "needInstallments";
573
- FieldNames["personId"] = "person_id";
574
- FieldNames["personIdAr"] = "person_id_ar";
575
- FieldNames["personIdCo"] = "person_id_co";
576
- FieldNames["phone"] = "phone";
577
- FieldNames["purchaseDescription"] = "purchaseDescription";
578
- FieldNames["recurrentType"] = "recurrent_type";
579
- FieldNames["rockstarTaxes"] = "rockstar_taxes";
580
- FieldNames["state"] = "state";
581
- FieldNames["street"] = "street";
582
- FieldNames["streetNumber"] = "street_number";
583
- FieldNames["take2Taxes"] = "take2_taxes";
584
- FieldNames["termsAndConditions"] = "termsAndConditions";
585
- FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
586
- FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
587
- FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
588
- FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
589
- FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
590
- FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
591
- FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
592
- FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
593
- FieldNames["zip"] = "zip";
594
- FieldNames["allowSave"] = "allowSave";
595
- FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
596
- FieldNames["tokenApplePay"] = "token_applepay";
597
- FieldNames["fixInvoice"] = "fix_invoice";
598
- FieldNames["fixPid"] = "fix_pid";
599
- FieldNames["signature"] = "signature";
600
- FieldNames["qr"] = "qr";
601
- FieldNames["sum"] = "sum";
602
- FieldNames["out"] = "out";
603
- FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
604
- })(FieldNames || (FieldNames = {}));
605
-
606
- class SubmitResponse {
607
- constructor(parameters, responseNumber = 0) {
608
- this.responseNumber = responseNumber;
609
- /* Todo split into properties */
610
- this.parameters = parameters;
611
- this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
612
- if (parameters.onlineBanking) {
613
- this.onlineBanking = {
614
- url: parameters.onlineBanking.value,
615
- };
616
- }
617
- this.isNeedRedirect =
618
- parameters.currentCommand === XpsCommand.account ||
619
- (parameters.currentCommand === XpsCommand.checkout &&
620
- Boolean(parameters.checkout));
621
- this.buyData = parameters.buyData;
622
- this.fixInvoice = this.fields.find((field) => field.name === FieldNames.fixInvoice)?.value;
623
- this.signature = this.fields.find((field) => field.name === FieldNames.signature)?.value;
624
- this.hasFatalErrors = parameters.textAll?.fatal;
625
- this.userSession = parameters.userSession;
626
- this.pid = parameters.pid;
627
- this.errors = parameters.errors;
628
- this.summary = parameters.summary;
629
- this.title = parameters.title;
630
- this.currentCommand = parameters.currentCommand;
631
- this.messages = parameters.messages;
632
- }
633
- }
634
-
635
646
  const submitResponseFactoryToken = new InjectionToken('SubmitResponse');
636
647
  const submitResponseFactoryProvider = {
637
648
  provide: submitResponseFactoryToken,
@@ -967,7 +978,9 @@ class SyncService extends EmitDataService {
967
978
  return Promise.resolve(null);
968
979
  }
969
980
  if (prevFieldState && value === prevFieldState.value) {
970
- return Promise.resolve(prevFieldState.result);
981
+ return Promise.resolve(prevFieldState.result).then((response) => {
982
+ return response?.rewritableError ?? null;
983
+ });
971
984
  }
972
985
  const requestPromise = this.request(field);
973
986
  this.setPrevFieldSyncState(field, value, requestPromise);
@@ -975,6 +988,16 @@ class SyncService extends EmitDataService {
975
988
  return response.rewritableError ?? null;
976
989
  });
977
990
  }
991
+ getSyncValidationErrors(field) {
992
+ const control = this.form.get(field.name);
993
+ if (!control) {
994
+ return null;
995
+ }
996
+ const rewritableError = control.errors?.rewritableError;
997
+ return rewritableError
998
+ ? { message: rewritableError.message, code: rewritableError.code }
999
+ : null;
1000
+ }
978
1001
  async request(field) {
979
1002
  const requestParams = this.requestFactory({
980
1003
  token: this.settingsService.token,
@@ -1030,7 +1053,7 @@ class TextControlConfig extends ControlConfig {
1030
1053
  }
1031
1054
  }
1032
1055
 
1033
- function convert(validator, message) {
1056
+ function convert(validator, message, errorCode) {
1034
1057
  return (control) => {
1035
1058
  const errors = validator(control);
1036
1059
  if (!errors) {
@@ -1041,6 +1064,7 @@ function convert(validator, message) {
1041
1064
  error = typeof error === 'object' && error !== null ? error : {};
1042
1065
  const rewritableError = { ...error };
1043
1066
  rewritableError.message = message;
1067
+ rewritableError.code = errorCode;
1044
1068
  if (error[firstErrorKey] != null) {
1045
1069
  rewritableError.value = error[firstErrorKey];
1046
1070
  }
@@ -1052,13 +1076,21 @@ function convert(validator, message) {
1052
1076
  };
1053
1077
  }
1054
1078
 
1079
+ var ErrorsCodes;
1080
+ (function (ErrorsCodes) {
1081
+ ErrorsCodes["minLength"] = "min-length";
1082
+ ErrorsCodes["maxLength"] = "max-length";
1083
+ ErrorsCodes["invalidValue"] = "invalid-value";
1084
+ ErrorsCodes["required"] = "required";
1085
+ })(ErrorsCodes || (ErrorsCodes = {}));
1086
+
1055
1087
  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
1056
1088
  function emailValidator() {
1057
- return convert(Validators.pattern(emailRegexp), 'Enter a valid email');
1089
+ return convert(Validators.pattern(emailRegexp), 'Enter a valid email', ErrorsCodes.invalidValue);
1058
1090
  }
1059
1091
 
1060
1092
  function requiredValidator() {
1061
- return convert(Validators.required, 'Required');
1093
+ return convert(Validators.required, 'Required', ErrorsCodes.required);
1062
1094
  }
1063
1095
 
1064
1096
  class Converter {
@@ -1073,7 +1105,7 @@ class Converter {
1073
1105
  return config;
1074
1106
  }
1075
1107
  convertToFormControl(field) {
1076
- return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
1108
+ return new UntypedFormControl(this.getValue(field), this.getValidators(field));
1077
1109
  }
1078
1110
  getValidators(field) {
1079
1111
  const validators = [];
@@ -1087,14 +1119,11 @@ class Converter {
1087
1119
  const errorMessage = field.validation_error_msg
1088
1120
  ? field.validation_error_msg
1089
1121
  : 'Enter valid data';
1090
- validators.push(convert(Validators.pattern(pattern), errorMessage));
1122
+ validators.push(convert(Validators.pattern(pattern), errorMessage, ErrorsCodes.invalidValue));
1091
1123
  }
1092
1124
  }
1093
1125
  return validators;
1094
1126
  }
1095
- getAsyncValidators(field) {
1096
- return async () => this.syncService.validate(field);
1097
- }
1098
1127
  createDefaultControlConfig(controlConfigClass, field) {
1099
1128
  const config = new controlConfigClass();
1100
1129
  this.copyCommonOptions(config, field);
@@ -1179,11 +1208,11 @@ class ZipConverter extends Converter {
1179
1208
  const validators = super
1180
1209
  .getValidators(field)
1181
1210
  .concat([
1182
- convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
1183
- convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
1211
+ convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`, ErrorsCodes.minLength),
1212
+ convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`, ErrorsCodes.maxLength),
1184
1213
  ]);
1185
1214
  if (this.isUsCountry) {
1186
- validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
1215
+ validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code', ErrorsCodes.invalidValue));
1187
1216
  }
1188
1217
  return validators;
1189
1218
  }
@@ -1192,12 +1221,14 @@ class ZipConverter extends Converter {
1192
1221
  config.icon = 'location';
1193
1222
  if (this.isUsCountry) {
1194
1223
  config.maskConfig = {
1195
- mask: () => new Array(this.usCountryLength).fill('9').join(''),
1196
1224
  guide: false,
1197
1225
  unmaskModelValue: true,
1198
1226
  showMask: true,
1199
1227
  };
1200
1228
  config.inputMode = 'numeric';
1229
+ if (masksFunctionsMap['zip']) {
1230
+ config.maskConfig.mask = masksFunctionsMap['zip'];
1231
+ }
1201
1232
  }
1202
1233
  else {
1203
1234
  config.maxLength = this.maxLength;
@@ -2273,7 +2304,7 @@ class ShowFieldsAction {
2273
2304
  messages: [],
2274
2305
  order: {},
2275
2306
  };
2276
- this.data.fields = submitResponse.fields;
2307
+ this.data.fields = submitResponse.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
2277
2308
  this.data.errors = submitResponse.errors;
2278
2309
  this.data.messages = submitResponse.messages;
2279
2310
  this.data.order = submitResponse.summary;
@@ -2285,7 +2316,9 @@ const showFieldsActionFactoryProvider = {
2285
2316
  provide: showFieldsActionFactoryToken,
2286
2317
  useValue: {
2287
2318
  factory: (...args) => new ShowFieldsAction(...args),
2288
- type: 'show_fields',
2319
+ isSuitable: (response) => {
2320
+ return response.currentCommand === XpsCommand.check;
2321
+ },
2289
2322
  },
2290
2323
  };
2291
2324
 
@@ -2310,7 +2343,9 @@ const checkStatusActionFactoryProvider = {
2310
2343
  provide: checkStatusActionFactoryToken,
2311
2344
  useValue: {
2312
2345
  factory: (...args) => new CheckStatusAction(...args),
2313
- type: 'check_status',
2346
+ isSuitable: (response) => {
2347
+ return response.currentCommand === XpsCommand.status;
2348
+ },
2314
2349
  },
2315
2350
  };
2316
2351
 
@@ -2319,7 +2354,40 @@ const statusUpdatedActionFactoryProvider = {
2319
2354
  provide: statusUpdatedActionFactoryToken,
2320
2355
  useValue: {
2321
2356
  factory: (...args) => new StatusUpdatedAction(...args),
2322
- type: 'status_updated',
2357
+ isSuitable: () => false,
2358
+ },
2359
+ };
2360
+
2361
+ class RedirectAction {
2362
+ constructor(submitResponse) {
2363
+ this.type = 'redirect';
2364
+ this.data = {
2365
+ fields: submitResponse.fields,
2366
+ errors: submitResponse.errors,
2367
+ messages: submitResponse.messages,
2368
+ order: submitResponse.summary,
2369
+ invoiceId: submitResponse.fixInvoice,
2370
+ redirect: this.getRedirect(submitResponse),
2371
+ };
2372
+ }
2373
+ getRedirect(submitResponse) {
2374
+ return {
2375
+ redirectUrl: submitResponse.parameters.checkout.action,
2376
+ data: submitResponse.parameters.checkout.data,
2377
+ };
2378
+ }
2379
+ }
2380
+
2381
+ const redirectActionFactoryToken = new InjectionToken('RedirectAction');
2382
+ const redirectActionFactoryProvider = {
2383
+ provide: redirectActionFactoryToken,
2384
+ useValue: {
2385
+ factory: (...args) => new RedirectAction(...args),
2386
+ isSuitable: (response) => {
2387
+ return (response.currentCommand === XpsCommand.account ||
2388
+ (response.currentCommand === XpsCommand.checkout &&
2389
+ Boolean(response.parameters.checkout)));
2390
+ },
2323
2391
  },
2324
2392
  };
2325
2393
 
@@ -2328,13 +2396,9 @@ const nextActions = [
2328
2396
  showFieldsActionFactoryProvider,
2329
2397
  checkStatusActionFactoryProvider,
2330
2398
  statusUpdatedActionFactoryProvider,
2399
+ redirectActionFactoryProvider,
2331
2400
  ];
2332
2401
 
2333
- const actionTypeCommandMap = {
2334
- [XpsCommand.check]: 'show_fields',
2335
- [XpsCommand.status]: 'check_status',
2336
- };
2337
-
2338
2402
  class NextActionService {
2339
2403
  get flowUpdates$() {
2340
2404
  return this.flowUpdatesSubject.asObservable();
@@ -2343,14 +2407,14 @@ class NextActionService {
2343
2407
  this.nextActionTokens = nextActionTokens;
2344
2408
  this.injector = injector;
2345
2409
  this.flowUpdatesSubject = new Subject();
2346
- this.nextActionsMap = new Map();
2347
- this.fillNextActionsMap();
2410
+ this.nextActionsList = [];
2411
+ this.fillNextActionsList();
2348
2412
  }
2349
2413
  getNextAction(submitResponse) {
2350
2414
  if (!submitResponse.currentCommand) {
2351
2415
  return null;
2352
2416
  }
2353
- const nextActionFactory = this.findNextAction(submitResponse.currentCommand);
2417
+ const nextActionFactory = this.findNextAction(submitResponse);
2354
2418
  if (nextActionFactory) {
2355
2419
  return nextActionFactory(submitResponse);
2356
2420
  }
@@ -2359,18 +2423,20 @@ class NextActionService {
2359
2423
  emitFlowUpdates(action) {
2360
2424
  this.flowUpdatesSubject.next(action);
2361
2425
  }
2362
- fillNextActionsMap() {
2426
+ fillNextActionsList() {
2363
2427
  this.nextActionTokens.forEach((nextAction) => {
2364
2428
  const item = this.injector.get(nextAction.provide);
2365
- this.nextActionsMap.set(item.type, item.factory);
2429
+ this.nextActionsList.push(item);
2366
2430
  });
2367
2431
  }
2368
- findNextAction(command) {
2369
- const actionType = actionTypeCommandMap[command];
2432
+ findNextAction(submitResponse) {
2433
+ const actionType = this.nextActionsList.find((nextAction) => {
2434
+ return nextAction.isSuitable(submitResponse);
2435
+ });
2370
2436
  if (!actionType) {
2371
2437
  return;
2372
2438
  }
2373
- return this.nextActionsMap.get(actionType);
2439
+ return actionType.factory;
2374
2440
  }
2375
2441
  }
2376
2442
  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 });
@@ -2451,6 +2517,9 @@ class FinanceDetails {
2451
2517
  constructor(parameters) {
2452
2518
  this.purchase = parameters.purchase;
2453
2519
  this.finance = parameters.finance;
2520
+ this.cartItems = this.getFormattedPurchaseForCart();
2521
+ this.cartSummary = this.getFormattedPricingForCart();
2522
+ this.paymentCountry = this.getPaymentCountry();
2454
2523
  }
2455
2524
  getFormattedPurchaseForCart() {
2456
2525
  const checkouts = this.purchase.checkout_items?.map((item) => {
@@ -2491,9 +2560,8 @@ class FinanceDetails {
2491
2560
  if (this.purchase.checkout) {
2492
2561
  checkoutArray = [
2493
2562
  {
2494
- title: this.purchase.checkout.description
2495
- ? this.purchase.checkout.description
2496
- : 'In-game purchase',
2563
+ key: 'checkout',
2564
+ title: this.purchase.checkout.description,
2497
2565
  price: extractMoneyCurrency(this.purchase.checkout),
2498
2566
  isBonus: this.purchase.checkout.is_bonus ?? false,
2499
2567
  },
@@ -2511,14 +2579,17 @@ class FinanceDetails {
2511
2579
  const subtotalDetailsSorting = [
2512
2580
  {
2513
2581
  key: 'discount',
2582
+ responseKey: 'discount',
2514
2583
  title: 'Discount',
2515
2584
  },
2516
2585
  {
2517
2586
  key: 'fee',
2587
+ responseKey: 'fee',
2518
2588
  title: 'Payment system fee',
2519
2589
  },
2520
2590
  {
2521
- key: 'user_balance',
2591
+ key: 'user-balance',
2592
+ responseKey: 'user_balance',
2522
2593
  title: 'Balance',
2523
2594
  },
2524
2595
  ];
@@ -2538,10 +2609,11 @@ class FinanceDetails {
2538
2609
  totalDetails: this.getTaxesForTotalDetails(),
2539
2610
  subtotalDetails: [
2540
2611
  ...subtotalDetailsSorting.map((sorting) => {
2541
- const field = this.finance[sorting.key];
2612
+ const field = this.finance[sorting.responseKey];
2542
2613
  if (field) {
2543
2614
  return {
2544
- ...sorting,
2615
+ key: sorting.key,
2616
+ title: sorting.title,
2545
2617
  money: {
2546
2618
  amount: sorting.key === 'discount' && field.amount
2547
2619
  ? -field.amount
@@ -2557,28 +2629,36 @@ class FinanceDetails {
2557
2629
  };
2558
2630
  }
2559
2631
  getPaymentCountry() {
2560
- return this.finance?.payment_country.iso;
2632
+ return this.finance.payment_country.iso;
2561
2633
  }
2562
2634
  getTaxForItem(indirectTaxRate) {
2563
2635
  if (indirectTaxRate ||
2564
2636
  (this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
2565
2637
  if (this.isSalesTaxes) {
2566
2638
  return {
2639
+ key: 'sales-tax',
2567
2640
  content: `Sales tax ${indirectTaxRate}%`,
2641
+ rate: indirectTaxRate,
2568
2642
  };
2569
2643
  }
2570
2644
  if (this.isIndia()) {
2571
2645
  return {
2646
+ key: 'vat-india',
2572
2647
  content: `GST ${indirectTaxRate}%`,
2648
+ rate: indirectTaxRate,
2573
2649
  };
2574
2650
  }
2575
2651
  if (this.isGhana()) {
2576
2652
  return {
2653
+ key: 'vat-ghana',
2577
2654
  content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
2655
+ rate: indirectTaxRate,
2578
2656
  };
2579
2657
  }
2580
2658
  return {
2659
+ key: 'vat',
2581
2660
  content: `VAT ${indirectTaxRate}%`,
2661
+ rate: indirectTaxRate,
2582
2662
  };
2583
2663
  }
2584
2664
  return null;
@@ -2589,14 +2669,14 @@ class FinanceDetails {
2589
2669
  if (this.finance.vat_user &&
2590
2670
  (this.finance?.vat_user?.amount ?? this.finance?.vat_user?.visible)) {
2591
2671
  ret.push({
2592
- key: 'vat_user',
2672
+ key: this.getVatKeyForDetails(),
2593
2673
  title: this.getVatLabelForSubtotalDetails(),
2594
2674
  money: extractMoneyCurrency(this.finance.vat_user),
2595
2675
  });
2596
2676
  }
2597
2677
  if (this.finance.sales_tax_user?.amount) {
2598
2678
  ret.push({
2599
- key: 'sales_tax_user',
2679
+ key: 'sales-tax',
2600
2680
  title: 'Sales tax',
2601
2681
  money: extractMoneyCurrency(this.finance.sales_tax_user),
2602
2682
  });
@@ -2618,7 +2698,7 @@ class FinanceDetails {
2618
2698
  if ((this.finance?.vat?.amount || this.finance?.vat?.visible) &&
2619
2699
  !this.finance?.vat_user?.amount) {
2620
2700
  ret.push({
2621
- key: 'vat',
2701
+ key: this.getVatKeyForDetails(),
2622
2702
  title: this.getVatLabelForTotalDetails(),
2623
2703
  money: extractMoneyCurrency(this.finance.vat),
2624
2704
  });
@@ -2626,13 +2706,22 @@ class FinanceDetails {
2626
2706
  if (this.finance?.sales_tax?.amount &&
2627
2707
  !this.finance?.sales_tax_user?.amount) {
2628
2708
  ret.push({
2629
- key: 'sales_tax',
2709
+ key: 'sales-tax',
2630
2710
  title: 'Sales tax included',
2631
2711
  money: extractMoneyCurrency(this.finance.sales_tax),
2632
2712
  });
2633
2713
  }
2634
2714
  return ret;
2635
2715
  }
2716
+ getVatKeyForDetails() {
2717
+ if (this.isIndia()) {
2718
+ return 'vat-india';
2719
+ }
2720
+ if (this.isGhana()) {
2721
+ return 'vat-ghana';
2722
+ }
2723
+ return 'vat';
2724
+ }
2636
2725
  getVatLabelForTotalDetails() {
2637
2726
  if (this.isIndia()) {
2638
2727
  return `Including ${this.finance.vat.percent}% GST`;
@@ -2705,20 +2794,28 @@ class PaymentService {
2705
2794
  this.form = this.formService.createForm(this.fields);
2706
2795
  this.emitFinanceDetails(this.data.paymentForm?.summary);
2707
2796
  this.setupSyncService(this.form, this.fields);
2708
- return this.fields;
2797
+ return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
2709
2798
  }
2710
2799
  async submit() {
2711
2800
  if (!this.form) {
2712
2801
  throw new Error('form is empty!');
2713
2802
  }
2714
2803
  const submitResponse = await this.submitService.request(this.fields, this.form);
2804
+ this.data = submitResponse;
2715
2805
  this.emitFinanceDetails(submitResponse.summary);
2716
2806
  return this.nextActionService.getNextAction(submitResponse);
2717
2807
  }
2718
2808
  getFields() {
2809
+ if (this.data instanceof SubmitResponse) {
2810
+ return this.data.fields ?? [];
2811
+ }
2719
2812
  return this.data?.paymentForm?.fields ?? [];
2720
2813
  }
2721
2814
  async validate(field) {
2815
+ const syncErrors = this.syncService.getSyncValidationErrors(field);
2816
+ if (syncErrors) {
2817
+ return Promise.resolve(syncErrors);
2818
+ }
2722
2819
  return this.syncService.validate(field);
2723
2820
  }
2724
2821
  runThreeDs() {
@@ -2727,7 +2824,16 @@ class PaymentService {
2727
2824
  getFinanceDetails() {
2728
2825
  return this.financeDetails;
2729
2826
  }
2730
- async getStatus(params) {
2827
+ async getStatus() {
2828
+ if (!isSubmitResponse(this.data)) {
2829
+ throw new Error('Should submit form first');
2830
+ }
2831
+ const params = {
2832
+ invoice: parseInt(this.data.fixInvoice ?? ''),
2833
+ signature: this.data.signature ?? '',
2834
+ locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
2835
+ 'en',
2836
+ };
2731
2837
  return this.statusService.getStatus({
2732
2838
  ...params,
2733
2839
  pid: this.config.paymentMethodId,
@@ -2907,7 +3013,7 @@ class CoreLibraryService {
2907
3013
  validate: async (field) => this.paymentService.validate(field),
2908
3014
  getFinanceDetails: () => this.paymentService.getFinanceDetails(),
2909
3015
  runThreeDs: () => this.paymentService.runThreeDs(),
2910
- getStatus: async (params) => this.paymentService.getStatus(params),
3016
+ getStatus: async () => this.paymentService.getStatus(),
2911
3017
  flowUpdates$: this.nextActionService.flowUpdates$,
2912
3018
  financeDetailsUpdates$: this.financeDetailsService.data$,
2913
3019
  form: {
@@ -2919,6 +3025,10 @@ class CoreLibraryService {
2919
3025
  getLegalComponentConfig() {
2920
3026
  return this.legalService.getLegalComponentConfig();
2921
3027
  }
3028
+ getFieldMask(field) {
3029
+ const sanitizedName = field.name.replace(/^fix_/i, '');
3030
+ return masksFunctionsMap[sanitizedName];
3031
+ }
2922
3032
  }
2923
3033
  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 });
2924
3034
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });