@xsolla/payment-client-core 0.1.14-test2 → 0.1.14-test20
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/status-updated/status-updated.action.class.mjs +17 -7
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.type.mjs +1 -1
- package/esm2020/lib/core/payment/config/config.service.mjs +12 -6
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +3 -3
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +11 -2
- package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +44 -0
- package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.mjs +6 -0
- package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +198 -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 +2 -1
- package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +8 -1
- package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status.service.mjs +13 -4
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +1 -1
- package/esm2020/lib/core-library.service.mjs +1 -1
- package/fesm2015/xsolla-payment-client-core.mjs +426 -145
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +417 -142
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/actions/status-updated/status-updated.action.class.d.ts +3 -1
- package/lib/core/payment/actions/status-updated/status-updated.action.type.d.ts +3 -0
- package/lib/core/payment/payment.interface.d.ts +1 -1
- package/lib/core/payment/payment.service.d.ts +2 -1
- package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.interface.d.ts +6 -0
- package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.d.ts +16 -0
- package/lib/core/payment/status/save-payment-method-status/api/saved-payment-account.interface.d.ts +7 -0
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.d.ts +4 -0
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +30 -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 +2 -1
- package/lib/core/payment/status/status.interface.d.ts +1 -0
- package/lib/core/payment/status/status.service.d.ts +5 -3
- package/lib/core/payment-methods/payment-methods.service.d.ts +1 -1
- package/lib/core-library.service.d.ts +2 -2
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test20.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test2.tgz +0 -0
|
@@ -5,7 +5,7 @@ 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';
|
|
7
7
|
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
-
import { filter, map as map$1, catchError } from 'rxjs/operators';
|
|
8
|
+
import { filter, map as map$1, tap, catchError } from 'rxjs/operators';
|
|
9
9
|
import * as i1$1 from '@angular/router';
|
|
10
10
|
import { CommonModule } from '@angular/common';
|
|
11
11
|
|
|
@@ -454,13 +454,19 @@ class PaymentConfigService {
|
|
|
454
454
|
}
|
|
455
455
|
return {
|
|
456
456
|
...config,
|
|
457
|
-
returnUrl: this.enrichReturnUrl(config.returnUrl)
|
|
457
|
+
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod)
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
|
-
enrichReturnUrl(returnUrl) {
|
|
461
|
-
|
|
462
|
-
token: this.settingsService.token
|
|
460
|
+
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
461
|
+
let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
462
|
+
token: this.settingsService.token
|
|
463
463
|
});
|
|
464
|
+
if (savePaymentMethod) {
|
|
465
|
+
enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
466
|
+
isSavePaymentAccount: "1" /* XpsBoolean.true */
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return enrichedUrl;
|
|
464
470
|
}
|
|
465
471
|
}
|
|
466
472
|
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 });
|
|
@@ -468,7 +474,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
|
|
|
468
474
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
469
475
|
type: Injectable,
|
|
470
476
|
args: [{
|
|
471
|
-
providedIn: 'root'
|
|
477
|
+
providedIn: 'root'
|
|
472
478
|
}]
|
|
473
479
|
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
474
480
|
|
|
@@ -782,15 +788,143 @@ const checkStatusActionFactoryProvider = {
|
|
|
782
788
|
},
|
|
783
789
|
};
|
|
784
790
|
|
|
791
|
+
class TerminalError extends AppError {
|
|
792
|
+
constructor(message, code) {
|
|
793
|
+
super(message);
|
|
794
|
+
this.code = code;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
var StatusGroups;
|
|
799
|
+
(function (StatusGroups) {
|
|
800
|
+
StatusGroups["troubled"] = "troubled";
|
|
801
|
+
StatusGroups["done"] = "done";
|
|
802
|
+
StatusGroups["invoice"] = "invoice";
|
|
803
|
+
})(StatusGroups || (StatusGroups = {}));
|
|
804
|
+
|
|
805
|
+
var StatusEnum;
|
|
806
|
+
(function (StatusEnum) {
|
|
807
|
+
StatusEnum["created"] = "created";
|
|
808
|
+
StatusEnum["awaiting"] = "awaiting";
|
|
809
|
+
StatusEnum["processing"] = "processing";
|
|
810
|
+
StatusEnum["authorized"] = "authorized";
|
|
811
|
+
StatusEnum["held"] = "held";
|
|
812
|
+
StatusEnum["done"] = "done";
|
|
813
|
+
StatusEnum["error"] = "error";
|
|
814
|
+
StatusEnum["canceled"] = "canceled";
|
|
815
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
816
|
+
|
|
817
|
+
class StatusResponse {
|
|
818
|
+
constructor(parameters) {
|
|
819
|
+
if (parameters.errors?.[0]) {
|
|
820
|
+
this.error = {
|
|
821
|
+
code: parameters.errors[0].code.toString(),
|
|
822
|
+
message: parameters.errors[0].message,
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
if (!parameters.status) {
|
|
826
|
+
throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
|
|
827
|
+
}
|
|
828
|
+
this.status = {
|
|
829
|
+
statusState: parameters.status.statusData.stateText,
|
|
830
|
+
email: parameters.status.statusData.email,
|
|
831
|
+
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
832
|
+
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
833
|
+
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
834
|
+
financeInfo: parameters.status.text.info,
|
|
835
|
+
discount: parameters.status.text.info.discount
|
|
836
|
+
? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
|
|
837
|
+
: null,
|
|
838
|
+
isCancelUser: parameters.status.isCancelUser,
|
|
839
|
+
postMessageStatus: parameters.status.isCancelUser
|
|
840
|
+
? StatusGroups.troubled
|
|
841
|
+
: parameters.status.group,
|
|
842
|
+
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
843
|
+
backUrlSettings: {
|
|
844
|
+
backUrl: parameters.status.text.backurl,
|
|
845
|
+
backUrlAction: parameters.status.text.backurl_action,
|
|
846
|
+
backUrlCaption: parameters.status.text.backurl_caption,
|
|
847
|
+
returnRegion: parameters.status.return_region,
|
|
848
|
+
},
|
|
849
|
+
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
850
|
+
group: parameters.status.group,
|
|
851
|
+
needToCheck: parameters.status.needToCheck,
|
|
852
|
+
autoRedirect: parameters.status.autoredirect,
|
|
853
|
+
statusMessage: parameters.status.text.state,
|
|
854
|
+
userId: parameters.status.statusData.v1,
|
|
855
|
+
invoice: parameters.status.statusData.invoice,
|
|
856
|
+
pid: parameters.status.statusData.pid,
|
|
857
|
+
projectAmount: this.getProjectAmount(parameters.status),
|
|
858
|
+
titleClass: parameters.status.title_class,
|
|
859
|
+
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
860
|
+
order: parameters.status.text.order,
|
|
861
|
+
};
|
|
862
|
+
if (parameters.form) {
|
|
863
|
+
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
864
|
+
}
|
|
865
|
+
if (this.status.statusState === StatusEnum.done ||
|
|
866
|
+
this.status.statusState === StatusEnum.authorized) {
|
|
867
|
+
this.status.isSuccess = true;
|
|
868
|
+
}
|
|
869
|
+
if (this.status.statusState === StatusEnum.canceled ||
|
|
870
|
+
this.status.isCancelUser) {
|
|
871
|
+
this.status.isCanceled = true;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
getUserReturnStatus(form) {
|
|
875
|
+
const value = form['fix_userReturnStatus']?.value;
|
|
876
|
+
if (value === 'undefined')
|
|
877
|
+
return undefined;
|
|
878
|
+
return value;
|
|
879
|
+
}
|
|
880
|
+
getProjectAmount(status) {
|
|
881
|
+
if (!status.statusData.projectAmount) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
885
|
+
return {
|
|
886
|
+
amount,
|
|
887
|
+
currency,
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
getAdditionalBackButton(status) {
|
|
891
|
+
if (!status.text.is_additional_back_url_enabled) {
|
|
892
|
+
return {
|
|
893
|
+
link: '',
|
|
894
|
+
action: '',
|
|
895
|
+
label: '',
|
|
896
|
+
region: '',
|
|
897
|
+
isEnabled: false,
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
return {
|
|
901
|
+
link: status.text.additional_back_url_link ?? '',
|
|
902
|
+
action: status.text.additional_back_url_action ?? '',
|
|
903
|
+
label: status.text.additional_back_url_label ?? '',
|
|
904
|
+
region: status.additional_button_return_region ?? '',
|
|
905
|
+
isEnabled: status.text.is_additional_back_url_enabled,
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
785
910
|
class StatusUpdatedAction {
|
|
786
|
-
constructor(statusResponse) {
|
|
911
|
+
constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
|
|
787
912
|
this.type = 'status_updated';
|
|
913
|
+
let status;
|
|
914
|
+
if (statusResponse instanceof StatusResponse) {
|
|
915
|
+
status = statusResponse.status;
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
status = statusResponse;
|
|
919
|
+
}
|
|
788
920
|
this.data = {
|
|
789
|
-
statusState:
|
|
790
|
-
invoice:
|
|
791
|
-
isSuccess:
|
|
792
|
-
isCanceled:
|
|
793
|
-
group:
|
|
921
|
+
statusState: status.statusState,
|
|
922
|
+
invoice: status.invoice,
|
|
923
|
+
isSuccess: status.isSuccess,
|
|
924
|
+
isCanceled: status.isCanceled,
|
|
925
|
+
group: status.group,
|
|
926
|
+
isSavePaymentMethodMode,
|
|
927
|
+
savePaymentMethodStatus
|
|
794
928
|
};
|
|
795
929
|
}
|
|
796
930
|
}
|
|
@@ -1468,7 +1602,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
|
|
|
1468
1602
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1469
1603
|
type: Injectable,
|
|
1470
1604
|
args: [{
|
|
1471
|
-
providedIn: 'root'
|
|
1605
|
+
providedIn: 'root'
|
|
1472
1606
|
}]
|
|
1473
1607
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1474
1608
|
type: Inject,
|
|
@@ -2826,6 +2960,7 @@ var StatusSearchParam;
|
|
|
2826
2960
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2827
2961
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2828
2962
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
2963
|
+
StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
|
|
2829
2964
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2830
2965
|
|
|
2831
2966
|
const requiredStatusSearchParams = [
|
|
@@ -2905,15 +3040,15 @@ const statusSearchParamsMap = new Map([
|
|
|
2905
3040
|
converter: numberConverter,
|
|
2906
3041
|
},
|
|
2907
3042
|
],
|
|
3043
|
+
[
|
|
3044
|
+
StatusSearchParam.isSavePaymentAccount,
|
|
3045
|
+
{
|
|
3046
|
+
key: 'isSavePaymentAccount',
|
|
3047
|
+
converter: numberConverter,
|
|
3048
|
+
},
|
|
3049
|
+
],
|
|
2908
3050
|
]);
|
|
2909
3051
|
|
|
2910
|
-
class TerminalError extends AppError {
|
|
2911
|
-
constructor(message, code) {
|
|
2912
|
-
super(message);
|
|
2913
|
-
this.code = code;
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
3052
|
class XpsApiPart {
|
|
2918
3053
|
constructor() {
|
|
2919
3054
|
this.response = new BehaviorSubject(null);
|
|
@@ -2957,118 +3092,6 @@ const statusRequestFactoryProvider = {
|
|
|
2957
3092
|
useValue: (...args) => new StatusRequest(...args),
|
|
2958
3093
|
};
|
|
2959
3094
|
|
|
2960
|
-
var StatusGroups;
|
|
2961
|
-
(function (StatusGroups) {
|
|
2962
|
-
StatusGroups["troubled"] = "troubled";
|
|
2963
|
-
StatusGroups["done"] = "done";
|
|
2964
|
-
StatusGroups["invoice"] = "invoice";
|
|
2965
|
-
})(StatusGroups || (StatusGroups = {}));
|
|
2966
|
-
|
|
2967
|
-
var StatusEnum;
|
|
2968
|
-
(function (StatusEnum) {
|
|
2969
|
-
StatusEnum["created"] = "created";
|
|
2970
|
-
StatusEnum["awaiting"] = "awaiting";
|
|
2971
|
-
StatusEnum["processing"] = "processing";
|
|
2972
|
-
StatusEnum["authorized"] = "authorized";
|
|
2973
|
-
StatusEnum["held"] = "held";
|
|
2974
|
-
StatusEnum["done"] = "done";
|
|
2975
|
-
StatusEnum["error"] = "error";
|
|
2976
|
-
StatusEnum["canceled"] = "canceled";
|
|
2977
|
-
})(StatusEnum || (StatusEnum = {}));
|
|
2978
|
-
|
|
2979
|
-
class StatusResponse {
|
|
2980
|
-
constructor(parameters) {
|
|
2981
|
-
if (parameters.errors?.[0]) {
|
|
2982
|
-
this.error = {
|
|
2983
|
-
code: parameters.errors[0].code.toString(),
|
|
2984
|
-
message: parameters.errors[0].message,
|
|
2985
|
-
};
|
|
2986
|
-
}
|
|
2987
|
-
if (!parameters.status) {
|
|
2988
|
-
throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
|
|
2989
|
-
}
|
|
2990
|
-
this.status = {
|
|
2991
|
-
statusState: parameters.status.statusData.stateText,
|
|
2992
|
-
email: parameters.status.statusData.email,
|
|
2993
|
-
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
2994
|
-
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
2995
|
-
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
2996
|
-
financeInfo: parameters.status.text.info,
|
|
2997
|
-
discount: parameters.status.text.info.discount
|
|
2998
|
-
? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
|
|
2999
|
-
: null,
|
|
3000
|
-
isCancelUser: parameters.status.isCancelUser,
|
|
3001
|
-
postMessageStatus: parameters.status.isCancelUser
|
|
3002
|
-
? StatusGroups.troubled
|
|
3003
|
-
: parameters.status.group,
|
|
3004
|
-
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
3005
|
-
backUrlSettings: {
|
|
3006
|
-
backUrl: parameters.status.text.backurl,
|
|
3007
|
-
backUrlAction: parameters.status.text.backurl_action,
|
|
3008
|
-
backUrlCaption: parameters.status.text.backurl_caption,
|
|
3009
|
-
returnRegion: parameters.status.return_region,
|
|
3010
|
-
},
|
|
3011
|
-
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
3012
|
-
group: parameters.status.group,
|
|
3013
|
-
needToCheck: parameters.status.needToCheck,
|
|
3014
|
-
autoRedirect: parameters.status.autoredirect,
|
|
3015
|
-
statusMessage: parameters.status.text.state,
|
|
3016
|
-
userId: parameters.status.statusData.v1,
|
|
3017
|
-
invoice: parameters.status.statusData.invoice,
|
|
3018
|
-
pid: parameters.status.statusData.pid,
|
|
3019
|
-
projectAmount: this.getProjectAmount(parameters.status),
|
|
3020
|
-
titleClass: parameters.status.title_class,
|
|
3021
|
-
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
3022
|
-
order: parameters.status.text.order,
|
|
3023
|
-
};
|
|
3024
|
-
if (parameters.form) {
|
|
3025
|
-
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
3026
|
-
}
|
|
3027
|
-
if (this.status.statusState === StatusEnum.done ||
|
|
3028
|
-
this.status.statusState === StatusEnum.authorized) {
|
|
3029
|
-
this.status.isSuccess = true;
|
|
3030
|
-
}
|
|
3031
|
-
if (this.status.statusState === StatusEnum.canceled ||
|
|
3032
|
-
this.status.isCancelUser) {
|
|
3033
|
-
this.status.isCanceled = true;
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
getUserReturnStatus(form) {
|
|
3037
|
-
const value = form['fix_userReturnStatus']?.value;
|
|
3038
|
-
if (value === 'undefined')
|
|
3039
|
-
return undefined;
|
|
3040
|
-
return value;
|
|
3041
|
-
}
|
|
3042
|
-
getProjectAmount(status) {
|
|
3043
|
-
if (!status.statusData.projectAmount) {
|
|
3044
|
-
return;
|
|
3045
|
-
}
|
|
3046
|
-
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
3047
|
-
return {
|
|
3048
|
-
amount,
|
|
3049
|
-
currency,
|
|
3050
|
-
};
|
|
3051
|
-
}
|
|
3052
|
-
getAdditionalBackButton(status) {
|
|
3053
|
-
if (!status.text.is_additional_back_url_enabled) {
|
|
3054
|
-
return {
|
|
3055
|
-
link: '',
|
|
3056
|
-
action: '',
|
|
3057
|
-
label: '',
|
|
3058
|
-
region: '',
|
|
3059
|
-
isEnabled: false,
|
|
3060
|
-
};
|
|
3061
|
-
}
|
|
3062
|
-
return {
|
|
3063
|
-
link: status.text.additional_back_url_link ?? '',
|
|
3064
|
-
action: status.text.additional_back_url_action ?? '',
|
|
3065
|
-
label: status.text.additional_back_url_label ?? '',
|
|
3066
|
-
region: status.additional_button_return_region ?? '',
|
|
3067
|
-
isEnabled: status.text.is_additional_back_url_enabled,
|
|
3068
|
-
};
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
|
|
3072
3095
|
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
3073
3096
|
const statusResponseFactoryProvider = {
|
|
3074
3097
|
provide: statusResponseFactoryToken,
|
|
@@ -4545,15 +4568,263 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4545
4568
|
}]
|
|
4546
4569
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
4547
4570
|
|
|
4571
|
+
var TitleClass;
|
|
4572
|
+
(function (TitleClass) {
|
|
4573
|
+
TitleClass["done"] = "done";
|
|
4574
|
+
TitleClass["cancel"] = "cancel";
|
|
4575
|
+
TitleClass["cancelUser"] = "canceluser";
|
|
4576
|
+
})(TitleClass || (TitleClass = {}));
|
|
4577
|
+
|
|
4578
|
+
var SavePaymentMethodStatus;
|
|
4579
|
+
(function (SavePaymentMethodStatus) {
|
|
4580
|
+
SavePaymentMethodStatus["success"] = "success";
|
|
4581
|
+
SavePaymentMethodStatus["failed"] = "failed";
|
|
4582
|
+
})(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
|
|
4583
|
+
|
|
4584
|
+
class XpsResponseError extends AppError {
|
|
4585
|
+
constructor(message) {
|
|
4586
|
+
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
class SavedPaymentAccountChangesService {
|
|
4591
|
+
constructor(settingsService, secureApi) {
|
|
4592
|
+
this.settingsService = settingsService;
|
|
4593
|
+
this.secureApi = secureApi;
|
|
4594
|
+
this.apiRoute = 'savedmethods/newaccountinfo';
|
|
4595
|
+
this.response = new Subject();
|
|
4596
|
+
}
|
|
4597
|
+
get response$() {
|
|
4598
|
+
return this.response.asObservable();
|
|
4599
|
+
}
|
|
4600
|
+
async request(invoice) {
|
|
4601
|
+
const requestParameters = {
|
|
4602
|
+
access_token: this.settingsService.token,
|
|
4603
|
+
invoice_id: invoice,
|
|
4604
|
+
};
|
|
4605
|
+
return lastValueFrom(this.secureApi
|
|
4606
|
+
.post(this.apiRoute, new URLSearchParams(requestParameters), {
|
|
4607
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
4608
|
+
responseType: 'json',
|
|
4609
|
+
})
|
|
4610
|
+
.pipe(tap((value) => {
|
|
4611
|
+
this.response.next(value);
|
|
4612
|
+
}))).catch((error) => {
|
|
4613
|
+
throw new XpsResponseError(error.message);
|
|
4614
|
+
});
|
|
4615
|
+
}
|
|
4616
|
+
}
|
|
4617
|
+
SavedPaymentAccountChangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, deps: [{ token: SettingsService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4618
|
+
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
|
|
4619
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4620
|
+
type: Injectable,
|
|
4621
|
+
args: [{
|
|
4622
|
+
providedIn: 'root'
|
|
4623
|
+
}]
|
|
4624
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4625
|
+
|
|
4626
|
+
class SavePaymentMethodStatusService {
|
|
4627
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
|
|
4628
|
+
this.statusRequestService = statusRequestService;
|
|
4629
|
+
this.listenStatusService = listenStatusService;
|
|
4630
|
+
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4631
|
+
this.nextActionService = nextActionService;
|
|
4632
|
+
this.checkStatusService = checkStatusService;
|
|
4633
|
+
this.statusChecked = false;
|
|
4634
|
+
}
|
|
4635
|
+
async getStatus(params) {
|
|
4636
|
+
this.statusRequestService.setRequestParams(params);
|
|
4637
|
+
this.statusRequestService.request();
|
|
4638
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4639
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4640
|
+
const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4641
|
+
if (this.savingFailedOrCancel(statusResponse?.status) || this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4642
|
+
return statusResponse.status;
|
|
4643
|
+
}
|
|
4644
|
+
if (!this.statusChecked) {
|
|
4645
|
+
this.checkStatus(params);
|
|
4646
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4647
|
+
return statusResponse.status;
|
|
4648
|
+
}
|
|
4649
|
+
statusResponse.status.statusState = StatusEnum.error;
|
|
4650
|
+
return statusResponse.status;
|
|
4651
|
+
}
|
|
4652
|
+
checkStatus(params) {
|
|
4653
|
+
if (!this.statusChecked) {
|
|
4654
|
+
this.statusChecked = true;
|
|
4655
|
+
}
|
|
4656
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4657
|
+
// this.statusRequestService.request();
|
|
4658
|
+
}
|
|
4659
|
+
async getStatusOld(params) {
|
|
4660
|
+
console.log('getStatus', params);
|
|
4661
|
+
this.statusRequestService.setRequestParams(params);
|
|
4662
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4663
|
+
this.statusRequestService.request();
|
|
4664
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4665
|
+
this.checkStatusService.setRequestParams(params.invoice);
|
|
4666
|
+
this.checkStatusService.request();
|
|
4667
|
+
const checkStatusResponse = await firstValueFrom(this.checkStatusService.response$);
|
|
4668
|
+
if (!checkStatusResponse.final) {
|
|
4669
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4670
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4671
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4672
|
+
return statusResponse.status;
|
|
4673
|
+
}
|
|
4674
|
+
// todo: get account
|
|
4675
|
+
const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4676
|
+
if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4677
|
+
// todo is proccessing
|
|
4678
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4679
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4680
|
+
}
|
|
4681
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4682
|
+
return statusResponse.status;
|
|
4683
|
+
// this.listenStatusService.listen(params.invoice);
|
|
4684
|
+
// this.statusRequestService.request();
|
|
4685
|
+
// const paramsCheck = {
|
|
4686
|
+
// section: 'getstatus',
|
|
4687
|
+
// action: 'getstatus',
|
|
4688
|
+
// // invoice: params.invoice,
|
|
4689
|
+
// ...params,
|
|
4690
|
+
// access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
|
|
4691
|
+
// };
|
|
4692
|
+
// // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
|
|
4693
|
+
// // console.log('requestPromise', check);
|
|
4694
|
+
// // todo: get account
|
|
4695
|
+
// // const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4696
|
+
// // this.startWaitingStatusUpdates(params.invoice);
|
|
4697
|
+
// // this.listenStatusService.statusUpdated$
|
|
4698
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4699
|
+
// this.statusRequestService.request();
|
|
4700
|
+
// this.checkStatusService.setRequestParams(params.invoice);
|
|
4701
|
+
// this.checkStatusService.request();
|
|
4702
|
+
// this.checkStatusService.response$.subscribe((resp) => {
|
|
4703
|
+
// console.log('checkSt', resp);
|
|
4704
|
+
// });
|
|
4705
|
+
// const statusResponse = await firstValueFrom(
|
|
4706
|
+
// this.statusRequestService.response$
|
|
4707
|
+
// );
|
|
4708
|
+
// const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
|
|
4709
|
+
// const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
|
|
4710
|
+
// if (!accountData) {
|
|
4711
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4712
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4713
|
+
// }
|
|
4714
|
+
// if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4715
|
+
// // todo is proccessing
|
|
4716
|
+
//
|
|
4717
|
+
// // this.startWaitingStatusUpdates(params.invoice);
|
|
4718
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4719
|
+
// }
|
|
4720
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4721
|
+
// return statusResponse.status;
|
|
4722
|
+
// return null;
|
|
4723
|
+
// if (!this.savePaymentMethodStatus) {
|
|
4724
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4725
|
+
// }
|
|
4726
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4727
|
+
// return statusResponse.status;
|
|
4728
|
+
}
|
|
4729
|
+
savingFailedOrCancel(status) {
|
|
4730
|
+
return status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4731
|
+
}
|
|
4732
|
+
savingSuccessful(accountData, status, checkStatus) {
|
|
4733
|
+
return !!(status?.titleClass === TitleClass.done && (accountData?.new_account || checkStatus?.isPaymentAccountAttached));
|
|
4734
|
+
}
|
|
4735
|
+
getPaymentAccountData(invoice) {
|
|
4736
|
+
return this.savedPaymentAccountChangesService
|
|
4737
|
+
.request(invoice);
|
|
4738
|
+
// .then((accountChanges: SavedPaymentAccountChanges) => {
|
|
4739
|
+
// if (accountChanges) {
|
|
4740
|
+
// this.handleSavingStatus(status, accountChanges.new_account);
|
|
4741
|
+
// }
|
|
4742
|
+
// });
|
|
4743
|
+
}
|
|
4744
|
+
startWaitingStatusUpdates(invoice) {
|
|
4745
|
+
if (this.listenStatusSubscription) {
|
|
4746
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4747
|
+
this.listenStatusService.stopListening();
|
|
4748
|
+
}
|
|
4749
|
+
// debugger
|
|
4750
|
+
this.listenStatusService.listen(invoice);
|
|
4751
|
+
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4752
|
+
.subscribe((statusSettings) => {
|
|
4753
|
+
// this.checkStatusService.response$.subscribe((res) => {
|
|
4754
|
+
// if (res.final) {
|
|
4755
|
+
// if (statusSettings?.statusResponse.status) {
|
|
4756
|
+
// this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
|
|
4757
|
+
// }
|
|
4758
|
+
// }
|
|
4759
|
+
// });
|
|
4760
|
+
void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
|
|
4761
|
+
if (checkStatusResponse.final && statusSettings?.statusResponse.status) {
|
|
4762
|
+
this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, checkStatusResponse);
|
|
4763
|
+
}
|
|
4764
|
+
});
|
|
4765
|
+
// this.checkStatusService.request();
|
|
4766
|
+
// const checkStatusResponse = await firstValueFrom(
|
|
4767
|
+
// this.checkStatusService.response$
|
|
4768
|
+
// );
|
|
4769
|
+
});
|
|
4770
|
+
// this.statusRequestService.request();
|
|
4771
|
+
}
|
|
4772
|
+
loadNewPaymentAccountData(status, checkStatus) {
|
|
4773
|
+
if (!status.invoice) {
|
|
4774
|
+
return;
|
|
4775
|
+
}
|
|
4776
|
+
void this.savedPaymentAccountChangesService
|
|
4777
|
+
.request(status.invoice)
|
|
4778
|
+
.then((accountChanges) => {
|
|
4779
|
+
if (accountChanges) {
|
|
4780
|
+
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4781
|
+
}
|
|
4782
|
+
});
|
|
4783
|
+
}
|
|
4784
|
+
handleSavingStatus(status, account, checkStatus) {
|
|
4785
|
+
// const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4786
|
+
//
|
|
4787
|
+
// const savingSuccessful = status?.titleClass === TitleClass.done && account;
|
|
4788
|
+
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4789
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4790
|
+
}
|
|
4791
|
+
else {
|
|
4792
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
|
|
4793
|
+
}
|
|
4794
|
+
this.listenStatusService.stopListening();
|
|
4795
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4796
|
+
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4797
|
+
const isSavePaymentMethod = true;
|
|
4798
|
+
// this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4799
|
+
console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
|
|
4800
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
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 });
|
|
4804
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4805
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4806
|
+
type: Injectable,
|
|
4807
|
+
args: [{
|
|
4808
|
+
providedIn: 'root'
|
|
4809
|
+
}]
|
|
4810
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4811
|
+
|
|
4548
4812
|
class StatusService {
|
|
4549
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4813
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4550
4814
|
this.urlService = urlService;
|
|
4551
4815
|
this.statusRequestService = statusRequestService;
|
|
4552
4816
|
this.financeDetailsService = financeDetailsService;
|
|
4553
4817
|
this.listenStatusService = listenStatusService;
|
|
4554
4818
|
this.nextActionService = nextActionService;
|
|
4819
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4555
4820
|
}
|
|
4556
4821
|
async getStatus(params) {
|
|
4822
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4823
|
+
// account status
|
|
4824
|
+
const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
|
|
4825
|
+
if (isSavePaymentMethodMode) {
|
|
4826
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4827
|
+
}
|
|
4557
4828
|
this.statusRequestService.setRequestParams(params);
|
|
4558
4829
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4559
4830
|
this.statusRequestService.request();
|
|
@@ -4563,6 +4834,7 @@ class StatusService {
|
|
|
4563
4834
|
}
|
|
4564
4835
|
async getStatusWithUrlSearchParams(url) {
|
|
4565
4836
|
const searchParams = this.getRequestParamsFromUrl(url);
|
|
4837
|
+
console.log('searchParams', searchParams);
|
|
4566
4838
|
if (!searchParams) {
|
|
4567
4839
|
throw new Error('No required search params to get status');
|
|
4568
4840
|
}
|
|
@@ -4590,14 +4862,14 @@ class StatusService {
|
|
|
4590
4862
|
});
|
|
4591
4863
|
}
|
|
4592
4864
|
}
|
|
4593
|
-
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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4865
|
+
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 });
|
|
4594
4866
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4595
4867
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4596
4868
|
type: Injectable,
|
|
4597
4869
|
args: [{
|
|
4598
4870
|
providedIn: 'root',
|
|
4599
4871
|
}]
|
|
4600
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4872
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4601
4873
|
|
|
4602
4874
|
class CreditCardStateService extends EmitDataService {
|
|
4603
4875
|
}
|
|
@@ -4622,12 +4894,6 @@ var ThreeDsStatusTypes;
|
|
|
4622
4894
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4623
4895
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4624
4896
|
|
|
4625
|
-
class XpsResponseError extends AppError {
|
|
4626
|
-
constructor(message) {
|
|
4627
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4628
|
-
}
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
4897
|
class StatusThreeDsRequest {
|
|
4632
4898
|
constructor(token, threeDsId) {
|
|
4633
4899
|
this.access_token = token;
|
|
@@ -5075,6 +5341,7 @@ class PaymentService {
|
|
|
5075
5341
|
this.destroy$ = new Subject();
|
|
5076
5342
|
this.formDestroy$ = new Subject();
|
|
5077
5343
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5344
|
+
this.isSavingMethodMode = false;
|
|
5078
5345
|
}
|
|
5079
5346
|
async initialize(config) {
|
|
5080
5347
|
this.destroy$ = new Subject();
|
|
@@ -5100,9 +5367,14 @@ class PaymentService {
|
|
|
5100
5367
|
this.emitFormFieldsStatus(this.form);
|
|
5101
5368
|
return;
|
|
5102
5369
|
}
|
|
5370
|
+
console.log('this.fields', this.fields);
|
|
5371
|
+
console.log('this.form', this.form);
|
|
5372
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5103
5373
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5104
5374
|
this.data = submitResponse;
|
|
5105
|
-
this.
|
|
5375
|
+
if (!this.isSavingMethodMode) {
|
|
5376
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5377
|
+
}
|
|
5106
5378
|
this.emitFormMessages(submitResponse.messages);
|
|
5107
5379
|
// Handle 3ds flow
|
|
5108
5380
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5151,7 +5423,10 @@ class PaymentService {
|
|
|
5151
5423
|
signature: this.data.signature ?? '',
|
|
5152
5424
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5153
5425
|
'en',
|
|
5426
|
+
isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
|
|
5154
5427
|
};
|
|
5428
|
+
console.log('this.data', this.data);
|
|
5429
|
+
console.log('getStatus', params);
|
|
5155
5430
|
return this.statusService.getStatus(params);
|
|
5156
5431
|
}
|
|
5157
5432
|
getFieldConfig(field) {
|