@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
|
@@ -6,7 +6,7 @@ import * as i1 from '@angular/common/http';
|
|
|
6
6
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
7
7
|
import JSEncrypt from 'jsencrypt';
|
|
8
8
|
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
-
import { filter, map as map$1, catchError } from 'rxjs/operators';
|
|
9
|
+
import { filter, map as map$1, tap, catchError } from 'rxjs/operators';
|
|
10
10
|
import * as i1$1 from '@angular/router';
|
|
11
11
|
import { CommonModule } from '@angular/common';
|
|
12
12
|
|
|
@@ -479,12 +479,18 @@ class PaymentConfigService {
|
|
|
479
479
|
if (!config.returnUrl) {
|
|
480
480
|
throw new Error('URL is not provided in payment config');
|
|
481
481
|
}
|
|
482
|
-
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl) });
|
|
482
|
+
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod) });
|
|
483
483
|
}
|
|
484
|
-
enrichReturnUrl(returnUrl) {
|
|
485
|
-
|
|
486
|
-
token: this.settingsService.token
|
|
484
|
+
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
485
|
+
let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
486
|
+
token: this.settingsService.token
|
|
487
487
|
});
|
|
488
|
+
if (savePaymentMethod) {
|
|
489
|
+
enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
490
|
+
isSavePaymentAccount: "1" /* XpsBoolean.true */
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return enrichedUrl;
|
|
488
494
|
}
|
|
489
495
|
}
|
|
490
496
|
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 });
|
|
@@ -492,7 +498,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
|
|
|
492
498
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
493
499
|
type: Injectable,
|
|
494
500
|
args: [{
|
|
495
|
-
providedIn: 'root'
|
|
501
|
+
providedIn: 'root'
|
|
496
502
|
}]
|
|
497
503
|
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
498
504
|
|
|
@@ -806,15 +812,146 @@ const checkStatusActionFactoryProvider = {
|
|
|
806
812
|
},
|
|
807
813
|
};
|
|
808
814
|
|
|
815
|
+
class TerminalError extends AppError {
|
|
816
|
+
constructor(message, code) {
|
|
817
|
+
super(message);
|
|
818
|
+
this.code = code;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
var StatusGroups;
|
|
823
|
+
(function (StatusGroups) {
|
|
824
|
+
StatusGroups["troubled"] = "troubled";
|
|
825
|
+
StatusGroups["done"] = "done";
|
|
826
|
+
StatusGroups["invoice"] = "invoice";
|
|
827
|
+
})(StatusGroups || (StatusGroups = {}));
|
|
828
|
+
|
|
829
|
+
var StatusEnum;
|
|
830
|
+
(function (StatusEnum) {
|
|
831
|
+
StatusEnum["created"] = "created";
|
|
832
|
+
StatusEnum["awaiting"] = "awaiting";
|
|
833
|
+
StatusEnum["processing"] = "processing";
|
|
834
|
+
StatusEnum["authorized"] = "authorized";
|
|
835
|
+
StatusEnum["held"] = "held";
|
|
836
|
+
StatusEnum["done"] = "done";
|
|
837
|
+
StatusEnum["error"] = "error";
|
|
838
|
+
StatusEnum["canceled"] = "canceled";
|
|
839
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
840
|
+
|
|
841
|
+
class StatusResponse {
|
|
842
|
+
constructor(parameters) {
|
|
843
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
844
|
+
if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
845
|
+
this.error = {
|
|
846
|
+
code: parameters.errors[0].code.toString(),
|
|
847
|
+
message: parameters.errors[0].message,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
if (!parameters.status) {
|
|
851
|
+
throw new TerminalError((_c = (_b = this.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_e = (_d = this.error) === null || _d === void 0 ? void 0 : _d.code.toString()) !== null && _e !== void 0 ? _e : '');
|
|
852
|
+
}
|
|
853
|
+
this.status = {
|
|
854
|
+
statusState: parameters.status.statusData.stateText,
|
|
855
|
+
email: parameters.status.statusData.email,
|
|
856
|
+
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
857
|
+
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
858
|
+
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
859
|
+
financeInfo: parameters.status.text.info,
|
|
860
|
+
discount: parameters.status.text.info.discount
|
|
861
|
+
? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
|
|
862
|
+
: null,
|
|
863
|
+
isCancelUser: parameters.status.isCancelUser,
|
|
864
|
+
postMessageStatus: parameters.status.isCancelUser
|
|
865
|
+
? StatusGroups.troubled
|
|
866
|
+
: parameters.status.group,
|
|
867
|
+
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
868
|
+
backUrlSettings: {
|
|
869
|
+
backUrl: parameters.status.text.backurl,
|
|
870
|
+
backUrlAction: parameters.status.text.backurl_action,
|
|
871
|
+
backUrlCaption: parameters.status.text.backurl_caption,
|
|
872
|
+
returnRegion: parameters.status.return_region,
|
|
873
|
+
},
|
|
874
|
+
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
875
|
+
group: parameters.status.group,
|
|
876
|
+
needToCheck: parameters.status.needToCheck,
|
|
877
|
+
autoRedirect: parameters.status.autoredirect,
|
|
878
|
+
statusMessage: parameters.status.text.state,
|
|
879
|
+
userId: parameters.status.statusData.v1,
|
|
880
|
+
invoice: parameters.status.statusData.invoice,
|
|
881
|
+
pid: parameters.status.statusData.pid,
|
|
882
|
+
projectAmount: this.getProjectAmount(parameters.status),
|
|
883
|
+
titleClass: parameters.status.title_class,
|
|
884
|
+
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
885
|
+
order: parameters.status.text.order,
|
|
886
|
+
};
|
|
887
|
+
if (parameters.form) {
|
|
888
|
+
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
889
|
+
}
|
|
890
|
+
if (this.status.statusState === StatusEnum.done ||
|
|
891
|
+
this.status.statusState === StatusEnum.authorized) {
|
|
892
|
+
this.status.isSuccess = true;
|
|
893
|
+
}
|
|
894
|
+
if (this.status.statusState === StatusEnum.canceled ||
|
|
895
|
+
this.status.isCancelUser) {
|
|
896
|
+
this.status.isCanceled = true;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
getUserReturnStatus(form) {
|
|
900
|
+
var _a;
|
|
901
|
+
const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
|
|
902
|
+
if (value === 'undefined')
|
|
903
|
+
return undefined;
|
|
904
|
+
return value;
|
|
905
|
+
}
|
|
906
|
+
getProjectAmount(status) {
|
|
907
|
+
if (!status.statusData.projectAmount) {
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
911
|
+
return {
|
|
912
|
+
amount,
|
|
913
|
+
currency,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
getAdditionalBackButton(status) {
|
|
917
|
+
var _a, _b, _c, _d;
|
|
918
|
+
if (!status.text.is_additional_back_url_enabled) {
|
|
919
|
+
return {
|
|
920
|
+
link: '',
|
|
921
|
+
action: '',
|
|
922
|
+
label: '',
|
|
923
|
+
region: '',
|
|
924
|
+
isEnabled: false,
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
return {
|
|
928
|
+
link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
|
|
929
|
+
action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
|
|
930
|
+
label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
|
|
931
|
+
region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
|
|
932
|
+
isEnabled: status.text.is_additional_back_url_enabled,
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
809
937
|
class StatusUpdatedAction {
|
|
810
|
-
constructor(statusResponse) {
|
|
938
|
+
constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
|
|
811
939
|
this.type = 'status_updated';
|
|
940
|
+
let status;
|
|
941
|
+
if (statusResponse instanceof StatusResponse) {
|
|
942
|
+
status = statusResponse.status;
|
|
943
|
+
}
|
|
944
|
+
else {
|
|
945
|
+
status = statusResponse;
|
|
946
|
+
}
|
|
812
947
|
this.data = {
|
|
813
|
-
statusState:
|
|
814
|
-
invoice:
|
|
815
|
-
isSuccess:
|
|
816
|
-
isCanceled:
|
|
817
|
-
group:
|
|
948
|
+
statusState: status.statusState,
|
|
949
|
+
invoice: status.invoice,
|
|
950
|
+
isSuccess: status.isSuccess,
|
|
951
|
+
isCanceled: status.isCanceled,
|
|
952
|
+
group: status.group,
|
|
953
|
+
isSavePaymentMethodMode,
|
|
954
|
+
savePaymentMethodStatus
|
|
818
955
|
};
|
|
819
956
|
}
|
|
820
957
|
}
|
|
@@ -1455,6 +1592,11 @@ class InitializeService {
|
|
|
1455
1592
|
refer: this.ps4ReferId,
|
|
1456
1593
|
country: this.countryService.getCountry(),
|
|
1457
1594
|
returnUrl: config.returnUrl,
|
|
1595
|
+
paymentWithSavedMethod: config.paymentWithSavedMethod === true
|
|
1596
|
+
? "1" /* XpsBoolean.true */
|
|
1597
|
+
: "0" /* XpsBoolean.false */,
|
|
1598
|
+
saved_method_id: config.savedMethodId,
|
|
1599
|
+
save_payment_account_only: !!config.savePaymentMethod ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
|
|
1458
1600
|
};
|
|
1459
1601
|
return this.xpsApiService
|
|
1460
1602
|
.directPaymentRequest(requestParams)
|
|
@@ -1488,7 +1630,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
|
|
|
1488
1630
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1489
1631
|
type: Injectable,
|
|
1490
1632
|
args: [{
|
|
1491
|
-
providedIn: 'root'
|
|
1633
|
+
providedIn: 'root'
|
|
1492
1634
|
}]
|
|
1493
1635
|
}], ctorParameters: function () {
|
|
1494
1636
|
return [{ type: undefined, decorators: [{
|
|
@@ -2876,6 +3018,7 @@ var StatusSearchParam;
|
|
|
2876
3018
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2877
3019
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2878
3020
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
3021
|
+
StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
|
|
2879
3022
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2880
3023
|
|
|
2881
3024
|
const requiredStatusSearchParams = [
|
|
@@ -2955,15 +3098,15 @@ const statusSearchParamsMap = new Map([
|
|
|
2955
3098
|
converter: numberConverter,
|
|
2956
3099
|
},
|
|
2957
3100
|
],
|
|
3101
|
+
[
|
|
3102
|
+
StatusSearchParam.isSavePaymentAccount,
|
|
3103
|
+
{
|
|
3104
|
+
key: 'isSavePaymentAccount',
|
|
3105
|
+
converter: numberConverter,
|
|
3106
|
+
},
|
|
3107
|
+
],
|
|
2958
3108
|
]);
|
|
2959
3109
|
|
|
2960
|
-
class TerminalError extends AppError {
|
|
2961
|
-
constructor(message, code) {
|
|
2962
|
-
super(message);
|
|
2963
|
-
this.code = code;
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
|
|
2967
3110
|
class XpsApiPart {
|
|
2968
3111
|
constructor() {
|
|
2969
3112
|
this.response = new BehaviorSubject(null);
|
|
@@ -3007,121 +3150,6 @@ const statusRequestFactoryProvider = {
|
|
|
3007
3150
|
useValue: (...args) => new StatusRequest(...args),
|
|
3008
3151
|
};
|
|
3009
3152
|
|
|
3010
|
-
var StatusGroups;
|
|
3011
|
-
(function (StatusGroups) {
|
|
3012
|
-
StatusGroups["troubled"] = "troubled";
|
|
3013
|
-
StatusGroups["done"] = "done";
|
|
3014
|
-
StatusGroups["invoice"] = "invoice";
|
|
3015
|
-
})(StatusGroups || (StatusGroups = {}));
|
|
3016
|
-
|
|
3017
|
-
var StatusEnum;
|
|
3018
|
-
(function (StatusEnum) {
|
|
3019
|
-
StatusEnum["created"] = "created";
|
|
3020
|
-
StatusEnum["awaiting"] = "awaiting";
|
|
3021
|
-
StatusEnum["processing"] = "processing";
|
|
3022
|
-
StatusEnum["authorized"] = "authorized";
|
|
3023
|
-
StatusEnum["held"] = "held";
|
|
3024
|
-
StatusEnum["done"] = "done";
|
|
3025
|
-
StatusEnum["error"] = "error";
|
|
3026
|
-
StatusEnum["canceled"] = "canceled";
|
|
3027
|
-
})(StatusEnum || (StatusEnum = {}));
|
|
3028
|
-
|
|
3029
|
-
class StatusResponse {
|
|
3030
|
-
constructor(parameters) {
|
|
3031
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3032
|
-
if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
3033
|
-
this.error = {
|
|
3034
|
-
code: parameters.errors[0].code.toString(),
|
|
3035
|
-
message: parameters.errors[0].message,
|
|
3036
|
-
};
|
|
3037
|
-
}
|
|
3038
|
-
if (!parameters.status) {
|
|
3039
|
-
throw new TerminalError((_c = (_b = this.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_e = (_d = this.error) === null || _d === void 0 ? void 0 : _d.code.toString()) !== null && _e !== void 0 ? _e : '');
|
|
3040
|
-
}
|
|
3041
|
-
this.status = {
|
|
3042
|
-
statusState: parameters.status.statusData.stateText,
|
|
3043
|
-
email: parameters.status.statusData.email,
|
|
3044
|
-
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
3045
|
-
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
3046
|
-
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
3047
|
-
financeInfo: parameters.status.text.info,
|
|
3048
|
-
discount: parameters.status.text.info.discount
|
|
3049
|
-
? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
|
|
3050
|
-
: null,
|
|
3051
|
-
isCancelUser: parameters.status.isCancelUser,
|
|
3052
|
-
postMessageStatus: parameters.status.isCancelUser
|
|
3053
|
-
? StatusGroups.troubled
|
|
3054
|
-
: parameters.status.group,
|
|
3055
|
-
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
3056
|
-
backUrlSettings: {
|
|
3057
|
-
backUrl: parameters.status.text.backurl,
|
|
3058
|
-
backUrlAction: parameters.status.text.backurl_action,
|
|
3059
|
-
backUrlCaption: parameters.status.text.backurl_caption,
|
|
3060
|
-
returnRegion: parameters.status.return_region,
|
|
3061
|
-
},
|
|
3062
|
-
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
3063
|
-
group: parameters.status.group,
|
|
3064
|
-
needToCheck: parameters.status.needToCheck,
|
|
3065
|
-
autoRedirect: parameters.status.autoredirect,
|
|
3066
|
-
statusMessage: parameters.status.text.state,
|
|
3067
|
-
userId: parameters.status.statusData.v1,
|
|
3068
|
-
invoice: parameters.status.statusData.invoice,
|
|
3069
|
-
pid: parameters.status.statusData.pid,
|
|
3070
|
-
projectAmount: this.getProjectAmount(parameters.status),
|
|
3071
|
-
titleClass: parameters.status.title_class,
|
|
3072
|
-
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
3073
|
-
order: parameters.status.text.order,
|
|
3074
|
-
};
|
|
3075
|
-
if (parameters.form) {
|
|
3076
|
-
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
3077
|
-
}
|
|
3078
|
-
if (this.status.statusState === StatusEnum.done ||
|
|
3079
|
-
this.status.statusState === StatusEnum.authorized) {
|
|
3080
|
-
this.status.isSuccess = true;
|
|
3081
|
-
}
|
|
3082
|
-
if (this.status.statusState === StatusEnum.canceled ||
|
|
3083
|
-
this.status.isCancelUser) {
|
|
3084
|
-
this.status.isCanceled = true;
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
getUserReturnStatus(form) {
|
|
3088
|
-
var _a;
|
|
3089
|
-
const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
|
|
3090
|
-
if (value === 'undefined')
|
|
3091
|
-
return undefined;
|
|
3092
|
-
return value;
|
|
3093
|
-
}
|
|
3094
|
-
getProjectAmount(status) {
|
|
3095
|
-
if (!status.statusData.projectAmount) {
|
|
3096
|
-
return;
|
|
3097
|
-
}
|
|
3098
|
-
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
3099
|
-
return {
|
|
3100
|
-
amount,
|
|
3101
|
-
currency,
|
|
3102
|
-
};
|
|
3103
|
-
}
|
|
3104
|
-
getAdditionalBackButton(status) {
|
|
3105
|
-
var _a, _b, _c, _d;
|
|
3106
|
-
if (!status.text.is_additional_back_url_enabled) {
|
|
3107
|
-
return {
|
|
3108
|
-
link: '',
|
|
3109
|
-
action: '',
|
|
3110
|
-
label: '',
|
|
3111
|
-
region: '',
|
|
3112
|
-
isEnabled: false,
|
|
3113
|
-
};
|
|
3114
|
-
}
|
|
3115
|
-
return {
|
|
3116
|
-
link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
|
|
3117
|
-
action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
|
|
3118
|
-
label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
|
|
3119
|
-
region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
|
|
3120
|
-
isEnabled: status.text.is_additional_back_url_enabled,
|
|
3121
|
-
};
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
|
|
3125
3153
|
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
3126
3154
|
const statusResponseFactoryProvider = {
|
|
3127
3155
|
provide: statusResponseFactoryToken,
|
|
@@ -4651,16 +4679,143 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4651
4679
|
}]
|
|
4652
4680
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
4653
4681
|
|
|
4682
|
+
var TitleClass;
|
|
4683
|
+
(function (TitleClass) {
|
|
4684
|
+
TitleClass["done"] = "done";
|
|
4685
|
+
TitleClass["cancel"] = "cancel";
|
|
4686
|
+
TitleClass["cancelUser"] = "canceluser";
|
|
4687
|
+
})(TitleClass || (TitleClass = {}));
|
|
4688
|
+
|
|
4689
|
+
var SavePaymentMethodStatus;
|
|
4690
|
+
(function (SavePaymentMethodStatus) {
|
|
4691
|
+
SavePaymentMethodStatus["success"] = "success";
|
|
4692
|
+
SavePaymentMethodStatus["failed"] = "failed";
|
|
4693
|
+
})(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
|
|
4694
|
+
|
|
4695
|
+
class XpsResponseError extends AppError {
|
|
4696
|
+
constructor(message) {
|
|
4697
|
+
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
|
|
4701
|
+
class SavedPaymentAccountChangesService {
|
|
4702
|
+
constructor(settingsService, secureApi) {
|
|
4703
|
+
this.settingsService = settingsService;
|
|
4704
|
+
this.secureApi = secureApi;
|
|
4705
|
+
this.apiRoute = 'savedmethods/newaccountinfo';
|
|
4706
|
+
this.response = new Subject();
|
|
4707
|
+
}
|
|
4708
|
+
get response$() {
|
|
4709
|
+
return this.response.asObservable();
|
|
4710
|
+
}
|
|
4711
|
+
request(invoice) {
|
|
4712
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4713
|
+
const requestParameters = {
|
|
4714
|
+
access_token: this.settingsService.token,
|
|
4715
|
+
invoice_id: invoice,
|
|
4716
|
+
};
|
|
4717
|
+
return lastValueFrom(this.secureApi
|
|
4718
|
+
.post(this.apiRoute, new URLSearchParams(requestParameters), {
|
|
4719
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
4720
|
+
responseType: 'json',
|
|
4721
|
+
})
|
|
4722
|
+
.pipe(tap((value) => {
|
|
4723
|
+
this.response.next(value);
|
|
4724
|
+
}))).catch((error) => {
|
|
4725
|
+
throw new XpsResponseError(error.message);
|
|
4726
|
+
});
|
|
4727
|
+
});
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
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 });
|
|
4731
|
+
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
|
|
4732
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4733
|
+
type: Injectable,
|
|
4734
|
+
args: [{
|
|
4735
|
+
providedIn: 'root'
|
|
4736
|
+
}]
|
|
4737
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4738
|
+
|
|
4739
|
+
class SavePaymentMethodStatusService {
|
|
4740
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
|
|
4741
|
+
this.statusRequestService = statusRequestService;
|
|
4742
|
+
this.listenStatusService = listenStatusService;
|
|
4743
|
+
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4744
|
+
this.nextActionService = nextActionService;
|
|
4745
|
+
}
|
|
4746
|
+
getStatus(params) {
|
|
4747
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4748
|
+
this.statusRequestService.setRequestParams(params);
|
|
4749
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4750
|
+
this.statusRequestService.request();
|
|
4751
|
+
const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
|
|
4752
|
+
if (!this.savePaymentMethodStatus) {
|
|
4753
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4754
|
+
}
|
|
4755
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4756
|
+
return statusResponse.status;
|
|
4757
|
+
});
|
|
4758
|
+
}
|
|
4759
|
+
startWaitingStatusUpdates(invoice) {
|
|
4760
|
+
this.listenStatusService.listen(invoice);
|
|
4761
|
+
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4762
|
+
.subscribe(({ statusResponse }) => {
|
|
4763
|
+
if (statusResponse.status) {
|
|
4764
|
+
this.loadNewPaymentAccountData(statusResponse.status);
|
|
4765
|
+
}
|
|
4766
|
+
});
|
|
4767
|
+
}
|
|
4768
|
+
loadNewPaymentAccountData(status) {
|
|
4769
|
+
if (!status.invoice) {
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4772
|
+
void this.savedPaymentAccountChangesService
|
|
4773
|
+
.request(status.invoice)
|
|
4774
|
+
.then((accountChanges) => {
|
|
4775
|
+
if (accountChanges) {
|
|
4776
|
+
this.handleSavingStatus(status, accountChanges.new_account);
|
|
4777
|
+
}
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4780
|
+
handleSavingStatus(status, account) {
|
|
4781
|
+
this.listenStatusService.stopListening();
|
|
4782
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4783
|
+
const updatingIsProcessing = (status === null || status === void 0 ? void 0 : status.titleClass) !== TitleClass.cancel && (status === null || status === void 0 ? void 0 : status.titleClass) !== TitleClass.cancelUser && !account;
|
|
4784
|
+
if (updatingIsProcessing) {
|
|
4785
|
+
return;
|
|
4786
|
+
}
|
|
4787
|
+
const paymentAccountWasSaved = (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.done && account !== null;
|
|
4788
|
+
const isSavePaymentMethod = true;
|
|
4789
|
+
this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4790
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4793
|
+
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 });
|
|
4794
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4795
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4796
|
+
type: Injectable,
|
|
4797
|
+
args: [{
|
|
4798
|
+
providedIn: 'root'
|
|
4799
|
+
}]
|
|
4800
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
|
|
4801
|
+
|
|
4654
4802
|
class StatusService {
|
|
4655
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4803
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4656
4804
|
this.urlService = urlService;
|
|
4657
4805
|
this.statusRequestService = statusRequestService;
|
|
4658
4806
|
this.financeDetailsService = financeDetailsService;
|
|
4659
4807
|
this.listenStatusService = listenStatusService;
|
|
4660
4808
|
this.nextActionService = nextActionService;
|
|
4809
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4661
4810
|
}
|
|
4662
4811
|
getStatus(params) {
|
|
4663
4812
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4813
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4814
|
+
// account status
|
|
4815
|
+
const isSavePaymentMethodMode = !!(params === null || params === void 0 ? void 0 : params.isSavePaymentAccount);
|
|
4816
|
+
if (isSavePaymentMethodMode) {
|
|
4817
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4818
|
+
}
|
|
4664
4819
|
this.statusRequestService.setRequestParams(params);
|
|
4665
4820
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4666
4821
|
this.statusRequestService.request();
|
|
@@ -4672,6 +4827,7 @@ class StatusService {
|
|
|
4672
4827
|
getStatusWithUrlSearchParams(url) {
|
|
4673
4828
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4674
4829
|
const searchParams = this.getRequestParamsFromUrl(url);
|
|
4830
|
+
console.log('searchParams', searchParams);
|
|
4675
4831
|
if (!searchParams) {
|
|
4676
4832
|
throw new Error('No required search params to get status');
|
|
4677
4833
|
}
|
|
@@ -4700,14 +4856,14 @@ class StatusService {
|
|
|
4700
4856
|
});
|
|
4701
4857
|
}
|
|
4702
4858
|
}
|
|
4703
|
-
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 });
|
|
4859
|
+
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 });
|
|
4704
4860
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4705
4861
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4706
4862
|
type: Injectable,
|
|
4707
4863
|
args: [{
|
|
4708
4864
|
providedIn: 'root',
|
|
4709
4865
|
}]
|
|
4710
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4866
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4711
4867
|
|
|
4712
4868
|
class CreditCardStateService extends EmitDataService {
|
|
4713
4869
|
}
|
|
@@ -4732,12 +4888,6 @@ var ThreeDsStatusTypes;
|
|
|
4732
4888
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4733
4889
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4734
4890
|
|
|
4735
|
-
class XpsResponseError extends AppError {
|
|
4736
|
-
constructor(message) {
|
|
4737
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4738
|
-
}
|
|
4739
|
-
}
|
|
4740
|
-
|
|
4741
4891
|
class StatusThreeDsRequest {
|
|
4742
4892
|
constructor(token, threeDsId) {
|
|
4743
4893
|
this.access_token = token;
|
|
@@ -5200,6 +5350,7 @@ class PaymentService {
|
|
|
5200
5350
|
this.destroy$ = new Subject();
|
|
5201
5351
|
this.formDestroy$ = new Subject();
|
|
5202
5352
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5353
|
+
this.isSavingMethodMode = false;
|
|
5203
5354
|
}
|
|
5204
5355
|
initialize(config) {
|
|
5205
5356
|
var _a, _b;
|
|
@@ -5229,9 +5380,14 @@ class PaymentService {
|
|
|
5229
5380
|
this.emitFormFieldsStatus(this.form);
|
|
5230
5381
|
return;
|
|
5231
5382
|
}
|
|
5383
|
+
console.log('this.fields', this.fields);
|
|
5384
|
+
console.log('this.form', this.form);
|
|
5385
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5232
5386
|
const submitResponse = yield this.submitService.request(this.fields, this.form);
|
|
5233
5387
|
this.data = submitResponse;
|
|
5234
|
-
this.
|
|
5388
|
+
if (!this.isSavingMethodMode) {
|
|
5389
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5390
|
+
}
|
|
5235
5391
|
this.emitFormMessages(submitResponse.messages);
|
|
5236
5392
|
// Handle 3ds flow
|
|
5237
5393
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5285,7 +5441,10 @@ class PaymentService {
|
|
|
5285
5441
|
invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
|
|
5286
5442
|
signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
|
|
5287
5443
|
locale: (_d = (_c = this.data.fields.find((field) => field.name === 'locale')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'en',
|
|
5444
|
+
isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
|
|
5288
5445
|
};
|
|
5446
|
+
console.log('this.data', this.data);
|
|
5447
|
+
console.log('getStatus', params);
|
|
5289
5448
|
return this.statusService.getStatus(params);
|
|
5290
5449
|
});
|
|
5291
5450
|
}
|