@xsolla/payment-client-core 0.0.9 → 0.0.10-2
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/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 +42 -8
- package/esm2020/lib/core/payment/sync/sync.service.mjs +18 -3
- 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 +9 -6
- package/fesm2015/xsolla-payment-client-core.mjs +353 -17
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +341 -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/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 +3 -2
- package/lib/core/payment/payment.service.d.ts +11 -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-2.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.9.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;
|
|
@@ -999,6 +1013,7 @@ class SyncService {
|
|
|
999
1013
|
if (!this.isReadyField(field)) {
|
|
1000
1014
|
return Promise.resolve(null);
|
|
1001
1015
|
}
|
|
1016
|
+
debugger;
|
|
1002
1017
|
const control = this.form.get(field.name);
|
|
1003
1018
|
const value = control === null || control === void 0 ? void 0 : control.value;
|
|
1004
1019
|
const prevFieldState = this.getPrevFieldSyncState(field);
|
|
@@ -1007,16 +1022,29 @@ class SyncService {
|
|
|
1007
1022
|
return Promise.resolve(null);
|
|
1008
1023
|
}
|
|
1009
1024
|
if (prevFieldState && value === prevFieldState.value) {
|
|
1010
|
-
return Promise.resolve(prevFieldState.result)
|
|
1025
|
+
return Promise.resolve(prevFieldState.result).then((response) => {
|
|
1026
|
+
var _a;
|
|
1027
|
+
return (_a = response === null || response === void 0 ? void 0 : response.rewritableError) !== null && _a !== void 0 ? _a : null;
|
|
1028
|
+
});
|
|
1011
1029
|
}
|
|
1012
1030
|
const requestPromise = this.request(field);
|
|
1013
1031
|
this.setPrevFieldSyncState(field, value, requestPromise);
|
|
1014
1032
|
return requestPromise.then((response) => {
|
|
1015
1033
|
var _a;
|
|
1034
|
+
debugger;
|
|
1016
1035
|
return (_a = response.rewritableError) !== null && _a !== void 0 ? _a : null;
|
|
1017
1036
|
});
|
|
1018
1037
|
});
|
|
1019
1038
|
}
|
|
1039
|
+
getSyncValidationErrors(field) {
|
|
1040
|
+
var _a;
|
|
1041
|
+
const control = this.form.get(field.name);
|
|
1042
|
+
if (!control) {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
const rewritableError = (_a = control.errors) === null || _a === void 0 ? void 0 : _a.rewritableError;
|
|
1046
|
+
return rewritableError ? { message: rewritableError.message } : null;
|
|
1047
|
+
}
|
|
1020
1048
|
request(field) {
|
|
1021
1049
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1022
1050
|
const requestParams = this.requestFactory({
|
|
@@ -1029,6 +1057,7 @@ class SyncService {
|
|
|
1029
1057
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1030
1058
|
responseType: 'json',
|
|
1031
1059
|
})).then((response) => {
|
|
1060
|
+
this.emit(response);
|
|
1032
1061
|
return this.responseFactory(field, response);
|
|
1033
1062
|
});
|
|
1034
1063
|
});
|
|
@@ -1119,7 +1148,7 @@ class Converter {
|
|
|
1119
1148
|
return config;
|
|
1120
1149
|
}
|
|
1121
1150
|
convertToFormControl(field) {
|
|
1122
|
-
return new UntypedFormControl(this.getValue(field), this.getValidators(field)
|
|
1151
|
+
return new UntypedFormControl(this.getValue(field), this.getValidators(field));
|
|
1123
1152
|
}
|
|
1124
1153
|
getValidators(field) {
|
|
1125
1154
|
const validators = [];
|
|
@@ -1138,9 +1167,6 @@ class Converter {
|
|
|
1138
1167
|
}
|
|
1139
1168
|
return validators;
|
|
1140
1169
|
}
|
|
1141
|
-
getAsyncValidators(field) {
|
|
1142
|
-
return () => __awaiter(this, void 0, void 0, function* () { return this.syncService.validate(field); });
|
|
1143
|
-
}
|
|
1144
1170
|
createDefaultControlConfig(controlConfigClass, field) {
|
|
1145
1171
|
const config = new controlConfigClass();
|
|
1146
1172
|
this.copyCommonOptions(config, field);
|
|
@@ -1225,8 +1251,8 @@ class ZipConverter extends Converter {
|
|
|
1225
1251
|
const validators = super
|
|
1226
1252
|
.getValidators(field)
|
|
1227
1253
|
.concat([
|
|
1228
|
-
convert(Validators.minLength(minLength),
|
|
1229
|
-
convert(Validators.maxLength(maxLength),
|
|
1254
|
+
convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`),
|
|
1255
|
+
convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`),
|
|
1230
1256
|
]);
|
|
1231
1257
|
if (this.isUsCountry) {
|
|
1232
1258
|
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
|
|
@@ -2505,26 +2531,306 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2505
2531
|
}]
|
|
2506
2532
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2507
2533
|
|
|
2534
|
+
/**
|
|
2535
|
+
* default image for purchase item is set on Publisher Account side.
|
|
2536
|
+
* for purchase checkout items the image url is converted into base64 string.
|
|
2537
|
+
* to determine default image fixed templates are used
|
|
2538
|
+
*/
|
|
2539
|
+
const defaultImagePatterns = [
|
|
2540
|
+
/^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
|
|
2541
|
+
/virtual_item_default_image/,
|
|
2542
|
+
];
|
|
2543
|
+
|
|
2544
|
+
function extractMoneyCurrency(money, allowZero = true) {
|
|
2545
|
+
var _a, _b;
|
|
2546
|
+
return {
|
|
2547
|
+
amount: (_a = money === null || money === void 0 ? void 0 : money.amount) !== null && _a !== void 0 ? _a : (allowZero ? 0 : null),
|
|
2548
|
+
currency: (_b = money === null || money === void 0 ? void 0 : money.currency) !== null && _b !== void 0 ? _b : '',
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
function createPriceOrUndefined(amount, currency) {
|
|
2552
|
+
return amount !== undefined && amount !== null
|
|
2553
|
+
? {
|
|
2554
|
+
amount,
|
|
2555
|
+
currency,
|
|
2556
|
+
}
|
|
2557
|
+
: undefined;
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
class FinanceDetails {
|
|
2561
|
+
get shouldShowZeroIndirectTaxRate() {
|
|
2562
|
+
var _a, _b, _c, _d;
|
|
2563
|
+
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));
|
|
2564
|
+
}
|
|
2565
|
+
get isSalesTaxes() {
|
|
2566
|
+
var _a, _b, _c, _d;
|
|
2567
|
+
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));
|
|
2568
|
+
}
|
|
2569
|
+
constructor(parameters) {
|
|
2570
|
+
this.purchase = parameters.purchase;
|
|
2571
|
+
this.finance = parameters.finance;
|
|
2572
|
+
}
|
|
2573
|
+
getFormattedPurchaseForCart() {
|
|
2574
|
+
var _a, _b, _c, _d;
|
|
2575
|
+
const checkouts = (_a = this.purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
2576
|
+
return {
|
|
2577
|
+
imgSrc: item.image_url,
|
|
2578
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2579
|
+
title: item.name,
|
|
2580
|
+
price: extractMoneyCurrency(item, false),
|
|
2581
|
+
priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
|
|
2582
|
+
quantity: item.quantity,
|
|
2583
|
+
description: item.description,
|
|
2584
|
+
tax: this.getTaxForItem(item.indirect_tax_rate),
|
|
2585
|
+
isBonus: item.is_bonus,
|
|
2586
|
+
};
|
|
2587
|
+
});
|
|
2588
|
+
const virtualCurrencies = (_b = this.purchase.virtual_currency) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
2589
|
+
return {
|
|
2590
|
+
imgSrc: item.image_url,
|
|
2591
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2592
|
+
title: `${item.quantity} ${item.name}`,
|
|
2593
|
+
price: extractMoneyCurrency(item),
|
|
2594
|
+
description: item.description,
|
|
2595
|
+
isBonus: item.is_bonus,
|
|
2596
|
+
};
|
|
2597
|
+
});
|
|
2598
|
+
const virtualItems = (_c = this.purchase.virtual_items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
2599
|
+
return {
|
|
2600
|
+
imgSrc: item.image_url,
|
|
2601
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
2602
|
+
title: item.name,
|
|
2603
|
+
price: extractMoneyCurrency(item),
|
|
2604
|
+
description: item.description,
|
|
2605
|
+
quantity: item.quantity,
|
|
2606
|
+
isBonus: item.is_bonus,
|
|
2607
|
+
};
|
|
2608
|
+
});
|
|
2609
|
+
let checkoutArray = undefined;
|
|
2610
|
+
if (this.purchase.checkout) {
|
|
2611
|
+
checkoutArray = [
|
|
2612
|
+
{
|
|
2613
|
+
title: this.purchase.checkout.description
|
|
2614
|
+
? this.purchase.checkout.description
|
|
2615
|
+
: 'In-game purchase',
|
|
2616
|
+
price: extractMoneyCurrency(this.purchase.checkout),
|
|
2617
|
+
isBonus: (_d = this.purchase.checkout.is_bonus) !== null && _d !== void 0 ? _d : false,
|
|
2618
|
+
},
|
|
2619
|
+
];
|
|
2620
|
+
}
|
|
2621
|
+
return [
|
|
2622
|
+
...(checkouts !== null && checkouts !== void 0 ? checkouts : []),
|
|
2623
|
+
...(virtualCurrencies !== null && virtualCurrencies !== void 0 ? virtualCurrencies : []),
|
|
2624
|
+
...(virtualItems !== null && virtualItems !== void 0 ? virtualItems : []),
|
|
2625
|
+
...(checkoutArray !== null && checkoutArray !== void 0 ? checkoutArray : []),
|
|
2626
|
+
];
|
|
2627
|
+
}
|
|
2628
|
+
getFormattedPricingForCart() {
|
|
2629
|
+
// subtotal details fields
|
|
2630
|
+
const subtotalDetailsSorting = [
|
|
2631
|
+
{
|
|
2632
|
+
key: 'discount',
|
|
2633
|
+
title: 'Discount',
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
key: 'fee',
|
|
2637
|
+
title: 'Payment system fee',
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
key: 'user_balance',
|
|
2641
|
+
title: 'Balance',
|
|
2642
|
+
},
|
|
2643
|
+
];
|
|
2644
|
+
return {
|
|
2645
|
+
subtotal: {
|
|
2646
|
+
title: 'Subtotal',
|
|
2647
|
+
money: createPriceOrUndefined(this.finance.sub_total.amount, this.finance.sub_total.currency),
|
|
2648
|
+
},
|
|
2649
|
+
subtotalPayment: {
|
|
2650
|
+
title: '',
|
|
2651
|
+
money: createPriceOrUndefined(this.finance.sub_total.payment_amount, this.finance.sub_total.payment_currency),
|
|
2652
|
+
},
|
|
2653
|
+
total: {
|
|
2654
|
+
title: 'Total',
|
|
2655
|
+
money: extractMoneyCurrency(this.finance.total),
|
|
2656
|
+
},
|
|
2657
|
+
totalDetails: this.getTaxesForTotalDetails(),
|
|
2658
|
+
subtotalDetails: [
|
|
2659
|
+
...subtotalDetailsSorting.map((sorting) => {
|
|
2660
|
+
const field = this.finance[sorting.key];
|
|
2661
|
+
if (field) {
|
|
2662
|
+
return Object.assign(Object.assign({}, sorting), { money: {
|
|
2663
|
+
amount: sorting.key === 'discount' && field.amount
|
|
2664
|
+
? -field.amount
|
|
2665
|
+
: field.amount,
|
|
2666
|
+
currency: field.currency,
|
|
2667
|
+
} });
|
|
2668
|
+
}
|
|
2669
|
+
return sorting;
|
|
2670
|
+
}),
|
|
2671
|
+
...this.getTaxesForSubtotalDetails(),
|
|
2672
|
+
],
|
|
2673
|
+
};
|
|
2674
|
+
}
|
|
2675
|
+
getPaymentCountry() {
|
|
2676
|
+
var _a;
|
|
2677
|
+
return (_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso;
|
|
2678
|
+
}
|
|
2679
|
+
getTaxForItem(indirectTaxRate) {
|
|
2680
|
+
if (indirectTaxRate ||
|
|
2681
|
+
(this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
|
|
2682
|
+
if (this.isSalesTaxes) {
|
|
2683
|
+
return {
|
|
2684
|
+
content: `Sales tax ${indirectTaxRate}%`,
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
if (this.isIndia()) {
|
|
2688
|
+
return {
|
|
2689
|
+
content: `GST ${indirectTaxRate}%`,
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
if (this.isGhana()) {
|
|
2693
|
+
return {
|
|
2694
|
+
content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
return {
|
|
2698
|
+
content: `VAT ${indirectTaxRate}%`,
|
|
2699
|
+
};
|
|
2700
|
+
}
|
|
2701
|
+
return null;
|
|
2702
|
+
}
|
|
2703
|
+
getTaxesForSubtotalDetails() {
|
|
2704
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2705
|
+
const ret = [];
|
|
2706
|
+
// subtotal. VAT %p
|
|
2707
|
+
if (this.finance.vat_user &&
|
|
2708
|
+
((_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)) {
|
|
2709
|
+
ret.push({
|
|
2710
|
+
key: 'vat_user',
|
|
2711
|
+
title: this.getVatLabelForSubtotalDetails(),
|
|
2712
|
+
money: extractMoneyCurrency(this.finance.vat_user),
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
if ((_f = this.finance.sales_tax_user) === null || _f === void 0 ? void 0 : _f.amount) {
|
|
2716
|
+
ret.push({
|
|
2717
|
+
key: 'sales_tax_user',
|
|
2718
|
+
title: 'Sales tax',
|
|
2719
|
+
money: extractMoneyCurrency(this.finance.sales_tax_user),
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
return ret;
|
|
2723
|
+
}
|
|
2724
|
+
getVatLabelForSubtotalDetails() {
|
|
2725
|
+
var _a, _b, _c, _d;
|
|
2726
|
+
if (this.isIndia()) {
|
|
2727
|
+
return `GST ${(_b = (_a = this.finance.vat_user) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : ''}%`;
|
|
2728
|
+
}
|
|
2729
|
+
if (this.isGhana()) {
|
|
2730
|
+
return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
|
|
2731
|
+
}
|
|
2732
|
+
return `VAT ${(_d = (_c = this.finance.vat_user) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : ''}%`;
|
|
2733
|
+
}
|
|
2734
|
+
getTaxesForTotalDetails() {
|
|
2735
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2736
|
+
const ret = [];
|
|
2737
|
+
// for totalDetails. VAT
|
|
2738
|
+
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)) &&
|
|
2739
|
+
!((_f = (_e = this.finance) === null || _e === void 0 ? void 0 : _e.vat_user) === null || _f === void 0 ? void 0 : _f.amount)) {
|
|
2740
|
+
ret.push({
|
|
2741
|
+
key: 'vat',
|
|
2742
|
+
title: this.getVatLabelForTotalDetails(),
|
|
2743
|
+
money: extractMoneyCurrency(this.finance.vat),
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
if (((_h = (_g = this.finance) === null || _g === void 0 ? void 0 : _g.sales_tax) === null || _h === void 0 ? void 0 : _h.amount) &&
|
|
2747
|
+
!((_k = (_j = this.finance) === null || _j === void 0 ? void 0 : _j.sales_tax_user) === null || _k === void 0 ? void 0 : _k.amount)) {
|
|
2748
|
+
ret.push({
|
|
2749
|
+
key: 'sales_tax',
|
|
2750
|
+
title: 'Sales tax included',
|
|
2751
|
+
money: extractMoneyCurrency(this.finance.sales_tax),
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
return ret;
|
|
2755
|
+
}
|
|
2756
|
+
getVatLabelForTotalDetails() {
|
|
2757
|
+
if (this.isIndia()) {
|
|
2758
|
+
return `Including ${this.finance.vat.percent}% GST`;
|
|
2759
|
+
}
|
|
2760
|
+
if (this.isGhana()) {
|
|
2761
|
+
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
2762
|
+
}
|
|
2763
|
+
return `Including ${this.finance.vat.percent}% VAT`;
|
|
2764
|
+
}
|
|
2765
|
+
isIndia() {
|
|
2766
|
+
var _a;
|
|
2767
|
+
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'IN';
|
|
2768
|
+
}
|
|
2769
|
+
isGhana() {
|
|
2770
|
+
var _a;
|
|
2771
|
+
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'GH';
|
|
2772
|
+
}
|
|
2773
|
+
isDefaultImage(url) {
|
|
2774
|
+
return defaultImagePatterns.some((regex) => regex.test(url));
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
const financeDetailsResponseFactoryToken = new InjectionToken('FinanceDetails');
|
|
2779
|
+
const financeDetailsResponseFactoryProvider = {
|
|
2780
|
+
provide: financeDetailsResponseFactoryToken,
|
|
2781
|
+
useValue: (...args) => new FinanceDetails(...args),
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
class FinanceDetailsService extends EmitDataService {
|
|
2785
|
+
constructor(responseFactory) {
|
|
2786
|
+
super();
|
|
2787
|
+
this.responseFactory = responseFactory;
|
|
2788
|
+
}
|
|
2789
|
+
emit(summary) {
|
|
2790
|
+
if (summary) {
|
|
2791
|
+
super.emit(this.responseFactory(summary));
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: financeDetailsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2796
|
+
FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
|
|
2797
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
|
|
2798
|
+
type: Injectable,
|
|
2799
|
+
args: [{ providedIn: 'root' }]
|
|
2800
|
+
}], ctorParameters: function () {
|
|
2801
|
+
return [{ type: undefined, decorators: [{
|
|
2802
|
+
type: Inject,
|
|
2803
|
+
args: [financeDetailsResponseFactoryToken]
|
|
2804
|
+
}] }];
|
|
2805
|
+
} });
|
|
2806
|
+
|
|
2508
2807
|
class PaymentService {
|
|
2509
|
-
constructor(initializeService, submitService, syncService, formService, statusService, nextActionService, controlConfigService) {
|
|
2808
|
+
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, nextActionService, controlConfigService) {
|
|
2510
2809
|
this.initializeService = initializeService;
|
|
2511
2810
|
this.submitService = submitService;
|
|
2512
2811
|
this.syncService = syncService;
|
|
2513
2812
|
this.formService = formService;
|
|
2514
2813
|
this.statusService = statusService;
|
|
2814
|
+
this.financeDetailsService = financeDetailsService;
|
|
2515
2815
|
this.nextActionService = nextActionService;
|
|
2516
2816
|
this.controlConfigService = controlConfigService;
|
|
2517
2817
|
this.form = null;
|
|
2518
2818
|
this.data = null;
|
|
2819
|
+
this.financeDetails = null;
|
|
2519
2820
|
this.fields = [];
|
|
2821
|
+
this.destroy$ = new Subject();
|
|
2520
2822
|
}
|
|
2521
2823
|
initialize(config) {
|
|
2824
|
+
var _a;
|
|
2522
2825
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2826
|
+
this.destroy$ = new Subject();
|
|
2827
|
+
this.listenFinanceDetails();
|
|
2523
2828
|
this.config = config;
|
|
2524
2829
|
this.data = yield this.initializeService.request(config);
|
|
2525
2830
|
this.fields = this.getFields();
|
|
2526
2831
|
this.form = this.formService.createForm(this.fields);
|
|
2527
|
-
this.
|
|
2832
|
+
this.emitFinanceDetails((_a = this.data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary);
|
|
2833
|
+
this.setupSyncService(this.form, this.fields);
|
|
2528
2834
|
return this.fields;
|
|
2529
2835
|
});
|
|
2530
2836
|
}
|
|
@@ -2534,6 +2840,7 @@ class PaymentService {
|
|
|
2534
2840
|
throw new Error('form is empty!');
|
|
2535
2841
|
}
|
|
2536
2842
|
const submitResponse = yield this.submitService.request(this.fields, this.form);
|
|
2843
|
+
this.emitFinanceDetails(submitResponse.summary);
|
|
2537
2844
|
return this.nextActionService.getNextAction(submitResponse);
|
|
2538
2845
|
});
|
|
2539
2846
|
}
|
|
@@ -2543,6 +2850,10 @@ class PaymentService {
|
|
|
2543
2850
|
}
|
|
2544
2851
|
validate(field) {
|
|
2545
2852
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2853
|
+
const syncErrors = this.syncService.getSyncValidationErrors(field);
|
|
2854
|
+
if (syncErrors) {
|
|
2855
|
+
return Promise.resolve(syncErrors);
|
|
2856
|
+
}
|
|
2546
2857
|
return this.syncService.validate(field);
|
|
2547
2858
|
});
|
|
2548
2859
|
}
|
|
@@ -2550,7 +2861,7 @@ class PaymentService {
|
|
|
2550
2861
|
throw new Error('Method not implemented.');
|
|
2551
2862
|
}
|
|
2552
2863
|
getFinanceDetails() {
|
|
2553
|
-
|
|
2864
|
+
return this.financeDetails;
|
|
2554
2865
|
}
|
|
2555
2866
|
getStatus(params) {
|
|
2556
2867
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2565,15 +2876,36 @@ class PaymentService {
|
|
|
2565
2876
|
const formControl = (_a = this.form) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
2566
2877
|
formControl === null || formControl === void 0 ? void 0 : formControl.setValue(value);
|
|
2567
2878
|
}
|
|
2879
|
+
destroy() {
|
|
2880
|
+
this.data = null;
|
|
2881
|
+
this.financeDetails = null;
|
|
2882
|
+
this.form = null;
|
|
2883
|
+
this.fields = [];
|
|
2884
|
+
this.destroy$.next();
|
|
2885
|
+
}
|
|
2886
|
+
emitFinanceDetails(summary) {
|
|
2887
|
+
this.financeDetailsService.emit(summary);
|
|
2888
|
+
}
|
|
2889
|
+
setupSyncService(form, fields) {
|
|
2890
|
+
this.syncService.setup(form, fields);
|
|
2891
|
+
this.syncService.data$
|
|
2892
|
+
.pipe(takeUntil(this.destroy$))
|
|
2893
|
+
.subscribe((response) => this.emitFinanceDetails(response.summary));
|
|
2894
|
+
}
|
|
2895
|
+
listenFinanceDetails() {
|
|
2896
|
+
this.financeDetailsService.data$
|
|
2897
|
+
.pipe(takeUntil(this.destroy$))
|
|
2898
|
+
.subscribe((financeDetails) => (this.financeDetails = financeDetails));
|
|
2899
|
+
}
|
|
2568
2900
|
}
|
|
2569
|
-
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 }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2901
|
+
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 });
|
|
2570
2902
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
2571
2903
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
2572
2904
|
type: Injectable,
|
|
2573
2905
|
args: [{
|
|
2574
2906
|
providedIn: 'root',
|
|
2575
2907
|
}]
|
|
2576
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }, { type: ControlConfigService }]; } });
|
|
2908
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: NextActionService }, { type: ControlConfigService }]; } });
|
|
2577
2909
|
|
|
2578
2910
|
class RefundPolicyService {
|
|
2579
2911
|
constructor(settingsService) {
|
|
@@ -2681,7 +3013,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2681
3013
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
2682
3014
|
|
|
2683
3015
|
class CoreLibraryService {
|
|
2684
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, legalService, nextActionService) {
|
|
3016
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, nextActionService) {
|
|
2685
3017
|
this.settingsService = settingsService;
|
|
2686
3018
|
this.countryService = countryService;
|
|
2687
3019
|
this.paymentMethodsService = paymentMethodsService;
|
|
@@ -2689,6 +3021,7 @@ class CoreLibraryService {
|
|
|
2689
3021
|
this.userBalanceService = userBalanceService;
|
|
2690
3022
|
this.paymentService = paymentService;
|
|
2691
3023
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
3024
|
+
this.financeDetailsService = financeDetailsService;
|
|
2692
3025
|
this.legalService = legalService;
|
|
2693
3026
|
this.nextActionService = nextActionService;
|
|
2694
3027
|
this.paymentMethods = {
|
|
@@ -2717,6 +3050,7 @@ class CoreLibraryService {
|
|
|
2717
3050
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
2718
3051
|
getStatus: (params) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.getStatus(params); }),
|
|
2719
3052
|
flowUpdates$: this.nextActionService.flowUpdates$,
|
|
3053
|
+
financeDetailsUpdates$: this.financeDetailsService.data$,
|
|
2720
3054
|
form: {
|
|
2721
3055
|
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
2722
3056
|
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
@@ -2727,14 +3061,14 @@ class CoreLibraryService {
|
|
|
2727
3061
|
return this.legalService.getLegalComponentConfig();
|
|
2728
3062
|
}
|
|
2729
3063
|
}
|
|
2730
|
-
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 });
|
|
3064
|
+
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 });
|
|
2731
3065
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
2732
3066
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
2733
3067
|
type: Injectable,
|
|
2734
3068
|
args: [{
|
|
2735
3069
|
providedIn: 'root',
|
|
2736
3070
|
}]
|
|
2737
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
3071
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
2738
3072
|
|
|
2739
3073
|
class HttpError extends AppError {
|
|
2740
3074
|
constructor(error, req) {
|
|
@@ -2837,6 +3171,7 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
2837
3171
|
statusResponseFactoryProvider,
|
|
2838
3172
|
checkStatusRequestFactoryProvider,
|
|
2839
3173
|
checkStatusResponseFactoryProvider,
|
|
3174
|
+
financeDetailsResponseFactoryProvider,
|
|
2840
3175
|
{
|
|
2841
3176
|
provide: nextActionsToken,
|
|
2842
3177
|
useValue: nextActions,
|
|
@@ -2866,6 +3201,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2866
3201
|
statusResponseFactoryProvider,
|
|
2867
3202
|
checkStatusRequestFactoryProvider,
|
|
2868
3203
|
checkStatusResponseFactoryProvider,
|
|
3204
|
+
financeDetailsResponseFactoryProvider,
|
|
2869
3205
|
{
|
|
2870
3206
|
provide: nextActionsToken,
|
|
2871
3207
|
useValue: nextActions,
|