@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.
- package/esm2020/lib/core/payment/actions/action-factory-value.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.token.mjs +5 -2
- package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-action.service.mjs +11 -10
- package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
- package/esm2020/lib/core/payment/actions/redirect/redirect.action.class.mjs +20 -0
- package/esm2020/lib/core/payment/actions/redirect/redirect.action.token.mjs +16 -0
- package/esm2020/lib/core/payment/actions/redirect/redirect.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +2 -2
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.token.mjs +5 -2
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.token.mjs +2 -2
- package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +5 -7
- package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +9 -5
- package/esm2020/lib/core/payment/form/mask-config.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/masks-functions.map.mjs +7 -0
- package/esm2020/lib/core/payment/form/validators/convert.function.mjs +3 -2
- package/esm2020/lib/core/payment/form/validators/email-validator.mjs +3 -2
- package/esm2020/lib/core/payment/form/validators/errors-codes.enum.mjs +8 -0
- package/esm2020/lib/core/payment/form/validators/required-validator.mjs +3 -2
- package/esm2020/lib/core/payment/form/validators/validation-error.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +23 -4
- package/esm2020/lib/core/payment/submit/response/is-submit-response.function.mjs +5 -0
- package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +1 -1
- package/esm2020/lib/core/payment/sync/sync.service.mjs +14 -2
- package/esm2020/lib/core-library.service.mjs +7 -2
- package/fesm2015/xsolla-payment-client-core.mjs +228 -139
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +223 -136
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/actions/action-factory-value.interface.d.ts +2 -1
- package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/next-action.service.d.ts +2 -2
- package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +9 -0
- package/lib/core/payment/actions/redirect/redirect.action.token.d.ts +4 -0
- package/lib/core/payment/actions/redirect/redirect.action.type.d.ts +17 -0
- package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -2
- package/lib/core/payment/form/mask-config.interface.d.ts +6 -0
- package/lib/core/payment/form/masks-functions.map.d.ts +3 -0
- package/lib/core/payment/form/validators/convert.function.d.ts +1 -1
- package/lib/core/payment/form/validators/errors-codes.enum.d.ts +6 -0
- package/lib/core/payment/form/validators/validation-error.interface.d.ts +1 -0
- package/lib/core/payment/payment.interface.d.ts +1 -2
- package/lib/core/payment/payment.service.d.ts +4 -5
- package/lib/core/payment/submit/response/is-submit-response.function.d.ts +2 -0
- package/lib/core/payment/sync/field-sync-state.interface.d.ts +2 -2
- package/lib/core/payment/sync/sync.service.d.ts +1 -0
- package/lib/core-library.service.d.ts +2 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.11.tgz +0 -0
- package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +0 -6
- package/lib/core/payment/actions/action-type-command.map.d.ts +0 -4
- package/xsolla-payment-client-core-0.0.10.tgz +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)
|
|
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),
|
|
1183
|
-
convert(Validators.maxLength(maxLength),
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
2347
|
-
this.
|
|
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
|
|
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
|
-
|
|
2426
|
+
fillNextActionsList() {
|
|
2363
2427
|
this.nextActionTokens.forEach((nextAction) => {
|
|
2364
2428
|
const item = this.injector.get(nextAction.provide);
|
|
2365
|
-
this.
|
|
2429
|
+
this.nextActionsList.push(item);
|
|
2366
2430
|
});
|
|
2367
2431
|
}
|
|
2368
|
-
findNextAction(
|
|
2369
|
-
const actionType =
|
|
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
|
|
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 });
|
|
@@ -2705,20 +2771,28 @@ class PaymentService {
|
|
|
2705
2771
|
this.form = this.formService.createForm(this.fields);
|
|
2706
2772
|
this.emitFinanceDetails(this.data.paymentForm?.summary);
|
|
2707
2773
|
this.setupSyncService(this.form, this.fields);
|
|
2708
|
-
return this.fields;
|
|
2774
|
+
return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
|
|
2709
2775
|
}
|
|
2710
2776
|
async submit() {
|
|
2711
2777
|
if (!this.form) {
|
|
2712
2778
|
throw new Error('form is empty!');
|
|
2713
2779
|
}
|
|
2714
2780
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
2781
|
+
this.data = submitResponse;
|
|
2715
2782
|
this.emitFinanceDetails(submitResponse.summary);
|
|
2716
2783
|
return this.nextActionService.getNextAction(submitResponse);
|
|
2717
2784
|
}
|
|
2718
2785
|
getFields() {
|
|
2786
|
+
if (this.data instanceof SubmitResponse) {
|
|
2787
|
+
return this.data.fields ?? [];
|
|
2788
|
+
}
|
|
2719
2789
|
return this.data?.paymentForm?.fields ?? [];
|
|
2720
2790
|
}
|
|
2721
2791
|
async validate(field) {
|
|
2792
|
+
const syncErrors = this.syncService.getSyncValidationErrors(field);
|
|
2793
|
+
if (syncErrors) {
|
|
2794
|
+
return Promise.resolve(syncErrors);
|
|
2795
|
+
}
|
|
2722
2796
|
return this.syncService.validate(field);
|
|
2723
2797
|
}
|
|
2724
2798
|
runThreeDs() {
|
|
@@ -2727,7 +2801,16 @@ class PaymentService {
|
|
|
2727
2801
|
getFinanceDetails() {
|
|
2728
2802
|
return this.financeDetails;
|
|
2729
2803
|
}
|
|
2730
|
-
async getStatus(
|
|
2804
|
+
async getStatus() {
|
|
2805
|
+
if (!isSubmitResponse(this.data)) {
|
|
2806
|
+
throw new Error('Should submit form first');
|
|
2807
|
+
}
|
|
2808
|
+
const params = {
|
|
2809
|
+
invoice: parseInt(this.data.fixInvoice ?? ''),
|
|
2810
|
+
signature: this.data.signature ?? '',
|
|
2811
|
+
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
2812
|
+
'en',
|
|
2813
|
+
};
|
|
2731
2814
|
return this.statusService.getStatus({
|
|
2732
2815
|
...params,
|
|
2733
2816
|
pid: this.config.paymentMethodId,
|
|
@@ -2907,7 +2990,7 @@ class CoreLibraryService {
|
|
|
2907
2990
|
validate: async (field) => this.paymentService.validate(field),
|
|
2908
2991
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
2909
2992
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
2910
|
-
getStatus: async (
|
|
2993
|
+
getStatus: async () => this.paymentService.getStatus(),
|
|
2911
2994
|
flowUpdates$: this.nextActionService.flowUpdates$,
|
|
2912
2995
|
financeDetailsUpdates$: this.financeDetailsService.data$,
|
|
2913
2996
|
form: {
|
|
@@ -2919,6 +3002,10 @@ class CoreLibraryService {
|
|
|
2919
3002
|
getLegalComponentConfig() {
|
|
2920
3003
|
return this.legalService.getLegalComponentConfig();
|
|
2921
3004
|
}
|
|
3005
|
+
getFieldMask(field) {
|
|
3006
|
+
const sanitizedName = field.name.replace(/^fix_/i, '');
|
|
3007
|
+
return masksFunctionsMap[sanitizedName];
|
|
3008
|
+
}
|
|
2922
3009
|
}
|
|
2923
3010
|
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
3011
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|