@xsolla/payment-client-core 0.0.8 → 0.0.10-1
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/emit-data.service.abstract.mjs +11 -0
- package/esm2020/lib/core/payment/finance-details/cart-item.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/cart-line.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/cart-pricing.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/default-image-patterns.const.mjs +10 -0
- package/esm2020/lib/core/payment/finance-details/finance-details-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/finance-details/finance-details.class.mjs +214 -0
- package/esm2020/lib/core/payment/finance-details/finance-details.service.mjs +25 -0
- package/esm2020/lib/core/payment/finance-details/price.helpers.mjs +15 -0
- package/esm2020/lib/core/payment/finance-details/price.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/controls/control-config.service.mjs +8 -1
- package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +2 -5
- package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +3 -3
- 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.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +46 -7
- package/esm2020/lib/core/payment/sync/sync.service.mjs +13 -2
- package/esm2020/lib/core/payment/xps-finance.interface.mjs +2 -0
- package/esm2020/lib/core/payment/xps-purchase.interface.mjs +2 -0
- package/esm2020/lib/core/payment/xps-response.interface.mjs +1 -1
- package/esm2020/lib/core/payment/xps-summary.interface.mjs +2 -0
- package/esm2020/lib/core-library.module.mjs +4 -1
- package/esm2020/lib/core-library.service.mjs +13 -7
- package/fesm2015/xsolla-payment-client-core.mjs +362 -17
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +351 -17
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/emit-data.service.abstract.d.ts +7 -0
- package/lib/core/payment/finance-details/cart-item.interface.d.ts +13 -0
- package/lib/core/payment/finance-details/cart-line.interface.d.ts +8 -0
- package/lib/core/payment/finance-details/cart-pricing.interface.d.ts +10 -0
- package/lib/core/payment/finance-details/default-image-patterns.const.d.ts +6 -0
- package/lib/core/payment/finance-details/finance-details-response.token.d.ts +7 -0
- package/lib/core/payment/finance-details/finance-details.class.d.ts +25 -0
- package/lib/core/payment/finance-details/finance-details.service.d.ts +12 -0
- package/lib/core/payment/finance-details/price.helpers.d.ts +6 -0
- package/lib/core/payment/finance-details/price.interface.d.ts +4 -0
- package/lib/core/payment/form/controls/control-config.service.d.ts +2 -0
- package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -2
- package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -0
- package/lib/core/payment/initialize/initialize.service.d.ts +1 -0
- package/lib/core/payment/payment.interface.d.ts +8 -3
- package/lib/core/payment/payment.service.d.ts +15 -3
- package/lib/core/payment/sync/sync.service.d.ts +6 -2
- package/lib/core/payment/xps-finance.interface.d.ts +57 -0
- package/lib/core/payment/xps-purchase.interface.d.ts +15 -0
- package/lib/core/payment/xps-response.interface.d.ts +2 -74
- package/lib/core/payment/xps-summary.interface.d.ts +6 -0
- package/lib/core-library.service.d.ts +3 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.10-1.tgz +0 -0
- package/esm2020/lib/core/payment/finance-details.interface.mjs +0 -2
- package/lib/core/payment/finance-details.interface.d.ts +0 -2
- package/xsolla-payment-client-core-0.0.8.tgz +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
|
|
4
|
-
import { firstValueFrom, lastValueFrom, map,
|
|
4
|
+
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/common/http';
|
|
6
6
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
7
7
|
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -482,12 +482,15 @@ class InitializeService {
|
|
|
482
482
|
this.settingsService = settingsService;
|
|
483
483
|
this.countryService = countryService;
|
|
484
484
|
this.apiRoute = 'directpayment';
|
|
485
|
+
// TODO PAYMENTS-15743: replace with new refer id for headless core
|
|
486
|
+
this.ps4ReferId = '22';
|
|
485
487
|
}
|
|
486
488
|
request(config) {
|
|
487
489
|
return __awaiter(this, void 0, void 0, function* () {
|
|
488
490
|
const requestParams = {
|
|
489
491
|
access_token: this.settingsService.token,
|
|
490
492
|
pid: String(config.paymentMethodId),
|
|
493
|
+
refer: this.ps4ReferId,
|
|
491
494
|
country: this.countryService.getCountry(),
|
|
492
495
|
returnUrl: config.returnUrl,
|
|
493
496
|
};
|
|
@@ -909,6 +912,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
909
912
|
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: SecureApiClient }];
|
|
910
913
|
} });
|
|
911
914
|
|
|
915
|
+
class EmitDataService {
|
|
916
|
+
constructor() {
|
|
917
|
+
this.dataSubject = new Subject();
|
|
918
|
+
this.data$ = this.dataSubject.asObservable();
|
|
919
|
+
}
|
|
920
|
+
emit(data) {
|
|
921
|
+
this.dataSubject.next(data);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
912
925
|
class XpsRequest {
|
|
913
926
|
addXpsParameters(parameters) {
|
|
914
927
|
for (const key in parameters) {
|
|
@@ -973,8 +986,9 @@ const syncResponseFactoryProvider = {
|
|
|
973
986
|
useValue: (...args) => new SyncResponse(...args),
|
|
974
987
|
};
|
|
975
988
|
|
|
976
|
-
class SyncService {
|
|
989
|
+
class SyncService extends EmitDataService {
|
|
977
990
|
constructor(requestFactory, responseFactory, secureApi, settingsService) {
|
|
991
|
+
super();
|
|
978
992
|
this.requestFactory = requestFactory;
|
|
979
993
|
this.responseFactory = responseFactory;
|
|
980
994
|
this.secureApi = secureApi;
|
|
@@ -1017,6 +1031,15 @@ class SyncService {
|
|
|
1017
1031
|
});
|
|
1018
1032
|
});
|
|
1019
1033
|
}
|
|
1034
|
+
getSyncValidationErrors(field) {
|
|
1035
|
+
var _a;
|
|
1036
|
+
const control = this.form.get(field.name);
|
|
1037
|
+
if (!control) {
|
|
1038
|
+
return null;
|
|
1039
|
+
}
|
|
1040
|
+
const rewritableError = (_a = control.errors) === null || _a === void 0 ? void 0 : _a.rewritableError;
|
|
1041
|
+
return rewritableError ? { message: rewritableError.message } : null;
|
|
1042
|
+
}
|
|
1020
1043
|
request(field) {
|
|
1021
1044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1022
1045
|
const requestParams = this.requestFactory({
|
|
@@ -1029,6 +1052,7 @@ class SyncService {
|
|
|
1029
1052
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1030
1053
|
responseType: 'json',
|
|
1031
1054
|
})).then((response) => {
|
|
1055
|
+
this.emit(response);
|
|
1032
1056
|
return this.responseFactory(field, response);
|
|
1033
1057
|
});
|
|
1034
1058
|
});
|
|
@@ -1119,7 +1143,7 @@ class Converter {
|
|
|
1119
1143
|
return config;
|
|
1120
1144
|
}
|
|
1121
1145
|
convertToFormControl(field) {
|
|
1122
|
-
return new UntypedFormControl(this.getValue(field), this.getValidators(field)
|
|
1146
|
+
return new UntypedFormControl(this.getValue(field), this.getValidators(field));
|
|
1123
1147
|
}
|
|
1124
1148
|
getValidators(field) {
|
|
1125
1149
|
const validators = [];
|
|
@@ -1138,9 +1162,6 @@ class Converter {
|
|
|
1138
1162
|
}
|
|
1139
1163
|
return validators;
|
|
1140
1164
|
}
|
|
1141
|
-
getAsyncValidators(field) {
|
|
1142
|
-
return () => __awaiter(this, void 0, void 0, function* () { return this.syncService.validate(field); });
|
|
1143
|
-
}
|
|
1144
1165
|
createDefaultControlConfig(controlConfigClass, field) {
|
|
1145
1166
|
const config = new controlConfigClass();
|
|
1146
1167
|
this.copyCommonOptions(config, field);
|
|
@@ -1225,8 +1246,8 @@ class ZipConverter extends Converter {
|
|
|
1225
1246
|
const validators = super
|
|
1226
1247
|
.getValidators(field)
|
|
1227
1248
|
.concat([
|
|
1228
|
-
convert(Validators.minLength(minLength),
|
|
1229
|
-
convert(Validators.maxLength(maxLength),
|
|
1249
|
+
convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
|
|
1250
|
+
convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`),
|
|
1230
1251
|
]);
|
|
1231
1252
|
if (this.isUsCountry) {
|
|
1232
1253
|
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
|
|
@@ -1281,6 +1302,13 @@ class ControlConfigService {
|
|
|
1281
1302
|
}
|
|
1282
1303
|
return converter.convertToFormControl(field);
|
|
1283
1304
|
}
|
|
1305
|
+
getConfig(field) {
|
|
1306
|
+
const converter = this.getConverter(field);
|
|
1307
|
+
if (!converter) {
|
|
1308
|
+
return null;
|
|
1309
|
+
}
|
|
1310
|
+
return converter.convertToConfig(field);
|
|
1311
|
+
}
|
|
1284
1312
|
getConverter(field) {
|
|
1285
1313
|
if (!field) {
|
|
1286
1314
|
return null;
|
|
@@ -2498,25 +2526,306 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2498
2526
|
}]
|
|
2499
2527
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2500
2528
|
|
|
2529
|
+
/**
|
|
2530
|
+
* default image for purchase item is set on Publisher Account side.
|
|
2531
|
+
* for purchase checkout items the image url is converted into base64 string.
|
|
2532
|
+
* to determine default image fixed templates are used
|
|
2533
|
+
*/
|
|
2534
|
+
const defaultImagePatterns = [
|
|
2535
|
+
/^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
|
|
2536
|
+
/virtual_item_default_image/,
|
|
2537
|
+
];
|
|
2538
|
+
|
|
2539
|
+
function extractMoneyCurrency(money, allowZero = true) {
|
|
2540
|
+
var _a, _b;
|
|
2541
|
+
return {
|
|
2542
|
+
amount: (_a = money === null || money === void 0 ? void 0 : money.amount) !== null && _a !== void 0 ? _a : (allowZero ? 0 : null),
|
|
2543
|
+
currency: (_b = money === null || money === void 0 ? void 0 : money.currency) !== null && _b !== void 0 ? _b : '',
|
|
2544
|
+
};
|
|
2545
|
+
}
|
|
2546
|
+
function createPriceOrUndefined(amount, currency) {
|
|
2547
|
+
return amount !== undefined && amount !== null
|
|
2548
|
+
? {
|
|
2549
|
+
amount,
|
|
2550
|
+
currency,
|
|
2551
|
+
}
|
|
2552
|
+
: undefined;
|
|
2553
|
+
}
|
|
2554
|
+
|
|
2555
|
+
class FinanceDetails {
|
|
2556
|
+
get shouldShowZeroIndirectTaxRate() {
|
|
2557
|
+
var _a, _b, _c, _d;
|
|
2558
|
+
return !!(((_b = (_a = this.finance) === null || _a === void 0 ? void 0 : _a.vat) === null || _b === void 0 ? void 0 : _b.visible) || ((_d = (_c = this.finance) === null || _c === void 0 ? void 0 : _c.vat_user) === null || _d === void 0 ? void 0 : _d.visible));
|
|
2559
|
+
}
|
|
2560
|
+
get isSalesTaxes() {
|
|
2561
|
+
var _a, _b, _c, _d;
|
|
2562
|
+
return !!(((_b = (_a = this.finance) === null || _a === void 0 ? void 0 : _a.sales_tax) === null || _b === void 0 ? void 0 : _b.amount) || ((_d = (_c = this.finance) === null || _c === void 0 ? void 0 : _c.sales_tax_user) === null || _d === void 0 ? void 0 : _d.amount));
|
|
2563
|
+
}
|
|
2564
|
+
constructor(parameters) {
|
|
2565
|
+
this.purchase = parameters.purchase;
|
|
2566
|
+
this.finance = parameters.finance;
|
|
2567
|
+
}
|
|
2568
|
+
getFormattedPurchaseForCart() {
|
|
2569
|
+
var _a, _b, _c, _d;
|
|
2570
|
+
const checkouts = (_a = this.purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
2571
|
+
return {
|
|
2572
|
+
imgSrc: item.image_url,
|
|
2573
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2574
|
+
title: item.name,
|
|
2575
|
+
price: extractMoneyCurrency(item, false),
|
|
2576
|
+
priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
|
|
2577
|
+
quantity: item.quantity,
|
|
2578
|
+
description: item.description,
|
|
2579
|
+
tax: this.getTaxForItem(item.indirect_tax_rate),
|
|
2580
|
+
isBonus: item.is_bonus,
|
|
2581
|
+
};
|
|
2582
|
+
});
|
|
2583
|
+
const virtualCurrencies = (_b = this.purchase.virtual_currency) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
2584
|
+
return {
|
|
2585
|
+
imgSrc: item.image_url,
|
|
2586
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2587
|
+
title: `${item.quantity} ${item.name}`,
|
|
2588
|
+
price: extractMoneyCurrency(item),
|
|
2589
|
+
description: item.description,
|
|
2590
|
+
isBonus: item.is_bonus,
|
|
2591
|
+
};
|
|
2592
|
+
});
|
|
2593
|
+
const virtualItems = (_c = this.purchase.virtual_items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
2594
|
+
return {
|
|
2595
|
+
imgSrc: item.image_url,
|
|
2596
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2597
|
+
title: item.name,
|
|
2598
|
+
price: extractMoneyCurrency(item),
|
|
2599
|
+
description: item.description,
|
|
2600
|
+
quantity: item.quantity,
|
|
2601
|
+
isBonus: item.is_bonus,
|
|
2602
|
+
};
|
|
2603
|
+
});
|
|
2604
|
+
let checkoutArray = undefined;
|
|
2605
|
+
if (this.purchase.checkout) {
|
|
2606
|
+
checkoutArray = [
|
|
2607
|
+
{
|
|
2608
|
+
title: this.purchase.checkout.description
|
|
2609
|
+
? this.purchase.checkout.description
|
|
2610
|
+
: 'In-game purchase',
|
|
2611
|
+
price: extractMoneyCurrency(this.purchase.checkout),
|
|
2612
|
+
isBonus: (_d = this.purchase.checkout.is_bonus) !== null && _d !== void 0 ? _d : false,
|
|
2613
|
+
},
|
|
2614
|
+
];
|
|
2615
|
+
}
|
|
2616
|
+
return [
|
|
2617
|
+
...(checkouts !== null && checkouts !== void 0 ? checkouts : []),
|
|
2618
|
+
...(virtualCurrencies !== null && virtualCurrencies !== void 0 ? virtualCurrencies : []),
|
|
2619
|
+
...(virtualItems !== null && virtualItems !== void 0 ? virtualItems : []),
|
|
2620
|
+
...(checkoutArray !== null && checkoutArray !== void 0 ? checkoutArray : []),
|
|
2621
|
+
];
|
|
2622
|
+
}
|
|
2623
|
+
getFormattedPricingForCart() {
|
|
2624
|
+
// subtotal details fields
|
|
2625
|
+
const subtotalDetailsSorting = [
|
|
2626
|
+
{
|
|
2627
|
+
key: 'discount',
|
|
2628
|
+
title: 'Discount',
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
key: 'fee',
|
|
2632
|
+
title: 'Payment system fee',
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
key: 'user_balance',
|
|
2636
|
+
title: 'Balance',
|
|
2637
|
+
},
|
|
2638
|
+
];
|
|
2639
|
+
return {
|
|
2640
|
+
subtotal: {
|
|
2641
|
+
title: 'Subtotal',
|
|
2642
|
+
money: createPriceOrUndefined(this.finance.sub_total.amount, this.finance.sub_total.currency),
|
|
2643
|
+
},
|
|
2644
|
+
subtotalPayment: {
|
|
2645
|
+
title: '',
|
|
2646
|
+
money: createPriceOrUndefined(this.finance.sub_total.payment_amount, this.finance.sub_total.payment_currency),
|
|
2647
|
+
},
|
|
2648
|
+
total: {
|
|
2649
|
+
title: 'Total',
|
|
2650
|
+
money: extractMoneyCurrency(this.finance.total),
|
|
2651
|
+
},
|
|
2652
|
+
totalDetails: this.getTaxesForTotalDetails(),
|
|
2653
|
+
subtotalDetails: [
|
|
2654
|
+
...subtotalDetailsSorting.map((sorting) => {
|
|
2655
|
+
const field = this.finance[sorting.key];
|
|
2656
|
+
if (field) {
|
|
2657
|
+
return Object.assign(Object.assign({}, sorting), { money: {
|
|
2658
|
+
amount: sorting.key === 'discount' && field.amount
|
|
2659
|
+
? -field.amount
|
|
2660
|
+
: field.amount,
|
|
2661
|
+
currency: field.currency,
|
|
2662
|
+
} });
|
|
2663
|
+
}
|
|
2664
|
+
return sorting;
|
|
2665
|
+
}),
|
|
2666
|
+
...this.getTaxesForSubtotalDetails(),
|
|
2667
|
+
],
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
getPaymentCountry() {
|
|
2671
|
+
var _a;
|
|
2672
|
+
return (_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso;
|
|
2673
|
+
}
|
|
2674
|
+
getTaxForItem(indirectTaxRate) {
|
|
2675
|
+
if (indirectTaxRate ||
|
|
2676
|
+
(this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
|
|
2677
|
+
if (this.isSalesTaxes) {
|
|
2678
|
+
return {
|
|
2679
|
+
content: `Sales tax ${indirectTaxRate}%`,
|
|
2680
|
+
};
|
|
2681
|
+
}
|
|
2682
|
+
if (this.isIndia()) {
|
|
2683
|
+
return {
|
|
2684
|
+
content: `GST ${indirectTaxRate}%`,
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
if (this.isGhana()) {
|
|
2688
|
+
return {
|
|
2689
|
+
content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
return {
|
|
2693
|
+
content: `VAT ${indirectTaxRate}%`,
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
return null;
|
|
2697
|
+
}
|
|
2698
|
+
getTaxesForSubtotalDetails() {
|
|
2699
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2700
|
+
const ret = [];
|
|
2701
|
+
// subtotal. VAT %p
|
|
2702
|
+
if (this.finance.vat_user &&
|
|
2703
|
+
((_c = (_b = (_a = this.finance) === null || _a === void 0 ? void 0 : _a.vat_user) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : (_e = (_d = this.finance) === null || _d === void 0 ? void 0 : _d.vat_user) === null || _e === void 0 ? void 0 : _e.visible)) {
|
|
2704
|
+
ret.push({
|
|
2705
|
+
key: 'vat_user',
|
|
2706
|
+
title: this.getVatLabelForSubtotalDetails(),
|
|
2707
|
+
money: extractMoneyCurrency(this.finance.vat_user),
|
|
2708
|
+
});
|
|
2709
|
+
}
|
|
2710
|
+
if ((_f = this.finance.sales_tax_user) === null || _f === void 0 ? void 0 : _f.amount) {
|
|
2711
|
+
ret.push({
|
|
2712
|
+
key: 'sales_tax_user',
|
|
2713
|
+
title: 'Sales tax',
|
|
2714
|
+
money: extractMoneyCurrency(this.finance.sales_tax_user),
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2717
|
+
return ret;
|
|
2718
|
+
}
|
|
2719
|
+
getVatLabelForSubtotalDetails() {
|
|
2720
|
+
var _a, _b, _c, _d;
|
|
2721
|
+
if (this.isIndia()) {
|
|
2722
|
+
return `GST ${(_b = (_a = this.finance.vat_user) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : ''}%`;
|
|
2723
|
+
}
|
|
2724
|
+
if (this.isGhana()) {
|
|
2725
|
+
return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
|
|
2726
|
+
}
|
|
2727
|
+
return `VAT ${(_d = (_c = this.finance.vat_user) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : ''}%`;
|
|
2728
|
+
}
|
|
2729
|
+
getTaxesForTotalDetails() {
|
|
2730
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2731
|
+
const ret = [];
|
|
2732
|
+
// for totalDetails. VAT
|
|
2733
|
+
if ((((_b = (_a = this.finance) === null || _a === void 0 ? void 0 : _a.vat) === null || _b === void 0 ? void 0 : _b.amount) || ((_d = (_c = this.finance) === null || _c === void 0 ? void 0 : _c.vat) === null || _d === void 0 ? void 0 : _d.visible)) &&
|
|
2734
|
+
!((_f = (_e = this.finance) === null || _e === void 0 ? void 0 : _e.vat_user) === null || _f === void 0 ? void 0 : _f.amount)) {
|
|
2735
|
+
ret.push({
|
|
2736
|
+
key: 'vat',
|
|
2737
|
+
title: this.getVatLabelForTotalDetails(),
|
|
2738
|
+
money: extractMoneyCurrency(this.finance.vat),
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
if (((_h = (_g = this.finance) === null || _g === void 0 ? void 0 : _g.sales_tax) === null || _h === void 0 ? void 0 : _h.amount) &&
|
|
2742
|
+
!((_k = (_j = this.finance) === null || _j === void 0 ? void 0 : _j.sales_tax_user) === null || _k === void 0 ? void 0 : _k.amount)) {
|
|
2743
|
+
ret.push({
|
|
2744
|
+
key: 'sales_tax',
|
|
2745
|
+
title: 'Sales tax included',
|
|
2746
|
+
money: extractMoneyCurrency(this.finance.sales_tax),
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
return ret;
|
|
2750
|
+
}
|
|
2751
|
+
getVatLabelForTotalDetails() {
|
|
2752
|
+
if (this.isIndia()) {
|
|
2753
|
+
return `Including ${this.finance.vat.percent}% GST`;
|
|
2754
|
+
}
|
|
2755
|
+
if (this.isGhana()) {
|
|
2756
|
+
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
2757
|
+
}
|
|
2758
|
+
return `Including ${this.finance.vat.percent}% VAT`;
|
|
2759
|
+
}
|
|
2760
|
+
isIndia() {
|
|
2761
|
+
var _a;
|
|
2762
|
+
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'IN';
|
|
2763
|
+
}
|
|
2764
|
+
isGhana() {
|
|
2765
|
+
var _a;
|
|
2766
|
+
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'GH';
|
|
2767
|
+
}
|
|
2768
|
+
isDefaultImage(url) {
|
|
2769
|
+
return defaultImagePatterns.some((regex) => regex.test(url));
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
const financeDetailsResponseFactoryToken = new InjectionToken('FinanceDetails');
|
|
2774
|
+
const financeDetailsResponseFactoryProvider = {
|
|
2775
|
+
provide: financeDetailsResponseFactoryToken,
|
|
2776
|
+
useValue: (...args) => new FinanceDetails(...args),
|
|
2777
|
+
};
|
|
2778
|
+
|
|
2779
|
+
class FinanceDetailsService extends EmitDataService {
|
|
2780
|
+
constructor(responseFactory) {
|
|
2781
|
+
super();
|
|
2782
|
+
this.responseFactory = responseFactory;
|
|
2783
|
+
}
|
|
2784
|
+
emit(summary) {
|
|
2785
|
+
if (summary) {
|
|
2786
|
+
super.emit(this.responseFactory(summary));
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: financeDetailsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2791
|
+
FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
|
|
2792
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
|
|
2793
|
+
type: Injectable,
|
|
2794
|
+
args: [{ providedIn: 'root' }]
|
|
2795
|
+
}], ctorParameters: function () {
|
|
2796
|
+
return [{ type: undefined, decorators: [{
|
|
2797
|
+
type: Inject,
|
|
2798
|
+
args: [financeDetailsResponseFactoryToken]
|
|
2799
|
+
}] }];
|
|
2800
|
+
} });
|
|
2801
|
+
|
|
2501
2802
|
class PaymentService {
|
|
2502
|
-
constructor(initializeService, submitService, syncService, formService, statusService, nextActionService) {
|
|
2803
|
+
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, nextActionService, controlConfigService) {
|
|
2503
2804
|
this.initializeService = initializeService;
|
|
2504
2805
|
this.submitService = submitService;
|
|
2505
2806
|
this.syncService = syncService;
|
|
2506
2807
|
this.formService = formService;
|
|
2507
2808
|
this.statusService = statusService;
|
|
2809
|
+
this.financeDetailsService = financeDetailsService;
|
|
2508
2810
|
this.nextActionService = nextActionService;
|
|
2811
|
+
this.controlConfigService = controlConfigService;
|
|
2509
2812
|
this.form = null;
|
|
2510
2813
|
this.data = null;
|
|
2814
|
+
this.financeDetails = null;
|
|
2511
2815
|
this.fields = [];
|
|
2816
|
+
this.destroy$ = new Subject();
|
|
2512
2817
|
}
|
|
2513
2818
|
initialize(config) {
|
|
2819
|
+
var _a;
|
|
2514
2820
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2821
|
+
this.destroy$ = new Subject();
|
|
2822
|
+
this.listenFinanceDetails();
|
|
2515
2823
|
this.config = config;
|
|
2516
2824
|
this.data = yield this.initializeService.request(config);
|
|
2517
2825
|
this.fields = this.getFields();
|
|
2518
2826
|
this.form = this.formService.createForm(this.fields);
|
|
2519
|
-
this.
|
|
2827
|
+
this.emitFinanceDetails((_a = this.data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary);
|
|
2828
|
+
this.setupSyncService(this.form, this.fields);
|
|
2520
2829
|
return this.fields;
|
|
2521
2830
|
});
|
|
2522
2831
|
}
|
|
@@ -2526,6 +2835,7 @@ class PaymentService {
|
|
|
2526
2835
|
throw new Error('form is empty!');
|
|
2527
2836
|
}
|
|
2528
2837
|
const submitResponse = yield this.submitService.request(this.fields, this.form);
|
|
2838
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
2529
2839
|
return this.nextActionService.getNextAction(submitResponse);
|
|
2530
2840
|
});
|
|
2531
2841
|
}
|
|
@@ -2535,6 +2845,10 @@ class PaymentService {
|
|
|
2535
2845
|
}
|
|
2536
2846
|
validate(field) {
|
|
2537
2847
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2848
|
+
const syncErrors = this.syncService.getSyncValidationErrors(field);
|
|
2849
|
+
if (syncErrors) {
|
|
2850
|
+
return Promise.resolve(syncErrors);
|
|
2851
|
+
}
|
|
2538
2852
|
return this.syncService.validate(field);
|
|
2539
2853
|
});
|
|
2540
2854
|
}
|
|
@@ -2542,27 +2856,51 @@ class PaymentService {
|
|
|
2542
2856
|
throw new Error('Method not implemented.');
|
|
2543
2857
|
}
|
|
2544
2858
|
getFinanceDetails() {
|
|
2545
|
-
|
|
2859
|
+
return this.financeDetails;
|
|
2546
2860
|
}
|
|
2547
2861
|
getStatus(params) {
|
|
2548
2862
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2549
2863
|
return this.statusService.getStatus(Object.assign(Object.assign({}, params), { pid: this.config.paymentMethodId }));
|
|
2550
2864
|
});
|
|
2551
2865
|
}
|
|
2866
|
+
getFieldConfig(field) {
|
|
2867
|
+
return this.controlConfigService.getConfig(field);
|
|
2868
|
+
}
|
|
2552
2869
|
changeFieldValue(name, value) {
|
|
2553
2870
|
var _a;
|
|
2554
2871
|
const formControl = (_a = this.form) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
2555
2872
|
formControl === null || formControl === void 0 ? void 0 : formControl.setValue(value);
|
|
2556
2873
|
}
|
|
2874
|
+
destroy() {
|
|
2875
|
+
this.data = null;
|
|
2876
|
+
this.financeDetails = null;
|
|
2877
|
+
this.form = null;
|
|
2878
|
+
this.fields = [];
|
|
2879
|
+
this.destroy$.next();
|
|
2880
|
+
}
|
|
2881
|
+
emitFinanceDetails(summary) {
|
|
2882
|
+
this.financeDetailsService.emit(summary);
|
|
2883
|
+
}
|
|
2884
|
+
setupSyncService(form, fields) {
|
|
2885
|
+
this.syncService.setup(form, fields);
|
|
2886
|
+
this.syncService.data$
|
|
2887
|
+
.pipe(takeUntil(this.destroy$))
|
|
2888
|
+
.subscribe((response) => this.emitFinanceDetails(response.summary));
|
|
2889
|
+
}
|
|
2890
|
+
listenFinanceDetails() {
|
|
2891
|
+
this.financeDetailsService.data$
|
|
2892
|
+
.pipe(takeUntil(this.destroy$))
|
|
2893
|
+
.subscribe((financeDetails) => (this.financeDetails = financeDetails));
|
|
2894
|
+
}
|
|
2557
2895
|
}
|
|
2558
|
-
PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2896
|
+
PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2559
2897
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
2560
2898
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
2561
2899
|
type: Injectable,
|
|
2562
2900
|
args: [{
|
|
2563
2901
|
providedIn: 'root',
|
|
2564
2902
|
}]
|
|
2565
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
2903
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: NextActionService }, { type: ControlConfigService }]; } });
|
|
2566
2904
|
|
|
2567
2905
|
class RefundPolicyService {
|
|
2568
2906
|
constructor(settingsService) {
|
|
@@ -2670,7 +3008,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2670
3008
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
2671
3009
|
|
|
2672
3010
|
class CoreLibraryService {
|
|
2673
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, legalService, nextActionService) {
|
|
3011
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
|
|
2674
3012
|
this.settingsService = settingsService;
|
|
2675
3013
|
this.countryService = countryService;
|
|
2676
3014
|
this.paymentMethodsService = paymentMethodsService;
|
|
@@ -2678,6 +3016,7 @@ class CoreLibraryService {
|
|
|
2678
3016
|
this.userBalanceService = userBalanceService;
|
|
2679
3017
|
this.paymentService = paymentService;
|
|
2680
3018
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
3019
|
+
this.financeDetailsService = financeDetailsService;
|
|
2681
3020
|
this.legalService = legalService;
|
|
2682
3021
|
this.nextActionService = nextActionService;
|
|
2683
3022
|
this.paymentMethods = {
|
|
@@ -2701,26 +3040,30 @@ class CoreLibraryService {
|
|
|
2701
3040
|
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(config); }),
|
|
2702
3041
|
submit: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.submit(); }),
|
|
2703
3042
|
getFields: () => this.paymentService.getFields(),
|
|
2704
|
-
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
2705
3043
|
validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
|
|
2706
3044
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
2707
3045
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
2708
3046
|
getStatus: (params) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.getStatus(params); }),
|
|
2709
3047
|
flowUpdates$: this.nextActionService.flowUpdates$,
|
|
3048
|
+
financeDetailsUpdates$: this.financeDetailsService.data$,
|
|
3049
|
+
form: {
|
|
3050
|
+
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
3051
|
+
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
3052
|
+
},
|
|
2710
3053
|
};
|
|
2711
3054
|
}
|
|
2712
3055
|
getLegalComponentConfig() {
|
|
2713
3056
|
return this.legalService.getLegalComponentConfig();
|
|
2714
3057
|
}
|
|
2715
3058
|
}
|
|
2716
|
-
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: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3059
|
+
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 });
|
|
2717
3060
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
2718
3061
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
2719
3062
|
type: Injectable,
|
|
2720
3063
|
args: [{
|
|
2721
3064
|
providedIn: 'root',
|
|
2722
3065
|
}]
|
|
2723
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
3066
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
2724
3067
|
|
|
2725
3068
|
class HttpError extends AppError {
|
|
2726
3069
|
constructor(error, req) {
|
|
@@ -2823,6 +3166,7 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
2823
3166
|
statusResponseFactoryProvider,
|
|
2824
3167
|
checkStatusRequestFactoryProvider,
|
|
2825
3168
|
checkStatusResponseFactoryProvider,
|
|
3169
|
+
financeDetailsResponseFactoryProvider,
|
|
2826
3170
|
{
|
|
2827
3171
|
provide: nextActionsToken,
|
|
2828
3172
|
useValue: nextActions,
|
|
@@ -2852,6 +3196,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2852
3196
|
statusResponseFactoryProvider,
|
|
2853
3197
|
checkStatusRequestFactoryProvider,
|
|
2854
3198
|
checkStatusResponseFactoryProvider,
|
|
3199
|
+
financeDetailsResponseFactoryProvider,
|
|
2855
3200
|
{
|
|
2856
3201
|
provide: nextActionsToken,
|
|
2857
3202
|
useValue: nextActions,
|