@xsolla/payment-client-core 0.0.13 → 0.0.14
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/config/config.service.mjs +30 -0
- package/esm2020/lib/core/payment/payment.service.mjs +3 -5
- package/esm2020/lib/core/payment/status/status-request/request/status-request.class.mjs +2 -2
- package/esm2020/lib/core/payment/status/status-request/required-status-search-params.const.mjs +9 -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 +13 -0
- package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +72 -0
- package/esm2020/lib/core/payment/status/status.service.mjs +30 -7
- package/esm2020/lib/core/url/search-params.interface.mjs +2 -0
- package/esm2020/lib/core/url/url.service.mjs +28 -0
- package/esm2020/lib/core-library.service.mjs +18 -10
- package/fesm2015/xsolla-payment-client-core.mjs +181 -9
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +180 -12
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/config/config.service.d.ts +13 -0
- package/lib/core/payment/status/status-request/request/status-request.class.d.ts +1 -3
- package/lib/core/payment/status/status-request/required-status-search-params.const.d.ts +2 -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 +11 -0
- package/lib/core/payment/status/status-request/status-search-params.map.d.ts +9 -0
- package/lib/core/payment/status/status.service.d.ts +5 -1
- package/lib/core/url/search-params.interface.d.ts +3 -0
- package/lib/core/url/url.service.d.ts +8 -0
- package/lib/core-library.service.d.ts +7 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.14.tgz +0 -0
- package/esm2020/lib/core/payment/status/status-params.interface.mjs +0 -2
- package/lib/core/payment/status/status-params.interface.d.ts +0 -9
- package/xsolla-payment-client-core-0.0.13.tgz +0 -0
|
@@ -405,6 +405,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
405
405
|
args: [userBalanceResponseFactoryToken]
|
|
406
406
|
}] }, { type: SettingsService }, { type: SecureApiClient }]; } });
|
|
407
407
|
|
|
408
|
+
class UrlService {
|
|
409
|
+
addSearchParams(url, params = {}) {
|
|
410
|
+
const urlObject = new URL(url);
|
|
411
|
+
for (const [key, value] of Object.entries(params)) {
|
|
412
|
+
urlObject.searchParams.set(key, value);
|
|
413
|
+
}
|
|
414
|
+
return urlObject.toString();
|
|
415
|
+
}
|
|
416
|
+
getSearchParams(url) {
|
|
417
|
+
const urlObject = new URL(url);
|
|
418
|
+
const searchParams = {};
|
|
419
|
+
for (const [key, value] of urlObject.searchParams) {
|
|
420
|
+
searchParams[key] = value;
|
|
421
|
+
}
|
|
422
|
+
return searchParams;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
UrlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
426
|
+
UrlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, providedIn: 'root' });
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, decorators: [{
|
|
428
|
+
type: Injectable,
|
|
429
|
+
args: [{
|
|
430
|
+
providedIn: 'root',
|
|
431
|
+
}]
|
|
432
|
+
}] });
|
|
433
|
+
|
|
434
|
+
class PaymentConfigService {
|
|
435
|
+
constructor(urlService, settingsService) {
|
|
436
|
+
this.urlService = urlService;
|
|
437
|
+
this.settingsService = settingsService;
|
|
438
|
+
}
|
|
439
|
+
enrich(config) {
|
|
440
|
+
return {
|
|
441
|
+
...config,
|
|
442
|
+
returnUrl: this.enrichReturnUrl(config.returnUrl),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
enrichReturnUrl(returnUrl) {
|
|
446
|
+
return this.urlService.addSearchParams(returnUrl, {
|
|
447
|
+
token: this.settingsService.token,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
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 });
|
|
452
|
+
PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, providedIn: 'root' });
|
|
453
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
454
|
+
type: Injectable,
|
|
455
|
+
args: [{
|
|
456
|
+
providedIn: 'root',
|
|
457
|
+
}]
|
|
458
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
459
|
+
|
|
408
460
|
var XpsCommand;
|
|
409
461
|
(function (XpsCommand) {
|
|
410
462
|
XpsCommand["form"] = "form";
|
|
@@ -1334,6 +1386,98 @@ class StatusUpdatedAction {
|
|
|
1334
1386
|
}
|
|
1335
1387
|
}
|
|
1336
1388
|
|
|
1389
|
+
var StatusSearchParam;
|
|
1390
|
+
(function (StatusSearchParam) {
|
|
1391
|
+
StatusSearchParam["token"] = "token";
|
|
1392
|
+
StatusSearchParam["pid"] = "fix_pid";
|
|
1393
|
+
StatusSearchParam["invoice"] = "fix_invoice";
|
|
1394
|
+
StatusSearchParam["signature"] = "signature";
|
|
1395
|
+
StatusSearchParam["locale"] = "locale";
|
|
1396
|
+
StatusSearchParam["testProject"] = "fix_testProject";
|
|
1397
|
+
StatusSearchParam["testPs"] = "fix_testPs";
|
|
1398
|
+
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
1399
|
+
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
1400
|
+
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
1401
|
+
|
|
1402
|
+
const requiredStatusSearchParams = [
|
|
1403
|
+
StatusSearchParam.token,
|
|
1404
|
+
StatusSearchParam.locale,
|
|
1405
|
+
StatusSearchParam.signature,
|
|
1406
|
+
StatusSearchParam.pid,
|
|
1407
|
+
StatusSearchParam.invoice,
|
|
1408
|
+
];
|
|
1409
|
+
|
|
1410
|
+
const stringConverter = (value) => value;
|
|
1411
|
+
const numberConverter = (value) => {
|
|
1412
|
+
const numberValue = Number(value);
|
|
1413
|
+
return isNaN(numberValue) ? 0 : numberValue;
|
|
1414
|
+
};
|
|
1415
|
+
const statusSearchParamsMap = new Map([
|
|
1416
|
+
[
|
|
1417
|
+
StatusSearchParam.token,
|
|
1418
|
+
{
|
|
1419
|
+
key: 'token',
|
|
1420
|
+
converter: stringConverter,
|
|
1421
|
+
},
|
|
1422
|
+
],
|
|
1423
|
+
[
|
|
1424
|
+
StatusSearchParam.signature,
|
|
1425
|
+
{
|
|
1426
|
+
key: 'signature',
|
|
1427
|
+
converter: stringConverter,
|
|
1428
|
+
},
|
|
1429
|
+
],
|
|
1430
|
+
[
|
|
1431
|
+
StatusSearchParam.locale,
|
|
1432
|
+
{
|
|
1433
|
+
key: 'locale',
|
|
1434
|
+
converter: stringConverter,
|
|
1435
|
+
},
|
|
1436
|
+
],
|
|
1437
|
+
[
|
|
1438
|
+
StatusSearchParam.userReturnStatus,
|
|
1439
|
+
{
|
|
1440
|
+
key: 'userReturnStatus',
|
|
1441
|
+
converter: stringConverter,
|
|
1442
|
+
},
|
|
1443
|
+
],
|
|
1444
|
+
[
|
|
1445
|
+
StatusSearchParam.pid,
|
|
1446
|
+
{
|
|
1447
|
+
key: 'pid',
|
|
1448
|
+
converter: numberConverter,
|
|
1449
|
+
},
|
|
1450
|
+
],
|
|
1451
|
+
[
|
|
1452
|
+
StatusSearchParam.invoice,
|
|
1453
|
+
{
|
|
1454
|
+
key: 'invoice',
|
|
1455
|
+
converter: numberConverter,
|
|
1456
|
+
},
|
|
1457
|
+
],
|
|
1458
|
+
[
|
|
1459
|
+
StatusSearchParam.testProject,
|
|
1460
|
+
{
|
|
1461
|
+
key: 'testProject',
|
|
1462
|
+
converter: numberConverter,
|
|
1463
|
+
},
|
|
1464
|
+
],
|
|
1465
|
+
[
|
|
1466
|
+
StatusSearchParam.testPs,
|
|
1467
|
+
{
|
|
1468
|
+
key: 'testPs',
|
|
1469
|
+
converter: numberConverter,
|
|
1470
|
+
},
|
|
1471
|
+
],
|
|
1472
|
+
[
|
|
1473
|
+
StatusSearchParam.testXsolla,
|
|
1474
|
+
{
|
|
1475
|
+
key: 'testXsolla',
|
|
1476
|
+
converter: numberConverter,
|
|
1477
|
+
},
|
|
1478
|
+
],
|
|
1479
|
+
]);
|
|
1480
|
+
|
|
1337
1481
|
class XpsApiPart {
|
|
1338
1482
|
constructor() {
|
|
1339
1483
|
this.response = new BehaviorSubject(null);
|
|
@@ -1356,7 +1500,7 @@ class StatusRequest extends XpsApiPartRequest {
|
|
|
1356
1500
|
constructor(parameters) {
|
|
1357
1501
|
super();
|
|
1358
1502
|
this.xps_fix_command = 'status';
|
|
1359
|
-
if (parameters.token
|
|
1503
|
+
if (!parameters.token) {
|
|
1360
1504
|
throw new TokenError();
|
|
1361
1505
|
}
|
|
1362
1506
|
this.access_token = parameters.token;
|
|
@@ -2452,7 +2596,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2452
2596
|
}] }, { type: i0.Injector }]; } });
|
|
2453
2597
|
|
|
2454
2598
|
class StatusService {
|
|
2455
|
-
constructor(statusRequestService, listenStatusService, nextActionService) {
|
|
2599
|
+
constructor(urlService, statusRequestService, listenStatusService, nextActionService) {
|
|
2600
|
+
this.urlService = urlService;
|
|
2456
2601
|
this.statusRequestService = statusRequestService;
|
|
2457
2602
|
this.listenStatusService = listenStatusService;
|
|
2458
2603
|
this.nextActionService = nextActionService;
|
|
@@ -2464,6 +2609,25 @@ class StatusService {
|
|
|
2464
2609
|
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
2465
2610
|
return statusResponse.status;
|
|
2466
2611
|
}
|
|
2612
|
+
async getStatusWithUrlSearchParams(url) {
|
|
2613
|
+
const searchParams = this.getRequestParamsFromUrl(url);
|
|
2614
|
+
if (!searchParams) {
|
|
2615
|
+
throw new Error('No required search params to get status');
|
|
2616
|
+
}
|
|
2617
|
+
return this.getStatus(searchParams);
|
|
2618
|
+
}
|
|
2619
|
+
getRequestParamsFromUrl(url) {
|
|
2620
|
+
const searchParams = this.urlService.getSearchParams(url ?? '');
|
|
2621
|
+
const keys = new Set(Object.keys(searchParams));
|
|
2622
|
+
if (requiredStatusSearchParams.some((requiredKey) => !keys.has(requiredKey))) {
|
|
2623
|
+
return null;
|
|
2624
|
+
}
|
|
2625
|
+
const params = {};
|
|
2626
|
+
statusSearchParamsMap.forEach((settings, key) => {
|
|
2627
|
+
params[settings.key] = settings.converter(searchParams[key]);
|
|
2628
|
+
});
|
|
2629
|
+
return params;
|
|
2630
|
+
}
|
|
2467
2631
|
startWaitingStatusUpdates(invoice) {
|
|
2468
2632
|
this.listenStatusService.listen(invoice);
|
|
2469
2633
|
this.listenStatusService.statusUpdated$
|
|
@@ -2473,14 +2637,14 @@ class StatusService {
|
|
|
2473
2637
|
});
|
|
2474
2638
|
}
|
|
2475
2639
|
}
|
|
2476
|
-
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2640
|
+
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2477
2641
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
2478
2642
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
2479
2643
|
type: Injectable,
|
|
2480
2644
|
args: [{
|
|
2481
2645
|
providedIn: 'root',
|
|
2482
2646
|
}]
|
|
2483
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2647
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2484
2648
|
|
|
2485
2649
|
/**
|
|
2486
2650
|
* default image for purchase item is set on Publisher Account side.
|
|
@@ -2829,15 +2993,13 @@ class PaymentService {
|
|
|
2829
2993
|
throw new Error('Should submit form first');
|
|
2830
2994
|
}
|
|
2831
2995
|
const params = {
|
|
2996
|
+
pid: this.config.paymentMethodId,
|
|
2832
2997
|
invoice: parseInt(this.data.fixInvoice ?? ''),
|
|
2833
2998
|
signature: this.data.signature ?? '',
|
|
2834
2999
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
2835
3000
|
'en',
|
|
2836
3001
|
};
|
|
2837
|
-
return this.statusService.getStatus(
|
|
2838
|
-
...params,
|
|
2839
|
-
pid: this.config.paymentMethodId,
|
|
2840
|
-
});
|
|
3002
|
+
return this.statusService.getStatus(params);
|
|
2841
3003
|
}
|
|
2842
3004
|
getFieldConfig(field) {
|
|
2843
3005
|
return this.controlConfigService.getConfig(field);
|
|
@@ -2980,16 +3142,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2980
3142
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
2981
3143
|
|
|
2982
3144
|
class CoreLibraryService {
|
|
2983
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
|
|
3145
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService) {
|
|
2984
3146
|
this.settingsService = settingsService;
|
|
2985
3147
|
this.countryService = countryService;
|
|
2986
3148
|
this.paymentMethodsService = paymentMethodsService;
|
|
2987
3149
|
this.savedMethodsService = savedMethodsService;
|
|
2988
3150
|
this.userBalanceService = userBalanceService;
|
|
3151
|
+
this.paymentConfigService = paymentConfigService;
|
|
2989
3152
|
this.paymentService = paymentService;
|
|
2990
3153
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
2991
3154
|
this.financeDetailsService = financeDetailsService;
|
|
2992
3155
|
this.legalService = legalService;
|
|
3156
|
+
this.statusService = statusService;
|
|
2993
3157
|
this.nextActionService = nextActionService;
|
|
2994
3158
|
this.paymentMethods = {
|
|
2995
3159
|
getList: async () => this.paymentMethodsService.getList(),
|
|
@@ -3002,12 +3166,16 @@ class CoreLibraryService {
|
|
|
3002
3166
|
await this.settingsService.init(configuration);
|
|
3003
3167
|
await this.deviceFingerPrintService.init();
|
|
3004
3168
|
}
|
|
3169
|
+
async getStatus(url) {
|
|
3170
|
+
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
3171
|
+
}
|
|
3005
3172
|
setCountry(country) {
|
|
3006
3173
|
this.countryService.setCountry(country);
|
|
3007
3174
|
}
|
|
3008
3175
|
createPayment(config) {
|
|
3176
|
+
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
3009
3177
|
return {
|
|
3010
|
-
initialize: async () => this.paymentService.initialize(
|
|
3178
|
+
initialize: async () => this.paymentService.initialize(enrichedConfig),
|
|
3011
3179
|
submit: async () => this.paymentService.submit(),
|
|
3012
3180
|
getFields: () => this.paymentService.getFields(),
|
|
3013
3181
|
validate: async (field) => this.paymentService.validate(field),
|
|
@@ -3030,14 +3198,14 @@ class CoreLibraryService {
|
|
|
3030
3198
|
return masksFunctionsMap[sanitizedName];
|
|
3031
3199
|
}
|
|
3032
3200
|
}
|
|
3033
|
-
CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3201
|
+
CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3034
3202
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
3035
3203
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
3036
3204
|
type: Injectable,
|
|
3037
3205
|
args: [{
|
|
3038
3206
|
providedIn: 'root',
|
|
3039
3207
|
}]
|
|
3040
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
3208
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
3041
3209
|
|
|
3042
3210
|
class HttpError extends AppError {
|
|
3043
3211
|
constructor(error, req) {
|