@xsolla/payment-client-core 0.1.22 → 0.2.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/extended-window.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.class.mjs +19 -11
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.type.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-action.service.mjs +12 -13
- package/esm2020/lib/core/payment/actions/next-actions.mjs +15 -13
- package/esm2020/lib/core/payment/actions/redirect/redirect.action.class.mjs +37 -15
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.class.mjs +18 -5
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +26 -8
- package/esm2020/lib/core/payment/actions/special-button/special-button.action.class.mjs +41 -0
- package/esm2020/lib/core/payment/actions/special-button/special-button.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.class.mjs +26 -11
- package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.class.mjs +19 -4
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +7 -6
- package/esm2020/lib/core/payment/payment.service.mjs +20 -4
- package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +11 -6
- package/esm2020/lib/core/payment/status/status.service.mjs +7 -6
- package/esm2020/lib/core/payment/sync/sync.service.mjs +7 -6
- package/esm2020/lib/core/payment/three-ds/three-ds.service.mjs +10 -8
- package/esm2020/lib/core/payment/xps-checkout.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/google-pay/google-pay-checkout.interface.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/google-pay/google-pay-init-params.interface.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/google-pay/google-pay-library.interface.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +205 -0
- package/esm2020/lib/core/sdk-payment-systems/payment-systems/payment-system-processing.service.mjs +84 -0
- package/esm2020/lib/core/sdk-payment-systems/sdk-payment-methods.const.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/sdk-payment-systems.interface.mjs +2 -0
- package/esm2020/lib/core-library.module.mjs +1 -1
- package/esm2020/lib/core-library.service.mjs +25 -4
- package/fesm2015/xsolla-payment-client-core.mjs +569 -197
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +560 -194
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/extended-window.interface.d.ts +4 -1
- package/lib/core/payment/actions/action.interface.d.ts +7 -0
- package/lib/core/payment/actions/check-status/check-status.action.class.d.ts +8 -5
- package/lib/core/payment/actions/check-status/check-status.action.type.d.ts +1 -10
- package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/next-action.service.d.ts +3 -3
- package/lib/core/payment/actions/next-actions.d.ts +4 -4
- package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +12 -6
- package/lib/core/payment/actions/show-errors/show-errors.action.class.d.ts +9 -4
- package/lib/core/payment/actions/show-fields/show-fields.action.class.d.ts +8 -5
- package/lib/core/payment/actions/special-button/special-button.action.class.d.ts +14 -0
- package/lib/core/payment/actions/special-button/special-button.action.type.d.ts +10 -0
- package/lib/core/payment/actions/status-updated/status-updated.action.class.d.ts +12 -5
- package/lib/core/payment/actions/three-ds/three-ds.action.class.d.ts +8 -5
- package/lib/core/payment/initialize/initialize.service.d.ts +3 -1
- package/lib/core/payment/payment.service.d.ts +7 -1
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +3 -1
- package/lib/core/payment/status/status.service.d.ts +3 -1
- package/lib/core/payment/sync/sync.service.d.ts +3 -1
- package/lib/core/payment/three-ds/three-ds.service.d.ts +5 -1
- package/lib/core/payment/xps-checkout.d.ts +17 -0
- package/lib/core/sdk-payment-systems/google-pay/google-pay-checkout.interface.d.ts +17 -0
- package/lib/core/sdk-payment-systems/google-pay/google-pay-init-params.interface.d.ts +4 -0
- package/lib/core/sdk-payment-systems/google-pay/google-pay-library.interface.d.ts +83 -0
- package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +37 -0
- package/lib/core/sdk-payment-systems/payment-systems/payment-system-processing.service.d.ts +20 -0
- package/lib/core/sdk-payment-systems/sdk-payment-methods.const.d.ts +1 -0
- package/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.d.ts +6 -0
- package/lib/core/sdk-payment-systems/sdk-payment-systems.interface.d.ts +21 -0
- package/lib/core-library.service.d.ts +7 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.2.0.tgz +0 -0
- package/esm2020/lib/core/payment/actions/action-factory-value.interface.mjs +0 -2
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.token.mjs +0 -14
- package/esm2020/lib/core/payment/actions/redirect/redirect.action.token.mjs +0 -16
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.token.mjs +0 -13
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.token.mjs +0 -15
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.token.mjs +0 -11
- package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.token.mjs +0 -11
- package/lib/core/payment/actions/action-factory-value.interface.d.ts +0 -6
- package/lib/core/payment/actions/check-status/check-status.action.token.d.ts +0 -4
- package/lib/core/payment/actions/redirect/redirect.action.token.d.ts +0 -4
- package/lib/core/payment/actions/show-errors/show-errors.action.token.d.ts +0 -4
- package/lib/core/payment/actions/show-fields/show-fields.action.token.d.ts +0 -4
- package/lib/core/payment/actions/status-updated/status-updated.action.token.d.ts +0 -4
- package/lib/core/payment/actions/three-ds/three-ds.action.token.d.ts +0 -4
- package/xsolla-payment-client-core-0.1.22.tgz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Inject, Pipe, isDevMode, NgModule } from '@angular/core';
|
|
3
|
-
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
3
|
+
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, take, throwError } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
6
6
|
import JSEncrypt from 'jsencrypt';
|
|
@@ -648,15 +648,6 @@ var InputEventName;
|
|
|
648
648
|
InputEventName["focus"] = "focus";
|
|
649
649
|
})(InputEventName || (InputEventName = {}));
|
|
650
650
|
|
|
651
|
-
class ShowErrorsAction {
|
|
652
|
-
constructor(errors) {
|
|
653
|
-
this.type = 'show_errors';
|
|
654
|
-
this.data = {
|
|
655
|
-
errors,
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
|
|
660
651
|
const initializeResponseFactoryToken = new InjectionToken('InitializeResponse');
|
|
661
652
|
const initializeResponseFactoryProvider = {
|
|
662
653
|
provide: initializeResponseFactoryToken,
|
|
@@ -748,59 +739,148 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
748
739
|
args: [windowToken]
|
|
749
740
|
}] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }]; } });
|
|
750
741
|
|
|
751
|
-
|
|
752
|
-
|
|
742
|
+
const vkPay = 3496;
|
|
743
|
+
const googlePay = 3431;
|
|
744
|
+
const applePay = 3175;
|
|
745
|
+
const barzahlenPay = 1679;
|
|
746
|
+
const naverPay = 3563;
|
|
747
|
+
const venmoPay = 3636;
|
|
748
|
+
|
|
749
|
+
const pagesRoutes = new Map([
|
|
750
|
+
[vkPay, '/payment/external-pages/vk-pay'],
|
|
751
|
+
[applePay, '/payment/external-pages/apple-pay'],
|
|
752
|
+
[barzahlenPay, '/payment/external-pages/barzahlen-pay'],
|
|
753
|
+
[naverPay, '/payment/external-pages/naver-pay'],
|
|
754
|
+
[venmoPay, '/payment/external-pages/venmo-pay'],
|
|
755
|
+
]);
|
|
756
|
+
|
|
757
|
+
const payStation4Url = 'https://secure.xsolla.com/paystation4';
|
|
758
|
+
const sandboxPayStationUrl = 'https://sandbox-secure.xsolla.com/paystation4';
|
|
759
|
+
|
|
760
|
+
class RedirectActionCreator {
|
|
761
|
+
constructor(settingsService) {
|
|
762
|
+
this.settingsService = settingsService;
|
|
763
|
+
this.type = 'redirect';
|
|
764
|
+
}
|
|
765
|
+
getActionData(submitResponse) {
|
|
766
|
+
return {
|
|
767
|
+
type: this.type,
|
|
768
|
+
data: {
|
|
769
|
+
fields: submitResponse.fields,
|
|
770
|
+
errors: submitResponse.errors,
|
|
771
|
+
messages: submitResponse.messages,
|
|
772
|
+
order: submitResponse.summary,
|
|
773
|
+
invoiceId: submitResponse.fixInvoice,
|
|
774
|
+
redirect: this.getRedirect(submitResponse),
|
|
775
|
+
},
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
isSuitable(response) {
|
|
779
|
+
return (response.currentCommand === XpsCommand.account ||
|
|
780
|
+
(response.currentCommand === XpsCommand.checkout &&
|
|
781
|
+
Boolean(response.parameters.checkout)));
|
|
782
|
+
}
|
|
783
|
+
getRedirect(submitResponse) {
|
|
784
|
+
return {
|
|
785
|
+
redirectUrl: this.getRedirectUrl(submitResponse),
|
|
786
|
+
data: submitResponse.parameters.checkout.data,
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
getRedirectUrl(submitResponse) {
|
|
790
|
+
const responseRedirectUrl = submitResponse.parameters.checkout.action;
|
|
791
|
+
const pid = submitResponse?.fields?.find(({ name }) => name === 'fix_pid')?.value;
|
|
792
|
+
if (!pid) {
|
|
793
|
+
return responseRedirectUrl;
|
|
794
|
+
}
|
|
795
|
+
const pagesPath = pagesRoutes.get(Number(pid));
|
|
796
|
+
if (!pagesPath) {
|
|
797
|
+
return responseRedirectUrl;
|
|
798
|
+
}
|
|
799
|
+
return this.preparePagesUrl(pagesPath);
|
|
800
|
+
}
|
|
801
|
+
preparePagesUrl(pagesPath) {
|
|
802
|
+
const isSandbox = this.settingsService.isSandboxMode();
|
|
803
|
+
const token = this.settingsService.token;
|
|
804
|
+
const payStationUrl = isSandbox ? sandboxPayStationUrl : payStation4Url;
|
|
805
|
+
return `${payStationUrl}/en${pagesPath}?token=${token}`;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
RedirectActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RedirectActionCreator, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
809
|
+
RedirectActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RedirectActionCreator });
|
|
810
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: RedirectActionCreator, decorators: [{
|
|
811
|
+
type: Injectable
|
|
812
|
+
}], ctorParameters: function () { return [{ type: SettingsService }]; } });
|
|
813
|
+
|
|
814
|
+
class ShowFieldsActionCreator {
|
|
815
|
+
constructor() {
|
|
753
816
|
this.type = 'show_fields';
|
|
754
|
-
|
|
817
|
+
}
|
|
818
|
+
getActionData(submitResponse) {
|
|
819
|
+
const data = {
|
|
755
820
|
fields: [],
|
|
756
821
|
errors: [],
|
|
757
822
|
messages: [],
|
|
758
823
|
order: {},
|
|
759
824
|
};
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
825
|
+
data.fields = submitResponse.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
|
|
826
|
+
data.errors = submitResponse.errors;
|
|
827
|
+
data.messages = submitResponse.messages;
|
|
828
|
+
data.order = submitResponse.summary;
|
|
829
|
+
return {
|
|
830
|
+
type: this.type,
|
|
831
|
+
data,
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
isSuitable(response) {
|
|
835
|
+
return (response.currentCommand === XpsCommand.check ||
|
|
836
|
+
response.currentCommand === XpsCommand.form);
|
|
764
837
|
}
|
|
765
838
|
}
|
|
839
|
+
ShowFieldsActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowFieldsActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
840
|
+
ShowFieldsActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowFieldsActionCreator });
|
|
841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowFieldsActionCreator, decorators: [{
|
|
842
|
+
type: Injectable
|
|
843
|
+
}] });
|
|
766
844
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
provide: showFieldsActionFactoryToken,
|
|
770
|
-
useValue: {
|
|
771
|
-
factory: (...args) => new ShowFieldsAction(...args),
|
|
772
|
-
isSuitable: (response) => {
|
|
773
|
-
return (response.currentCommand === XpsCommand.check ||
|
|
774
|
-
response.currentCommand === XpsCommand.form);
|
|
775
|
-
},
|
|
776
|
-
},
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
class CheckStatusAction {
|
|
780
|
-
constructor(submitResponse) {
|
|
845
|
+
class CheckStatusActionCreator {
|
|
846
|
+
constructor() {
|
|
781
847
|
this.type = 'check_status';
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
testXsolla: submitResponse.parameters.form.testXsolla?.value,
|
|
788
|
-
testProject: submitResponse.parameters.form.testProject?.value,
|
|
789
|
-
userReturnStatus: submitResponse.parameters.form.userReturnStatus?.value,
|
|
848
|
+
}
|
|
849
|
+
getActionData() {
|
|
850
|
+
return {
|
|
851
|
+
type: this.type,
|
|
852
|
+
data: null,
|
|
790
853
|
};
|
|
791
854
|
}
|
|
855
|
+
isSuitable(response) {
|
|
856
|
+
return response.currentCommand === XpsCommand.status;
|
|
857
|
+
}
|
|
792
858
|
}
|
|
859
|
+
CheckStatusActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
860
|
+
CheckStatusActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusActionCreator });
|
|
861
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusActionCreator, decorators: [{
|
|
862
|
+
type: Injectable
|
|
863
|
+
}] });
|
|
793
864
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}
|
|
865
|
+
class ShowErrorsActionCreator {
|
|
866
|
+
constructor() {
|
|
867
|
+
this.type = 'show_errors';
|
|
868
|
+
}
|
|
869
|
+
getActionData(errors) {
|
|
870
|
+
return {
|
|
871
|
+
type: this.type,
|
|
872
|
+
data: { errors },
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
isSuitable(response) {
|
|
876
|
+
return Boolean(response.errors?.length);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
ShowErrorsActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowErrorsActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
880
|
+
ShowErrorsActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowErrorsActionCreator });
|
|
881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowErrorsActionCreator, decorators: [{
|
|
882
|
+
type: Injectable
|
|
883
|
+
}] });
|
|
804
884
|
|
|
805
885
|
class TerminalError extends AppError {
|
|
806
886
|
constructor(message, code) {
|
|
@@ -921,9 +1001,11 @@ class StatusResponse {
|
|
|
921
1001
|
}
|
|
922
1002
|
}
|
|
923
1003
|
|
|
924
|
-
class
|
|
925
|
-
constructor(
|
|
1004
|
+
class StatusUpdatedActionCreator {
|
|
1005
|
+
constructor() {
|
|
926
1006
|
this.type = 'status_updated';
|
|
1007
|
+
}
|
|
1008
|
+
getActionData({ statusResponse, isSavePaymentMethodMode, savePaymentMethodStatus, }) {
|
|
927
1009
|
let status;
|
|
928
1010
|
if (statusResponse instanceof StatusResponse) {
|
|
929
1011
|
status = statusResponse.status;
|
|
@@ -931,155 +1013,123 @@ class StatusUpdatedAction {
|
|
|
931
1013
|
else {
|
|
932
1014
|
status = statusResponse;
|
|
933
1015
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1016
|
+
return {
|
|
1017
|
+
type: this.type,
|
|
1018
|
+
data: {
|
|
1019
|
+
statusState: status.statusState,
|
|
1020
|
+
invoice: status.invoice,
|
|
1021
|
+
isSuccess: status.isSuccess,
|
|
1022
|
+
isCanceled: status.isCanceled,
|
|
1023
|
+
group: status.group,
|
|
1024
|
+
isSavePaymentMethodMode: Boolean(isSavePaymentMethodMode),
|
|
1025
|
+
savePaymentMethodStatus,
|
|
1026
|
+
},
|
|
942
1027
|
};
|
|
943
1028
|
}
|
|
1029
|
+
isSuitable() {
|
|
1030
|
+
return false;
|
|
1031
|
+
}
|
|
944
1032
|
}
|
|
1033
|
+
StatusUpdatedActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusUpdatedActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1034
|
+
StatusUpdatedActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusUpdatedActionCreator });
|
|
1035
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusUpdatedActionCreator, decorators: [{
|
|
1036
|
+
type: Injectable
|
|
1037
|
+
}] });
|
|
945
1038
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
useValue: {
|
|
950
|
-
factory: (...args) => new StatusUpdatedAction(...args),
|
|
951
|
-
isSuitable: () => false,
|
|
952
|
-
},
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
const vkPay = 3496;
|
|
956
|
-
const googlePay = 3431;
|
|
957
|
-
const applePay = 3175;
|
|
958
|
-
const barzahlenPay = 1679;
|
|
959
|
-
const naverPay = 3563;
|
|
960
|
-
const venmoPay = 3636;
|
|
961
|
-
|
|
962
|
-
const pagesRoutes = new Map([
|
|
963
|
-
[vkPay, '/payment/external-pages/vk-pay'],
|
|
964
|
-
[applePay, '/payment/external-pages/apple-pay'],
|
|
965
|
-
[barzahlenPay, '/payment/external-pages/barzahlen-pay'],
|
|
966
|
-
[naverPay, '/payment/external-pages/naver-pay'],
|
|
967
|
-
[venmoPay, '/payment/external-pages/venmo-pay'],
|
|
968
|
-
]);
|
|
969
|
-
|
|
970
|
-
const payStation4Url = 'https://secure.xsolla.com/paystation4';
|
|
971
|
-
const sandboxPayStationUrl = 'https://sandbox-secure.xsolla.com/paystation4';
|
|
972
|
-
|
|
973
|
-
class RedirectAction {
|
|
974
|
-
constructor(submitResponse, token, isSandbox) {
|
|
975
|
-
this.type = 'redirect';
|
|
976
|
-
this.data = {
|
|
977
|
-
fields: submitResponse.fields,
|
|
978
|
-
errors: submitResponse.errors,
|
|
979
|
-
messages: submitResponse.messages,
|
|
980
|
-
order: submitResponse.summary,
|
|
981
|
-
invoiceId: submitResponse.fixInvoice,
|
|
982
|
-
redirect: this.getRedirect(submitResponse, token, isSandbox),
|
|
983
|
-
};
|
|
1039
|
+
class ThreeDsActionCreator {
|
|
1040
|
+
constructor() {
|
|
1041
|
+
this.type = '3DS';
|
|
984
1042
|
}
|
|
985
|
-
|
|
1043
|
+
getActionData(actionData) {
|
|
986
1044
|
return {
|
|
987
|
-
|
|
988
|
-
data:
|
|
1045
|
+
type: this.type,
|
|
1046
|
+
data: actionData,
|
|
989
1047
|
};
|
|
990
1048
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
const pid = submitResponse?.fields?.find(({ name }) => name === 'fix_pid')?.value;
|
|
994
|
-
if (!pid) {
|
|
995
|
-
return responseRedirectUrl;
|
|
996
|
-
}
|
|
997
|
-
const pagesPath = pagesRoutes.get(Number(pid));
|
|
998
|
-
if (!pagesPath) {
|
|
999
|
-
return responseRedirectUrl;
|
|
1000
|
-
}
|
|
1001
|
-
return this.preparePagesUrl(pagesPath, token, isSandbox);
|
|
1002
|
-
}
|
|
1003
|
-
preparePagesUrl(pagesPath, token, isSandbox) {
|
|
1004
|
-
const payStationUrl = isSandbox ? sandboxPayStationUrl : payStation4Url;
|
|
1005
|
-
return `${payStationUrl}/en${pagesPath}?token=${token}`;
|
|
1049
|
+
isSuitable() {
|
|
1050
|
+
return false;
|
|
1006
1051
|
}
|
|
1007
1052
|
}
|
|
1053
|
+
ThreeDsActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1054
|
+
ThreeDsActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsActionCreator });
|
|
1055
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsActionCreator, decorators: [{
|
|
1056
|
+
type: Injectable
|
|
1057
|
+
}] });
|
|
1008
1058
|
|
|
1009
|
-
const
|
|
1010
|
-
const redirectActionFactoryProvider = {
|
|
1011
|
-
provide: redirectActionFactoryToken,
|
|
1012
|
-
useValue: {
|
|
1013
|
-
factory: (...args) => new RedirectAction(...args),
|
|
1014
|
-
isSuitable: (response) => {
|
|
1015
|
-
return (response.currentCommand === XpsCommand.account ||
|
|
1016
|
-
(response.currentCommand === XpsCommand.checkout &&
|
|
1017
|
-
Boolean(response.parameters.checkout)));
|
|
1018
|
-
},
|
|
1019
|
-
},
|
|
1020
|
-
};
|
|
1021
|
-
|
|
1022
|
-
const showErrorsActionFactoryToken = new InjectionToken('ShowErrorsAction');
|
|
1023
|
-
const showErrorsActionFactoryProvider = {
|
|
1024
|
-
provide: showErrorsActionFactoryToken,
|
|
1025
|
-
useValue: {
|
|
1026
|
-
factory: (...args) => new ShowErrorsAction(...args),
|
|
1027
|
-
isSuitable: (response) => {
|
|
1028
|
-
return Boolean(response.errors?.length);
|
|
1029
|
-
},
|
|
1030
|
-
},
|
|
1031
|
-
};
|
|
1059
|
+
const googlePayPid = 3431;
|
|
1032
1060
|
|
|
1033
|
-
class
|
|
1034
|
-
constructor(
|
|
1035
|
-
this.type = '
|
|
1036
|
-
this.
|
|
1061
|
+
class SpecialButtonActionCreator {
|
|
1062
|
+
constructor() {
|
|
1063
|
+
this.type = 'special_button';
|
|
1064
|
+
this.pids = [googlePayPid];
|
|
1065
|
+
this.sdkPaymentMethodsName = new Map([
|
|
1066
|
+
[googlePayPid, 'google-pay'],
|
|
1067
|
+
]);
|
|
1068
|
+
}
|
|
1069
|
+
getActionData(submitResponse) {
|
|
1070
|
+
return {
|
|
1071
|
+
type: this.type,
|
|
1072
|
+
data: {
|
|
1073
|
+
errors: submitResponse.errors,
|
|
1074
|
+
messages: submitResponse.messages,
|
|
1075
|
+
buttonName: this.getPaymentMethodName(submitResponse.pid),
|
|
1076
|
+
},
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
isSuitable(response) {
|
|
1080
|
+
return (response.currentCommand === XpsCommand.checkout &&
|
|
1081
|
+
Boolean(response.parameters.checkout) &&
|
|
1082
|
+
this.pids.includes(response.pid));
|
|
1083
|
+
}
|
|
1084
|
+
getPaymentMethodName(pid) {
|
|
1085
|
+
const buttonName = this.sdkPaymentMethodsName.get(pid);
|
|
1086
|
+
if (!buttonName) {
|
|
1087
|
+
throw new Error('Special button not found');
|
|
1088
|
+
}
|
|
1089
|
+
return buttonName;
|
|
1037
1090
|
}
|
|
1038
1091
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
factory: (...args) => new ThreeDsAction(...args),
|
|
1045
|
-
isSuitable: () => false,
|
|
1046
|
-
},
|
|
1047
|
-
};
|
|
1092
|
+
SpecialButtonActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SpecialButtonActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1093
|
+
SpecialButtonActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SpecialButtonActionCreator });
|
|
1094
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SpecialButtonActionCreator, decorators: [{
|
|
1095
|
+
type: Injectable
|
|
1096
|
+
}] });
|
|
1048
1097
|
|
|
1049
1098
|
const nextActionsToken = new InjectionToken('Action');
|
|
1050
1099
|
const nextActions = [
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1100
|
+
ShowFieldsActionCreator,
|
|
1101
|
+
CheckStatusActionCreator,
|
|
1102
|
+
SpecialButtonActionCreator,
|
|
1103
|
+
RedirectActionCreator,
|
|
1054
1104
|
];
|
|
1055
1105
|
const flowUpdateNextActions = [
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1106
|
+
ShowErrorsActionCreator,
|
|
1107
|
+
StatusUpdatedActionCreator,
|
|
1108
|
+
ThreeDsActionCreator,
|
|
1059
1109
|
];
|
|
1060
1110
|
|
|
1061
1111
|
class NextActionService {
|
|
1062
1112
|
get flowUpdates$() {
|
|
1063
1113
|
return this.flowUpdatesSubject.asObservable();
|
|
1064
1114
|
}
|
|
1065
|
-
constructor(nextActionTokens, injector,
|
|
1115
|
+
constructor(nextActionTokens, injector, showErrorsActionCreator) {
|
|
1066
1116
|
this.nextActionTokens = nextActionTokens;
|
|
1067
1117
|
this.injector = injector;
|
|
1068
|
-
this.
|
|
1118
|
+
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
1069
1119
|
this.flowUpdatesSubject = new Subject();
|
|
1070
1120
|
this.nextActionsList = [];
|
|
1071
1121
|
this.fillNextActionsList();
|
|
1072
1122
|
}
|
|
1073
1123
|
getNextAction(submitResponse) {
|
|
1074
1124
|
if (submitResponse.errors?.length) {
|
|
1075
|
-
this.emitFlowUpdates(
|
|
1125
|
+
this.emitFlowUpdates(this.showErrorsActionCreator.getActionData(submitResponse.errors));
|
|
1076
1126
|
}
|
|
1077
1127
|
if (!submitResponse.currentCommand) {
|
|
1078
1128
|
return null;
|
|
1079
1129
|
}
|
|
1080
|
-
const
|
|
1081
|
-
if (
|
|
1082
|
-
return
|
|
1130
|
+
const nextAction = this.findNextAction(submitResponse);
|
|
1131
|
+
if (nextAction) {
|
|
1132
|
+
return nextAction.getActionData(submitResponse);
|
|
1083
1133
|
}
|
|
1084
1134
|
throw new Error('Next action is undefined.');
|
|
1085
1135
|
}
|
|
@@ -1088,7 +1138,7 @@ class NextActionService {
|
|
|
1088
1138
|
}
|
|
1089
1139
|
fillNextActionsList() {
|
|
1090
1140
|
this.nextActionTokens.forEach((nextAction) => {
|
|
1091
|
-
const item = this.injector.get(nextAction
|
|
1141
|
+
const item = this.injector.get(nextAction);
|
|
1092
1142
|
this.nextActionsList.push(item);
|
|
1093
1143
|
});
|
|
1094
1144
|
}
|
|
@@ -1099,10 +1149,10 @@ class NextActionService {
|
|
|
1099
1149
|
if (!actionType) {
|
|
1100
1150
|
return;
|
|
1101
1151
|
}
|
|
1102
|
-
return actionType
|
|
1152
|
+
return actionType;
|
|
1103
1153
|
}
|
|
1104
1154
|
}
|
|
1105
|
-
NextActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }, { token:
|
|
1155
|
+
NextActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }, { token: ShowErrorsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1106
1156
|
NextActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, providedIn: 'root' });
|
|
1107
1157
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, decorators: [{
|
|
1108
1158
|
type: Injectable,
|
|
@@ -1112,7 +1162,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1112
1162
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1113
1163
|
type: Inject,
|
|
1114
1164
|
args: [nextActionsToken]
|
|
1115
|
-
}] }, { type: i0.Injector }, { type:
|
|
1165
|
+
}] }, { type: i0.Injector }, { type: ShowErrorsActionCreator }]; } });
|
|
1116
1166
|
|
|
1117
1167
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
1118
1168
|
const cardNumberSanctionErrorCodes = [
|
|
@@ -1597,7 +1647,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1597
1647
|
}], ctorParameters: function () { return [{ type: CreditCardService }]; } });
|
|
1598
1648
|
|
|
1599
1649
|
class InitializeService {
|
|
1600
|
-
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService) {
|
|
1650
|
+
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator) {
|
|
1601
1651
|
this.responseFactory = responseFactory;
|
|
1602
1652
|
this.xpsApiService = xpsApiService;
|
|
1603
1653
|
this.settingsService = settingsService;
|
|
@@ -1605,6 +1655,7 @@ class InitializeService {
|
|
|
1605
1655
|
this.nextActionService = nextActionService;
|
|
1606
1656
|
this.xpsResponseErrorsMappingService = xpsResponseErrorsMappingService;
|
|
1607
1657
|
this.encryptCreditCardService = encryptCreditCardService;
|
|
1658
|
+
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
1608
1659
|
// TODO PAYMENTS-15743: replace with new refer id for headless core
|
|
1609
1660
|
this.ps4ReferId = '22';
|
|
1610
1661
|
}
|
|
@@ -1631,7 +1682,7 @@ class InitializeService {
|
|
|
1631
1682
|
const response = this.xpsResponseErrorsMappingService.mapErrors(xpsResponse);
|
|
1632
1683
|
const initializeResponse = this.responseFactory(response);
|
|
1633
1684
|
if (initializeResponse.paymentForm?.errors?.length) {
|
|
1634
|
-
this.nextActionService.emitFlowUpdates(
|
|
1685
|
+
this.nextActionService.emitFlowUpdates(this.showErrorsActionCreator.getActionData(initializeResponse.paymentForm.errors));
|
|
1635
1686
|
}
|
|
1636
1687
|
if (initializeResponse.paymentForm) {
|
|
1637
1688
|
this.setCreditCardEncryptKey(initializeResponse.paymentForm);
|
|
@@ -1650,7 +1701,7 @@ class InitializeService {
|
|
|
1650
1701
|
this.encryptCreditCardService.setPublicKey(atob(publicKeyField.value));
|
|
1651
1702
|
}
|
|
1652
1703
|
}
|
|
1653
|
-
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1704
|
+
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1654
1705
|
InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
|
|
1655
1706
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1656
1707
|
type: Injectable,
|
|
@@ -1660,7 +1711,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1660
1711
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1661
1712
|
type: Inject,
|
|
1662
1713
|
args: [initializeResponseFactoryToken]
|
|
1663
|
-
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }]; } });
|
|
1714
|
+
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }]; } });
|
|
1664
1715
|
|
|
1665
1716
|
class XpsApiPartRequest {
|
|
1666
1717
|
addXpsParameters(parameters) {
|
|
@@ -1895,7 +1946,7 @@ const syncResponseFactoryProvider = {
|
|
|
1895
1946
|
};
|
|
1896
1947
|
|
|
1897
1948
|
class SyncService extends EmitDataService {
|
|
1898
|
-
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService) {
|
|
1949
|
+
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator) {
|
|
1899
1950
|
super();
|
|
1900
1951
|
this.requestFactory = requestFactory;
|
|
1901
1952
|
this.responseFactory = responseFactory;
|
|
@@ -1904,6 +1955,7 @@ class SyncService extends EmitDataService {
|
|
|
1904
1955
|
this.settingsService = settingsService;
|
|
1905
1956
|
this.xpsResponseErrorsMappingService = xpsResponseErrorsMappingService;
|
|
1906
1957
|
this.encryptCreditCardService = encryptCreditCardService;
|
|
1958
|
+
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
1907
1959
|
this.prevFieldSyncStates = {};
|
|
1908
1960
|
this.form = new UntypedFormGroup({});
|
|
1909
1961
|
this.fields = [];
|
|
@@ -2001,7 +2053,7 @@ class SyncService extends EmitDataService {
|
|
|
2001
2053
|
emitFormErrors(response) {
|
|
2002
2054
|
const formErrors = response.errors?.filter((error) => !error.element_name);
|
|
2003
2055
|
if (formErrors?.length) {
|
|
2004
|
-
this.nextActionService.emitFlowUpdates(
|
|
2056
|
+
this.nextActionService.emitFlowUpdates(this.showErrorsActionCreator.getActionData(formErrors));
|
|
2005
2057
|
}
|
|
2006
2058
|
}
|
|
2007
2059
|
resetFieldSyncTimer(field, timerId) {
|
|
@@ -2012,7 +2064,7 @@ class SyncService extends EmitDataService {
|
|
|
2012
2064
|
this.fieldSyncTimers[field.name] = timerId;
|
|
2013
2065
|
}
|
|
2014
2066
|
}
|
|
2015
|
-
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2067
|
+
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2016
2068
|
SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
|
|
2017
2069
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, decorators: [{
|
|
2018
2070
|
type: Injectable,
|
|
@@ -2025,7 +2077,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2025
2077
|
}] }, { type: undefined, decorators: [{
|
|
2026
2078
|
type: Inject,
|
|
2027
2079
|
args: [syncResponseFactoryToken]
|
|
2028
|
-
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }]; } });
|
|
2080
|
+
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }]; } });
|
|
2029
2081
|
|
|
2030
2082
|
class ControlConfig {
|
|
2031
2083
|
constructor() {
|
|
@@ -4701,12 +4753,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4701
4753
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4702
4754
|
|
|
4703
4755
|
class SavePaymentMethodStatusService {
|
|
4704
|
-
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
|
|
4756
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService, statusUpdatedActionCreator) {
|
|
4705
4757
|
this.statusRequestService = statusRequestService;
|
|
4706
4758
|
this.listenStatusService = listenStatusService;
|
|
4707
4759
|
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4708
4760
|
this.nextActionService = nextActionService;
|
|
4709
4761
|
this.checkStatusService = checkStatusService;
|
|
4762
|
+
this.statusUpdatedActionCreator = statusUpdatedActionCreator;
|
|
4710
4763
|
this.statusChecked = false;
|
|
4711
4764
|
}
|
|
4712
4765
|
async getStatus(params) {
|
|
@@ -4792,26 +4845,31 @@ class SavePaymentMethodStatusService {
|
|
|
4792
4845
|
this.listenStatusService.stopListening();
|
|
4793
4846
|
this.listenStatusSubscription.unsubscribe();
|
|
4794
4847
|
const isSavePaymentMethod = true;
|
|
4795
|
-
this.nextActionService.emitFlowUpdates(
|
|
4848
|
+
this.nextActionService.emitFlowUpdates(this.statusUpdatedActionCreator.getActionData({
|
|
4849
|
+
statusResponse: status,
|
|
4850
|
+
isSavePaymentMethodMode: isSavePaymentMethod,
|
|
4851
|
+
savePaymentMethodStatus: this.savePaymentMethodStatus,
|
|
4852
|
+
}));
|
|
4796
4853
|
}
|
|
4797
4854
|
}
|
|
4798
|
-
SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }, { token: CheckStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4855
|
+
SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }, { token: CheckStatusService }, { token: StatusUpdatedActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4799
4856
|
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4800
4857
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4801
4858
|
type: Injectable,
|
|
4802
4859
|
args: [{
|
|
4803
4860
|
providedIn: 'root',
|
|
4804
4861
|
}]
|
|
4805
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4862
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }, { type: StatusUpdatedActionCreator }]; } });
|
|
4806
4863
|
|
|
4807
4864
|
class StatusService {
|
|
4808
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4865
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService, statusUpdatedActionCreator) {
|
|
4809
4866
|
this.urlService = urlService;
|
|
4810
4867
|
this.statusRequestService = statusRequestService;
|
|
4811
4868
|
this.financeDetailsService = financeDetailsService;
|
|
4812
4869
|
this.listenStatusService = listenStatusService;
|
|
4813
4870
|
this.nextActionService = nextActionService;
|
|
4814
4871
|
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4872
|
+
this.statusUpdatedActionCreator = statusUpdatedActionCreator;
|
|
4815
4873
|
}
|
|
4816
4874
|
async getStatus(params) {
|
|
4817
4875
|
const isSavePaymentMethodMode = params?.isSavePaymentAccount === "1" /* XpsBoolean.true */;
|
|
@@ -4850,18 +4908,18 @@ class StatusService {
|
|
|
4850
4908
|
.pipe(skip(1))
|
|
4851
4909
|
.subscribe(({ statusResponse }) => {
|
|
4852
4910
|
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
4853
|
-
this.nextActionService.emitFlowUpdates(
|
|
4911
|
+
this.nextActionService.emitFlowUpdates(this.statusUpdatedActionCreator.getActionData({ statusResponse }));
|
|
4854
4912
|
});
|
|
4855
4913
|
}
|
|
4856
4914
|
}
|
|
4857
|
-
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4915
|
+
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }, { token: StatusUpdatedActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4858
4916
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4859
4917
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4860
4918
|
type: Injectable,
|
|
4861
4919
|
args: [{
|
|
4862
4920
|
providedIn: 'root',
|
|
4863
4921
|
}]
|
|
4864
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4922
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }, { type: StatusUpdatedActionCreator }]; } });
|
|
4865
4923
|
|
|
4866
4924
|
class CreditCardStateService extends EmitDataService {
|
|
4867
4925
|
}
|
|
@@ -5254,9 +5312,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
5254
5312
|
}], ctorParameters: function () { return [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }]; } });
|
|
5255
5313
|
|
|
5256
5314
|
class ThreeDsService {
|
|
5257
|
-
constructor(threeDs20Service, nextActionService) {
|
|
5315
|
+
constructor(threeDs20Service, nextActionService, checkStatusActionCreator, threeDsActionCreator) {
|
|
5258
5316
|
this.threeDs20Service = threeDs20Service;
|
|
5259
5317
|
this.nextActionService = nextActionService;
|
|
5318
|
+
this.checkStatusActionCreator = checkStatusActionCreator;
|
|
5319
|
+
this.threeDsActionCreator = threeDsActionCreator;
|
|
5260
5320
|
this.statusSubscription = null;
|
|
5261
5321
|
}
|
|
5262
5322
|
checkThreeDs(params) {
|
|
@@ -5269,23 +5329,23 @@ class ThreeDsService {
|
|
|
5269
5329
|
this.statusSubscription?.unsubscribe();
|
|
5270
5330
|
this.statusSubscription = this.threeDs20Service.statusUpdates$.subscribe((statusUpdate) => {
|
|
5271
5331
|
if (statusUpdate.type === 'complete') {
|
|
5272
|
-
return this.nextActionService.emitFlowUpdates(
|
|
5332
|
+
return this.nextActionService.emitFlowUpdates(this.checkStatusActionCreator.getActionData());
|
|
5273
5333
|
}
|
|
5274
|
-
this.nextActionService.emitFlowUpdates(
|
|
5334
|
+
this.nextActionService.emitFlowUpdates(this.threeDsActionCreator.getActionData(statusUpdate));
|
|
5275
5335
|
});
|
|
5276
5336
|
}
|
|
5277
5337
|
stopChecking() {
|
|
5278
5338
|
this.statusSubscription?.unsubscribe();
|
|
5279
5339
|
}
|
|
5280
5340
|
}
|
|
5281
|
-
ThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, deps: [{ token: ThreeDs20Service }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5341
|
+
ThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, deps: [{ token: ThreeDs20Service }, { token: NextActionService }, { token: CheckStatusActionCreator }, { token: ThreeDsActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5282
5342
|
ThreeDsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, providedIn: 'root' });
|
|
5283
5343
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, decorators: [{
|
|
5284
5344
|
type: Injectable,
|
|
5285
5345
|
args: [{
|
|
5286
5346
|
providedIn: 'root',
|
|
5287
5347
|
}]
|
|
5288
|
-
}], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
|
|
5348
|
+
}], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }, { type: CheckStatusActionCreator }, { type: ThreeDsActionCreator }]; } });
|
|
5289
5349
|
|
|
5290
5350
|
class FormMessagesService extends EmitDataService {
|
|
5291
5351
|
constructor(unescapeHtmlPipe) {
|
|
@@ -5313,7 +5373,7 @@ class PaymentService {
|
|
|
5313
5373
|
get formFieldsStatus$() {
|
|
5314
5374
|
return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
|
|
5315
5375
|
}
|
|
5316
|
-
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService) {
|
|
5376
|
+
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService) {
|
|
5317
5377
|
this.initializeService = initializeService;
|
|
5318
5378
|
this.submitService = submitService;
|
|
5319
5379
|
this.syncService = syncService;
|
|
@@ -5325,6 +5385,8 @@ class PaymentService {
|
|
|
5325
5385
|
this.controlConfigService = controlConfigService;
|
|
5326
5386
|
this.threeDsService = threeDsService;
|
|
5327
5387
|
this.formMessagesService = formMessagesService;
|
|
5388
|
+
this.settingsService = settingsService;
|
|
5389
|
+
this.countryService = countryService;
|
|
5328
5390
|
this.form = null;
|
|
5329
5391
|
this.data = null;
|
|
5330
5392
|
this.financeDetails = null;
|
|
@@ -5383,6 +5445,18 @@ class PaymentService {
|
|
|
5383
5445
|
}
|
|
5384
5446
|
return this.data?.paymentForm?.fields ?? [];
|
|
5385
5447
|
}
|
|
5448
|
+
getInitialDataForSdkPaymentSystems() {
|
|
5449
|
+
if (!isSubmitResponse(this.data)) {
|
|
5450
|
+
throw new Error('Should submit form first');
|
|
5451
|
+
}
|
|
5452
|
+
return {
|
|
5453
|
+
data: this.data.parameters.checkout.data.data,
|
|
5454
|
+
sandbox: this.settingsService.isSandboxMode()
|
|
5455
|
+
? "1" /* XpsBoolean.true */
|
|
5456
|
+
: "0" /* XpsBoolean.false */,
|
|
5457
|
+
country: this.countryService.getCountry(),
|
|
5458
|
+
};
|
|
5459
|
+
}
|
|
5386
5460
|
getPid() {
|
|
5387
5461
|
if (this.data instanceof SubmitResponse) {
|
|
5388
5462
|
return (Number(this.data.fields.find((field) => field.name === 'fix_pid')?.value) || null);
|
|
@@ -5524,14 +5598,14 @@ class PaymentService {
|
|
|
5524
5598
|
}
|
|
5525
5599
|
}
|
|
5526
5600
|
}
|
|
5527
|
-
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: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5601
|
+
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: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5528
5602
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
5529
5603
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
5530
5604
|
type: Injectable,
|
|
5531
5605
|
args: [{
|
|
5532
5606
|
providedIn: 'root',
|
|
5533
5607
|
}]
|
|
5534
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }]; } });
|
|
5608
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }]; } });
|
|
5535
5609
|
|
|
5536
5610
|
class RefundPolicyService {
|
|
5537
5611
|
constructor(settingsService) {
|
|
@@ -5671,8 +5745,281 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
5671
5745
|
}]
|
|
5672
5746
|
}], ctorParameters: function () { return [{ type: SavedMethodsService }, { type: SettingsService }, { type: SecureApiClient }]; } });
|
|
5673
5747
|
|
|
5748
|
+
class PaymentSystemProcessingService {
|
|
5749
|
+
constructor(window) {
|
|
5750
|
+
this.window = window;
|
|
5751
|
+
this.statusUrl = new BehaviorSubject('');
|
|
5752
|
+
this.initialize = new BehaviorSubject(false);
|
|
5753
|
+
}
|
|
5754
|
+
get initialize$() {
|
|
5755
|
+
return this.initialize.asObservable();
|
|
5756
|
+
}
|
|
5757
|
+
get status$() {
|
|
5758
|
+
return this.statusUrl.asObservable().pipe(filter((status) => !!status));
|
|
5759
|
+
}
|
|
5760
|
+
emitPayment(payment) {
|
|
5761
|
+
this.statusUrl.next(payment);
|
|
5762
|
+
}
|
|
5763
|
+
emitInitialize(isInitialized) {
|
|
5764
|
+
this.initialize.next(isInitialized);
|
|
5765
|
+
}
|
|
5766
|
+
getDecodedCheckout(base64checkoutData) {
|
|
5767
|
+
try {
|
|
5768
|
+
return JSON.parse(atob(base64checkoutData));
|
|
5769
|
+
}
|
|
5770
|
+
catch (error) {
|
|
5771
|
+
throw new AppError('load script service: decode error');
|
|
5772
|
+
}
|
|
5773
|
+
}
|
|
5774
|
+
loadScript(url, onLoad, addScriptCustomAttributes) {
|
|
5775
|
+
this.initialize.next(false);
|
|
5776
|
+
let script = this.window.document.createElement('script');
|
|
5777
|
+
script.async = true;
|
|
5778
|
+
script.src = url;
|
|
5779
|
+
if (addScriptCustomAttributes) {
|
|
5780
|
+
script = addScriptCustomAttributes(script);
|
|
5781
|
+
}
|
|
5782
|
+
this.window.document.body.append(script);
|
|
5783
|
+
script.onload = () => {
|
|
5784
|
+
try {
|
|
5785
|
+
onLoad();
|
|
5786
|
+
}
|
|
5787
|
+
catch (error) {
|
|
5788
|
+
let message = error;
|
|
5789
|
+
if (error instanceof Error) {
|
|
5790
|
+
message = error.message;
|
|
5791
|
+
}
|
|
5792
|
+
throw new AppError(`Pages: error during script onload handler: ${message}, url - ${url}`);
|
|
5793
|
+
}
|
|
5794
|
+
};
|
|
5795
|
+
script.onerror = (event, source, lineno, colno, error) => {
|
|
5796
|
+
const errorMessage = error ? error.message : '';
|
|
5797
|
+
let eventMessage = event;
|
|
5798
|
+
if (typeof event === 'object') {
|
|
5799
|
+
eventMessage = JSON.stringify(event);
|
|
5800
|
+
}
|
|
5801
|
+
throw new AppError(`Pages: error during script onerror handler:
|
|
5802
|
+
url - ${url},
|
|
5803
|
+
event - ${eventMessage},
|
|
5804
|
+
source - ${source ?? ''},
|
|
5805
|
+
lineno - ${lineno ?? ''},
|
|
5806
|
+
colno - ${colno ?? ''},
|
|
5807
|
+
error - ${errorMessage}`);
|
|
5808
|
+
};
|
|
5809
|
+
}
|
|
5810
|
+
isInitialized() {
|
|
5811
|
+
return this.initialize.getValue();
|
|
5812
|
+
}
|
|
5813
|
+
}
|
|
5814
|
+
PaymentSystemProcessingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentSystemProcessingService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5815
|
+
PaymentSystemProcessingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentSystemProcessingService, providedIn: 'root' });
|
|
5816
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentSystemProcessingService, decorators: [{
|
|
5817
|
+
type: Injectable,
|
|
5818
|
+
args: [{
|
|
5819
|
+
providedIn: 'root',
|
|
5820
|
+
}]
|
|
5821
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
5822
|
+
type: Inject,
|
|
5823
|
+
args: [windowToken]
|
|
5824
|
+
}] }]; } });
|
|
5825
|
+
|
|
5826
|
+
class GooglePayService {
|
|
5827
|
+
get libraryWasInitialized() {
|
|
5828
|
+
return !!this.window.google;
|
|
5829
|
+
}
|
|
5830
|
+
get googlePaymentClientWasInitialized() {
|
|
5831
|
+
return !!this.googlePaymentClient;
|
|
5832
|
+
}
|
|
5833
|
+
constructor(window, elkLoggerService, commonPayProcessingService, httpClient, injector) {
|
|
5834
|
+
this.window = window;
|
|
5835
|
+
this.elkLoggerService = elkLoggerService;
|
|
5836
|
+
this.commonPayProcessingService = commonPayProcessingService;
|
|
5837
|
+
this.httpClient = httpClient;
|
|
5838
|
+
this.injector = injector;
|
|
5839
|
+
this.googlePayScriptUrl = 'https://pay.google.com/gp/p/js/pay.js';
|
|
5840
|
+
this.readyToPay = new BehaviorSubject(null);
|
|
5841
|
+
this.checkout = null;
|
|
5842
|
+
this.googlePaymentClient = null;
|
|
5843
|
+
this.commonPayProcessingService.status$.subscribe((path) => {
|
|
5844
|
+
this.sendUserBack(path);
|
|
5845
|
+
});
|
|
5846
|
+
}
|
|
5847
|
+
get readyToPay$() {
|
|
5848
|
+
return this.readyToPay.asObservable();
|
|
5849
|
+
}
|
|
5850
|
+
isReadyToPay() {
|
|
5851
|
+
return this.readyToPay.getValue();
|
|
5852
|
+
}
|
|
5853
|
+
sendUserBack(path) {
|
|
5854
|
+
void this.httpClient.get(path);
|
|
5855
|
+
}
|
|
5856
|
+
initGooglePayLibrary(data) {
|
|
5857
|
+
this.isSandbox = data.isSandbox;
|
|
5858
|
+
this.country = data.country;
|
|
5859
|
+
if (this.libraryWasInitialized && this.googlePaymentClientWasInitialized) {
|
|
5860
|
+
return;
|
|
5861
|
+
}
|
|
5862
|
+
if (this.libraryWasInitialized && !this.googlePaymentClientWasInitialized) {
|
|
5863
|
+
this.setupGooglePayClient();
|
|
5864
|
+
return;
|
|
5865
|
+
}
|
|
5866
|
+
this.commonPayProcessingService.loadScript(this.googlePayScriptUrl, this.onLoadScript.bind(this));
|
|
5867
|
+
this.elkLoggerService.log('Google Pay: loading script is starting', [
|
|
5868
|
+
ErrorTags.GOOGLEPAY,
|
|
5869
|
+
]);
|
|
5870
|
+
}
|
|
5871
|
+
checkPaymentDevice(base64checkoutData) {
|
|
5872
|
+
this.commonPayProcessingService.initialize$
|
|
5873
|
+
.pipe(filter$1(Boolean), take(1))
|
|
5874
|
+
.subscribe(() => {
|
|
5875
|
+
this.checkout =
|
|
5876
|
+
this.commonPayProcessingService.getDecodedCheckout(base64checkoutData);
|
|
5877
|
+
if (!this.checkout || !this.googlePaymentClient) {
|
|
5878
|
+
throw new AppError(`Google Pay: no checkout or google payment client, checkout - ${Boolean(this.checkout).toString()}, client - ${Boolean(this.googlePaymentClient).toString()}`);
|
|
5879
|
+
}
|
|
5880
|
+
const checkoutData = this.checkout.request.form.fields;
|
|
5881
|
+
const isReadyToPayRequest = JSON.parse(checkoutData.isReadyToPayRequest);
|
|
5882
|
+
this.googlePaymentClient
|
|
5883
|
+
.isReadyToPay(isReadyToPayRequest)
|
|
5884
|
+
.then((response) => {
|
|
5885
|
+
if (response.result && this.googlePaymentClient) {
|
|
5886
|
+
this.googlePaymentClient.prefetchPaymentData(JSON.parse(checkoutData.paymentDataRequest));
|
|
5887
|
+
return this.readyToPay.next(true);
|
|
5888
|
+
}
|
|
5889
|
+
this.readyToPay.next(false);
|
|
5890
|
+
const result = response.result?.toString() ?? '';
|
|
5891
|
+
const isHavePaymentClient = Boolean(this.googlePaymentClient).toString();
|
|
5892
|
+
this.elkLoggerService.log(`Google Pay: possibly no response.result or googlePaymentClient is missing, result - ${result}, isHavePaymentClient - ${isHavePaymentClient}`, [ErrorTags.GOOGLEPAY], {
|
|
5893
|
+
result: response.result,
|
|
5894
|
+
response: response,
|
|
5895
|
+
googlePaymentClient: !!this.googlePaymentClient,
|
|
5896
|
+
});
|
|
5897
|
+
throw new Error();
|
|
5898
|
+
})
|
|
5899
|
+
.catch((error) => {
|
|
5900
|
+
this.readyToPay.next(false);
|
|
5901
|
+
let message = error ?? '';
|
|
5902
|
+
if (error instanceof Error) {
|
|
5903
|
+
message = error.message;
|
|
5904
|
+
}
|
|
5905
|
+
throw new AppError(`Google Pay: device is not ready to pay, ${message}`);
|
|
5906
|
+
});
|
|
5907
|
+
});
|
|
5908
|
+
}
|
|
5909
|
+
async proceedCheckout() {
|
|
5910
|
+
if (!this.checkout || !this.googlePaymentClient) {
|
|
5911
|
+
const isHaveCheckout = !!this.checkout;
|
|
5912
|
+
const isHaveClient = !!this.googlePaymentClient;
|
|
5913
|
+
throw new AppError(`Google Pay: no checkout or google payment client, checkout - ${isHaveCheckout.toString()}, client - ${isHaveClient.toString()}`);
|
|
5914
|
+
}
|
|
5915
|
+
const checkoutData = this.checkout.request.form.fields;
|
|
5916
|
+
const paymentDataRequest = JSON.parse(checkoutData.paymentDataRequest);
|
|
5917
|
+
paymentDataRequest.transactionInfo = {
|
|
5918
|
+
currencyCode: checkoutData.currency,
|
|
5919
|
+
totalPriceStatus: 'FINAL',
|
|
5920
|
+
totalPrice: checkoutData.sum,
|
|
5921
|
+
countryCode: this.country,
|
|
5922
|
+
};
|
|
5923
|
+
const checkStatusAction = this.injector
|
|
5924
|
+
.get(CheckStatusActionCreator)
|
|
5925
|
+
.getActionData();
|
|
5926
|
+
try {
|
|
5927
|
+
const paymentData = await this.googlePaymentClient.loadPaymentData(paymentDataRequest);
|
|
5928
|
+
if (!paymentData?.paymentMethodData?.tokenizationData?.token) {
|
|
5929
|
+
throw new AppError('Google Pay: token is missing');
|
|
5930
|
+
}
|
|
5931
|
+
if (!this.checkout) {
|
|
5932
|
+
throw new AppError('Google Pay: no checkout data in then');
|
|
5933
|
+
}
|
|
5934
|
+
let returnUrl = this.checkout.request.form.fields.returnSuccessUrl;
|
|
5935
|
+
const data = this.checkout.request.form.fields;
|
|
5936
|
+
returnUrl += `&cpf_number=${data.cpf_number}&descriptor=${data.descriptor}&paymentData=${JSON.stringify(paymentData)}`;
|
|
5937
|
+
this.commonPayProcessingService.emitPayment(returnUrl);
|
|
5938
|
+
return checkStatusAction;
|
|
5939
|
+
}
|
|
5940
|
+
catch (error) {
|
|
5941
|
+
this.elkLoggerService.log(`Google Pay: google payment window error. ${JSON.stringify(error)}`, [ErrorTags.GOOGLEPAY], {
|
|
5942
|
+
error: error,
|
|
5943
|
+
});
|
|
5944
|
+
if (!this.checkout) {
|
|
5945
|
+
throw new AppError(`Google Pay: no checkout data`);
|
|
5946
|
+
}
|
|
5947
|
+
const statusCode = error
|
|
5948
|
+
?.statusCode;
|
|
5949
|
+
const isStatusCanceled = statusCode && this.isCancelledStatus(statusCode);
|
|
5950
|
+
if (isStatusCanceled) {
|
|
5951
|
+
return null;
|
|
5952
|
+
}
|
|
5953
|
+
const returnUrl = this.checkout.request.form.fields.returnFailUrl;
|
|
5954
|
+
this.commonPayProcessingService.emitPayment(returnUrl);
|
|
5955
|
+
return checkStatusAction;
|
|
5956
|
+
}
|
|
5957
|
+
}
|
|
5958
|
+
createButton(onClickHandler) {
|
|
5959
|
+
if (!this.checkout || !this.googlePaymentClient) {
|
|
5960
|
+
return null;
|
|
5961
|
+
}
|
|
5962
|
+
const checkoutData = this.checkout.request.form.fields;
|
|
5963
|
+
const paymentDataRequest = JSON.parse(checkoutData.paymentDataRequest);
|
|
5964
|
+
return this.googlePaymentClient.createButton({
|
|
5965
|
+
onClick: onClickHandler,
|
|
5966
|
+
allowedPaymentMethods: paymentDataRequest.allowedPaymentMethods,
|
|
5967
|
+
buttonSizeMode: 'fill',
|
|
5968
|
+
buttonType: 'buy',
|
|
5969
|
+
buttonColor: 'white',
|
|
5970
|
+
});
|
|
5971
|
+
}
|
|
5972
|
+
setupGooglePayClient() {
|
|
5973
|
+
if (!this.window.google) {
|
|
5974
|
+
return;
|
|
5975
|
+
}
|
|
5976
|
+
const environment = this.isSandbox ? 'TEST' : 'PRODUCTION';
|
|
5977
|
+
this.googlePaymentClient =
|
|
5978
|
+
new this.window.google.payments.api.PaymentsClient({
|
|
5979
|
+
environment,
|
|
5980
|
+
});
|
|
5981
|
+
this.elkLoggerService.log(`Google Pay: payments client is initialized, paymentsClient - ${Boolean(this.googlePaymentClient).toString()}`, [ErrorTags.GOOGLEPAY], { environment: environment, initialized: !!this.googlePaymentClient });
|
|
5982
|
+
}
|
|
5983
|
+
onLoadScript() {
|
|
5984
|
+
if (!this.window.google) {
|
|
5985
|
+
const retryTimeout = 1000;
|
|
5986
|
+
setTimeout(() => {
|
|
5987
|
+
const isAvailableGoogleClient = !!this.window.google;
|
|
5988
|
+
if (!isAvailableGoogleClient) {
|
|
5989
|
+
this.elkLoggerService.log('Google Pay: google library is missing', [
|
|
5990
|
+
ErrorTags.GOOGLEPAY,
|
|
5991
|
+
]);
|
|
5992
|
+
}
|
|
5993
|
+
else {
|
|
5994
|
+
this.setupGooglePayClient();
|
|
5995
|
+
this.commonPayProcessingService.emitInitialize(true);
|
|
5996
|
+
}
|
|
5997
|
+
}, retryTimeout);
|
|
5998
|
+
throw new AppError('Google Pay: google library now is available');
|
|
5999
|
+
}
|
|
6000
|
+
else {
|
|
6001
|
+
this.setupGooglePayClient();
|
|
6002
|
+
this.commonPayProcessingService.emitInitialize(true);
|
|
6003
|
+
}
|
|
6004
|
+
}
|
|
6005
|
+
isCancelledStatus(statusCode) {
|
|
6006
|
+
return statusCode.toLowerCase() === 'canceled';
|
|
6007
|
+
}
|
|
6008
|
+
}
|
|
6009
|
+
GooglePayService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: ElkLoggerService }, { token: PaymentSystemProcessingService }, { token: i1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6010
|
+
GooglePayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: GooglePayService, providedIn: 'root' });
|
|
6011
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: GooglePayService, decorators: [{
|
|
6012
|
+
type: Injectable,
|
|
6013
|
+
args: [{
|
|
6014
|
+
providedIn: 'root',
|
|
6015
|
+
}]
|
|
6016
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
6017
|
+
type: Inject,
|
|
6018
|
+
args: [windowToken]
|
|
6019
|
+
}] }, { type: ElkLoggerService }, { type: PaymentSystemProcessingService }, { type: i1.HttpClient }, { type: i0.Injector }]; } });
|
|
6020
|
+
|
|
5674
6021
|
class CoreLibraryService {
|
|
5675
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService, editSavedMethodsService) {
|
|
6022
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService, editSavedMethodsService, googlePayService, commonPayProcessingService) {
|
|
5676
6023
|
this.settingsService = settingsService;
|
|
5677
6024
|
this.countryService = countryService;
|
|
5678
6025
|
this.paymentMethodsService = paymentMethodsService;
|
|
@@ -5689,6 +6036,8 @@ class CoreLibraryService {
|
|
|
5689
6036
|
this.creditCardStateService = creditCardStateService;
|
|
5690
6037
|
this.formMessagesService = formMessagesService;
|
|
5691
6038
|
this.editSavedMethodsService = editSavedMethodsService;
|
|
6039
|
+
this.googlePayService = googlePayService;
|
|
6040
|
+
this.commonPayProcessingService = commonPayProcessingService;
|
|
5692
6041
|
this.paymentMethods = {
|
|
5693
6042
|
getList: async (isSaveMethodMode) => this.paymentMethodsService.getList(isSaveMethodMode),
|
|
5694
6043
|
getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
|
|
@@ -5696,6 +6045,23 @@ class CoreLibraryService {
|
|
|
5696
6045
|
getUserBalance: async () => this.userBalanceService.getUserBalance(),
|
|
5697
6046
|
deleteSavedMethod: async (id, type) => this.editSavedMethodsService.deleteSavedMethodRequest(id, type),
|
|
5698
6047
|
};
|
|
6048
|
+
this.sdkPaymentSystems = {
|
|
6049
|
+
commonPayProcessingService: {
|
|
6050
|
+
initialize$: this.commonPayProcessingService.initialize$,
|
|
6051
|
+
isInitialized: () => this.commonPayProcessingService.isInitialized(),
|
|
6052
|
+
status$: this.commonPayProcessingService.status$,
|
|
6053
|
+
},
|
|
6054
|
+
googlePay: {
|
|
6055
|
+
readyToPay$: this.googlePayService.readyToPay$,
|
|
6056
|
+
isReadyToPay: () => this.googlePayService.isReadyToPay(),
|
|
6057
|
+
initGooglePayLibrary: (params) => this.googlePayService.initGooglePayLibrary(params),
|
|
6058
|
+
checkPaymentDevice: (base64checkoutData) => this.googlePayService.checkPaymentDevice(base64checkoutData),
|
|
6059
|
+
proceedCheckout: async () => this.googlePayService.proceedCheckout(),
|
|
6060
|
+
createButton: (onClickHandler) => this.googlePayService.createButton(onClickHandler),
|
|
6061
|
+
sendUserBack: (path) => this.googlePayService.sendUserBack(path),
|
|
6062
|
+
},
|
|
6063
|
+
getInitialData: () => this.paymentService.getInitialDataForSdkPaymentSystems(),
|
|
6064
|
+
};
|
|
5699
6065
|
}
|
|
5700
6066
|
async init(configuration) {
|
|
5701
6067
|
await this.settingsService.init(configuration);
|
|
@@ -5760,14 +6126,14 @@ class CoreLibraryService {
|
|
|
5760
6126
|
return this.userBalanceService.getUserBalanceValue();
|
|
5761
6127
|
}
|
|
5762
6128
|
}
|
|
5763
|
-
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 }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }, { token: EditSavedMethodsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6129
|
+
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 }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }, { token: EditSavedMethodsService }, { token: GooglePayService }, { token: PaymentSystemProcessingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5764
6130
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
5765
6131
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
5766
6132
|
type: Injectable,
|
|
5767
6133
|
args: [{
|
|
5768
6134
|
providedIn: 'root',
|
|
5769
6135
|
}]
|
|
5770
|
-
}], 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 }, { type: CreditCardService }, { type: CreditCardStateService }, { type: FormMessagesService }, { type: EditSavedMethodsService }]; } });
|
|
6136
|
+
}], 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 }, { type: CreditCardService }, { type: CreditCardStateService }, { type: FormMessagesService }, { type: EditSavedMethodsService }, { type: GooglePayService }, { type: PaymentSystemProcessingService }]; } });
|
|
5771
6137
|
|
|
5772
6138
|
class HttpError extends AppError {
|
|
5773
6139
|
constructor(error, req) {
|