@xsolla/payment-client-core 0.1.16 → 0.1.17
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.tgz +0 -0
- package/xsolla-payment-client-core-0.1.16.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
|
|
|
@@ -238,18 +238,21 @@ class PaymentMethodsService {
|
|
|
238
238
|
this.apiRoute = 'remained_payment_methods';
|
|
239
239
|
this.cache = new Map();
|
|
240
240
|
}
|
|
241
|
-
async getList() {
|
|
242
|
-
const response = await this.request();
|
|
241
|
+
async getList(isSaveMethodMode) {
|
|
242
|
+
const response = await this.request(isSaveMethodMode);
|
|
243
243
|
return response.remained;
|
|
244
244
|
}
|
|
245
245
|
async getQuickMethods() {
|
|
246
246
|
const response = await this.request();
|
|
247
247
|
return response.especial;
|
|
248
248
|
}
|
|
249
|
-
async request() {
|
|
249
|
+
async request(isSaveMethodMode) {
|
|
250
250
|
const requestParams = {
|
|
251
251
|
access_token: this.settingsService.token,
|
|
252
252
|
country: this.countryService.getCountry(),
|
|
253
|
+
save_payment_account_only: isSaveMethodMode
|
|
254
|
+
? "1" /* XpsBoolean.true */
|
|
255
|
+
: "0" /* XpsBoolean.false */,
|
|
253
256
|
};
|
|
254
257
|
const cacheKey = JSON.stringify(requestParams);
|
|
255
258
|
if (!this.cache.has(cacheKey)) {
|
|
@@ -456,13 +459,17 @@ class PaymentConfigService {
|
|
|
456
459
|
}
|
|
457
460
|
return {
|
|
458
461
|
...config,
|
|
459
|
-
returnUrl: this.enrichReturnUrl(config.returnUrl),
|
|
462
|
+
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod),
|
|
460
463
|
};
|
|
461
464
|
}
|
|
462
|
-
enrichReturnUrl(returnUrl) {
|
|
463
|
-
|
|
465
|
+
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
466
|
+
const enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
464
467
|
token: this.settingsService.token,
|
|
468
|
+
isSavePaymentAccount: savePaymentMethod
|
|
469
|
+
? "1" /* XpsBoolean.true */
|
|
470
|
+
: "0" /* XpsBoolean.false */,
|
|
465
471
|
});
|
|
472
|
+
return enrichedUrl;
|
|
466
473
|
}
|
|
467
474
|
}
|
|
468
475
|
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 });
|
|
@@ -784,15 +791,143 @@ const checkStatusActionFactoryProvider = {
|
|
|
784
791
|
},
|
|
785
792
|
};
|
|
786
793
|
|
|
794
|
+
class TerminalError extends AppError {
|
|
795
|
+
constructor(message, code) {
|
|
796
|
+
super(message);
|
|
797
|
+
this.code = code;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
var StatusGroups;
|
|
802
|
+
(function (StatusGroups) {
|
|
803
|
+
StatusGroups["troubled"] = "troubled";
|
|
804
|
+
StatusGroups["done"] = "done";
|
|
805
|
+
StatusGroups["invoice"] = "invoice";
|
|
806
|
+
})(StatusGroups || (StatusGroups = {}));
|
|
807
|
+
|
|
808
|
+
var StatusEnum;
|
|
809
|
+
(function (StatusEnum) {
|
|
810
|
+
StatusEnum["created"] = "created";
|
|
811
|
+
StatusEnum["awaiting"] = "awaiting";
|
|
812
|
+
StatusEnum["processing"] = "processing";
|
|
813
|
+
StatusEnum["authorized"] = "authorized";
|
|
814
|
+
StatusEnum["held"] = "held";
|
|
815
|
+
StatusEnum["done"] = "done";
|
|
816
|
+
StatusEnum["error"] = "error";
|
|
817
|
+
StatusEnum["canceled"] = "canceled";
|
|
818
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
819
|
+
|
|
820
|
+
class StatusResponse {
|
|
821
|
+
constructor(parameters) {
|
|
822
|
+
if (parameters.errors?.[0]) {
|
|
823
|
+
this.error = {
|
|
824
|
+
code: parameters.errors[0].code.toString(),
|
|
825
|
+
message: parameters.errors[0].message,
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
if (!parameters.status) {
|
|
829
|
+
throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
|
|
830
|
+
}
|
|
831
|
+
this.status = {
|
|
832
|
+
statusState: parameters.status.statusData.stateText,
|
|
833
|
+
email: parameters.status.statusData.email,
|
|
834
|
+
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
835
|
+
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
836
|
+
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
837
|
+
financeInfo: parameters.status.text.info,
|
|
838
|
+
discount: parameters.status.text.info.discount
|
|
839
|
+
? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
|
|
840
|
+
: null,
|
|
841
|
+
isCancelUser: parameters.status.isCancelUser,
|
|
842
|
+
postMessageStatus: parameters.status.isCancelUser
|
|
843
|
+
? StatusGroups.troubled
|
|
844
|
+
: parameters.status.group,
|
|
845
|
+
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
846
|
+
backUrlSettings: {
|
|
847
|
+
backUrl: parameters.status.text.backurl,
|
|
848
|
+
backUrlAction: parameters.status.text.backurl_action,
|
|
849
|
+
backUrlCaption: parameters.status.text.backurl_caption,
|
|
850
|
+
returnRegion: parameters.status.return_region,
|
|
851
|
+
},
|
|
852
|
+
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
853
|
+
group: parameters.status.group,
|
|
854
|
+
needToCheck: parameters.status.needToCheck,
|
|
855
|
+
autoRedirect: parameters.status.autoredirect,
|
|
856
|
+
statusMessage: parameters.status.text.state,
|
|
857
|
+
userId: parameters.status.statusData.v1,
|
|
858
|
+
invoice: parameters.status.statusData.invoice,
|
|
859
|
+
pid: parameters.status.statusData.pid,
|
|
860
|
+
projectAmount: this.getProjectAmount(parameters.status),
|
|
861
|
+
titleClass: parameters.status.title_class,
|
|
862
|
+
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
863
|
+
order: parameters.status.text.order,
|
|
864
|
+
};
|
|
865
|
+
if (parameters.form) {
|
|
866
|
+
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
867
|
+
}
|
|
868
|
+
if (this.status.statusState === StatusEnum.done ||
|
|
869
|
+
this.status.statusState === StatusEnum.authorized) {
|
|
870
|
+
this.status.isSuccess = true;
|
|
871
|
+
}
|
|
872
|
+
if (this.status.statusState === StatusEnum.canceled ||
|
|
873
|
+
this.status.isCancelUser) {
|
|
874
|
+
this.status.isCanceled = true;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
getUserReturnStatus(form) {
|
|
878
|
+
const value = form['fix_userReturnStatus']?.value;
|
|
879
|
+
if (value === 'undefined')
|
|
880
|
+
return undefined;
|
|
881
|
+
return value;
|
|
882
|
+
}
|
|
883
|
+
getProjectAmount(status) {
|
|
884
|
+
if (!status.statusData.projectAmount) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
888
|
+
return {
|
|
889
|
+
amount,
|
|
890
|
+
currency,
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
getAdditionalBackButton(status) {
|
|
894
|
+
if (!status.text.is_additional_back_url_enabled) {
|
|
895
|
+
return {
|
|
896
|
+
link: '',
|
|
897
|
+
action: '',
|
|
898
|
+
label: '',
|
|
899
|
+
region: '',
|
|
900
|
+
isEnabled: false,
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return {
|
|
904
|
+
link: status.text.additional_back_url_link ?? '',
|
|
905
|
+
action: status.text.additional_back_url_action ?? '',
|
|
906
|
+
label: status.text.additional_back_url_label ?? '',
|
|
907
|
+
region: status.additional_button_return_region ?? '',
|
|
908
|
+
isEnabled: status.text.is_additional_back_url_enabled,
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
787
913
|
class StatusUpdatedAction {
|
|
788
|
-
constructor(statusResponse) {
|
|
914
|
+
constructor(statusResponse, isSavePaymentMethodMode = false, savePaymentMethodStatus) {
|
|
789
915
|
this.type = 'status_updated';
|
|
916
|
+
let status;
|
|
917
|
+
if (statusResponse instanceof StatusResponse) {
|
|
918
|
+
status = statusResponse.status;
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
status = statusResponse;
|
|
922
|
+
}
|
|
790
923
|
this.data = {
|
|
791
|
-
statusState:
|
|
792
|
-
invoice:
|
|
793
|
-
isSuccess:
|
|
794
|
-
isCanceled:
|
|
795
|
-
group:
|
|
924
|
+
statusState: status.statusState,
|
|
925
|
+
invoice: status.invoice,
|
|
926
|
+
isSuccess: status.isSuccess,
|
|
927
|
+
isCanceled: status.isCanceled,
|
|
928
|
+
group: status.group,
|
|
929
|
+
isSavePaymentMethodMode,
|
|
930
|
+
savePaymentMethodStatus,
|
|
796
931
|
};
|
|
797
932
|
}
|
|
798
933
|
}
|
|
@@ -1438,6 +1573,9 @@ class InitializeService {
|
|
|
1438
1573
|
? "1" /* XpsBoolean.true */
|
|
1439
1574
|
: "0" /* XpsBoolean.false */,
|
|
1440
1575
|
saved_method_id: config.savedMethodId,
|
|
1576
|
+
save_payment_account_only: config.savePaymentMethod
|
|
1577
|
+
? "1" /* XpsBoolean.true */
|
|
1578
|
+
: "0" /* XpsBoolean.false */,
|
|
1441
1579
|
};
|
|
1442
1580
|
return this.xpsApiService
|
|
1443
1581
|
.directPaymentRequest(requestParams)
|
|
@@ -2827,6 +2965,7 @@ var StatusSearchParam;
|
|
|
2827
2965
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2828
2966
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2829
2967
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
2968
|
+
StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
|
|
2830
2969
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2831
2970
|
|
|
2832
2971
|
const requiredStatusSearchParams = [
|
|
@@ -2906,15 +3045,15 @@ const statusSearchParamsMap = new Map([
|
|
|
2906
3045
|
converter: numberConverter,
|
|
2907
3046
|
},
|
|
2908
3047
|
],
|
|
3048
|
+
[
|
|
3049
|
+
StatusSearchParam.isSavePaymentAccount,
|
|
3050
|
+
{
|
|
3051
|
+
key: 'isSavePaymentAccount',
|
|
3052
|
+
converter: stringConverter,
|
|
3053
|
+
},
|
|
3054
|
+
],
|
|
2909
3055
|
]);
|
|
2910
3056
|
|
|
2911
|
-
class TerminalError extends AppError {
|
|
2912
|
-
constructor(message, code) {
|
|
2913
|
-
super(message);
|
|
2914
|
-
this.code = code;
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
|
|
2918
3057
|
class XpsApiPart {
|
|
2919
3058
|
constructor() {
|
|
2920
3059
|
this.response = new BehaviorSubject(null);
|
|
@@ -2958,118 +3097,6 @@ const statusRequestFactoryProvider = {
|
|
|
2958
3097
|
useValue: (...args) => new StatusRequest(...args),
|
|
2959
3098
|
};
|
|
2960
3099
|
|
|
2961
|
-
var StatusGroups;
|
|
2962
|
-
(function (StatusGroups) {
|
|
2963
|
-
StatusGroups["troubled"] = "troubled";
|
|
2964
|
-
StatusGroups["done"] = "done";
|
|
2965
|
-
StatusGroups["invoice"] = "invoice";
|
|
2966
|
-
})(StatusGroups || (StatusGroups = {}));
|
|
2967
|
-
|
|
2968
|
-
var StatusEnum;
|
|
2969
|
-
(function (StatusEnum) {
|
|
2970
|
-
StatusEnum["created"] = "created";
|
|
2971
|
-
StatusEnum["awaiting"] = "awaiting";
|
|
2972
|
-
StatusEnum["processing"] = "processing";
|
|
2973
|
-
StatusEnum["authorized"] = "authorized";
|
|
2974
|
-
StatusEnum["held"] = "held";
|
|
2975
|
-
StatusEnum["done"] = "done";
|
|
2976
|
-
StatusEnum["error"] = "error";
|
|
2977
|
-
StatusEnum["canceled"] = "canceled";
|
|
2978
|
-
})(StatusEnum || (StatusEnum = {}));
|
|
2979
|
-
|
|
2980
|
-
class StatusResponse {
|
|
2981
|
-
constructor(parameters) {
|
|
2982
|
-
if (parameters.errors?.[0]) {
|
|
2983
|
-
this.error = {
|
|
2984
|
-
code: parameters.errors[0].code.toString(),
|
|
2985
|
-
message: parameters.errors[0].message,
|
|
2986
|
-
};
|
|
2987
|
-
}
|
|
2988
|
-
if (!parameters.status) {
|
|
2989
|
-
throw new TerminalError(this.error?.message ?? '', this.error?.code.toString() ?? '');
|
|
2990
|
-
}
|
|
2991
|
-
this.status = {
|
|
2992
|
-
statusState: parameters.status.statusData.stateText,
|
|
2993
|
-
email: parameters.status.statusData.email,
|
|
2994
|
-
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
2995
|
-
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
2996
|
-
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
2997
|
-
financeInfo: parameters.status.text.info,
|
|
2998
|
-
discount: parameters.status.text.info.discount
|
|
2999
|
-
? Math.abs(Number.parseFloat(parameters.status.text.info.discount?.value ?? ''))
|
|
3000
|
-
: null,
|
|
3001
|
-
isCancelUser: parameters.status.isCancelUser,
|
|
3002
|
-
postMessageStatus: parameters.status.isCancelUser
|
|
3003
|
-
? StatusGroups.troubled
|
|
3004
|
-
: parameters.status.group,
|
|
3005
|
-
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
3006
|
-
backUrlSettings: {
|
|
3007
|
-
backUrl: parameters.status.text.backurl,
|
|
3008
|
-
backUrlAction: parameters.status.text.backurl_action,
|
|
3009
|
-
backUrlCaption: parameters.status.text.backurl_caption,
|
|
3010
|
-
returnRegion: parameters.status.return_region,
|
|
3011
|
-
},
|
|
3012
|
-
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
3013
|
-
group: parameters.status.group,
|
|
3014
|
-
needToCheck: parameters.status.needToCheck,
|
|
3015
|
-
autoRedirect: parameters.status.autoredirect,
|
|
3016
|
-
statusMessage: parameters.status.text.state,
|
|
3017
|
-
userId: parameters.status.statusData.v1,
|
|
3018
|
-
invoice: parameters.status.statusData.invoice,
|
|
3019
|
-
pid: parameters.status.statusData.pid,
|
|
3020
|
-
projectAmount: this.getProjectAmount(parameters.status),
|
|
3021
|
-
titleClass: parameters.status.title_class,
|
|
3022
|
-
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
3023
|
-
order: parameters.status.text.order,
|
|
3024
|
-
};
|
|
3025
|
-
if (parameters.form) {
|
|
3026
|
-
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
3027
|
-
}
|
|
3028
|
-
if (this.status.statusState === StatusEnum.done ||
|
|
3029
|
-
this.status.statusState === StatusEnum.authorized) {
|
|
3030
|
-
this.status.isSuccess = true;
|
|
3031
|
-
}
|
|
3032
|
-
if (this.status.statusState === StatusEnum.canceled ||
|
|
3033
|
-
this.status.isCancelUser) {
|
|
3034
|
-
this.status.isCanceled = true;
|
|
3035
|
-
}
|
|
3036
|
-
}
|
|
3037
|
-
getUserReturnStatus(form) {
|
|
3038
|
-
const value = form['fix_userReturnStatus']?.value;
|
|
3039
|
-
if (value === 'undefined')
|
|
3040
|
-
return undefined;
|
|
3041
|
-
return value;
|
|
3042
|
-
}
|
|
3043
|
-
getProjectAmount(status) {
|
|
3044
|
-
if (!status.statusData.projectAmount) {
|
|
3045
|
-
return;
|
|
3046
|
-
}
|
|
3047
|
-
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
3048
|
-
return {
|
|
3049
|
-
amount,
|
|
3050
|
-
currency,
|
|
3051
|
-
};
|
|
3052
|
-
}
|
|
3053
|
-
getAdditionalBackButton(status) {
|
|
3054
|
-
if (!status.text.is_additional_back_url_enabled) {
|
|
3055
|
-
return {
|
|
3056
|
-
link: '',
|
|
3057
|
-
action: '',
|
|
3058
|
-
label: '',
|
|
3059
|
-
region: '',
|
|
3060
|
-
isEnabled: false,
|
|
3061
|
-
};
|
|
3062
|
-
}
|
|
3063
|
-
return {
|
|
3064
|
-
link: status.text.additional_back_url_link ?? '',
|
|
3065
|
-
action: status.text.additional_back_url_action ?? '',
|
|
3066
|
-
label: status.text.additional_back_url_label ?? '',
|
|
3067
|
-
region: status.additional_button_return_region ?? '',
|
|
3068
|
-
isEnabled: status.text.is_additional_back_url_enabled,
|
|
3069
|
-
};
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
|
|
3073
3100
|
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
3074
3101
|
const statusResponseFactoryProvider = {
|
|
3075
3102
|
provide: statusResponseFactoryToken,
|
|
@@ -4546,15 +4573,179 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4546
4573
|
}]
|
|
4547
4574
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
4548
4575
|
|
|
4576
|
+
var TitleClass;
|
|
4577
|
+
(function (TitleClass) {
|
|
4578
|
+
TitleClass["done"] = "done";
|
|
4579
|
+
TitleClass["cancel"] = "cancel";
|
|
4580
|
+
TitleClass["cancelUser"] = "canceluser";
|
|
4581
|
+
})(TitleClass || (TitleClass = {}));
|
|
4582
|
+
|
|
4583
|
+
var SavePaymentMethodStatus;
|
|
4584
|
+
(function (SavePaymentMethodStatus) {
|
|
4585
|
+
SavePaymentMethodStatus["success"] = "success";
|
|
4586
|
+
SavePaymentMethodStatus["failed"] = "failed";
|
|
4587
|
+
})(SavePaymentMethodStatus || (SavePaymentMethodStatus = {}));
|
|
4588
|
+
|
|
4589
|
+
class XpsResponseError extends AppError {
|
|
4590
|
+
constructor(message) {
|
|
4591
|
+
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4595
|
+
class SavedPaymentAccountChangesService {
|
|
4596
|
+
constructor(settingsService, secureApi) {
|
|
4597
|
+
this.settingsService = settingsService;
|
|
4598
|
+
this.secureApi = secureApi;
|
|
4599
|
+
this.apiRoute = 'savedmethods/newaccountinfo';
|
|
4600
|
+
this.response = new Subject();
|
|
4601
|
+
}
|
|
4602
|
+
get response$() {
|
|
4603
|
+
return this.response.asObservable();
|
|
4604
|
+
}
|
|
4605
|
+
async request(invoice) {
|
|
4606
|
+
const requestParameters = {
|
|
4607
|
+
access_token: this.settingsService.token,
|
|
4608
|
+
invoice_id: invoice,
|
|
4609
|
+
};
|
|
4610
|
+
return lastValueFrom(this.secureApi
|
|
4611
|
+
.post(this.apiRoute, new URLSearchParams(requestParameters), {
|
|
4612
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
4613
|
+
responseType: 'json',
|
|
4614
|
+
})
|
|
4615
|
+
.pipe(tap((value) => {
|
|
4616
|
+
this.response.next(value);
|
|
4617
|
+
}))).catch((error) => {
|
|
4618
|
+
throw new XpsResponseError(error.message);
|
|
4619
|
+
});
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
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 });
|
|
4623
|
+
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
|
|
4624
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4625
|
+
type: Injectable,
|
|
4626
|
+
args: [{
|
|
4627
|
+
providedIn: 'root',
|
|
4628
|
+
}]
|
|
4629
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4630
|
+
|
|
4631
|
+
class SavePaymentMethodStatusService {
|
|
4632
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
|
|
4633
|
+
this.statusRequestService = statusRequestService;
|
|
4634
|
+
this.listenStatusService = listenStatusService;
|
|
4635
|
+
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4636
|
+
this.nextActionService = nextActionService;
|
|
4637
|
+
this.checkStatusService = checkStatusService;
|
|
4638
|
+
this.statusChecked = false;
|
|
4639
|
+
}
|
|
4640
|
+
async getStatus(params) {
|
|
4641
|
+
if (!this.accountData || !this.status) {
|
|
4642
|
+
this.statusRequestService.setRequestParams(params);
|
|
4643
|
+
this.statusRequestService.request();
|
|
4644
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4645
|
+
this.status = statusResponse.status;
|
|
4646
|
+
this.status.isSavePaymentAccount = true;
|
|
4647
|
+
this.accountData = await this.getPaymentAccountData(params.invoice);
|
|
4648
|
+
}
|
|
4649
|
+
if (this.savingFailedOrCancel(this.status) ||
|
|
4650
|
+
(this.accountData && this.savingSuccessful(this.accountData, this.status))) {
|
|
4651
|
+
return this.status;
|
|
4652
|
+
}
|
|
4653
|
+
if (!this.statusChecked) {
|
|
4654
|
+
this.checkStatus(params);
|
|
4655
|
+
this.status.statusState = StatusEnum.processing;
|
|
4656
|
+
return this.status;
|
|
4657
|
+
}
|
|
4658
|
+
this.statusChecked = false;
|
|
4659
|
+
this.status.statusState = StatusEnum.error;
|
|
4660
|
+
const outStatus = { ...this.status };
|
|
4661
|
+
this.status = null;
|
|
4662
|
+
return outStatus;
|
|
4663
|
+
}
|
|
4664
|
+
checkStatus(params) {
|
|
4665
|
+
if (!this.statusChecked) {
|
|
4666
|
+
this.statusChecked = true;
|
|
4667
|
+
}
|
|
4668
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4669
|
+
this.statusRequestService.request();
|
|
4670
|
+
}
|
|
4671
|
+
savingFailedOrCancel(status) {
|
|
4672
|
+
return (status?.titleClass === TitleClass.cancel ||
|
|
4673
|
+
status?.titleClass === TitleClass.cancelUser);
|
|
4674
|
+
}
|
|
4675
|
+
savingSuccessful(accountData, status, checkStatus) {
|
|
4676
|
+
return !!(status?.titleClass === TitleClass.done &&
|
|
4677
|
+
(accountData?.new_account || checkStatus?.isPaymentAccountAttached));
|
|
4678
|
+
}
|
|
4679
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4680
|
+
getPaymentAccountData(invoice) {
|
|
4681
|
+
return this.savedPaymentAccountChangesService.request(invoice);
|
|
4682
|
+
}
|
|
4683
|
+
startWaitingStatusUpdates(invoice) {
|
|
4684
|
+
if (this.listenStatusSubscription) {
|
|
4685
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4686
|
+
this.listenStatusService.stopListening();
|
|
4687
|
+
}
|
|
4688
|
+
this.listenStatusService.listen(invoice);
|
|
4689
|
+
this.listenStatusSubscription =
|
|
4690
|
+
this.listenStatusService.statusUpdated$.subscribe(({ statusResponse }) => {
|
|
4691
|
+
if (!statusResponse?.status) {
|
|
4692
|
+
return;
|
|
4693
|
+
}
|
|
4694
|
+
this.status = statusResponse.status;
|
|
4695
|
+
void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
|
|
4696
|
+
if (checkStatusResponse?.final && statusResponse.status) {
|
|
4697
|
+
this.loadNewPaymentAccountData(statusResponse.status, checkStatusResponse);
|
|
4698
|
+
}
|
|
4699
|
+
});
|
|
4700
|
+
});
|
|
4701
|
+
}
|
|
4702
|
+
loadNewPaymentAccountData(status, checkStatus) {
|
|
4703
|
+
if (!status.invoice) {
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
void this.getPaymentAccountData(status.invoice).then((accountChanges) => {
|
|
4707
|
+
if (accountChanges) {
|
|
4708
|
+
this.accountData = accountChanges;
|
|
4709
|
+
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4710
|
+
}
|
|
4711
|
+
});
|
|
4712
|
+
}
|
|
4713
|
+
handleSavingStatus(status, account, checkStatus) {
|
|
4714
|
+
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4715
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4716
|
+
}
|
|
4717
|
+
else {
|
|
4718
|
+
this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
|
|
4719
|
+
}
|
|
4720
|
+
this.listenStatusService.stopListening();
|
|
4721
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4722
|
+
const isSavePaymentMethod = true;
|
|
4723
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4724
|
+
}
|
|
4725
|
+
}
|
|
4726
|
+
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 });
|
|
4727
|
+
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4728
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4729
|
+
type: Injectable,
|
|
4730
|
+
args: [{
|
|
4731
|
+
providedIn: 'root',
|
|
4732
|
+
}]
|
|
4733
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4734
|
+
|
|
4549
4735
|
class StatusService {
|
|
4550
|
-
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
4736
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
4551
4737
|
this.urlService = urlService;
|
|
4552
4738
|
this.statusRequestService = statusRequestService;
|
|
4553
4739
|
this.financeDetailsService = financeDetailsService;
|
|
4554
4740
|
this.listenStatusService = listenStatusService;
|
|
4555
4741
|
this.nextActionService = nextActionService;
|
|
4742
|
+
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4556
4743
|
}
|
|
4557
4744
|
async getStatus(params) {
|
|
4745
|
+
const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
|
|
4746
|
+
if (isSavePaymentMethodMode) {
|
|
4747
|
+
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4748
|
+
}
|
|
4558
4749
|
this.statusRequestService.setRequestParams(params);
|
|
4559
4750
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4560
4751
|
this.statusRequestService.request();
|
|
@@ -4591,14 +4782,14 @@ class StatusService {
|
|
|
4591
4782
|
});
|
|
4592
4783
|
}
|
|
4593
4784
|
}
|
|
4594
|
-
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 });
|
|
4785
|
+
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 });
|
|
4595
4786
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
4596
4787
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
4597
4788
|
type: Injectable,
|
|
4598
4789
|
args: [{
|
|
4599
4790
|
providedIn: 'root',
|
|
4600
4791
|
}]
|
|
4601
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4792
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }, { type: SavePaymentMethodStatusService }]; } });
|
|
4602
4793
|
|
|
4603
4794
|
class CreditCardStateService extends EmitDataService {
|
|
4604
4795
|
}
|
|
@@ -4623,12 +4814,6 @@ var ThreeDsStatusTypes;
|
|
|
4623
4814
|
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
4624
4815
|
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
4625
4816
|
|
|
4626
|
-
class XpsResponseError extends AppError {
|
|
4627
|
-
constructor(message) {
|
|
4628
|
-
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
|
|
4632
4817
|
class StatusThreeDsRequest {
|
|
4633
4818
|
constructor(token, threeDsId) {
|
|
4634
4819
|
this.access_token = token;
|
|
@@ -5076,6 +5261,7 @@ class PaymentService {
|
|
|
5076
5261
|
this.destroy$ = new Subject();
|
|
5077
5262
|
this.formDestroy$ = new Subject();
|
|
5078
5263
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5264
|
+
this.isSavingMethodMode = false;
|
|
5079
5265
|
}
|
|
5080
5266
|
async initialize(config) {
|
|
5081
5267
|
this.destroy$ = new Subject();
|
|
@@ -5101,9 +5287,12 @@ class PaymentService {
|
|
|
5101
5287
|
this.emitFormFieldsStatus(this.form);
|
|
5102
5288
|
return;
|
|
5103
5289
|
}
|
|
5290
|
+
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5104
5291
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5105
5292
|
this.data = submitResponse;
|
|
5106
|
-
this.
|
|
5293
|
+
if (!this.isSavingMethodMode) {
|
|
5294
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
5295
|
+
}
|
|
5107
5296
|
this.emitFormMessages(submitResponse.messages);
|
|
5108
5297
|
// Handle 3ds flow
|
|
5109
5298
|
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
@@ -5152,6 +5341,9 @@ class PaymentService {
|
|
|
5152
5341
|
signature: this.data.signature ?? '',
|
|
5153
5342
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5154
5343
|
'en',
|
|
5344
|
+
isSavePaymentAccount: this.isSavingMethodMode
|
|
5345
|
+
? "1" /* XpsBoolean.true */
|
|
5346
|
+
: "0" /* XpsBoolean.false */,
|
|
5155
5347
|
};
|
|
5156
5348
|
return this.statusService.getStatus(params);
|
|
5157
5349
|
}
|
|
@@ -5407,7 +5599,7 @@ class CoreLibraryService {
|
|
|
5407
5599
|
this.formMessagesService = formMessagesService;
|
|
5408
5600
|
this.editSavedMethodsService = editSavedMethodsService;
|
|
5409
5601
|
this.paymentMethods = {
|
|
5410
|
-
getList: async () => this.paymentMethodsService.getList(),
|
|
5602
|
+
getList: async (isSaveMethodMode) => this.paymentMethodsService.getList(isSaveMethodMode),
|
|
5411
5603
|
getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
|
|
5412
5604
|
getSavedMethods: async () => this.savedMethodsService.getList(),
|
|
5413
5605
|
getUserBalance: async () => this.userBalanceService.getUserBalance(),
|