@xsolla/payment-client-core 0.0.10-6 → 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 (49) 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 +4 -3
  13. package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +6 -15
  14. package/esm2020/lib/core/payment/form/mask-config.interface.mjs +2 -0
  15. package/esm2020/lib/core/payment/form/masks-functions.map.mjs +5 -2
  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 +19 -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 +4 -2
  26. package/esm2020/lib/core-library.service.mjs +3 -3
  27. package/fesm2015/xsolla-payment-client-core.mjs +201 -145
  28. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  29. package/fesm2020/xsolla-payment-client-core.mjs +198 -142
  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/mask-config.interface.d.ts +6 -0
  38. package/lib/core/payment/form/validators/convert.function.d.ts +1 -1
  39. package/lib/core/payment/form/validators/errors-codes.enum.d.ts +6 -0
  40. package/lib/core/payment/form/validators/validation-error.interface.d.ts +1 -0
  41. package/lib/core/payment/payment.interface.d.ts +1 -2
  42. package/lib/core/payment/payment.service.d.ts +4 -5
  43. package/lib/core/payment/submit/response/is-submit-response.function.d.ts +2 -0
  44. package/lib/core/payment/sync/field-sync-state.interface.d.ts +2 -2
  45. package/package.json +1 -1
  46. package/xsolla-payment-client-core-0.0.11.tgz +0 -0
  47. package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +0 -6
  48. package/lib/core/payment/actions/action-type-command.map.d.ts +0 -4
  49. package/xsolla-payment-client-core-0.0.10-6.tgz +0 -0
@@ -9,7 +9,10 @@ import { filter, map as map$1, catchError } from 'rxjs/operators';
9
9
  import * as i1$1 from '@angular/router';
10
10
 
11
11
  const masksFunctionsMap = {
12
- zip: () => new Array(5).fill('9').join(''),
12
+ zip: () => {
13
+ const zipLength = 5;
14
+ return new Array(zipLength).fill('9').join('');
15
+ },
13
16
  };
14
17
 
15
18
  class AppError extends Error {
@@ -429,6 +432,114 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
429
432
  }] }, { type: SettingsService }, { type: SecureApiClient }];
430
433
  } });
431
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
+
432
543
  class InitializeResponse {
433
544
  constructor(response) {
434
545
  this.paymentForm = null;
@@ -565,110 +676,6 @@ const submitRequestFactoryProvider = {
565
676
  useValue: (...args) => new SubmitRequest(...args),
566
677
  };
567
678
 
568
- var XpsCommand;
569
- (function (XpsCommand) {
570
- XpsCommand["form"] = "form";
571
- XpsCommand["check"] = "check";
572
- XpsCommand["status"] = "status";
573
- XpsCommand["checkout"] = "checkout";
574
- XpsCommand["account"] = "account";
575
- XpsCommand["create"] = "create";
576
- })(XpsCommand || (XpsCommand = {}));
577
-
578
- var FieldNames;
579
- (function (FieldNames) {
580
- FieldNames["address1"] = "address1";
581
- FieldNames["address2"] = "address2";
582
- FieldNames["address"] = "address";
583
- FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
584
- FieldNames["allowSubscription"] = "allowSubscription";
585
- FieldNames["apt"] = "apt";
586
- FieldNames["availableCardTypes"] = "available_card_types";
587
- FieldNames["bank"] = "bank";
588
- FieldNames["birthDate"] = "birth_date";
589
- FieldNames["cardMonth"] = "card_month";
590
- FieldNames["cardYear"] = "card_year";
591
- FieldNames["cardNumber"] = "card_number";
592
- FieldNames["cardholdername"] = "cardholdername";
593
- FieldNames["city"] = "city";
594
- FieldNames["couponCode"] = "couponCode";
595
- FieldNames["cpfName"] = "cpf_name";
596
- FieldNames["cpfNumber"] = "cpf_number";
597
- FieldNames["cvv"] = "cvv";
598
- FieldNames["description"] = "description";
599
- FieldNames["email"] = "email";
600
- FieldNames["psEmail"] = "psEmail";
601
- FieldNames["euCheck"] = "eu_check";
602
- FieldNames["extraCvv"] = "extra_cvv";
603
- FieldNames["extraCardNumber"] = "extra_card_number";
604
- FieldNames["extraCardType"] = "extra_card_type";
605
- FieldNames["fName"] = "f_name";
606
- FieldNames["installments"] = "installments";
607
- FieldNames["lName"] = "l_name";
608
- FieldNames["needInstallments"] = "needInstallments";
609
- FieldNames["personId"] = "person_id";
610
- FieldNames["personIdAr"] = "person_id_ar";
611
- FieldNames["personIdCo"] = "person_id_co";
612
- FieldNames["phone"] = "phone";
613
- FieldNames["purchaseDescription"] = "purchaseDescription";
614
- FieldNames["recurrentType"] = "recurrent_type";
615
- FieldNames["rockstarTaxes"] = "rockstar_taxes";
616
- FieldNames["state"] = "state";
617
- FieldNames["street"] = "street";
618
- FieldNames["streetNumber"] = "street_number";
619
- FieldNames["take2Taxes"] = "take2_taxes";
620
- FieldNames["termsAndConditions"] = "termsAndConditions";
621
- FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
622
- FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
623
- FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
624
- FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
625
- FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
626
- FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
627
- FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
628
- FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
629
- FieldNames["zip"] = "zip";
630
- FieldNames["allowSave"] = "allowSave";
631
- FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
632
- FieldNames["tokenApplePay"] = "token_applepay";
633
- FieldNames["fixInvoice"] = "fix_invoice";
634
- FieldNames["fixPid"] = "fix_pid";
635
- FieldNames["signature"] = "signature";
636
- FieldNames["qr"] = "qr";
637
- FieldNames["sum"] = "sum";
638
- FieldNames["out"] = "out";
639
- FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
640
- })(FieldNames || (FieldNames = {}));
641
-
642
- class SubmitResponse {
643
- constructor(parameters, responseNumber = 0) {
644
- var _a, _b, _c;
645
- this.responseNumber = responseNumber;
646
- /* Todo split into properties */
647
- this.parameters = parameters;
648
- this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
649
- if (parameters.onlineBanking) {
650
- this.onlineBanking = {
651
- url: parameters.onlineBanking.value,
652
- };
653
- }
654
- this.isNeedRedirect =
655
- parameters.currentCommand === XpsCommand.account ||
656
- (parameters.currentCommand === XpsCommand.checkout &&
657
- Boolean(parameters.checkout));
658
- this.buyData = parameters.buyData;
659
- this.fixInvoice = (_a = this.fields.find((field) => field.name === FieldNames.fixInvoice)) === null || _a === void 0 ? void 0 : _a.value;
660
- this.signature = (_b = this.fields.find((field) => field.name === FieldNames.signature)) === null || _b === void 0 ? void 0 : _b.value;
661
- this.hasFatalErrors = (_c = parameters.textAll) === null || _c === void 0 ? void 0 : _c.fatal;
662
- this.userSession = parameters.userSession;
663
- this.pid = parameters.pid;
664
- this.errors = parameters.errors;
665
- this.summary = parameters.summary;
666
- this.title = parameters.title;
667
- this.currentCommand = parameters.currentCommand;
668
- this.messages = parameters.messages;
669
- }
670
- }
671
-
672
679
  const submitResponseFactoryToken = new InjectionToken('SubmitResponse');
673
680
  const submitResponseFactoryProvider = {
674
681
  provide: submitResponseFactoryToken,
@@ -1045,7 +1052,9 @@ class SyncService extends EmitDataService {
1045
1052
  return null;
1046
1053
  }
1047
1054
  const rewritableError = (_a = control.errors) === null || _a === void 0 ? void 0 : _a.rewritableError;
1048
- return rewritableError ? { message: rewritableError.message } : null;
1055
+ return rewritableError
1056
+ ? { message: rewritableError.message, code: rewritableError.code }
1057
+ : null;
1049
1058
  }
1050
1059
  request(field) {
1051
1060
  return __awaiter(this, void 0, void 0, function* () {
@@ -1107,7 +1116,7 @@ class TextControlConfig extends ControlConfig {
1107
1116
  }
1108
1117
  }
1109
1118
 
1110
- function convert(validator, message) {
1119
+ function convert(validator, message, errorCode) {
1111
1120
  return (control) => {
1112
1121
  const errors = validator(control);
1113
1122
  if (!errors) {
@@ -1118,6 +1127,7 @@ function convert(validator, message) {
1118
1127
  error = typeof error === 'object' && error !== null ? error : {};
1119
1128
  const rewritableError = Object.assign({}, error);
1120
1129
  rewritableError.message = message;
1130
+ rewritableError.code = errorCode;
1121
1131
  if (error[firstErrorKey] != null) {
1122
1132
  rewritableError.value = error[firstErrorKey];
1123
1133
  }
@@ -1129,13 +1139,21 @@ function convert(validator, message) {
1129
1139
  };
1130
1140
  }
1131
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
+
1132
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
1133
1151
  function emailValidator() {
1134
- return convert(Validators.pattern(emailRegexp), 'Enter a valid email');
1152
+ return convert(Validators.pattern(emailRegexp), 'Enter a valid email', ErrorsCodes.invalidValue);
1135
1153
  }
1136
1154
 
1137
1155
  function requiredValidator() {
1138
- return convert(Validators.required, 'Required');
1156
+ return convert(Validators.required, 'Required', ErrorsCodes.required);
1139
1157
  }
1140
1158
 
1141
1159
  class Converter {
@@ -1164,7 +1182,7 @@ class Converter {
1164
1182
  const errorMessage = field.validation_error_msg
1165
1183
  ? field.validation_error_msg
1166
1184
  : 'Enter valid data';
1167
- validators.push(convert(Validators.pattern(pattern), errorMessage));
1185
+ validators.push(convert(Validators.pattern(pattern), errorMessage, ErrorsCodes.invalidValue));
1168
1186
  }
1169
1187
  }
1170
1188
  return validators;
@@ -1253,11 +1271,11 @@ class ZipConverter extends Converter {
1253
1271
  const validators = super
1254
1272
  .getValidators(field)
1255
1273
  .concat([
1256
- convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
1257
- 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),
1258
1276
  ]);
1259
1277
  if (this.isUsCountry) {
1260
- validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
1278
+ validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code', ErrorsCodes.invalidValue));
1261
1279
  }
1262
1280
  return validators;
1263
1281
  }
@@ -1266,16 +1284,6 @@ class ZipConverter extends Converter {
1266
1284
  config.icon = 'location';
1267
1285
  if (this.isUsCountry) {
1268
1286
  config.maskConfig = {
1269
- // mask: () => new Array(this.usCountryLength).fill('9').join(''),
1270
- // mask: () => new Array(5).fill('9').join(''),
1271
- // mask: function() { return new Array(5).fill('9').join('') },
1272
- // mask: MasksFunctionsMap['zip'],
1273
- // mask: function mask() {
1274
- // const length = this.usCountryLength;
1275
- // return function() {
1276
- // return new Array(length).fill('9').join('');
1277
- // }
1278
- // },
1279
1287
  guide: false,
1280
1288
  unmaskModelValue: true,
1281
1289
  showMask: true,
@@ -2397,7 +2405,7 @@ class ShowFieldsAction {
2397
2405
  messages: [],
2398
2406
  order: {},
2399
2407
  };
2400
- 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 */);
2401
2409
  this.data.errors = submitResponse.errors;
2402
2410
  this.data.messages = submitResponse.messages;
2403
2411
  this.data.order = submitResponse.summary;
@@ -2409,7 +2417,9 @@ const showFieldsActionFactoryProvider = {
2409
2417
  provide: showFieldsActionFactoryToken,
2410
2418
  useValue: {
2411
2419
  factory: (...args) => new ShowFieldsAction(...args),
2412
- type: 'show_fields',
2420
+ isSuitable: (response) => {
2421
+ return response.currentCommand === XpsCommand.check;
2422
+ },
2413
2423
  },
2414
2424
  };
2415
2425
 
@@ -2435,7 +2445,9 @@ const checkStatusActionFactoryProvider = {
2435
2445
  provide: checkStatusActionFactoryToken,
2436
2446
  useValue: {
2437
2447
  factory: (...args) => new CheckStatusAction(...args),
2438
- type: 'check_status',
2448
+ isSuitable: (response) => {
2449
+ return response.currentCommand === XpsCommand.status;
2450
+ },
2439
2451
  },
2440
2452
  };
2441
2453
 
@@ -2444,7 +2456,40 @@ const statusUpdatedActionFactoryProvider = {
2444
2456
  provide: statusUpdatedActionFactoryToken,
2445
2457
  useValue: {
2446
2458
  factory: (...args) => new StatusUpdatedAction(...args),
2447
- 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
+ },
2448
2493
  },
2449
2494
  };
2450
2495
 
@@ -2453,13 +2498,9 @@ const nextActions = [
2453
2498
  showFieldsActionFactoryProvider,
2454
2499
  checkStatusActionFactoryProvider,
2455
2500
  statusUpdatedActionFactoryProvider,
2501
+ redirectActionFactoryProvider,
2456
2502
  ];
2457
2503
 
2458
- const actionTypeCommandMap = {
2459
- [XpsCommand.check]: 'show_fields',
2460
- [XpsCommand.status]: 'check_status',
2461
- };
2462
-
2463
2504
  class NextActionService {
2464
2505
  get flowUpdates$() {
2465
2506
  return this.flowUpdatesSubject.asObservable();
@@ -2468,14 +2509,14 @@ class NextActionService {
2468
2509
  this.nextActionTokens = nextActionTokens;
2469
2510
  this.injector = injector;
2470
2511
  this.flowUpdatesSubject = new Subject();
2471
- this.nextActionsMap = new Map();
2472
- this.fillNextActionsMap();
2512
+ this.nextActionsList = [];
2513
+ this.fillNextActionsList();
2473
2514
  }
2474
2515
  getNextAction(submitResponse) {
2475
2516
  if (!submitResponse.currentCommand) {
2476
2517
  return null;
2477
2518
  }
2478
- const nextActionFactory = this.findNextAction(submitResponse.currentCommand);
2519
+ const nextActionFactory = this.findNextAction(submitResponse);
2479
2520
  if (nextActionFactory) {
2480
2521
  return nextActionFactory(submitResponse);
2481
2522
  }
@@ -2484,18 +2525,20 @@ class NextActionService {
2484
2525
  emitFlowUpdates(action) {
2485
2526
  this.flowUpdatesSubject.next(action);
2486
2527
  }
2487
- fillNextActionsMap() {
2528
+ fillNextActionsList() {
2488
2529
  this.nextActionTokens.forEach((nextAction) => {
2489
2530
  const item = this.injector.get(nextAction.provide);
2490
- this.nextActionsMap.set(item.type, item.factory);
2531
+ this.nextActionsList.push(item);
2491
2532
  });
2492
2533
  }
2493
- findNextAction(command) {
2494
- const actionType = actionTypeCommandMap[command];
2534
+ findNextAction(submitResponse) {
2535
+ const actionType = this.nextActionsList.find((nextAction) => {
2536
+ return nextAction.isSuitable(submitResponse);
2537
+ });
2495
2538
  if (!actionType) {
2496
2539
  return;
2497
2540
  }
2498
- return this.nextActionsMap.get(actionType);
2541
+ return actionType.factory;
2499
2542
  }
2500
2543
  }
2501
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 });
@@ -2845,7 +2888,7 @@ class PaymentService {
2845
2888
  this.form = this.formService.createForm(this.fields);
2846
2889
  this.emitFinanceDetails((_a = this.data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary);
2847
2890
  this.setupSyncService(this.form, this.fields);
2848
- return this.fields;
2891
+ return this.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
2849
2892
  });
2850
2893
  }
2851
2894
  submit() {
@@ -2854,13 +2897,17 @@ class PaymentService {
2854
2897
  throw new Error('form is empty!');
2855
2898
  }
2856
2899
  const submitResponse = yield this.submitService.request(this.fields, this.form);
2900
+ this.data = submitResponse;
2857
2901
  this.emitFinanceDetails(submitResponse.summary);
2858
2902
  return this.nextActionService.getNextAction(submitResponse);
2859
2903
  });
2860
2904
  }
2861
2905
  getFields() {
2862
- var _a, _b, _c;
2863
- 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 : [];
2864
2911
  }
2865
2912
  validate(field) {
2866
2913
  return __awaiter(this, void 0, void 0, function* () {
@@ -2877,8 +2924,17 @@ class PaymentService {
2877
2924
  getFinanceDetails() {
2878
2925
  return this.financeDetails;
2879
2926
  }
2880
- getStatus(params) {
2927
+ getStatus() {
2928
+ var _a, _b, _c, _d;
2881
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
+ };
2882
2938
  return this.statusService.getStatus(Object.assign(Object.assign({}, params), { pid: this.config.paymentMethodId }));
2883
2939
  });
2884
2940
  }
@@ -3062,7 +3118,7 @@ class CoreLibraryService {
3062
3118
  validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
3063
3119
  getFinanceDetails: () => this.paymentService.getFinanceDetails(),
3064
3120
  runThreeDs: () => this.paymentService.runThreeDs(),
3065
- 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(); }),
3066
3122
  flowUpdates$: this.nextActionService.flowUpdates$,
3067
3123
  financeDetailsUpdates$: this.financeDetailsService.data$,
3068
3124
  form: {