@xsolla/payment-client-core 0.1.16 → 0.1.17-test
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 +8 -4
- package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +4 -1
- package/esm2020/lib/core/payment/payment-config.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +9 -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 +116 -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 +10 -4
- package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +7 -4
- package/esm2020/lib/core-library.service.mjs +2 -2
- package/fesm2015/xsolla-payment-client-core.mjs +342 -146
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +335 -143
- 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 +1 -0
- package/lib/core/payment/payment-config.interface.d.ts +1 -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 +31 -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-request-params.interface.d.ts +2 -0
- 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.17-test.tgz +0 -0
- package/xsolla-payment-client-core-0.1.16.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
|
|
|
@@ -244,9 +244,9 @@ class PaymentMethodsService {
|
|
|
244
244
|
this.apiRoute = 'remained_payment_methods';
|
|
245
245
|
this.cache = new Map();
|
|
246
246
|
}
|
|
247
|
-
getList() {
|
|
247
|
+
getList(isSaveMethodMode) {
|
|
248
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
const response = yield this.request();
|
|
249
|
+
const response = yield this.request(isSaveMethodMode);
|
|
250
250
|
return response.remained;
|
|
251
251
|
});
|
|
252
252
|
}
|
|
@@ -256,11 +256,14 @@ class PaymentMethodsService {
|
|
|
256
256
|
return response.especial;
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
-
request() {
|
|
259
|
+
request(isSaveMethodMode) {
|
|
260
260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
261
|
const requestParams = {
|
|
262
262
|
access_token: this.settingsService.token,
|
|
263
263
|
country: this.countryService.getCountry(),
|
|
264
|
+
save_payment_account_only: isSaveMethodMode
|
|
265
|
+
? "1" /* XpsBoolean.true */
|
|
266
|
+
: "0" /* XpsBoolean.false */,
|
|
264
267
|
};
|
|
265
268
|
const cacheKey = JSON.stringify(requestParams);
|
|
266
269
|
if (!this.cache.has(cacheKey)) {
|
|
@@ -481,12 +484,16 @@ class PaymentConfigService {
|
|
|
481
484
|
if (!config.returnUrl) {
|
|
482
485
|
throw new Error('URL is not provided in payment config');
|
|
483
486
|
}
|
|
484
|
-
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl) });
|
|
487
|
+
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod) });
|
|
485
488
|
}
|
|
486
|
-
enrichReturnUrl(returnUrl) {
|
|
487
|
-
|
|
489
|
+
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
490
|
+
const enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
488
491
|
token: this.settingsService.token,
|
|
492
|
+
isSavePaymentAccount: savePaymentMethod
|
|
493
|
+
? "1" /* XpsBoolean.true */
|
|
494
|
+
: "0" /* XpsBoolean.false */,
|
|
489
495
|
});
|
|
496
|
+
return enrichedUrl;
|
|
490
497
|
}
|
|
491
498
|
}
|
|
492
499
|
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 });
|
|
@@ -808,15 +815,146 @@ const checkStatusActionFactoryProvider = {
|
|
|
808
815
|
},
|
|
809
816
|
};
|
|
810
817
|
|
|
818
|
+
class TerminalError extends AppError {
|
|
819
|
+
constructor(message, code) {
|
|
820
|
+
super(message);
|
|
821
|
+
this.code = code;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
var StatusGroups;
|
|
826
|
+
(function (StatusGroups) {
|
|
827
|
+
StatusGroups["troubled"] = "troubled";
|
|
828
|
+
StatusGroups["done"] = "done";
|
|
829
|
+
StatusGroups["invoice"] = "invoice";
|
|
830
|
+
})(StatusGroups || (StatusGroups = {}));
|
|
831
|
+
|
|
832
|
+
var StatusEnum;
|
|
833
|
+
(function (StatusEnum) {
|
|
834
|
+
StatusEnum["created"] = "created";
|
|
835
|
+
StatusEnum["awaiting"] = "awaiting";
|
|
836
|
+
StatusEnum["processing"] = "processing";
|
|
837
|
+
StatusEnum["authorized"] = "authorized";
|
|
838
|
+
StatusEnum["held"] = "held";
|
|
839
|
+
StatusEnum["done"] = "done";
|
|
840
|
+
StatusEnum["error"] = "error";
|
|
841
|
+
StatusEnum["canceled"] = "canceled";
|
|
842
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
843
|
+
|
|
844
|
+
class StatusResponse {
|
|
845
|
+
constructor(parameters) {
|
|
846
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
847
|
+
if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
848
|
+
this.error = {
|
|
849
|
+
code: parameters.errors[0].code.toString(),
|
|
850
|
+
message: parameters.errors[0].message,
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
if (!parameters.status) {
|
|
854
|
+
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 : '');
|
|
855
|
+
}
|
|
856
|
+
this.status = {
|
|
857
|
+
statusState: parameters.status.statusData.stateText,
|
|
858
|
+
email: parameters.status.statusData.email,
|
|
859
|
+
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
860
|
+
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
861
|
+
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
862
|
+
financeInfo: parameters.status.text.info,
|
|
863
|
+
discount: parameters.status.text.info.discount
|
|
864
|
+
? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
|
|
865
|
+
: null,
|
|
866
|
+
isCancelUser: parameters.status.isCancelUser,
|
|
867
|
+
postMessageStatus: parameters.status.isCancelUser
|
|
868
|
+
? StatusGroups.troubled
|
|
869
|
+
: parameters.status.group,
|
|
870
|
+
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
871
|
+
backUrlSettings: {
|
|
872
|
+
backUrl: parameters.status.text.backurl,
|
|
873
|
+
backUrlAction: parameters.status.text.backurl_action,
|
|
874
|
+
backUrlCaption: parameters.status.text.backurl_caption,
|
|
875
|
+
returnRegion: parameters.status.return_region,
|
|
876
|
+
},
|
|
877
|
+
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
878
|
+
group: parameters.status.group,
|
|
879
|
+
needToCheck: parameters.status.needToCheck,
|
|
880
|
+
autoRedirect: parameters.status.autoredirect,
|
|
881
|
+
statusMessage: parameters.status.text.state,
|
|
882
|
+
userId: parameters.status.statusData.v1,
|
|
883
|
+
invoice: parameters.status.statusData.invoice,
|
|
884
|
+
pid: parameters.status.statusData.pid,
|
|
885
|
+
projectAmount: this.getProjectAmount(parameters.status),
|
|
886
|
+
titleClass: parameters.status.title_class,
|
|
887
|
+
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
888
|
+
order: parameters.status.text.order,
|
|
889
|
+
};
|
|
890
|
+
if (parameters.form) {
|
|
891
|
+
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
892
|
+
}
|
|
893
|
+
if (this.status.statusState === StatusEnum.done ||
|
|
894
|
+
this.status.statusState === StatusEnum.authorized) {
|
|
895
|
+
this.status.isSuccess = true;
|
|
896
|
+
}
|
|
897
|
+
if (this.status.statusState === StatusEnum.canceled ||
|
|
898
|
+
this.status.isCancelUser) {
|
|
899
|
+
this.status.isCanceled = true;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
getUserReturnStatus(form) {
|
|
903
|
+
var _a;
|
|
904
|
+
const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
|
|
905
|
+
if (value === 'undefined')
|
|
906
|
+
return undefined;
|
|
907
|
+
return value;
|
|
908
|
+
}
|
|
909
|
+
getProjectAmount(status) {
|
|
910
|
+
if (!status.statusData.projectAmount) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
914
|
+
return {
|
|
915
|
+
amount,
|
|
916
|
+
currency,
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
getAdditionalBackButton(status) {
|
|
920
|
+
var _a, _b, _c, _d;
|
|
921
|
+
if (!status.text.is_additional_back_url_enabled) {
|
|
922
|
+
return {
|
|
923
|
+
link: '',
|
|
924
|
+
action: '',
|
|
925
|
+
label: '',
|
|
926
|
+
region: '',
|
|
927
|
+
isEnabled: false,
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
|
|
932
|
+
action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
|
|
933
|
+
label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
|
|
934
|
+
region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
|
|
935
|
+
isEnabled: status.text.is_additional_back_url_enabled,
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
811
940
|
class StatusUpdatedAction {
|
|
812
|
-
constructor(statusResponse) {
|
|
941
|
+
constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
|
|
813
942
|
this.type = 'status_updated';
|
|
943
|
+
let status;
|
|
944
|
+
if (statusResponse instanceof StatusResponse) {
|
|
945
|
+
status = statusResponse.status;
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
status = statusResponse;
|
|
949
|
+
}
|
|
814
950
|
this.data = {
|
|
815
|
-
statusState:
|
|
816
|
-
invoice:
|
|
817
|
-
isSuccess:
|
|
818
|
-
isCanceled:
|
|
819
|
-
group:
|
|
951
|
+
statusState: status.statusState,
|
|
952
|
+
invoice: status.invoice,
|
|
953
|
+
isSuccess: status.isSuccess,
|
|
954
|
+
isCanceled: status.isCanceled,
|
|
955
|
+
group: status.group,
|
|
956
|
+
isSavePaymentMethodMode,
|
|
957
|
+
savePaymentMethodStatus,
|
|
820
958
|
};
|
|
821
959
|
}
|
|
822
960
|
}
|
|
@@ -1461,6 +1599,9 @@ class InitializeService {
|
|
|
1461
1599
|
? "1" /* XpsBoolean.true */
|
|
1462
1600
|
: "0" /* XpsBoolean.false */,
|
|
1463
1601
|
saved_method_id: config.savedMethodId,
|
|
1602
|
+
save_payment_account_only: config.savePaymentMethod
|
|
1603
|
+
? "1" /* XpsBoolean.true */
|
|
1604
|
+
: "0" /* XpsBoolean.false */,
|
|
1464
1605
|
};
|
|
1465
1606
|
return this.xpsApiService
|
|
1466
1607
|
.directPaymentRequest(requestParams)
|
|
@@ -2882,6 +3023,7 @@ var StatusSearchParam;
|
|
|
2882
3023
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2883
3024
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2884
3025
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
3026
|
+
StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
|
|
2885
3027
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2886
3028
|
|
|
2887
3029
|
const requiredStatusSearchParams = [
|
|
@@ -2961,15 +3103,15 @@ const statusSearchParamsMap = new Map([
|
|
|
2961
3103
|
converter: numberConverter,
|
|
2962
3104
|
},
|
|
2963
3105
|
],
|
|
3106
|
+
[
|
|
3107
|
+
StatusSearchParam.isSavePaymentAccount,
|
|
3108
|
+
{
|
|
3109
|
+
key: 'isSavePaymentAccount',
|
|
3110
|
+
converter: stringConverter,
|
|
3111
|
+
},
|
|
3112
|
+
],
|
|
2964
3113
|
]);
|
|
2965
3114
|
|
|
2966
|
-
class TerminalError extends AppError {
|
|
2967
|
-
constructor(message, code) {
|
|
2968
|
-
super(message);
|
|
2969
|
-
this.code = code;
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
3115
|
class XpsApiPart {
|
|
2974
3116
|
constructor() {
|
|
2975
3117
|
this.response = new BehaviorSubject(null);
|
|
@@ -3013,121 +3155,6 @@ const statusRequestFactoryProvider = {
|
|
|
3013
3155
|
useValue: (...args) => new StatusRequest(...args),
|
|
3014
3156
|
};
|
|
3015
3157
|
|
|
3016
|
-
var StatusGroups;
|
|
3017
|
-
(function (StatusGroups) {
|
|
3018
|
-
StatusGroups["troubled"] = "troubled";
|
|
3019
|
-
StatusGroups["done"] = "done";
|
|
3020
|
-
StatusGroups["invoice"] = "invoice";
|
|
3021
|
-
})(StatusGroups || (StatusGroups = {}));
|
|
3022
|
-
|
|
3023
|
-
var StatusEnum;
|
|
3024
|
-
(function (StatusEnum) {
|
|
3025
|
-
StatusEnum["created"] = "created";
|
|
3026
|
-
StatusEnum["awaiting"] = "awaiting";
|
|
3027
|
-
StatusEnum["processing"] = "processing";
|
|
3028
|
-
StatusEnum["authorized"] = "authorized";
|
|
3029
|
-
StatusEnum["held"] = "held";
|
|
3030
|
-
StatusEnum["done"] = "done";
|
|
3031
|
-
StatusEnum["error"] = "error";
|
|
3032
|
-
StatusEnum["canceled"] = "canceled";
|
|
3033
|
-
})(StatusEnum || (StatusEnum = {}));
|
|
3034
|
-
|
|
3035
|
-
class StatusResponse {
|
|
3036
|
-
constructor(parameters) {
|
|
3037
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3038
|
-
if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
3039
|
-
this.error = {
|
|
3040
|
-
code: parameters.errors[0].code.toString(),
|
|
3041
|
-
message: parameters.errors[0].message,
|
|
3042
|
-
};
|
|
3043
|
-
}
|
|
3044
|
-
if (!parameters.status) {
|
|
3045
|
-
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 : '');
|
|
3046
|
-
}
|
|
3047
|
-
this.status = {
|
|
3048
|
-
statusState: parameters.status.statusData.stateText,
|
|
3049
|
-
email: parameters.status.statusData.email,
|
|
3050
|
-
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
3051
|
-
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
3052
|
-
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
3053
|
-
financeInfo: parameters.status.text.info,
|
|
3054
|
-
discount: parameters.status.text.info.discount
|
|
3055
|
-
? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
|
|
3056
|
-
: null,
|
|
3057
|
-
isCancelUser: parameters.status.isCancelUser,
|
|
3058
|
-
postMessageStatus: parameters.status.isCancelUser
|
|
3059
|
-
? StatusGroups.troubled
|
|
3060
|
-
: parameters.status.group,
|
|
3061
|
-
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
3062
|
-
backUrlSettings: {
|
|
3063
|
-
backUrl: parameters.status.text.backurl,
|
|
3064
|
-
backUrlAction: parameters.status.text.backurl_action,
|
|
3065
|
-
backUrlCaption: parameters.status.text.backurl_caption,
|
|
3066
|
-
returnRegion: parameters.status.return_region,
|
|
3067
|
-
},
|
|
3068
|
-
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
3069
|
-
group: parameters.status.group,
|
|
3070
|
-
needToCheck: parameters.status.needToCheck,
|
|
3071
|
-
autoRedirect: parameters.status.autoredirect,
|
|
3072
|
-
statusMessage: parameters.status.text.state,
|
|
3073
|
-
userId: parameters.status.statusData.v1,
|
|
3074
|
-
invoice: parameters.status.statusData.invoice,
|
|
3075
|
-
pid: parameters.status.statusData.pid,
|
|
3076
|
-
projectAmount: this.getProjectAmount(parameters.status),
|
|
3077
|
-
titleClass: parameters.status.title_class,
|
|
3078
|
-
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
3079
|
-
order: parameters.status.text.order,
|
|
3080
|
-
};
|
|
3081
|
-
if (parameters.form) {
|
|
3082
|
-
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
3083
|
-
}
|
|
3084
|
-
if (this.status.statusState === StatusEnum.done ||
|
|
3085
|
-
this.status.statusState === StatusEnum.authorized) {
|
|
3086
|
-
this.status.isSuccess = true;
|
|
3087
|
-
}
|
|
3088
|
-
if (this.status.statusState === StatusEnum.canceled ||
|
|
3089
|
-
this.status.isCancelUser) {
|
|
3090
|
-
this.status.isCanceled = true;
|
|
3091
|
-
}
|
|
3092
|
-
}
|
|
3093
|
-
getUserReturnStatus(form) {
|
|
3094
|
-
var _a;
|
|
3095
|
-
const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
|
|
3096
|
-
if (value === 'undefined')
|
|
3097
|
-
return undefined;
|
|
3098
|
-
return value;
|
|
3099
|
-
}
|
|
3100
|
-
getProjectAmount(status) {
|
|
3101
|
-
if (!status.statusData.projectAmount) {
|
|
3102
|
-
return;
|
|
3103
|
-
}
|
|
3104
|
-
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
3105
|
-
return {
|
|
3106
|
-
amount,
|
|
3107
|
-
currency,
|
|
3108
|
-
};
|
|
3109
|
-
}
|
|
3110
|
-
getAdditionalBackButton(status) {
|
|
3111
|
-
var _a, _b, _c, _d;
|
|
3112
|
-
if (!status.text.is_additional_back_url_enabled) {
|
|
3113
|
-
return {
|
|
3114
|
-
link: '',
|
|
3115
|
-
action: '',
|
|
3116
|
-
label: '',
|
|
3117
|
-
region: '',
|
|
3118
|
-
isEnabled: false,
|
|
3119
|
-
};
|
|
3120
|
-
}
|
|
3121
|
-
return {
|
|
3122
|
-
link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
|
|
3123
|
-
action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
|
|
3124
|
-
label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
|
|
3125
|
-
region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
|
|
3126
|
-
isEnabled: status.text.is_additional_back_url_enabled,
|
|
3127
|
-
};
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
|
|
3131
3158
|
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
3132
3159
|
const statusResponseFactoryProvider = {
|
|
3133
3160
|
provide: statusResponseFactoryToken,
|
|
@@ -4657,16 +4684,184 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4657
4684
|
}]
|
|
4658
4685
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
4659
4686
|
|
|
4687
|
+
var TitleClass;
|
|
4688
|
+
(function (TitleClass) {
|
|
4689
|
+
TitleClass["done"] = "done";
|
|
4690
|
+
TitleClass["cancel"] = "cancel";
|
|
4691
|
+
TitleClass["cancelUser"] = "canceluser";
|
|
4692
|
+
})(TitleClass || (TitleClass = {}));
|
|
4693
|
+
|
|
4694
|
+
var SavePaymentMethodStatus;
|
|
4695
|
+
(function (SavePaymentMethodStatus) {
|
|
4696
|
+
SavePaymentMethodStatus["success"] = "success";
|
|
4697
|
+
SavePaymentMethodStatus["failed"] = "failed";
|
|
4698
|
+
})(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
|
|
4699
|
+
|
|
4700
|
+
class XpsResponseError extends AppError {
|
|
4701
|
+
constructor(message) {
|
|
4702
|
+
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4706
|
+
class SavedPaymentAccountChangesService {
|
|
4707
|
+
constructor(settingsService, secureApi) {
|
|
4708
|
+
this.settingsService = settingsService;
|
|
4709
|
+
this.secureApi = secureApi;
|
|
4710
|
+
this.apiRoute = 'savedmethods/newaccountinfo';
|
|
4711
|
+
this.response = new Subject();
|
|
4712
|
+
}
|
|
4713
|
+
get response$() {
|
|
4714
|
+
return this.response.asObservable();
|
|
4715
|
+
}
|
|
4716
|
+
request(invoice) {
|
|
4717
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4718
|
+
const requestParameters = {
|
|
4719
|
+
access_token: this.settingsService.token,
|
|
4720
|
+
invoice_id: invoice,
|
|
4721
|
+
};
|
|
4722
|
+
return lastValueFrom(this.secureApi
|
|
4723
|
+
.post(this.apiRoute, new URLSearchParams(requestParameters), {
|
|
4724
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
4725
|
+
responseType: 'json',
|
|
4726
|
+
})
|
|
4727
|
+
.pipe(tap((value) => {
|
|
4728
|
+
this.response.next(value);
|
|
4729
|
+
}))).catch((error) => {
|
|
4730
|
+
throw new XpsResponseError(error.message);
|
|
4731
|
+
});
|
|
4732
|
+
});
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
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 });
|
|
4736
|
+
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
|
|
4737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4738
|
+
type: Injectable,
|
|
4739
|
+
args: [{
|
|
4740
|
+
providedIn: 'root',
|
|
4741
|
+
}]
|
|
4742
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4743
|
+
|
|
4744
|
+
class SavePaymentMethodStatusService {
|
|
4745
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
|
|
4746
|
+
this.statusRequestService = statusRequestService;
|
|
4747
|
+
this.listenStatusService = listenStatusService;
|
|
4748
|
+
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4749
|
+
this.nextActionService = nextActionService;
|
|
4750
|
+
this.checkStatusService = checkStatusService;
|
|
4751
|
+
this.statusChecked = false;
|
|
4752
|
+
}
|
|
4753
|
+
getStatus(params) {
|
|
4754
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4755
|
+
if (!this.accountData || !this.status) {
|
|
4756
|
+
this.statusRequestService.setRequestParams(params);
|
|
4757
|
+
this.statusRequestService.request();
|
|
4758
|
+
const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
|
|
4759
|
+
this.status = statusResponse.status;
|
|
4760
|
+
this.status.isSavePaymentAccount = true;
|
|
4761
|
+
this.accountData = yield this.getPaymentAccountData(params.invoice);
|
|
4762
|
+
}
|
|
4763
|
+
if (this.savingFailedOrCancel(this.status) ||
|
|
4764
|
+
(this.accountData && this.savingSuccessful(this.accountData, this.status))) {
|
|
4765
|
+
return this.status;
|
|
4766
|
+
}
|
|
4767
|
+
if (!this.statusChecked) {
|
|
4768
|
+
this.checkStatus(params);
|
|
4769
|
+
this.status.statusState = StatusEnum.processing;
|
|
4770
|
+
return this.status;
|
|
4771
|
+
}
|
|
4772
|
+
this.statusChecked = false;
|
|
4773
|
+
this.status.statusState = StatusEnum.error;
|
|
4774
|
+
const outStatus = Object.assign({}, this.status);
|
|
4775
|
+
this.status = null;
|
|
4776
|
+
return outStatus;
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
checkStatus(params) {
|
|
4780
|
+
if (!this.statusChecked) {
|
|
4781
|
+
this.statusChecked = true;
|
|
4782
|
+
}
|
|
4783
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4784
|
+
this.statusRequestService.request();
|
|
4785
|
+
}
|
|
4786
|
+
savingFailedOrCancel(status) {
|
|
4787
|
+
return ((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancel ||
|
|
4788
|
+
(status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancelUser);
|
|
4789
|
+
}
|
|
4790
|
+
savingSuccessful(accountData, status, checkStatus) {
|
|
4791
|
+
return !!((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.done &&
|
|
4792
|
+
((accountData === null || accountData === void 0 ? void 0 : accountData.new_account) || (checkStatus === null || checkStatus === void 0 ? void 0 : checkStatus.isPaymentAccountAttached)));
|
|
4793
|
+
}
|
|
4794
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4795
|
+
getPaymentAccountData(invoice) {
|
|
4796
|
+
return this.savedPaymentAccountChangesService.request(invoice);
|
|
4797
|
+
}
|
|
4798
|
+
startWaitingStatusUpdates(invoice) {
|
|
4799
|
+
if (this.listenStatusSubscription) {
|
|
4800
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4801
|
+
this.listenStatusService.stopListening();
|
|
4802
|
+
}
|
|
4803
|
+
this.listenStatusService.listen(invoice);
|
|
4804
|
+
this.listenStatusSubscription =
|
|
4805
|
+
this.listenStatusService.statusUpdated$.subscribe(({ statusResponse }) => {
|
|
4806
|
+
if (!(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
|
|
4807
|
+
return;
|
|
4808
|
+
}
|
|
4809
|
+
this.status = statusResponse.status;
|
|
4810
|
+
void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
|
|
4811
|
+
if ((checkStatusResponse === null || checkStatusResponse === void 0 ? void 0 : checkStatusResponse.final) && statusResponse.status) {
|
|
4812
|
+
this.loadNewPaymentAccountData(statusResponse.status, checkStatusResponse);
|
|
4813
|
+
}
|
|
4814
|
+
});
|
|
4815
|
+
});
|
|
4816
|
+
}
|
|
4817
|
+
loadNewPaymentAccountData(status, checkStatus) {
|
|
4818
|
+
if (!status.invoice) {
|
|
4819
|
+
return;
|
|
4820
|
+
}
|
|
4821
|
+
void this.getPaymentAccountData(status.invoice).then((accountChanges) => {
|
|
4822
|
+
if (accountChanges) {
|
|
4823
|
+
this.accountData = accountChanges;
|
|
4824
|
+
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4825
|
+
}
|
|
4826
|
+
});
|
|
4827
|
+
}
|
|
4828
|
+
handleSavingStatus(status, account, checkStatus) {
|
|
4829
|
+
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4830
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4831
|
+
}
|
|
4832
|
+
else {
|
|
4833
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
|
|
4834
|
+
}
|
|
4835
|
+
this.listenStatusService.stopListening();
|
|
4836
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4837
|
+
const isSavePaymentMethod = true;
|
|
4838
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4839
|
+
}
|
|
4840
|
+
}
|
|
4841
|
+
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 });
|
|
4842
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4843
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4844
|
+
type: Injectable,
|
|
4845
|
+
args: [{
|
|
4846
|
+
providedIn: 'root',
|
|
4847
|
+
}]
|
|
4848
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4849
|
+
|
|
4660
4850
|
class StatusService {
|
|
4661
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4851
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4662
4852
|
this.urlService = urlService;
|
|
4663
4853
|
this.statusRequestService = statusRequestService;
|
|
4664
4854
|
this.financeDetailsService = financeDetailsService;
|
|
4665
4855
|
this.listenStatusService = listenStatusService;
|
|
4666
4856
|
this.nextActionService = nextActionService;
|
|
4857
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4667
4858
|
}
|
|
4668
4859
|
getStatus(params) {
|
|
4669
4860
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4861
|
+
const isSavePaymentMethodMode = !!(params === null || params === void 0 ? void 0 : params.isSavePaymentAccount);
|
|
4862
|
+
if (isSavePaymentMethodMode) {
|
|
4863
|
+
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4864
|
+
}
|
|
4670
4865
|
this.statusRequestService.setRequestParams(params);
|
|
4671
4866
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4672
4867
|
this.statusRequestService.request();
|
|
@@ -4706,14 +4901,14 @@ class StatusService {
|
|
|
4706
4901
|
});
|
|
4707
4902
|
}
|
|
4708
4903
|
}
|
|
4709
|
-
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 });
|
|
4904
|
+
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 });
|
|
4710
4905
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4711
4906
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4712
4907
|
type: Injectable,
|
|
4713
4908
|
args: [{
|
|
4714
4909
|
providedIn: 'root',
|
|
4715
4910
|
}]
|
|
4716
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4911
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4717
4912
|
|
|
4718
4913
|
class CreditCardStateService extends EmitDataService {
|
|
4719
4914
|
}
|
|
@@ -4738,12 +4933,6 @@ var ThreeDsStatusTypes;
|
|
|
4738
4933
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4739
4934
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4740
4935
|
|
|
4741
|
-
class XpsResponseError extends AppError {
|
|
4742
|
-
constructor(message) {
|
|
4743
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4744
|
-
}
|
|
4745
|
-
}
|
|
4746
|
-
|
|
4747
4936
|
class StatusThreeDsRequest {
|
|
4748
4937
|
constructor(token, threeDsId) {
|
|
4749
4938
|
this.access_token = token;
|
|
@@ -5206,6 +5395,7 @@ class PaymentService {
|
|
|
5206
5395
|
this.destroy$ = new Subject();
|
|
5207
5396
|
this.formDestroy$ = new Subject();
|
|
5208
5397
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5398
|
+
this.isSavingMethodMode = false;
|
|
5209
5399
|
}
|
|
5210
5400
|
initialize(config) {
|
|
5211
5401
|
var _a, _b;
|
|
@@ -5235,9 +5425,12 @@ class PaymentService {
|
|
|
5235
5425
|
this.emitFormFieldsStatus(this.form);
|
|
5236
5426
|
return;
|
|
5237
5427
|
}
|
|
5428
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5238
5429
|
const submitResponse = yield this.submitService.request(this.fields, this.form);
|
|
5239
5430
|
this.data = submitResponse;
|
|
5240
|
-
this.
|
|
5431
|
+
if (!this.isSavingMethodMode) {
|
|
5432
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5433
|
+
}
|
|
5241
5434
|
this.emitFormMessages(submitResponse.messages);
|
|
5242
5435
|
// Handle 3ds flow
|
|
5243
5436
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5291,6 +5484,9 @@ class PaymentService {
|
|
|
5291
5484
|
invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
|
|
5292
5485
|
signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
|
|
5293
5486
|
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',
|
|
5487
|
+
isSavePaymentAccount: this.isSavingMethodMode
|
|
5488
|
+
? "1" /* XpsBoolean.true */
|
|
5489
|
+
: "0" /* XpsBoolean.false */,
|
|
5294
5490
|
};
|
|
5295
5491
|
return this.statusService.getStatus(params);
|
|
5296
5492
|
});
|
|
@@ -5554,7 +5750,7 @@ class CoreLibraryService {
|
|
|
5554
5750
|
this.formMessagesService = formMessagesService;
|
|
5555
5751
|
this.editSavedMethodsService = editSavedMethodsService;
|
|
5556
5752
|
this.paymentMethods = {
|
|
5557
|
-
getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
|
|
5753
|
+
getList: (isSaveMethodMode) => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(isSaveMethodMode); }),
|
|
5558
5754
|
getQuickMethods: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getQuickMethods(); }),
|
|
5559
5755
|
getSavedMethods: () => __awaiter(this, void 0, void 0, function* () { return this.savedMethodsService.getList(); }),
|
|
5560
5756
|
getUserBalance: () => __awaiter(this, void 0, void 0, function* () { return this.userBalanceService.getUserBalance(); }),
|