@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
|
@@ -432,6 +432,55 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
432
432
|
}] }, { type: SettingsService }, { type: SecureApiClient }];
|
|
433
433
|
} });
|
|
434
434
|
|
|
435
|
+
class UrlService {
|
|
436
|
+
addSearchParams(url, params = {}) {
|
|
437
|
+
const urlObject = new URL(url);
|
|
438
|
+
for (const [key, value] of Object.entries(params)) {
|
|
439
|
+
urlObject.searchParams.set(key, value);
|
|
440
|
+
}
|
|
441
|
+
return urlObject.toString();
|
|
442
|
+
}
|
|
443
|
+
getSearchParams(url) {
|
|
444
|
+
const urlObject = new URL(url);
|
|
445
|
+
const searchParams = {};
|
|
446
|
+
for (const [key, value] of urlObject.searchParams) {
|
|
447
|
+
searchParams[key] = value;
|
|
448
|
+
}
|
|
449
|
+
return searchParams;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
UrlService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
453
|
+
UrlService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, providedIn: 'root' });
|
|
454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UrlService, decorators: [{
|
|
455
|
+
type: Injectable,
|
|
456
|
+
args: [{
|
|
457
|
+
providedIn: 'root',
|
|
458
|
+
}]
|
|
459
|
+
}] });
|
|
460
|
+
|
|
461
|
+
class PaymentConfigService {
|
|
462
|
+
constructor(urlService, settingsService) {
|
|
463
|
+
this.urlService = urlService;
|
|
464
|
+
this.settingsService = settingsService;
|
|
465
|
+
}
|
|
466
|
+
enrich(config) {
|
|
467
|
+
return Object.assign(Object.assign({}, config), { returnUrl: this.enrichReturnUrl(config.returnUrl) });
|
|
468
|
+
}
|
|
469
|
+
enrichReturnUrl(returnUrl) {
|
|
470
|
+
return this.urlService.addSearchParams(returnUrl, {
|
|
471
|
+
token: this.settingsService.token,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
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 });
|
|
476
|
+
PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, providedIn: 'root' });
|
|
477
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
478
|
+
type: Injectable,
|
|
479
|
+
args: [{
|
|
480
|
+
providedIn: 'root',
|
|
481
|
+
}]
|
|
482
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
483
|
+
|
|
435
484
|
var XpsCommand;
|
|
436
485
|
(function (XpsCommand) {
|
|
437
486
|
XpsCommand["form"] = "form";
|
|
@@ -1399,6 +1448,98 @@ class StatusUpdatedAction {
|
|
|
1399
1448
|
}
|
|
1400
1449
|
}
|
|
1401
1450
|
|
|
1451
|
+
var StatusSearchParam;
|
|
1452
|
+
(function (StatusSearchParam) {
|
|
1453
|
+
StatusSearchParam["token"] = "token";
|
|
1454
|
+
StatusSearchParam["pid"] = "fix_pid";
|
|
1455
|
+
StatusSearchParam["invoice"] = "fix_invoice";
|
|
1456
|
+
StatusSearchParam["signature"] = "signature";
|
|
1457
|
+
StatusSearchParam["locale"] = "locale";
|
|
1458
|
+
StatusSearchParam["testProject"] = "fix_testProject";
|
|
1459
|
+
StatusSearchParam["testPs"] = "fix_testPs";
|
|
1460
|
+
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
1461
|
+
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
1462
|
+
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
1463
|
+
|
|
1464
|
+
const requiredStatusSearchParams = [
|
|
1465
|
+
StatusSearchParam.token,
|
|
1466
|
+
StatusSearchParam.locale,
|
|
1467
|
+
StatusSearchParam.signature,
|
|
1468
|
+
StatusSearchParam.pid,
|
|
1469
|
+
StatusSearchParam.invoice,
|
|
1470
|
+
];
|
|
1471
|
+
|
|
1472
|
+
const stringConverter = (value) => value;
|
|
1473
|
+
const numberConverter = (value) => {
|
|
1474
|
+
const numberValue = Number(value);
|
|
1475
|
+
return isNaN(numberValue) ? 0 : numberValue;
|
|
1476
|
+
};
|
|
1477
|
+
const statusSearchParamsMap = new Map([
|
|
1478
|
+
[
|
|
1479
|
+
StatusSearchParam.token,
|
|
1480
|
+
{
|
|
1481
|
+
key: 'token',
|
|
1482
|
+
converter: stringConverter,
|
|
1483
|
+
},
|
|
1484
|
+
],
|
|
1485
|
+
[
|
|
1486
|
+
StatusSearchParam.signature,
|
|
1487
|
+
{
|
|
1488
|
+
key: 'signature',
|
|
1489
|
+
converter: stringConverter,
|
|
1490
|
+
},
|
|
1491
|
+
],
|
|
1492
|
+
[
|
|
1493
|
+
StatusSearchParam.locale,
|
|
1494
|
+
{
|
|
1495
|
+
key: 'locale',
|
|
1496
|
+
converter: stringConverter,
|
|
1497
|
+
},
|
|
1498
|
+
],
|
|
1499
|
+
[
|
|
1500
|
+
StatusSearchParam.userReturnStatus,
|
|
1501
|
+
{
|
|
1502
|
+
key: 'userReturnStatus',
|
|
1503
|
+
converter: stringConverter,
|
|
1504
|
+
},
|
|
1505
|
+
],
|
|
1506
|
+
[
|
|
1507
|
+
StatusSearchParam.pid,
|
|
1508
|
+
{
|
|
1509
|
+
key: 'pid',
|
|
1510
|
+
converter: numberConverter,
|
|
1511
|
+
},
|
|
1512
|
+
],
|
|
1513
|
+
[
|
|
1514
|
+
StatusSearchParam.invoice,
|
|
1515
|
+
{
|
|
1516
|
+
key: 'invoice',
|
|
1517
|
+
converter: numberConverter,
|
|
1518
|
+
},
|
|
1519
|
+
],
|
|
1520
|
+
[
|
|
1521
|
+
StatusSearchParam.testProject,
|
|
1522
|
+
{
|
|
1523
|
+
key: 'testProject',
|
|
1524
|
+
converter: numberConverter,
|
|
1525
|
+
},
|
|
1526
|
+
],
|
|
1527
|
+
[
|
|
1528
|
+
StatusSearchParam.testPs,
|
|
1529
|
+
{
|
|
1530
|
+
key: 'testPs',
|
|
1531
|
+
converter: numberConverter,
|
|
1532
|
+
},
|
|
1533
|
+
],
|
|
1534
|
+
[
|
|
1535
|
+
StatusSearchParam.testXsolla,
|
|
1536
|
+
{
|
|
1537
|
+
key: 'testXsolla',
|
|
1538
|
+
converter: numberConverter,
|
|
1539
|
+
},
|
|
1540
|
+
],
|
|
1541
|
+
]);
|
|
1542
|
+
|
|
1402
1543
|
class XpsApiPart {
|
|
1403
1544
|
constructor() {
|
|
1404
1545
|
this.response = new BehaviorSubject(null);
|
|
@@ -1421,7 +1562,7 @@ class StatusRequest extends XpsApiPartRequest {
|
|
|
1421
1562
|
constructor(parameters) {
|
|
1422
1563
|
super();
|
|
1423
1564
|
this.xps_fix_command = 'status';
|
|
1424
|
-
if (parameters.token
|
|
1565
|
+
if (!parameters.token) {
|
|
1425
1566
|
throw new TokenError();
|
|
1426
1567
|
}
|
|
1427
1568
|
this.access_token = parameters.token;
|
|
@@ -2556,7 +2697,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2556
2697
|
} });
|
|
2557
2698
|
|
|
2558
2699
|
class StatusService {
|
|
2559
|
-
constructor(statusRequestService, listenStatusService, nextActionService) {
|
|
2700
|
+
constructor(urlService, statusRequestService, listenStatusService, nextActionService) {
|
|
2701
|
+
this.urlService = urlService;
|
|
2560
2702
|
this.statusRequestService = statusRequestService;
|
|
2561
2703
|
this.listenStatusService = listenStatusService;
|
|
2562
2704
|
this.nextActionService = nextActionService;
|
|
@@ -2570,6 +2712,27 @@ class StatusService {
|
|
|
2570
2712
|
return statusResponse.status;
|
|
2571
2713
|
});
|
|
2572
2714
|
}
|
|
2715
|
+
getStatusWithUrlSearchParams(url) {
|
|
2716
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2717
|
+
const searchParams = this.getRequestParamsFromUrl(url);
|
|
2718
|
+
if (!searchParams) {
|
|
2719
|
+
throw new Error('No required search params to get status');
|
|
2720
|
+
}
|
|
2721
|
+
return this.getStatus(searchParams);
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
getRequestParamsFromUrl(url) {
|
|
2725
|
+
const searchParams = this.urlService.getSearchParams(url !== null && url !== void 0 ? url : '');
|
|
2726
|
+
const keys = new Set(Object.keys(searchParams));
|
|
2727
|
+
if (requiredStatusSearchParams.some((requiredKey) => !keys.has(requiredKey))) {
|
|
2728
|
+
return null;
|
|
2729
|
+
}
|
|
2730
|
+
const params = {};
|
|
2731
|
+
statusSearchParamsMap.forEach((settings, key) => {
|
|
2732
|
+
params[settings.key] = settings.converter(searchParams[key]);
|
|
2733
|
+
});
|
|
2734
|
+
return params;
|
|
2735
|
+
}
|
|
2573
2736
|
startWaitingStatusUpdates(invoice) {
|
|
2574
2737
|
this.listenStatusService.listen(invoice);
|
|
2575
2738
|
this.listenStatusService.statusUpdated$
|
|
@@ -2579,14 +2742,14 @@ class StatusService {
|
|
|
2579
2742
|
});
|
|
2580
2743
|
}
|
|
2581
2744
|
}
|
|
2582
|
-
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 });
|
|
2745
|
+
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 });
|
|
2583
2746
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
2584
2747
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
2585
2748
|
type: Injectable,
|
|
2586
2749
|
args: [{
|
|
2587
2750
|
providedIn: 'root',
|
|
2588
2751
|
}]
|
|
2589
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2752
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2590
2753
|
|
|
2591
2754
|
/**
|
|
2592
2755
|
* default image for purchase item is set on Publisher Account side.
|
|
@@ -2956,11 +3119,12 @@ class PaymentService {
|
|
|
2956
3119
|
throw new Error('Should submit form first');
|
|
2957
3120
|
}
|
|
2958
3121
|
const params = {
|
|
3122
|
+
pid: this.config.paymentMethodId,
|
|
2959
3123
|
invoice: parseInt((_a = this.data.fixInvoice) !== null && _a !== void 0 ? _a : ''),
|
|
2960
3124
|
signature: (_b = this.data.signature) !== null && _b !== void 0 ? _b : '',
|
|
2961
3125
|
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',
|
|
2962
3126
|
};
|
|
2963
|
-
return this.statusService.getStatus(
|
|
3127
|
+
return this.statusService.getStatus(params);
|
|
2964
3128
|
});
|
|
2965
3129
|
}
|
|
2966
3130
|
getFieldConfig(field) {
|
|
@@ -3108,16 +3272,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3108
3272
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
3109
3273
|
|
|
3110
3274
|
class CoreLibraryService {
|
|
3111
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
|
|
3275
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService) {
|
|
3112
3276
|
this.settingsService = settingsService;
|
|
3113
3277
|
this.countryService = countryService;
|
|
3114
3278
|
this.paymentMethodsService = paymentMethodsService;
|
|
3115
3279
|
this.savedMethodsService = savedMethodsService;
|
|
3116
3280
|
this.userBalanceService = userBalanceService;
|
|
3281
|
+
this.paymentConfigService = paymentConfigService;
|
|
3117
3282
|
this.paymentService = paymentService;
|
|
3118
3283
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
3119
3284
|
this.financeDetailsService = financeDetailsService;
|
|
3120
3285
|
this.legalService = legalService;
|
|
3286
|
+
this.statusService = statusService;
|
|
3121
3287
|
this.nextActionService = nextActionService;
|
|
3122
3288
|
this.paymentMethods = {
|
|
3123
3289
|
getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
|
|
@@ -3132,12 +3298,18 @@ class CoreLibraryService {
|
|
|
3132
3298
|
yield this.deviceFingerPrintService.init();
|
|
3133
3299
|
});
|
|
3134
3300
|
}
|
|
3301
|
+
getStatus(url) {
|
|
3302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3303
|
+
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3135
3306
|
setCountry(country) {
|
|
3136
3307
|
this.countryService.setCountry(country);
|
|
3137
3308
|
}
|
|
3138
3309
|
createPayment(config) {
|
|
3310
|
+
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
3139
3311
|
return {
|
|
3140
|
-
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(
|
|
3312
|
+
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(enrichedConfig); }),
|
|
3141
3313
|
submit: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.submit(); }),
|
|
3142
3314
|
getFields: () => this.paymentService.getFields(),
|
|
3143
3315
|
validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
|
|
@@ -3160,14 +3332,14 @@ class CoreLibraryService {
|
|
|
3160
3332
|
return masksFunctionsMap[sanitizedName];
|
|
3161
3333
|
}
|
|
3162
3334
|
}
|
|
3163
|
-
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 });
|
|
3335
|
+
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 });
|
|
3164
3336
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
3165
3337
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
3166
3338
|
type: Injectable,
|
|
3167
3339
|
args: [{
|
|
3168
3340
|
providedIn: 'root',
|
|
3169
3341
|
}]
|
|
3170
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
3342
|
+
}], 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 }]; } });
|
|
3171
3343
|
|
|
3172
3344
|
class HttpError extends AppError {
|
|
3173
3345
|
constructor(error, req) {
|