@xsolla/payment-client-core 0.1.14-test2 → 0.1.14-test21
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 +203 -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 +431 -145
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +422 -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-test21.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,268 @@ 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
|
+
if (this.listenStatusSubscription) {
|
|
4637
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4638
|
+
this.listenStatusService.stopListening();
|
|
4639
|
+
}
|
|
4640
|
+
this.statusRequestService.setRequestParams(params);
|
|
4641
|
+
this.statusRequestService.request();
|
|
4642
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4643
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4644
|
+
// this.listenStatusService.stopListening();
|
|
4645
|
+
const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4646
|
+
if (this.savingFailedOrCancel(statusResponse?.status) || this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4647
|
+
return statusResponse.status;
|
|
4648
|
+
}
|
|
4649
|
+
if (!this.statusChecked) {
|
|
4650
|
+
this.checkStatus(params);
|
|
4651
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4652
|
+
return statusResponse.status;
|
|
4653
|
+
}
|
|
4654
|
+
statusResponse.status.statusState = StatusEnum.error;
|
|
4655
|
+
return statusResponse.status;
|
|
4656
|
+
}
|
|
4657
|
+
checkStatus(params) {
|
|
4658
|
+
if (!this.statusChecked) {
|
|
4659
|
+
this.statusChecked = true;
|
|
4660
|
+
}
|
|
4661
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4662
|
+
this.statusRequestService.request();
|
|
4663
|
+
}
|
|
4664
|
+
async getStatusOld(params) {
|
|
4665
|
+
console.log('getStatus', params);
|
|
4666
|
+
this.statusRequestService.setRequestParams(params);
|
|
4667
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4668
|
+
this.statusRequestService.request();
|
|
4669
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4670
|
+
this.checkStatusService.setRequestParams(params.invoice);
|
|
4671
|
+
this.checkStatusService.request();
|
|
4672
|
+
const checkStatusResponse = await firstValueFrom(this.checkStatusService.response$);
|
|
4673
|
+
if (!checkStatusResponse.final) {
|
|
4674
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4675
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4676
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4677
|
+
return statusResponse.status;
|
|
4678
|
+
}
|
|
4679
|
+
// todo: get account
|
|
4680
|
+
const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4681
|
+
if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4682
|
+
// todo is proccessing
|
|
4683
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4684
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4685
|
+
}
|
|
4686
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4687
|
+
return statusResponse.status;
|
|
4688
|
+
// this.listenStatusService.listen(params.invoice);
|
|
4689
|
+
// this.statusRequestService.request();
|
|
4690
|
+
// const paramsCheck = {
|
|
4691
|
+
// section: 'getstatus',
|
|
4692
|
+
// action: 'getstatus',
|
|
4693
|
+
// // invoice: params.invoice,
|
|
4694
|
+
// ...params,
|
|
4695
|
+
// access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
|
|
4696
|
+
// };
|
|
4697
|
+
// // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
|
|
4698
|
+
// // console.log('requestPromise', check);
|
|
4699
|
+
// // todo: get account
|
|
4700
|
+
// // const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4701
|
+
// // this.startWaitingStatusUpdates(params.invoice);
|
|
4702
|
+
// // this.listenStatusService.statusUpdated$
|
|
4703
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4704
|
+
// this.statusRequestService.request();
|
|
4705
|
+
// this.checkStatusService.setRequestParams(params.invoice);
|
|
4706
|
+
// this.checkStatusService.request();
|
|
4707
|
+
// this.checkStatusService.response$.subscribe((resp) => {
|
|
4708
|
+
// console.log('checkSt', resp);
|
|
4709
|
+
// });
|
|
4710
|
+
// const statusResponse = await firstValueFrom(
|
|
4711
|
+
// this.statusRequestService.response$
|
|
4712
|
+
// );
|
|
4713
|
+
// const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
|
|
4714
|
+
// const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
|
|
4715
|
+
// if (!accountData) {
|
|
4716
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4717
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4718
|
+
// }
|
|
4719
|
+
// if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4720
|
+
// // todo is proccessing
|
|
4721
|
+
//
|
|
4722
|
+
// // this.startWaitingStatusUpdates(params.invoice);
|
|
4723
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4724
|
+
// }
|
|
4725
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4726
|
+
// return statusResponse.status;
|
|
4727
|
+
// return null;
|
|
4728
|
+
// if (!this.savePaymentMethodStatus) {
|
|
4729
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4730
|
+
// }
|
|
4731
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4732
|
+
// return statusResponse.status;
|
|
4733
|
+
}
|
|
4734
|
+
savingFailedOrCancel(status) {
|
|
4735
|
+
return status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4736
|
+
}
|
|
4737
|
+
savingSuccessful(accountData, status, checkStatus) {
|
|
4738
|
+
return !!(status?.titleClass === TitleClass.done && (accountData?.new_account || checkStatus?.isPaymentAccountAttached));
|
|
4739
|
+
}
|
|
4740
|
+
getPaymentAccountData(invoice) {
|
|
4741
|
+
return this.savedPaymentAccountChangesService
|
|
4742
|
+
.request(invoice);
|
|
4743
|
+
// .then((accountChanges: SavedPaymentAccountChanges) => {
|
|
4744
|
+
// if (accountChanges) {
|
|
4745
|
+
// this.handleSavingStatus(status, accountChanges.new_account);
|
|
4746
|
+
// }
|
|
4747
|
+
// });
|
|
4748
|
+
}
|
|
4749
|
+
startWaitingStatusUpdates(invoice) {
|
|
4750
|
+
if (this.listenStatusSubscription) {
|
|
4751
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4752
|
+
this.listenStatusService.stopListening();
|
|
4753
|
+
}
|
|
4754
|
+
// debugger
|
|
4755
|
+
this.listenStatusService.listen(invoice);
|
|
4756
|
+
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4757
|
+
.subscribe((statusSettings) => {
|
|
4758
|
+
// this.checkStatusService.response$.subscribe((res) => {
|
|
4759
|
+
// if (res.final) {
|
|
4760
|
+
// if (statusSettings?.statusResponse.status) {
|
|
4761
|
+
// this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
|
|
4762
|
+
// }
|
|
4763
|
+
// }
|
|
4764
|
+
// });
|
|
4765
|
+
void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
|
|
4766
|
+
if (checkStatusResponse.final && statusSettings?.statusResponse.status) {
|
|
4767
|
+
this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, checkStatusResponse);
|
|
4768
|
+
}
|
|
4769
|
+
});
|
|
4770
|
+
// this.checkStatusService.request();
|
|
4771
|
+
// const checkStatusResponse = await firstValueFrom(
|
|
4772
|
+
// this.checkStatusService.response$
|
|
4773
|
+
// );
|
|
4774
|
+
});
|
|
4775
|
+
// this.statusRequestService.request();
|
|
4776
|
+
}
|
|
4777
|
+
loadNewPaymentAccountData(status, checkStatus) {
|
|
4778
|
+
if (!status.invoice) {
|
|
4779
|
+
return;
|
|
4780
|
+
}
|
|
4781
|
+
void this.savedPaymentAccountChangesService
|
|
4782
|
+
.request(status.invoice)
|
|
4783
|
+
.then((accountChanges) => {
|
|
4784
|
+
if (accountChanges) {
|
|
4785
|
+
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4786
|
+
}
|
|
4787
|
+
});
|
|
4788
|
+
}
|
|
4789
|
+
handleSavingStatus(status, account, checkStatus) {
|
|
4790
|
+
// const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4791
|
+
//
|
|
4792
|
+
// const savingSuccessful = status?.titleClass === TitleClass.done && account;
|
|
4793
|
+
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4794
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4795
|
+
}
|
|
4796
|
+
else {
|
|
4797
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
|
|
4798
|
+
}
|
|
4799
|
+
this.listenStatusService.stopListening();
|
|
4800
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4801
|
+
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4802
|
+
const isSavePaymentMethod = true;
|
|
4803
|
+
// this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4804
|
+
console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
|
|
4805
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
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 });
|
|
4809
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4810
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4811
|
+
type: Injectable,
|
|
4812
|
+
args: [{
|
|
4813
|
+
providedIn: 'root'
|
|
4814
|
+
}]
|
|
4815
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4816
|
+
|
|
4548
4817
|
class StatusService {
|
|
4549
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4818
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4550
4819
|
this.urlService = urlService;
|
|
4551
4820
|
this.statusRequestService = statusRequestService;
|
|
4552
4821
|
this.financeDetailsService = financeDetailsService;
|
|
4553
4822
|
this.listenStatusService = listenStatusService;
|
|
4554
4823
|
this.nextActionService = nextActionService;
|
|
4824
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4555
4825
|
}
|
|
4556
4826
|
async getStatus(params) {
|
|
4827
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4828
|
+
// account status
|
|
4829
|
+
const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
|
|
4830
|
+
if (isSavePaymentMethodMode) {
|
|
4831
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4832
|
+
}
|
|
4557
4833
|
this.statusRequestService.setRequestParams(params);
|
|
4558
4834
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4559
4835
|
this.statusRequestService.request();
|
|
@@ -4563,6 +4839,7 @@ class StatusService {
|
|
|
4563
4839
|
}
|
|
4564
4840
|
async getStatusWithUrlSearchParams(url) {
|
|
4565
4841
|
const searchParams = this.getRequestParamsFromUrl(url);
|
|
4842
|
+
console.log('searchParams', searchParams);
|
|
4566
4843
|
if (!searchParams) {
|
|
4567
4844
|
throw new Error('No required search params to get status');
|
|
4568
4845
|
}
|
|
@@ -4590,14 +4867,14 @@ class StatusService {
|
|
|
4590
4867
|
});
|
|
4591
4868
|
}
|
|
4592
4869
|
}
|
|
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 });
|
|
4870
|
+
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
4871
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4595
4872
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4596
4873
|
type: Injectable,
|
|
4597
4874
|
args: [{
|
|
4598
4875
|
providedIn: 'root',
|
|
4599
4876
|
}]
|
|
4600
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4877
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4601
4878
|
|
|
4602
4879
|
class CreditCardStateService extends EmitDataService {
|
|
4603
4880
|
}
|
|
@@ -4622,12 +4899,6 @@ var ThreeDsStatusTypes;
|
|
|
4622
4899
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4623
4900
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4624
4901
|
|
|
4625
|
-
class XpsResponseError extends AppError {
|
|
4626
|
-
constructor(message) {
|
|
4627
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4628
|
-
}
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
4902
|
class StatusThreeDsRequest {
|
|
4632
4903
|
constructor(token, threeDsId) {
|
|
4633
4904
|
this.access_token = token;
|
|
@@ -5075,6 +5346,7 @@ class PaymentService {
|
|
|
5075
5346
|
this.destroy$ = new Subject();
|
|
5076
5347
|
this.formDestroy$ = new Subject();
|
|
5077
5348
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5349
|
+
this.isSavingMethodMode = false;
|
|
5078
5350
|
}
|
|
5079
5351
|
async initialize(config) {
|
|
5080
5352
|
this.destroy$ = new Subject();
|
|
@@ -5100,9 +5372,14 @@ class PaymentService {
|
|
|
5100
5372
|
this.emitFormFieldsStatus(this.form);
|
|
5101
5373
|
return;
|
|
5102
5374
|
}
|
|
5375
|
+
console.log('this.fields', this.fields);
|
|
5376
|
+
console.log('this.form', this.form);
|
|
5377
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5103
5378
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5104
5379
|
this.data = submitResponse;
|
|
5105
|
-
this.
|
|
5380
|
+
if (!this.isSavingMethodMode) {
|
|
5381
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5382
|
+
}
|
|
5106
5383
|
this.emitFormMessages(submitResponse.messages);
|
|
5107
5384
|
// Handle 3ds flow
|
|
5108
5385
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5151,7 +5428,10 @@ class PaymentService {
|
|
|
5151
5428
|
signature: this.data.signature ?? '',
|
|
5152
5429
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5153
5430
|
'en',
|
|
5431
|
+
isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
|
|
5154
5432
|
};
|
|
5433
|
+
console.log('this.data', this.data);
|
|
5434
|
+
console.log('getStatus', params);
|
|
5155
5435
|
return this.statusService.getStatus(params);
|
|
5156
5436
|
}
|
|
5157
5437
|
getFieldConfig(field) {
|