@xsolla/payment-client-core 0.0.13 → 0.1.0
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/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-action.service.mjs +6 -2
- package/esm2020/lib/core/payment/actions/next-actions.mjs +6 -2
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.class.mjs +9 -0
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.token.mjs +13 -0
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/config/config.service.mjs +33 -0
- package/esm2020/lib/core/payment/extended-xps-error.mjs +2 -0
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +13 -6
- package/esm2020/lib/core/payment/payment.service.mjs +30 -5
- package/esm2020/lib/core/payment/status/status-request/request/status-request.class.mjs +2 -2
- package/esm2020/lib/core/payment/status/status-request/required-status-search-params.const.mjs +9 -0
- package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status-request/status-search-param.enum.mjs +13 -0
- package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +72 -0
- package/esm2020/lib/core/payment/status/status.service.mjs +30 -7
- package/esm2020/lib/core/payment/sync/sync.service.mjs +11 -5
- package/esm2020/lib/core/url/search-params.interface.mjs +2 -0
- package/esm2020/lib/core/url/url.service.mjs +34 -0
- package/esm2020/lib/core-library.module.mjs +4 -2
- package/esm2020/lib/core-library.service.mjs +18 -10
- package/fesm2015/xsolla-payment-client-core.mjs +438 -188
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +428 -188
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/next-action.service.d.ts +1 -1
- package/lib/core/payment/actions/next-actions.d.ts +1 -0
- package/lib/core/payment/actions/show-errors/show-errors.action.class.d.ts +8 -0
- package/lib/core/payment/actions/show-errors/show-errors.action.token.d.ts +4 -0
- package/lib/core/payment/actions/show-errors/show-errors.action.type.d.ts +7 -0
- package/lib/core/payment/config/config.service.d.ts +13 -0
- package/lib/core/payment/extended-xps-error.d.ts +4 -0
- package/lib/core/payment/initialize/initialize.service.d.ts +3 -1
- package/lib/core/payment/payment.service.d.ts +3 -1
- package/lib/core/payment/status/status-request/request/status-request.class.d.ts +1 -3
- package/lib/core/payment/status/status-request/required-status-search-params.const.d.ts +2 -0
- package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +1 -0
- package/lib/core/payment/status/status-request/status-search-param.enum.d.ts +11 -0
- package/lib/core/payment/status/status-request/status-search-params.map.d.ts +9 -0
- package/lib/core/payment/status/status.service.d.ts +5 -1
- package/lib/core/payment/sync/sync.service.d.ts +3 -1
- package/lib/core/url/search-params.interface.d.ts +3 -0
- package/lib/core/url/url.service.d.ts +8 -0
- package/lib/core-library.service.d.ts +7 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.0.tgz +0 -0
- package/esm2020/lib/core/payment/status/status-params.interface.mjs +0 -2
- package/lib/core/payment/status/status-params.interface.d.ts +0 -9
- package/xsolla-payment-client-core-0.0.13.tgz +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
|
|
4
|
-
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
4
|
+
import { firstValueFrom, lastValueFrom, map, Subject, tap, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/common/http';
|
|
6
6
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
7
7
|
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -432,6 +432,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
432
432
|
}] }, { type: SettingsService }, { type: SecureApiClient }];
|
|
433
433
|
} });
|
|
434
434
|
|
|
435
|
+
class UrlService {
|
|
436
|
+
addSearchParams(url, params = {}) {
|
|
437
|
+
if (!url) {
|
|
438
|
+
return '';
|
|
439
|
+
}
|
|
440
|
+
const urlObject = new URL(url);
|
|
441
|
+
for (const [key, value] of Object.entries(params)) {
|
|
442
|
+
urlObject.searchParams.set(key, value);
|
|
443
|
+
}
|
|
444
|
+
return urlObject.toString();
|
|
445
|
+
}
|
|
446
|
+
getSearchParams(url) {
|
|
447
|
+
if (!url) {
|
|
448
|
+
return {};
|
|
449
|
+
}
|
|
450
|
+
const urlObject = new URL(url);
|
|
451
|
+
const searchParams = {};
|
|
452
|
+
for (const [key, value] of urlObject.searchParams) {
|
|
453
|
+
searchParams[key] = value;
|
|
454
|
+
}
|
|
455
|
+
return searchParams;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
UrlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
459
|
+
UrlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, providedIn: 'root' });
|
|
460
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, decorators: [{
|
|
461
|
+
type: Injectable,
|
|
462
|
+
args: [{
|
|
463
|
+
providedIn: 'root',
|
|
464
|
+
}]
|
|
465
|
+
}] });
|
|
466
|
+
|
|
467
|
+
class PaymentConfigService {
|
|
468
|
+
constructor(urlService, settingsService) {
|
|
469
|
+
this.urlService = urlService;
|
|
470
|
+
this.settingsService = settingsService;
|
|
471
|
+
}
|
|
472
|
+
enrich(config) {
|
|
473
|
+
if (!config.returnUrl) {
|
|
474
|
+
throw new Error('URL is not provided in payment config');
|
|
475
|
+
}
|
|
476
|
+
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl) });
|
|
477
|
+
}
|
|
478
|
+
enrichReturnUrl(returnUrl) {
|
|
479
|
+
return this.urlService.addSearchParams(returnUrl, {
|
|
480
|
+
token: this.settingsService.token,
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
PaymentConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, deps: [{ token: UrlService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
485
|
+
PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, providedIn: 'root' });
|
|
486
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
487
|
+
type: Injectable,
|
|
488
|
+
args: [{
|
|
489
|
+
providedIn: 'root',
|
|
490
|
+
}]
|
|
491
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
492
|
+
|
|
435
493
|
var XpsCommand;
|
|
436
494
|
(function (XpsCommand) {
|
|
437
495
|
XpsCommand["form"] = "form";
|
|
@@ -540,6 +598,15 @@ const isSubmitResponse = (value) => {
|
|
|
540
598
|
return value instanceof SubmitResponse;
|
|
541
599
|
};
|
|
542
600
|
|
|
601
|
+
class ShowErrorsAction {
|
|
602
|
+
constructor(errors) {
|
|
603
|
+
this.type = 'show_errors';
|
|
604
|
+
this.data = {
|
|
605
|
+
errors,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
543
610
|
class InitializeResponse {
|
|
544
611
|
constructor(response) {
|
|
545
612
|
this.paymentForm = null;
|
|
@@ -590,12 +657,204 @@ const initializeResponseFactoryProvider = {
|
|
|
590
657
|
useValue: (...args) => new InitializeResponse(...args),
|
|
591
658
|
};
|
|
592
659
|
|
|
660
|
+
class ShowFieldsAction {
|
|
661
|
+
constructor(submitResponse) {
|
|
662
|
+
this.type = 'show_fields';
|
|
663
|
+
this.data = {
|
|
664
|
+
fields: [],
|
|
665
|
+
errors: [],
|
|
666
|
+
messages: [],
|
|
667
|
+
order: {},
|
|
668
|
+
};
|
|
669
|
+
this.data.fields = submitResponse.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
|
|
670
|
+
this.data.errors = submitResponse.errors;
|
|
671
|
+
this.data.messages = submitResponse.messages;
|
|
672
|
+
this.data.order = submitResponse.summary;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const showFieldsActionFactoryToken = new InjectionToken('ShowFieldsAction');
|
|
677
|
+
const showFieldsActionFactoryProvider = {
|
|
678
|
+
provide: showFieldsActionFactoryToken,
|
|
679
|
+
useValue: {
|
|
680
|
+
factory: (...args) => new ShowFieldsAction(...args),
|
|
681
|
+
isSuitable: (response) => {
|
|
682
|
+
return response.currentCommand === XpsCommand.check;
|
|
683
|
+
},
|
|
684
|
+
},
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
class CheckStatusAction {
|
|
688
|
+
constructor(submitResponse) {
|
|
689
|
+
var _a, _b, _c, _d, _e, _f;
|
|
690
|
+
this.type = 'check_status';
|
|
691
|
+
const status = submitResponse.parameters.status;
|
|
692
|
+
this.data = {
|
|
693
|
+
invoice: status === null || status === void 0 ? void 0 : status.invoice,
|
|
694
|
+
signature: (_a = submitResponse.parameters.form.signature) === null || _a === void 0 ? void 0 : _a.value,
|
|
695
|
+
locale: (_b = submitResponse.parameters.form.locale) === null || _b === void 0 ? void 0 : _b.value,
|
|
696
|
+
testPs: (_c = submitResponse.parameters.form.testPs) === null || _c === void 0 ? void 0 : _c.value,
|
|
697
|
+
testXsolla: (_d = submitResponse.parameters.form.testXsolla) === null || _d === void 0 ? void 0 : _d.value,
|
|
698
|
+
testProject: (_e = submitResponse.parameters.form.testProject) === null || _e === void 0 ? void 0 : _e.value,
|
|
699
|
+
userReturnStatus: (_f = submitResponse.parameters.form.userReturnStatus) === null || _f === void 0 ? void 0 : _f.value,
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const checkStatusActionFactoryToken = new InjectionToken('CheckStatusAction');
|
|
705
|
+
const checkStatusActionFactoryProvider = {
|
|
706
|
+
provide: checkStatusActionFactoryToken,
|
|
707
|
+
useValue: {
|
|
708
|
+
factory: (...args) => new CheckStatusAction(...args),
|
|
709
|
+
isSuitable: (response) => {
|
|
710
|
+
return response.currentCommand === XpsCommand.status;
|
|
711
|
+
},
|
|
712
|
+
},
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
class StatusUpdatedAction {
|
|
716
|
+
constructor(statusResponse) {
|
|
717
|
+
this.type = 'status_updated';
|
|
718
|
+
this.data = {
|
|
719
|
+
statusState: statusResponse.status.statusState,
|
|
720
|
+
invoice: statusResponse.status.invoice,
|
|
721
|
+
isSuccess: statusResponse.status.isSuccess,
|
|
722
|
+
isCanceled: statusResponse.status.isCanceled,
|
|
723
|
+
group: statusResponse.status.group,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
const statusUpdatedActionFactoryToken = new InjectionToken('StatusUpdatedAction');
|
|
729
|
+
const statusUpdatedActionFactoryProvider = {
|
|
730
|
+
provide: statusUpdatedActionFactoryToken,
|
|
731
|
+
useValue: {
|
|
732
|
+
factory: (...args) => new StatusUpdatedAction(...args),
|
|
733
|
+
isSuitable: () => false,
|
|
734
|
+
},
|
|
735
|
+
};
|
|
736
|
+
|
|
737
|
+
class RedirectAction {
|
|
738
|
+
constructor(submitResponse) {
|
|
739
|
+
this.type = 'redirect';
|
|
740
|
+
this.data = {
|
|
741
|
+
fields: submitResponse.fields,
|
|
742
|
+
errors: submitResponse.errors,
|
|
743
|
+
messages: submitResponse.messages,
|
|
744
|
+
order: submitResponse.summary,
|
|
745
|
+
invoiceId: submitResponse.fixInvoice,
|
|
746
|
+
redirect: this.getRedirect(submitResponse),
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
getRedirect(submitResponse) {
|
|
750
|
+
return {
|
|
751
|
+
redirectUrl: submitResponse.parameters.checkout.action,
|
|
752
|
+
data: submitResponse.parameters.checkout.data,
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
const redirectActionFactoryToken = new InjectionToken('RedirectAction');
|
|
758
|
+
const redirectActionFactoryProvider = {
|
|
759
|
+
provide: redirectActionFactoryToken,
|
|
760
|
+
useValue: {
|
|
761
|
+
factory: (...args) => new RedirectAction(...args),
|
|
762
|
+
isSuitable: (response) => {
|
|
763
|
+
return (response.currentCommand === XpsCommand.account ||
|
|
764
|
+
(response.currentCommand === XpsCommand.checkout &&
|
|
765
|
+
Boolean(response.parameters.checkout)));
|
|
766
|
+
},
|
|
767
|
+
},
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
const showErrorsActionFactoryToken = new InjectionToken('ShowErrorsAction');
|
|
771
|
+
const showErrorsActionFactoryProvider = {
|
|
772
|
+
provide: showErrorsActionFactoryToken,
|
|
773
|
+
useValue: {
|
|
774
|
+
factory: (...args) => new ShowErrorsAction(...args),
|
|
775
|
+
isSuitable: (response) => {
|
|
776
|
+
var _a;
|
|
777
|
+
return Boolean((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length);
|
|
778
|
+
},
|
|
779
|
+
},
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const nextActionsToken = new InjectionToken('Action');
|
|
783
|
+
const nextActions = [
|
|
784
|
+
showFieldsActionFactoryProvider,
|
|
785
|
+
checkStatusActionFactoryProvider,
|
|
786
|
+
redirectActionFactoryProvider,
|
|
787
|
+
];
|
|
788
|
+
const flowUpdateNextActions = [
|
|
789
|
+
statusUpdatedActionFactoryProvider,
|
|
790
|
+
showErrorsActionFactoryProvider,
|
|
791
|
+
];
|
|
792
|
+
|
|
793
|
+
class NextActionService {
|
|
794
|
+
get flowUpdates$() {
|
|
795
|
+
return this.flowUpdatesSubject.asObservable();
|
|
796
|
+
}
|
|
797
|
+
constructor(nextActionTokens, injector) {
|
|
798
|
+
this.nextActionTokens = nextActionTokens;
|
|
799
|
+
this.injector = injector;
|
|
800
|
+
this.flowUpdatesSubject = new Subject();
|
|
801
|
+
this.nextActionsList = [];
|
|
802
|
+
this.fillNextActionsList();
|
|
803
|
+
}
|
|
804
|
+
getNextAction(submitResponse) {
|
|
805
|
+
var _a;
|
|
806
|
+
if ((_a = submitResponse.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
807
|
+
this.emitFlowUpdates(new ShowErrorsAction(submitResponse.errors));
|
|
808
|
+
}
|
|
809
|
+
if (!submitResponse.currentCommand) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
const nextActionFactory = this.findNextAction(submitResponse);
|
|
813
|
+
if (nextActionFactory) {
|
|
814
|
+
return nextActionFactory(submitResponse);
|
|
815
|
+
}
|
|
816
|
+
throw new Error('Next action is undefined.');
|
|
817
|
+
}
|
|
818
|
+
emitFlowUpdates(action) {
|
|
819
|
+
this.flowUpdatesSubject.next(action);
|
|
820
|
+
}
|
|
821
|
+
fillNextActionsList() {
|
|
822
|
+
this.nextActionTokens.forEach((nextAction) => {
|
|
823
|
+
const item = this.injector.get(nextAction.provide);
|
|
824
|
+
this.nextActionsList.push(item);
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
findNextAction(submitResponse) {
|
|
828
|
+
const actionType = this.nextActionsList.find((nextAction) => {
|
|
829
|
+
return nextAction.isSuitable(submitResponse);
|
|
830
|
+
});
|
|
831
|
+
if (!actionType) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
return actionType.factory;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
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 });
|
|
838
|
+
NextActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, providedIn: 'root' });
|
|
839
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, decorators: [{
|
|
840
|
+
type: Injectable,
|
|
841
|
+
args: [{
|
|
842
|
+
providedIn: 'root',
|
|
843
|
+
}]
|
|
844
|
+
}], ctorParameters: function () {
|
|
845
|
+
return [{ type: undefined, decorators: [{
|
|
846
|
+
type: Inject,
|
|
847
|
+
args: [nextActionsToken]
|
|
848
|
+
}] }, { type: i0.Injector }];
|
|
849
|
+
} });
|
|
850
|
+
|
|
593
851
|
class InitializeService {
|
|
594
|
-
constructor(responseFactory, secureApi, settingsService, countryService) {
|
|
852
|
+
constructor(responseFactory, secureApi, settingsService, countryService, nextActionService) {
|
|
595
853
|
this.responseFactory = responseFactory;
|
|
596
854
|
this.secureApi = secureApi;
|
|
597
855
|
this.settingsService = settingsService;
|
|
598
856
|
this.countryService = countryService;
|
|
857
|
+
this.nextActionService = nextActionService;
|
|
599
858
|
this.apiRoute = 'directpayment';
|
|
600
859
|
// TODO PAYMENTS-15743: replace with new refer id for headless core
|
|
601
860
|
this.ps4ReferId = '22';
|
|
@@ -614,13 +873,18 @@ class InitializeService {
|
|
|
614
873
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
615
874
|
responseType: 'json',
|
|
616
875
|
})
|
|
617
|
-
.pipe(map((response) => this.responseFactory(response))
|
|
876
|
+
.pipe(map((response) => this.responseFactory(response)), tap((response) => {
|
|
877
|
+
var _a, _b;
|
|
878
|
+
if ((_b = (_a = response.paymentForm) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
879
|
+
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.paymentForm.errors));
|
|
880
|
+
}
|
|
881
|
+
}))).catch((error) => {
|
|
618
882
|
throw new ResponseError(error.message);
|
|
619
883
|
});
|
|
620
884
|
});
|
|
621
885
|
}
|
|
622
886
|
}
|
|
623
|
-
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
887
|
+
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
624
888
|
InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
|
|
625
889
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
626
890
|
type: Injectable,
|
|
@@ -631,7 +895,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
631
895
|
return [{ type: undefined, decorators: [{
|
|
632
896
|
type: Inject,
|
|
633
897
|
args: [initializeResponseFactoryToken]
|
|
634
|
-
}] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }];
|
|
898
|
+
}] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }];
|
|
635
899
|
} });
|
|
636
900
|
|
|
637
901
|
class XpsApiPartRequest {
|
|
@@ -998,11 +1262,12 @@ const syncResponseFactoryProvider = {
|
|
|
998
1262
|
};
|
|
999
1263
|
|
|
1000
1264
|
class SyncService extends EmitDataService {
|
|
1001
|
-
constructor(requestFactory, responseFactory, secureApi, settingsService) {
|
|
1265
|
+
constructor(requestFactory, responseFactory, secureApi, nextActionService, settingsService) {
|
|
1002
1266
|
super();
|
|
1003
1267
|
this.requestFactory = requestFactory;
|
|
1004
1268
|
this.responseFactory = responseFactory;
|
|
1005
1269
|
this.secureApi = secureApi;
|
|
1270
|
+
this.nextActionService = nextActionService;
|
|
1006
1271
|
this.settingsService = settingsService;
|
|
1007
1272
|
this.apiRoute = 'directpayment';
|
|
1008
1273
|
this.prevFieldSyncStates = {};
|
|
@@ -1068,6 +1333,10 @@ class SyncService extends EmitDataService {
|
|
|
1068
1333
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1069
1334
|
responseType: 'json',
|
|
1070
1335
|
})).then((response) => {
|
|
1336
|
+
var _a;
|
|
1337
|
+
if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1338
|
+
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.errors));
|
|
1339
|
+
}
|
|
1071
1340
|
this.emit(response);
|
|
1072
1341
|
return this.responseFactory(field, response);
|
|
1073
1342
|
});
|
|
@@ -1086,7 +1355,7 @@ class SyncService extends EmitDataService {
|
|
|
1086
1355
|
this.prevFieldSyncStates[field.name] = { value, result };
|
|
1087
1356
|
}
|
|
1088
1357
|
}
|
|
1089
|
-
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1358
|
+
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: SecureApiClient }, { token: NextActionService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1090
1359
|
SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
|
|
1091
1360
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, decorators: [{
|
|
1092
1361
|
type: Injectable,
|
|
@@ -1100,7 +1369,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1100
1369
|
}] }, { type: undefined, decorators: [{
|
|
1101
1370
|
type: Inject,
|
|
1102
1371
|
args: [syncResponseFactoryToken]
|
|
1103
|
-
}] }, { type: SecureApiClient }, { type: SettingsService }];
|
|
1372
|
+
}] }, { type: SecureApiClient }, { type: NextActionService }, { type: SettingsService }];
|
|
1104
1373
|
} });
|
|
1105
1374
|
|
|
1106
1375
|
class ControlConfig {
|
|
@@ -1386,18 +1655,97 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1386
1655
|
type: Injectable
|
|
1387
1656
|
}], ctorParameters: function () { return [{ type: ControlConfigService }]; } });
|
|
1388
1657
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1658
|
+
var StatusSearchParam;
|
|
1659
|
+
(function (StatusSearchParam) {
|
|
1660
|
+
StatusSearchParam["token"] = "token";
|
|
1661
|
+
StatusSearchParam["pid"] = "fix_pid";
|
|
1662
|
+
StatusSearchParam["invoice"] = "fix_invoice";
|
|
1663
|
+
StatusSearchParam["signature"] = "signature";
|
|
1664
|
+
StatusSearchParam["locale"] = "locale";
|
|
1665
|
+
StatusSearchParam["testProject"] = "fix_testProject";
|
|
1666
|
+
StatusSearchParam["testPs"] = "fix_testPs";
|
|
1667
|
+
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
1668
|
+
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
1669
|
+
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
1670
|
+
|
|
1671
|
+
const requiredStatusSearchParams = [
|
|
1672
|
+
StatusSearchParam.token,
|
|
1673
|
+
StatusSearchParam.locale,
|
|
1674
|
+
StatusSearchParam.signature,
|
|
1675
|
+
StatusSearchParam.pid,
|
|
1676
|
+
StatusSearchParam.invoice,
|
|
1677
|
+
];
|
|
1678
|
+
|
|
1679
|
+
const stringConverter = (value) => value;
|
|
1680
|
+
const numberConverter = (value) => {
|
|
1681
|
+
const numberValue = Number(value);
|
|
1682
|
+
return isNaN(numberValue) ? 0 : numberValue;
|
|
1683
|
+
};
|
|
1684
|
+
const statusSearchParamsMap = new Map([
|
|
1685
|
+
[
|
|
1686
|
+
StatusSearchParam.token,
|
|
1687
|
+
{
|
|
1688
|
+
key: 'token',
|
|
1689
|
+
converter: stringConverter,
|
|
1690
|
+
},
|
|
1691
|
+
],
|
|
1692
|
+
[
|
|
1693
|
+
StatusSearchParam.signature,
|
|
1694
|
+
{
|
|
1695
|
+
key: 'signature',
|
|
1696
|
+
converter: stringConverter,
|
|
1697
|
+
},
|
|
1698
|
+
],
|
|
1699
|
+
[
|
|
1700
|
+
StatusSearchParam.locale,
|
|
1701
|
+
{
|
|
1702
|
+
key: 'locale',
|
|
1703
|
+
converter: stringConverter,
|
|
1704
|
+
},
|
|
1705
|
+
],
|
|
1706
|
+
[
|
|
1707
|
+
StatusSearchParam.userReturnStatus,
|
|
1708
|
+
{
|
|
1709
|
+
key: 'userReturnStatus',
|
|
1710
|
+
converter: stringConverter,
|
|
1711
|
+
},
|
|
1712
|
+
],
|
|
1713
|
+
[
|
|
1714
|
+
StatusSearchParam.pid,
|
|
1715
|
+
{
|
|
1716
|
+
key: 'pid',
|
|
1717
|
+
converter: numberConverter,
|
|
1718
|
+
},
|
|
1719
|
+
],
|
|
1720
|
+
[
|
|
1721
|
+
StatusSearchParam.invoice,
|
|
1722
|
+
{
|
|
1723
|
+
key: 'invoice',
|
|
1724
|
+
converter: numberConverter,
|
|
1725
|
+
},
|
|
1726
|
+
],
|
|
1727
|
+
[
|
|
1728
|
+
StatusSearchParam.testProject,
|
|
1729
|
+
{
|
|
1730
|
+
key: 'testProject',
|
|
1731
|
+
converter: numberConverter,
|
|
1732
|
+
},
|
|
1733
|
+
],
|
|
1734
|
+
[
|
|
1735
|
+
StatusSearchParam.testPs,
|
|
1736
|
+
{
|
|
1737
|
+
key: 'testPs',
|
|
1738
|
+
converter: numberConverter,
|
|
1739
|
+
},
|
|
1740
|
+
],
|
|
1741
|
+
[
|
|
1742
|
+
StatusSearchParam.testXsolla,
|
|
1743
|
+
{
|
|
1744
|
+
key: 'testXsolla',
|
|
1745
|
+
converter: numberConverter,
|
|
1746
|
+
},
|
|
1747
|
+
],
|
|
1748
|
+
]);
|
|
1401
1749
|
|
|
1402
1750
|
class XpsApiPart {
|
|
1403
1751
|
constructor() {
|
|
@@ -1421,7 +1769,7 @@ class StatusRequest extends XpsApiPartRequest {
|
|
|
1421
1769
|
constructor(parameters) {
|
|
1422
1770
|
super();
|
|
1423
1771
|
this.xps_fix_command = 'status';
|
|
1424
|
-
if (parameters.token
|
|
1772
|
+
if (!parameters.token) {
|
|
1425
1773
|
throw new TokenError();
|
|
1426
1774
|
}
|
|
1427
1775
|
this.access_token = parameters.token;
|
|
@@ -2396,167 +2744,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2396
2744
|
}]
|
|
2397
2745
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
2398
2746
|
|
|
2399
|
-
class ShowFieldsAction {
|
|
2400
|
-
constructor(submitResponse) {
|
|
2401
|
-
this.type = 'show_fields';
|
|
2402
|
-
this.data = {
|
|
2403
|
-
fields: [],
|
|
2404
|
-
errors: [],
|
|
2405
|
-
messages: [],
|
|
2406
|
-
order: {},
|
|
2407
|
-
};
|
|
2408
|
-
this.data.fields = submitResponse.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
|
|
2409
|
-
this.data.errors = submitResponse.errors;
|
|
2410
|
-
this.data.messages = submitResponse.messages;
|
|
2411
|
-
this.data.order = submitResponse.summary;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
const showFieldsActionFactoryToken = new InjectionToken('ShowFieldsAction');
|
|
2416
|
-
const showFieldsActionFactoryProvider = {
|
|
2417
|
-
provide: showFieldsActionFactoryToken,
|
|
2418
|
-
useValue: {
|
|
2419
|
-
factory: (...args) => new ShowFieldsAction(...args),
|
|
2420
|
-
isSuitable: (response) => {
|
|
2421
|
-
return response.currentCommand === XpsCommand.check;
|
|
2422
|
-
},
|
|
2423
|
-
},
|
|
2424
|
-
};
|
|
2425
|
-
|
|
2426
|
-
class CheckStatusAction {
|
|
2427
|
-
constructor(submitResponse) {
|
|
2428
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2429
|
-
this.type = 'check_status';
|
|
2430
|
-
const status = submitResponse.parameters.status;
|
|
2431
|
-
this.data = {
|
|
2432
|
-
invoice: status === null || status === void 0 ? void 0 : status.invoice,
|
|
2433
|
-
signature: (_a = submitResponse.parameters.form.signature) === null || _a === void 0 ? void 0 : _a.value,
|
|
2434
|
-
locale: (_b = submitResponse.parameters.form.locale) === null || _b === void 0 ? void 0 : _b.value,
|
|
2435
|
-
testPs: (_c = submitResponse.parameters.form.testPs) === null || _c === void 0 ? void 0 : _c.value,
|
|
2436
|
-
testXsolla: (_d = submitResponse.parameters.form.testXsolla) === null || _d === void 0 ? void 0 : _d.value,
|
|
2437
|
-
testProject: (_e = submitResponse.parameters.form.testProject) === null || _e === void 0 ? void 0 : _e.value,
|
|
2438
|
-
userReturnStatus: (_f = submitResponse.parameters.form.userReturnStatus) === null || _f === void 0 ? void 0 : _f.value,
|
|
2439
|
-
};
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
const checkStatusActionFactoryToken = new InjectionToken('CheckStatusAction');
|
|
2444
|
-
const checkStatusActionFactoryProvider = {
|
|
2445
|
-
provide: checkStatusActionFactoryToken,
|
|
2446
|
-
useValue: {
|
|
2447
|
-
factory: (...args) => new CheckStatusAction(...args),
|
|
2448
|
-
isSuitable: (response) => {
|
|
2449
|
-
return response.currentCommand === XpsCommand.status;
|
|
2450
|
-
},
|
|
2451
|
-
},
|
|
2452
|
-
};
|
|
2453
|
-
|
|
2454
|
-
const statusUpdatedActionFactoryToken = new InjectionToken('StatusUpdatedAction');
|
|
2455
|
-
const statusUpdatedActionFactoryProvider = {
|
|
2456
|
-
provide: statusUpdatedActionFactoryToken,
|
|
2457
|
-
useValue: {
|
|
2458
|
-
factory: (...args) => new StatusUpdatedAction(...args),
|
|
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
|
-
},
|
|
2493
|
-
},
|
|
2494
|
-
};
|
|
2495
|
-
|
|
2496
|
-
const nextActionsToken = new InjectionToken('Action');
|
|
2497
|
-
const nextActions = [
|
|
2498
|
-
showFieldsActionFactoryProvider,
|
|
2499
|
-
checkStatusActionFactoryProvider,
|
|
2500
|
-
statusUpdatedActionFactoryProvider,
|
|
2501
|
-
redirectActionFactoryProvider,
|
|
2502
|
-
];
|
|
2503
|
-
|
|
2504
|
-
class NextActionService {
|
|
2505
|
-
get flowUpdates$() {
|
|
2506
|
-
return this.flowUpdatesSubject.asObservable();
|
|
2507
|
-
}
|
|
2508
|
-
constructor(nextActionTokens, injector) {
|
|
2509
|
-
this.nextActionTokens = nextActionTokens;
|
|
2510
|
-
this.injector = injector;
|
|
2511
|
-
this.flowUpdatesSubject = new Subject();
|
|
2512
|
-
this.nextActionsList = [];
|
|
2513
|
-
this.fillNextActionsList();
|
|
2514
|
-
}
|
|
2515
|
-
getNextAction(submitResponse) {
|
|
2516
|
-
if (!submitResponse.currentCommand) {
|
|
2517
|
-
return null;
|
|
2518
|
-
}
|
|
2519
|
-
const nextActionFactory = this.findNextAction(submitResponse);
|
|
2520
|
-
if (nextActionFactory) {
|
|
2521
|
-
return nextActionFactory(submitResponse);
|
|
2522
|
-
}
|
|
2523
|
-
throw new Error('Next action is undefined.');
|
|
2524
|
-
}
|
|
2525
|
-
emitFlowUpdates(action) {
|
|
2526
|
-
this.flowUpdatesSubject.next(action);
|
|
2527
|
-
}
|
|
2528
|
-
fillNextActionsList() {
|
|
2529
|
-
this.nextActionTokens.forEach((nextAction) => {
|
|
2530
|
-
const item = this.injector.get(nextAction.provide);
|
|
2531
|
-
this.nextActionsList.push(item);
|
|
2532
|
-
});
|
|
2533
|
-
}
|
|
2534
|
-
findNextAction(submitResponse) {
|
|
2535
|
-
const actionType = this.nextActionsList.find((nextAction) => {
|
|
2536
|
-
return nextAction.isSuitable(submitResponse);
|
|
2537
|
-
});
|
|
2538
|
-
if (!actionType) {
|
|
2539
|
-
return;
|
|
2540
|
-
}
|
|
2541
|
-
return actionType.factory;
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
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 });
|
|
2545
|
-
NextActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, providedIn: 'root' });
|
|
2546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, decorators: [{
|
|
2547
|
-
type: Injectable,
|
|
2548
|
-
args: [{
|
|
2549
|
-
providedIn: 'root',
|
|
2550
|
-
}]
|
|
2551
|
-
}], ctorParameters: function () {
|
|
2552
|
-
return [{ type: undefined, decorators: [{
|
|
2553
|
-
type: Inject,
|
|
2554
|
-
args: [nextActionsToken]
|
|
2555
|
-
}] }, { type: i0.Injector }];
|
|
2556
|
-
} });
|
|
2557
|
-
|
|
2558
2747
|
class StatusService {
|
|
2559
|
-
constructor(statusRequestService, listenStatusService, nextActionService) {
|
|
2748
|
+
constructor(urlService, statusRequestService, listenStatusService, nextActionService) {
|
|
2749
|
+
this.urlService = urlService;
|
|
2560
2750
|
this.statusRequestService = statusRequestService;
|
|
2561
2751
|
this.listenStatusService = listenStatusService;
|
|
2562
2752
|
this.nextActionService = nextActionService;
|
|
@@ -2570,6 +2760,27 @@ class StatusService {
|
|
|
2570
2760
|
return statusResponse.status;
|
|
2571
2761
|
});
|
|
2572
2762
|
}
|
|
2763
|
+
getStatusWithUrlSearchParams(url) {
|
|
2764
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2765
|
+
const searchParams = this.getRequestParamsFromUrl(url);
|
|
2766
|
+
if (!searchParams) {
|
|
2767
|
+
throw new Error('No required search params to get status');
|
|
2768
|
+
}
|
|
2769
|
+
return this.getStatus(searchParams);
|
|
2770
|
+
});
|
|
2771
|
+
}
|
|
2772
|
+
getRequestParamsFromUrl(url) {
|
|
2773
|
+
const searchParams = this.urlService.getSearchParams(url !== null && url !== void 0 ? url : '');
|
|
2774
|
+
const keys = new Set(Object.keys(searchParams));
|
|
2775
|
+
if (requiredStatusSearchParams.some((requiredKey) => !keys.has(requiredKey))) {
|
|
2776
|
+
return null;
|
|
2777
|
+
}
|
|
2778
|
+
const params = {};
|
|
2779
|
+
statusSearchParamsMap.forEach((settings, key) => {
|
|
2780
|
+
params[settings.key] = settings.converter(searchParams[key]);
|
|
2781
|
+
});
|
|
2782
|
+
return params;
|
|
2783
|
+
}
|
|
2573
2784
|
startWaitingStatusUpdates(invoice) {
|
|
2574
2785
|
this.listenStatusService.listen(invoice);
|
|
2575
2786
|
this.listenStatusService.statusUpdated$
|
|
@@ -2579,14 +2790,14 @@ class StatusService {
|
|
|
2579
2790
|
});
|
|
2580
2791
|
}
|
|
2581
2792
|
}
|
|
2582
|
-
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2793
|
+
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2583
2794
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
2584
2795
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
2585
2796
|
type: Injectable,
|
|
2586
2797
|
args: [{
|
|
2587
2798
|
providedIn: 'root',
|
|
2588
2799
|
}]
|
|
2589
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2800
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2590
2801
|
|
|
2591
2802
|
/**
|
|
2592
2803
|
* default image for purchase item is set on Publisher Account side.
|
|
@@ -2911,6 +3122,7 @@ class PaymentService {
|
|
|
2911
3122
|
this.data = yield this.initializeService.request(config);
|
|
2912
3123
|
this.fields = this.getFields();
|
|
2913
3124
|
this.form = this.formService.createForm(this.fields);
|
|
3125
|
+
this.listenSyncValidationErrors(this.form);
|
|
2914
3126
|
this.emitFinanceDetails((_a = this.data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary);
|
|
2915
3127
|
this.setupSyncService(this.form, this.fields);
|
|
2916
3128
|
return this.fields.filter((field) => (field === null || field === void 0 ? void 0 : field.isVisible) === "1" /* XpsBoolean.true */);
|
|
@@ -2956,11 +3168,12 @@ class PaymentService {
|
|
|
2956
3168
|
throw new Error('Should submit form first');
|
|
2957
3169
|
}
|
|
2958
3170
|
const params = {
|
|
3171
|
+
pid: this.config.paymentMethodId,
|
|
2959
3172
|
invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
|
|
2960
3173
|
signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
|
|
2961
3174
|
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',
|
|
2962
3175
|
};
|
|
2963
|
-
return this.statusService.getStatus(
|
|
3176
|
+
return this.statusService.getStatus(params);
|
|
2964
3177
|
});
|
|
2965
3178
|
}
|
|
2966
3179
|
getFieldConfig(field) {
|
|
@@ -2992,6 +3205,33 @@ class PaymentService {
|
|
|
2992
3205
|
.pipe(takeUntil(this.destroy$))
|
|
2993
3206
|
.subscribe((financeDetails) => (this.financeDetails = financeDetails));
|
|
2994
3207
|
}
|
|
3208
|
+
listenSyncValidationErrors(form) {
|
|
3209
|
+
form.statusChanges.subscribe(() => {
|
|
3210
|
+
var _a;
|
|
3211
|
+
const controls = (_a = this.form) === null || _a === void 0 ? void 0 : _a.controls;
|
|
3212
|
+
if (controls) {
|
|
3213
|
+
const invalidControls = Object.entries(controls).filter(([key]) => controls[key].invalid);
|
|
3214
|
+
if (invalidControls.length) {
|
|
3215
|
+
const syncValidationErrors = invalidControls
|
|
3216
|
+
.map(([controlName, control]) => {
|
|
3217
|
+
var _a, _b;
|
|
3218
|
+
const error = (_a = control.errors) === null || _a === void 0 ? void 0 : _a['rewritableError'];
|
|
3219
|
+
if (!error) {
|
|
3220
|
+
return null;
|
|
3221
|
+
}
|
|
3222
|
+
return {
|
|
3223
|
+
code: 101,
|
|
3224
|
+
fieldValidationError: error === null || error === void 0 ? void 0 : error.code,
|
|
3225
|
+
message: (_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : '',
|
|
3226
|
+
element_name: controlName,
|
|
3227
|
+
};
|
|
3228
|
+
})
|
|
3229
|
+
.filter(Boolean);
|
|
3230
|
+
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(syncValidationErrors));
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
});
|
|
3234
|
+
}
|
|
2995
3235
|
}
|
|
2996
3236
|
PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2997
3237
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
@@ -3108,16 +3348,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3108
3348
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
3109
3349
|
|
|
3110
3350
|
class CoreLibraryService {
|
|
3111
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
|
|
3351
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService) {
|
|
3112
3352
|
this.settingsService = settingsService;
|
|
3113
3353
|
this.countryService = countryService;
|
|
3114
3354
|
this.paymentMethodsService = paymentMethodsService;
|
|
3115
3355
|
this.savedMethodsService = savedMethodsService;
|
|
3116
3356
|
this.userBalanceService = userBalanceService;
|
|
3357
|
+
this.paymentConfigService = paymentConfigService;
|
|
3117
3358
|
this.paymentService = paymentService;
|
|
3118
3359
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
3119
3360
|
this.financeDetailsService = financeDetailsService;
|
|
3120
3361
|
this.legalService = legalService;
|
|
3362
|
+
this.statusService = statusService;
|
|
3121
3363
|
this.nextActionService = nextActionService;
|
|
3122
3364
|
this.paymentMethods = {
|
|
3123
3365
|
getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
|
|
@@ -3132,12 +3374,18 @@ class CoreLibraryService {
|
|
|
3132
3374
|
yield this.deviceFingerPrintService.init();
|
|
3133
3375
|
});
|
|
3134
3376
|
}
|
|
3377
|
+
getStatus(url) {
|
|
3378
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3379
|
+
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3135
3382
|
setCountry(country) {
|
|
3136
3383
|
this.countryService.setCountry(country);
|
|
3137
3384
|
}
|
|
3138
3385
|
createPayment(config) {
|
|
3386
|
+
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
3139
3387
|
return {
|
|
3140
|
-
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(
|
|
3388
|
+
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(enrichedConfig); }),
|
|
3141
3389
|
submit: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.submit(); }),
|
|
3142
3390
|
getFields: () => this.paymentService.getFields(),
|
|
3143
3391
|
validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
|
|
@@ -3160,14 +3408,14 @@ class CoreLibraryService {
|
|
|
3160
3408
|
return masksFunctionsMap[sanitizedName];
|
|
3161
3409
|
}
|
|
3162
3410
|
}
|
|
3163
|
-
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 });
|
|
3411
|
+
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: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3164
3412
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
3165
3413
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
3166
3414
|
type: Injectable,
|
|
3167
3415
|
args: [{
|
|
3168
3416
|
providedIn: 'root',
|
|
3169
3417
|
}]
|
|
3170
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
3418
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
3171
3419
|
|
|
3172
3420
|
class HttpError extends AppError {
|
|
3173
3421
|
constructor(error, req) {
|
|
@@ -3276,6 +3524,7 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
3276
3524
|
useValue: nextActions,
|
|
3277
3525
|
},
|
|
3278
3526
|
...nextActions,
|
|
3527
|
+
...flowUpdateNextActions,
|
|
3279
3528
|
], imports: [HttpClientModule, FormModule] });
|
|
3280
3529
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
|
|
3281
3530
|
type: NgModule,
|
|
@@ -3306,6 +3555,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3306
3555
|
useValue: nextActions,
|
|
3307
3556
|
},
|
|
3308
3557
|
...nextActions,
|
|
3558
|
+
...flowUpdateNextActions,
|
|
3309
3559
|
],
|
|
3310
3560
|
}]
|
|
3311
3561
|
}] });
|