@xsolla/payment-client-core 0.1.14-test → 0.1.14-test11
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-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +8 -3
- package/esm2020/lib/core/payment/payment-config.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 +72 -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 +304 -145
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +297 -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/initialize/initialize-request-params.interface.d.ts +4 -0
- package/lib/core/payment/payment-config.interface.d.ts +3 -0
- package/lib/core/payment/payment.service.d.ts +1 -0
- 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 +22 -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 +3 -1
- package/lib/core/payment-methods/payment-methods.service.d.ts +1 -1
- package/lib/core-library.service.d.ts +1 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test11.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test.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
|
}
|
|
@@ -1432,6 +1566,11 @@ class InitializeService {
|
|
|
1432
1566
|
refer: this.ps4ReferId,
|
|
1433
1567
|
country: this.countryService.getCountry(),
|
|
1434
1568
|
returnUrl: config.returnUrl,
|
|
1569
|
+
paymentWithSavedMethod: config.paymentWithSavedMethod === true
|
|
1570
|
+
? "1" /* XpsBoolean.true */
|
|
1571
|
+
: "0" /* XpsBoolean.false */,
|
|
1572
|
+
saved_method_id: config.savedMethodId,
|
|
1573
|
+
save_payment_account_only: !!config.savePaymentMethod ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
|
|
1435
1574
|
};
|
|
1436
1575
|
return this.xpsApiService
|
|
1437
1576
|
.directPaymentRequest(requestParams)
|
|
@@ -1463,7 +1602,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
|
|
|
1463
1602
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1464
1603
|
type: Injectable,
|
|
1465
1604
|
args: [{
|
|
1466
|
-
providedIn: 'root'
|
|
1605
|
+
providedIn: 'root'
|
|
1467
1606
|
}]
|
|
1468
1607
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1469
1608
|
type: Inject,
|
|
@@ -2821,6 +2960,7 @@ var StatusSearchParam;
|
|
|
2821
2960
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2822
2961
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2823
2962
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
2963
|
+
StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
|
|
2824
2964
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2825
2965
|
|
|
2826
2966
|
const requiredStatusSearchParams = [
|
|
@@ -2900,15 +3040,15 @@ const statusSearchParamsMap = new Map([
|
|
|
2900
3040
|
converter: numberConverter,
|
|
2901
3041
|
},
|
|
2902
3042
|
],
|
|
3043
|
+
[
|
|
3044
|
+
StatusSearchParam.isSavePaymentAccount,
|
|
3045
|
+
{
|
|
3046
|
+
key: 'isSavePaymentAccount',
|
|
3047
|
+
converter: numberConverter,
|
|
3048
|
+
},
|
|
3049
|
+
],
|
|
2903
3050
|
]);
|
|
2904
3051
|
|
|
2905
|
-
class TerminalError extends AppError {
|
|
2906
|
-
constructor(message, code) {
|
|
2907
|
-
super(message);
|
|
2908
|
-
this.code = code;
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
|
|
2912
3052
|
class XpsApiPart {
|
|
2913
3053
|
constructor() {
|
|
2914
3054
|
this.response = new BehaviorSubject(null);
|
|
@@ -2952,118 +3092,6 @@ const statusRequestFactoryProvider = {
|
|
|
2952
3092
|
useValue: (...args) => new StatusRequest(...args),
|
|
2953
3093
|
};
|
|
2954
3094
|
|
|
2955
|
-
var StatusGroups;
|
|
2956
|
-
(function (StatusGroups) {
|
|
2957
|
-
StatusGroups["troubled"] = "troubled";
|
|
2958
|
-
StatusGroups["done"] = "done";
|
|
2959
|
-
StatusGroups["invoice"] = "invoice";
|
|
2960
|
-
})(StatusGroups || (StatusGroups = {}));
|
|
2961
|
-
|
|
2962
|
-
var StatusEnum;
|
|
2963
|
-
(function (StatusEnum) {
|
|
2964
|
-
StatusEnum["created"] = "created";
|
|
2965
|
-
StatusEnum["awaiting"] = "awaiting";
|
|
2966
|
-
StatusEnum["processing"] = "processing";
|
|
2967
|
-
StatusEnum["authorized"] = "authorized";
|
|
2968
|
-
StatusEnum["held"] = "held";
|
|
2969
|
-
StatusEnum["done"] = "done";
|
|
2970
|
-
StatusEnum["error"] = "error";
|
|
2971
|
-
StatusEnum["canceled"] = "canceled";
|
|
2972
|
-
})(StatusEnum || (StatusEnum = {}));
|
|
2973
|
-
|
|
2974
|
-
class StatusResponse {
|
|
2975
|
-
constructor(parameters) {
|
|
2976
|
-
if (parameters.errors?.[0]) {
|
|
2977
|
-
this.error = {
|
|
2978
|
-
code: parameters.errors[0].code.toString(),
|
|
2979
|
-
message: parameters.errors[0].message,
|
|
2980
|
-
};
|
|
2981
|
-
}
|
|
2982
|
-
if (!parameters.status) {
|
|
2983
|
-
throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
|
|
2984
|
-
}
|
|
2985
|
-
this.status = {
|
|
2986
|
-
statusState: parameters.status.statusData.stateText,
|
|
2987
|
-
email: parameters.status.statusData.email,
|
|
2988
|
-
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
2989
|
-
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
2990
|
-
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
2991
|
-
financeInfo: parameters.status.text.info,
|
|
2992
|
-
discount: parameters.status.text.info.discount
|
|
2993
|
-
? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
|
|
2994
|
-
: null,
|
|
2995
|
-
isCancelUser: parameters.status.isCancelUser,
|
|
2996
|
-
postMessageStatus: parameters.status.isCancelUser
|
|
2997
|
-
? StatusGroups.troubled
|
|
2998
|
-
: parameters.status.group,
|
|
2999
|
-
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
3000
|
-
backUrlSettings: {
|
|
3001
|
-
backUrl: parameters.status.text.backurl,
|
|
3002
|
-
backUrlAction: parameters.status.text.backurl_action,
|
|
3003
|
-
backUrlCaption: parameters.status.text.backurl_caption,
|
|
3004
|
-
returnRegion: parameters.status.return_region,
|
|
3005
|
-
},
|
|
3006
|
-
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
3007
|
-
group: parameters.status.group,
|
|
3008
|
-
needToCheck: parameters.status.needToCheck,
|
|
3009
|
-
autoRedirect: parameters.status.autoredirect,
|
|
3010
|
-
statusMessage: parameters.status.text.state,
|
|
3011
|
-
userId: parameters.status.statusData.v1,
|
|
3012
|
-
invoice: parameters.status.statusData.invoice,
|
|
3013
|
-
pid: parameters.status.statusData.pid,
|
|
3014
|
-
projectAmount: this.getProjectAmount(parameters.status),
|
|
3015
|
-
titleClass: parameters.status.title_class,
|
|
3016
|
-
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
3017
|
-
order: parameters.status.text.order,
|
|
3018
|
-
};
|
|
3019
|
-
if (parameters.form) {
|
|
3020
|
-
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
3021
|
-
}
|
|
3022
|
-
if (this.status.statusState === StatusEnum.done ||
|
|
3023
|
-
this.status.statusState === StatusEnum.authorized) {
|
|
3024
|
-
this.status.isSuccess = true;
|
|
3025
|
-
}
|
|
3026
|
-
if (this.status.statusState === StatusEnum.canceled ||
|
|
3027
|
-
this.status.isCancelUser) {
|
|
3028
|
-
this.status.isCanceled = true;
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
getUserReturnStatus(form) {
|
|
3032
|
-
const value = form['fix_userReturnStatus']?.value;
|
|
3033
|
-
if (value === 'undefined')
|
|
3034
|
-
return undefined;
|
|
3035
|
-
return value;
|
|
3036
|
-
}
|
|
3037
|
-
getProjectAmount(status) {
|
|
3038
|
-
if (!status.statusData.projectAmount) {
|
|
3039
|
-
return;
|
|
3040
|
-
}
|
|
3041
|
-
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
3042
|
-
return {
|
|
3043
|
-
amount,
|
|
3044
|
-
currency,
|
|
3045
|
-
};
|
|
3046
|
-
}
|
|
3047
|
-
getAdditionalBackButton(status) {
|
|
3048
|
-
if (!status.text.is_additional_back_url_enabled) {
|
|
3049
|
-
return {
|
|
3050
|
-
link: '',
|
|
3051
|
-
action: '',
|
|
3052
|
-
label: '',
|
|
3053
|
-
region: '',
|
|
3054
|
-
isEnabled: false,
|
|
3055
|
-
};
|
|
3056
|
-
}
|
|
3057
|
-
return {
|
|
3058
|
-
link: status.text.additional_back_url_link ?? '',
|
|
3059
|
-
action: status.text.additional_back_url_action ?? '',
|
|
3060
|
-
label: status.text.additional_back_url_label ?? '',
|
|
3061
|
-
region: status.additional_button_return_region ?? '',
|
|
3062
|
-
isEnabled: status.text.is_additional_back_url_enabled,
|
|
3063
|
-
};
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
|
|
3067
3095
|
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
3068
3096
|
const statusResponseFactoryProvider = {
|
|
3069
3097
|
provide: statusResponseFactoryToken,
|
|
@@ -4540,15 +4568,138 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4540
4568
|
}]
|
|
4541
4569
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
4542
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) {
|
|
4628
|
+
this.statusRequestService = statusRequestService;
|
|
4629
|
+
this.listenStatusService = listenStatusService;
|
|
4630
|
+
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4631
|
+
this.nextActionService = nextActionService;
|
|
4632
|
+
}
|
|
4633
|
+
async getStatus(params) {
|
|
4634
|
+
this.statusRequestService.setRequestParams(params);
|
|
4635
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4636
|
+
this.statusRequestService.request();
|
|
4637
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4638
|
+
if (!this.savePaymentMethodStatus) {
|
|
4639
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4640
|
+
}
|
|
4641
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4642
|
+
return statusResponse.status;
|
|
4643
|
+
}
|
|
4644
|
+
startWaitingStatusUpdates(invoice) {
|
|
4645
|
+
this.listenStatusService.listen(invoice);
|
|
4646
|
+
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4647
|
+
.subscribe(({ statusResponse }) => {
|
|
4648
|
+
if (statusResponse.status) {
|
|
4649
|
+
this.loadNewPaymentAccountData(statusResponse.status);
|
|
4650
|
+
}
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
loadNewPaymentAccountData(status) {
|
|
4654
|
+
if (!status.invoice) {
|
|
4655
|
+
return;
|
|
4656
|
+
}
|
|
4657
|
+
void this.savedPaymentAccountChangesService
|
|
4658
|
+
.request(status.invoice)
|
|
4659
|
+
.then((accountChanges) => {
|
|
4660
|
+
if (accountChanges) {
|
|
4661
|
+
this.handleSavingStatus(status, accountChanges.new_account);
|
|
4662
|
+
}
|
|
4663
|
+
});
|
|
4664
|
+
}
|
|
4665
|
+
handleSavingStatus(status, account) {
|
|
4666
|
+
this.listenStatusService.stopListening();
|
|
4667
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4668
|
+
const updatingIsProcessing = status?.titleClass !== TitleClass.cancel && status?.titleClass !== TitleClass.cancelUser && !account;
|
|
4669
|
+
if (updatingIsProcessing) {
|
|
4670
|
+
return;
|
|
4671
|
+
}
|
|
4672
|
+
const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4673
|
+
const isSavePaymentMethod = true;
|
|
4674
|
+
this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4675
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4679
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4680
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4681
|
+
type: Injectable,
|
|
4682
|
+
args: [{
|
|
4683
|
+
providedIn: 'root'
|
|
4684
|
+
}]
|
|
4685
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
|
|
4686
|
+
|
|
4543
4687
|
class StatusService {
|
|
4544
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4688
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4545
4689
|
this.urlService = urlService;
|
|
4546
4690
|
this.statusRequestService = statusRequestService;
|
|
4547
4691
|
this.financeDetailsService = financeDetailsService;
|
|
4548
4692
|
this.listenStatusService = listenStatusService;
|
|
4549
4693
|
this.nextActionService = nextActionService;
|
|
4694
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4550
4695
|
}
|
|
4551
4696
|
async getStatus(params) {
|
|
4697
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4698
|
+
// account status
|
|
4699
|
+
const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
|
|
4700
|
+
if (isSavePaymentMethodMode) {
|
|
4701
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4702
|
+
}
|
|
4552
4703
|
this.statusRequestService.setRequestParams(params);
|
|
4553
4704
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4554
4705
|
this.statusRequestService.request();
|
|
@@ -4558,6 +4709,7 @@ class StatusService {
|
|
|
4558
4709
|
}
|
|
4559
4710
|
async getStatusWithUrlSearchParams(url) {
|
|
4560
4711
|
const searchParams = this.getRequestParamsFromUrl(url);
|
|
4712
|
+
console.log('searchParams', searchParams);
|
|
4561
4713
|
if (!searchParams) {
|
|
4562
4714
|
throw new Error('No required search params to get status');
|
|
4563
4715
|
}
|
|
@@ -4585,14 +4737,14 @@ class StatusService {
|
|
|
4585
4737
|
});
|
|
4586
4738
|
}
|
|
4587
4739
|
}
|
|
4588
|
-
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 });
|
|
4740
|
+
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 });
|
|
4589
4741
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4590
4742
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4591
4743
|
type: Injectable,
|
|
4592
4744
|
args: [{
|
|
4593
4745
|
providedIn: 'root',
|
|
4594
4746
|
}]
|
|
4595
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4747
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4596
4748
|
|
|
4597
4749
|
class CreditCardStateService extends EmitDataService {
|
|
4598
4750
|
}
|
|
@@ -4617,12 +4769,6 @@ var ThreeDsStatusTypes;
|
|
|
4617
4769
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4618
4770
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4619
4771
|
|
|
4620
|
-
class XpsResponseError extends AppError {
|
|
4621
|
-
constructor(message) {
|
|
4622
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4623
|
-
}
|
|
4624
|
-
}
|
|
4625
|
-
|
|
4626
4772
|
class StatusThreeDsRequest {
|
|
4627
4773
|
constructor(token, threeDsId) {
|
|
4628
4774
|
this.access_token = token;
|
|
@@ -5070,6 +5216,7 @@ class PaymentService {
|
|
|
5070
5216
|
this.destroy$ = new Subject();
|
|
5071
5217
|
this.formDestroy$ = new Subject();
|
|
5072
5218
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5219
|
+
this.isSavingMethodMode = false;
|
|
5073
5220
|
}
|
|
5074
5221
|
async initialize(config) {
|
|
5075
5222
|
this.destroy$ = new Subject();
|
|
@@ -5095,9 +5242,14 @@ class PaymentService {
|
|
|
5095
5242
|
this.emitFormFieldsStatus(this.form);
|
|
5096
5243
|
return;
|
|
5097
5244
|
}
|
|
5245
|
+
console.log('this.fields', this.fields);
|
|
5246
|
+
console.log('this.form', this.form);
|
|
5247
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5098
5248
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5099
5249
|
this.data = submitResponse;
|
|
5100
|
-
this.
|
|
5250
|
+
if (!this.isSavingMethodMode) {
|
|
5251
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5252
|
+
}
|
|
5101
5253
|
this.emitFormMessages(submitResponse.messages);
|
|
5102
5254
|
// Handle 3ds flow
|
|
5103
5255
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5146,7 +5298,10 @@ class PaymentService {
|
|
|
5146
5298
|
signature: this.data.signature ?? '',
|
|
5147
5299
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5148
5300
|
'en',
|
|
5301
|
+
isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
|
|
5149
5302
|
};
|
|
5303
|
+
console.log('this.data', this.data);
|
|
5304
|
+
console.log('getStatus', params);
|
|
5150
5305
|
return this.statusService.getStatus(params);
|
|
5151
5306
|
}
|
|
5152
5307
|
getFieldConfig(field) {
|