@xsolla/payment-client-core 0.1.6 → 0.1.8
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/country/country-iso-code.enum.mjs +6 -0
- package/esm2020/lib/core/payment/finance-details/cart-summary.interface.mjs +1 -1
- package/esm2020/lib/core/payment/finance-details/finance-details.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/finance-details.service.mjs +25 -12
- package/esm2020/lib/core/payment/finance-details/price.helpers.mjs +2 -2
- package/esm2020/lib/core/payment/finance-details/status/field-with-amount-and-currency.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/status/fields-with-currency.mjs +16 -0
- package/esm2020/lib/core/payment/finance-details/status/finance-info.interface.mjs +2 -0
- package/esm2020/lib/core/payment/finance-details/status/status-finance-details-adapter.service.mjs +290 -0
- package/esm2020/lib/core/payment/finance-details/summary/default-image-patterns.const.mjs +10 -0
- package/esm2020/lib/core/payment/finance-details/summary/sales-tax-details-key.enum.mjs +7 -0
- package/esm2020/lib/core/payment/finance-details/summary/summary-finance-details-adapter.service.mjs +264 -0
- package/esm2020/lib/core/payment/finance-details/vat-details-key.enum.mjs +14 -0
- package/esm2020/lib/core/payment/form/controls/phone-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/converters/converters-map.mjs +3 -1
- package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +37 -0
- package/esm2020/lib/core/payment/form/form.module.mjs +6 -1
- package/esm2020/lib/core/payment/form/validators/max-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/min-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/phone-validator.mjs +6 -0
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +2 -2
- package/esm2020/lib/core/payment/status/status-finance-info.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status-order.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status.service.mjs +10 -6
- package/esm2020/lib/core/payment/xps-summary.interface.mjs +1 -1
- package/esm2020/lib/core/session/session.service.mjs +57 -0
- package/esm2020/lib/core/type-guards/is-null.function.mjs +4 -0
- package/esm2020/lib/core/type-guards/is-undefined.function.mjs +4 -0
- package/esm2020/lib/core-library.module.mjs +1 -4
- package/esm2020/lib/core-library.service.mjs +4 -1
- package/fesm2015/xsolla-payment-client-core.mjs +829 -352
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +812 -344
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/country/country-iso-code.enum.d.ts +4 -0
- package/lib/core/payment/finance-details/cart-summary.interface.d.ts +2 -2
- package/lib/core/payment/finance-details/finance-details.interface.d.ts +11 -0
- package/lib/core/payment/finance-details/finance-details.service.d.ts +12 -5
- package/lib/core/payment/finance-details/price.helpers.d.ts +3 -3
- package/lib/core/payment/finance-details/status/field-with-amount-and-currency.interface.d.ts +7 -0
- package/lib/core/payment/finance-details/status/fields-with-currency.d.ts +1 -0
- package/lib/core/payment/finance-details/status/finance-info.interface.d.ts +4 -0
- package/lib/core/payment/finance-details/status/status-finance-details-adapter.service.d.ts +31 -0
- package/lib/core/payment/finance-details/summary/sales-tax-details-key.enum.d.ts +5 -0
- package/lib/core/payment/finance-details/summary/summary-finance-details-adapter.service.d.ts +24 -0
- package/lib/core/payment/finance-details/vat-details-key.enum.d.ts +12 -0
- package/lib/core/payment/form/controls/phone-control.config.d.ts +6 -0
- package/lib/core/payment/form/converters/phone.converter.d.ts +13 -0
- package/lib/core/payment/form/validators/max-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/min-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/phone-validator.d.ts +2 -0
- package/lib/core/payment/payment.interface.d.ts +1 -1
- package/lib/core/payment/payment.service.d.ts +1 -1
- package/lib/core/payment/status/status-finance-info.interface.d.ts +4 -0
- package/lib/core/payment/status/status-order.interface.d.ts +12 -0
- package/lib/core/payment/status/status.interface.d.ts +4 -16
- package/lib/core/payment/status/status.service.d.ts +3 -1
- package/lib/core/payment/xps-summary.interface.d.ts +1 -1
- package/lib/core/session/session.service.d.ts +18 -0
- package/lib/core/type-guards/is-null.function.d.ts +1 -0
- package/lib/core/type-guards/is-undefined.function.d.ts +1 -0
- package/lib/core-library.service.d.ts +1 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.8.tgz +0 -0
- package/esm2020/lib/core/payment/finance-details/default-image-patterns.const.mjs +0 -10
- package/esm2020/lib/core/payment/finance-details/finance-details-response.token.mjs +0 -8
- package/esm2020/lib/core/payment/finance-details/finance-details.class.mjs +0 -237
- package/lib/core/payment/finance-details/finance-details-response.token.d.ts +0 -7
- package/lib/core/payment/finance-details/finance-details.class.d.ts +0 -29
- package/xsolla-payment-client-core-0.1.6.tgz +0 -0
- /package/lib/core/payment/finance-details/{default-image-patterns.const.d.ts → summary/default-image-patterns.const.d.ts} +0 -0
|
@@ -2619,6 +2619,53 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2619
2619
|
type: Injectable
|
|
2620
2620
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2621
2621
|
|
|
2622
|
+
function phoneValidator() {
|
|
2623
|
+
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
function minLengthValidator(minLength) {
|
|
2627
|
+
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
function maxLengthValidator(maxLength) {
|
|
2631
|
+
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
class PhoneControlConfig extends ControlConfig {
|
|
2635
|
+
constructor() {
|
|
2636
|
+
super(...arguments);
|
|
2637
|
+
this.controlType = 'phone';
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
class PhoneConverter extends Converter {
|
|
2642
|
+
constructor(syncService) {
|
|
2643
|
+
super(syncService);
|
|
2644
|
+
}
|
|
2645
|
+
getValidators(field) {
|
|
2646
|
+
const minLength = 10;
|
|
2647
|
+
const maxLength = 15;
|
|
2648
|
+
return super
|
|
2649
|
+
.getValidators(field)
|
|
2650
|
+
.concat([
|
|
2651
|
+
convertedRequiredValidator(),
|
|
2652
|
+
phoneValidator(),
|
|
2653
|
+
minLengthValidator(minLength),
|
|
2654
|
+
maxLengthValidator(maxLength),
|
|
2655
|
+
]);
|
|
2656
|
+
}
|
|
2657
|
+
createControlConfig(field) {
|
|
2658
|
+
const config = this.createDefaultControlConfig(PhoneControlConfig, field);
|
|
2659
|
+
config.inputMode = 'numeric';
|
|
2660
|
+
return config;
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
PhoneConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2664
|
+
PhoneConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter });
|
|
2665
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, decorators: [{
|
|
2666
|
+
type: Injectable
|
|
2667
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2668
|
+
|
|
2622
2669
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
2623
2670
|
const convertersMap = {
|
|
2624
2671
|
card_number: CardNumberConverter,
|
|
@@ -2643,6 +2690,7 @@ const convertersMap = {
|
|
|
2643
2690
|
sum: PricepointConverter,
|
|
2644
2691
|
out: PricepointConverter,
|
|
2645
2692
|
couponCode: CouponConverter,
|
|
2693
|
+
phone: PhoneConverter,
|
|
2646
2694
|
};
|
|
2647
2695
|
|
|
2648
2696
|
class ControlConfigService {
|
|
@@ -2996,59 +3044,778 @@ const statusResponseFactoryProvider = {
|
|
|
2996
3044
|
class StatusRequestService extends XpsApiPart {
|
|
2997
3045
|
constructor(secureApiClient, settingsService, requestFactory, responseFactory) {
|
|
2998
3046
|
super();
|
|
2999
|
-
this.secureApiClient = secureApiClient;
|
|
3000
|
-
this.settingsService = settingsService;
|
|
3001
|
-
this.requestFactory = requestFactory;
|
|
3002
|
-
this.responseFactory = responseFactory;
|
|
3003
|
-
this.apiRoute = 'directpayment';
|
|
3047
|
+
this.secureApiClient = secureApiClient;
|
|
3048
|
+
this.settingsService = settingsService;
|
|
3049
|
+
this.requestFactory = requestFactory;
|
|
3050
|
+
this.responseFactory = responseFactory;
|
|
3051
|
+
this.apiRoute = 'directpayment';
|
|
3052
|
+
}
|
|
3053
|
+
setRequestParams(params) {
|
|
3054
|
+
this.requestParams = {
|
|
3055
|
+
locale: params.locale,
|
|
3056
|
+
testProject: params.testProject,
|
|
3057
|
+
testPs: params.testPs,
|
|
3058
|
+
testXsolla: params.testXsolla,
|
|
3059
|
+
userReturnStatus: params.userReturnStatus,
|
|
3060
|
+
invoice: params.invoice,
|
|
3061
|
+
pid: params.pid,
|
|
3062
|
+
signature: params.signature,
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
request() {
|
|
3066
|
+
const requestParams = this.requestFactory(Object.assign({ token: this.settingsService.token }, this.requestParams));
|
|
3067
|
+
lastValueFrom(this.secureApiClient.post(this.apiRoute, new URLSearchParams(requestParams), {
|
|
3068
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
3069
|
+
responseType: 'json',
|
|
3070
|
+
}))
|
|
3071
|
+
.then((response) => {
|
|
3072
|
+
const statusResponse = this.responseFactory({
|
|
3073
|
+
status: response.status,
|
|
3074
|
+
errors: response.errors,
|
|
3075
|
+
form: response.form,
|
|
3076
|
+
});
|
|
3077
|
+
this.emitResponse(statusResponse);
|
|
3078
|
+
})
|
|
3079
|
+
.catch((e) => {
|
|
3080
|
+
throw new TerminalError(e.message, e.code);
|
|
3081
|
+
});
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
StatusRequestService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: statusRequestFactoryToken }, { token: statusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3085
|
+
StatusRequestService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, providedIn: 'root' });
|
|
3086
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, decorators: [{
|
|
3087
|
+
type: Injectable,
|
|
3088
|
+
args: [{
|
|
3089
|
+
providedIn: 'root',
|
|
3090
|
+
}]
|
|
3091
|
+
}], ctorParameters: function () {
|
|
3092
|
+
return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
3093
|
+
type: Inject,
|
|
3094
|
+
args: [statusRequestFactoryToken]
|
|
3095
|
+
}] }, { type: undefined, decorators: [{
|
|
3096
|
+
type: Inject,
|
|
3097
|
+
args: [statusResponseFactoryToken]
|
|
3098
|
+
}] }];
|
|
3099
|
+
} });
|
|
3100
|
+
|
|
3101
|
+
function isNull(value) {
|
|
3102
|
+
return value === null;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
function isUndefined(value) {
|
|
3106
|
+
return typeof value === 'undefined';
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
class SessionService {
|
|
3110
|
+
constructor(window, settingsService) {
|
|
3111
|
+
this.window = window;
|
|
3112
|
+
this.settingsService = settingsService;
|
|
3113
|
+
this.cache = {};
|
|
3114
|
+
}
|
|
3115
|
+
/**
|
|
3116
|
+
* @param {string} key must be uniq entire all app
|
|
3117
|
+
* @param {unknown} value can be anything
|
|
3118
|
+
*/
|
|
3119
|
+
set(key, value) {
|
|
3120
|
+
this.cache[key] = value;
|
|
3121
|
+
try {
|
|
3122
|
+
this.window.sessionStorage.setItem(this.getStorageKey(key), JSON.stringify(value));
|
|
3123
|
+
}
|
|
3124
|
+
catch (error) {
|
|
3125
|
+
console.warn('Session storage not available.');
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
get(key) {
|
|
3129
|
+
const cacheValue = this.cache[key];
|
|
3130
|
+
if (!isUndefined(cacheValue)) {
|
|
3131
|
+
return cacheValue;
|
|
3132
|
+
}
|
|
3133
|
+
try {
|
|
3134
|
+
const storageValue = this.window.sessionStorage.getItem(this.getStorageKey(key));
|
|
3135
|
+
if (isNull(storageValue)) {
|
|
3136
|
+
return null;
|
|
3137
|
+
}
|
|
3138
|
+
return JSON.parse(storageValue);
|
|
3139
|
+
}
|
|
3140
|
+
catch (error) {
|
|
3141
|
+
return null;
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
getStorageKey(key) {
|
|
3145
|
+
return `${key}${this.settingsService.token}`;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
SessionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SessionService, deps: [{ token: windowToken }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3149
|
+
SessionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SessionService, providedIn: 'root' });
|
|
3150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SessionService, decorators: [{
|
|
3151
|
+
type: Injectable,
|
|
3152
|
+
args: [{
|
|
3153
|
+
providedIn: 'root',
|
|
3154
|
+
}]
|
|
3155
|
+
}], ctorParameters: function () {
|
|
3156
|
+
return [{ type: undefined, decorators: [{
|
|
3157
|
+
type: Inject,
|
|
3158
|
+
args: [windowToken]
|
|
3159
|
+
}] }, { type: SettingsService }];
|
|
3160
|
+
} });
|
|
3161
|
+
|
|
3162
|
+
function extractMoneyCurrency(money, allowZero = true) {
|
|
3163
|
+
var _a, _b;
|
|
3164
|
+
return {
|
|
3165
|
+
amount: (_a = money === null || money === void 0 ? void 0 : money.amount) !== null && _a !== void 0 ? _a : (allowZero ? 0 : null),
|
|
3166
|
+
currency: (_b = money === null || money === void 0 ? void 0 : money.currency) !== null && _b !== void 0 ? _b : '',
|
|
3167
|
+
};
|
|
3168
|
+
}
|
|
3169
|
+
function createPriceOrUndefined(amount, currency) {
|
|
3170
|
+
return amount !== undefined && amount !== null && currency !== undefined
|
|
3171
|
+
? {
|
|
3172
|
+
amount,
|
|
3173
|
+
currency,
|
|
3174
|
+
}
|
|
3175
|
+
: undefined;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
/**
|
|
3179
|
+
* default image for purchase item is set on Publisher Account side.
|
|
3180
|
+
* for purchase checkout items the image url is converted into base64 string.
|
|
3181
|
+
* to determine default image fixed templates are used
|
|
3182
|
+
*/
|
|
3183
|
+
const defaultImagePatterns = [
|
|
3184
|
+
/^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
|
|
3185
|
+
/virtual_item_default_image/,
|
|
3186
|
+
];
|
|
3187
|
+
|
|
3188
|
+
var VatDetailsKey;
|
|
3189
|
+
(function (VatDetailsKey) {
|
|
3190
|
+
VatDetailsKey["vat"] = "vat";
|
|
3191
|
+
VatDetailsKey["vatPercent"] = "vat-percent";
|
|
3192
|
+
VatDetailsKey["vatIncluding"] = "vat-including";
|
|
3193
|
+
VatDetailsKey["vatPercentIncluding"] = "vat-percent-including";
|
|
3194
|
+
VatDetailsKey["vatIndia"] = "vat-india";
|
|
3195
|
+
VatDetailsKey["vatIndiaPercent"] = "vat-india-percent";
|
|
3196
|
+
VatDetailsKey["vatIndiaIncluding"] = "vat-india-including";
|
|
3197
|
+
VatDetailsKey["vatIndiaPercentIncluding"] = "vat-india-percent-including";
|
|
3198
|
+
VatDetailsKey["vatGhana"] = "vat-ghana";
|
|
3199
|
+
VatDetailsKey["vatGhanaIncluding"] = "vat-ghana-including";
|
|
3200
|
+
})(VatDetailsKey || (VatDetailsKey = {}));
|
|
3201
|
+
|
|
3202
|
+
var SalesTaxDetailsKey;
|
|
3203
|
+
(function (SalesTaxDetailsKey) {
|
|
3204
|
+
SalesTaxDetailsKey["salesTax"] = "sales-tax";
|
|
3205
|
+
SalesTaxDetailsKey["salesTaxPercent"] = "sales-tax-percent";
|
|
3206
|
+
SalesTaxDetailsKey["salesTaxIncluding"] = "sales-tax-including";
|
|
3207
|
+
})(SalesTaxDetailsKey || (SalesTaxDetailsKey = {}));
|
|
3208
|
+
|
|
3209
|
+
class SummaryFinanceDetailsAdapterService {
|
|
3210
|
+
getFinanceDetails(summary) {
|
|
3211
|
+
const { purchase, finance } = summary;
|
|
3212
|
+
return {
|
|
3213
|
+
purchase: purchase,
|
|
3214
|
+
finance: finance,
|
|
3215
|
+
cartItems: this.getCartItems(purchase, finance),
|
|
3216
|
+
cartSummary: this.getCartSummary(finance),
|
|
3217
|
+
paymentCountry: this.getPaymentCountry(finance),
|
|
3218
|
+
};
|
|
3219
|
+
}
|
|
3220
|
+
shouldShowZeroIndirectTaxRate(finance) {
|
|
3221
|
+
var _a, _b, _c;
|
|
3222
|
+
return !!((_b = (_a = finance === null || finance === void 0 ? void 0 : finance.vat) === null || _a === void 0 ? void 0 : _a.visible) !== null && _b !== void 0 ? _b : (_c = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _c === void 0 ? void 0 : _c.visible);
|
|
3223
|
+
}
|
|
3224
|
+
isSalesTaxes(finance) {
|
|
3225
|
+
var _a, _b, _c;
|
|
3226
|
+
return !!((_b = (_a = finance === null || finance === void 0 ? void 0 : finance.sales_tax) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : (_c = finance === null || finance === void 0 ? void 0 : finance.sales_tax_user) === null || _c === void 0 ? void 0 : _c.amount);
|
|
3227
|
+
}
|
|
3228
|
+
getCartItems(purchase, finance) {
|
|
3229
|
+
var _a, _b, _c, _d;
|
|
3230
|
+
const checkouts = (_a = purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
3231
|
+
return {
|
|
3232
|
+
imgSrc: item.image_url,
|
|
3233
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3234
|
+
title: item.name,
|
|
3235
|
+
price: extractMoneyCurrency(item, false),
|
|
3236
|
+
priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
|
|
3237
|
+
quantity: item.quantity,
|
|
3238
|
+
description: item.description,
|
|
3239
|
+
tax: this.getTaxForItem(finance, item.indirect_tax_rate),
|
|
3240
|
+
isBonus: item.is_bonus,
|
|
3241
|
+
};
|
|
3242
|
+
});
|
|
3243
|
+
const virtualCurrencies = (_b = purchase.virtual_currency) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
3244
|
+
return {
|
|
3245
|
+
imgSrc: item.image_url,
|
|
3246
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3247
|
+
title: `${item.quantity} ${item.name}`,
|
|
3248
|
+
price: extractMoneyCurrency(item),
|
|
3249
|
+
description: item.description,
|
|
3250
|
+
isBonus: item.is_bonus,
|
|
3251
|
+
};
|
|
3252
|
+
});
|
|
3253
|
+
const virtualItems = (_c = purchase.virtual_items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
3254
|
+
return {
|
|
3255
|
+
imgSrc: item.image_url,
|
|
3256
|
+
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3257
|
+
title: item.name,
|
|
3258
|
+
price: extractMoneyCurrency(item),
|
|
3259
|
+
description: item.description,
|
|
3260
|
+
quantity: item.quantity,
|
|
3261
|
+
isBonus: item.is_bonus,
|
|
3262
|
+
};
|
|
3263
|
+
});
|
|
3264
|
+
let checkoutArray = undefined;
|
|
3265
|
+
if (purchase.checkout) {
|
|
3266
|
+
checkoutArray = [
|
|
3267
|
+
{
|
|
3268
|
+
key: 'checkout',
|
|
3269
|
+
title: purchase.checkout.description,
|
|
3270
|
+
price: extractMoneyCurrency(purchase.checkout),
|
|
3271
|
+
isBonus: (_d = purchase.checkout.is_bonus) !== null && _d !== void 0 ? _d : false,
|
|
3272
|
+
},
|
|
3273
|
+
];
|
|
3274
|
+
}
|
|
3275
|
+
return [
|
|
3276
|
+
...(checkouts !== null && checkouts !== void 0 ? checkouts : []),
|
|
3277
|
+
...(virtualCurrencies !== null && virtualCurrencies !== void 0 ? virtualCurrencies : []),
|
|
3278
|
+
...(virtualItems !== null && virtualItems !== void 0 ? virtualItems : []),
|
|
3279
|
+
...(checkoutArray !== null && checkoutArray !== void 0 ? checkoutArray : []),
|
|
3280
|
+
];
|
|
3281
|
+
}
|
|
3282
|
+
getCartSummary(finance) {
|
|
3283
|
+
var _a, _b, _c, _d;
|
|
3284
|
+
return {
|
|
3285
|
+
subtotal: {
|
|
3286
|
+
title: 'Subtotal',
|
|
3287
|
+
money: createPriceOrUndefined((_a = finance === null || finance === void 0 ? void 0 : finance.sub_total) === null || _a === void 0 ? void 0 : _a.amount, (_b = finance === null || finance === void 0 ? void 0 : finance.sub_total) === null || _b === void 0 ? void 0 : _b.currency),
|
|
3288
|
+
},
|
|
3289
|
+
subtotalPayment: {
|
|
3290
|
+
title: '',
|
|
3291
|
+
money: createPriceOrUndefined((_c = finance === null || finance === void 0 ? void 0 : finance.sub_total) === null || _c === void 0 ? void 0 : _c.payment_amount, (_d = finance === null || finance === void 0 ? void 0 : finance.sub_total) === null || _d === void 0 ? void 0 : _d.payment_currency),
|
|
3292
|
+
},
|
|
3293
|
+
total: {
|
|
3294
|
+
title: 'Total',
|
|
3295
|
+
money: extractMoneyCurrency(finance === null || finance === void 0 ? void 0 : finance.total),
|
|
3296
|
+
},
|
|
3297
|
+
totalDetails: this.getTaxesForTotalDetails(finance),
|
|
3298
|
+
subtotalDetails: [
|
|
3299
|
+
...this.getSubtotalDetails(finance),
|
|
3300
|
+
...this.getTaxesForSubtotalDetails(finance),
|
|
3301
|
+
],
|
|
3302
|
+
};
|
|
3303
|
+
}
|
|
3304
|
+
getPaymentCountry(finance) {
|
|
3305
|
+
var _a, _b;
|
|
3306
|
+
return (_b = (_a = finance === null || finance === void 0 ? void 0 : finance.payment_country) === null || _a === void 0 ? void 0 : _a.iso) !== null && _b !== void 0 ? _b : '';
|
|
3307
|
+
}
|
|
3308
|
+
getTaxForItem(finance, indirectTaxRate) {
|
|
3309
|
+
if (indirectTaxRate ||
|
|
3310
|
+
(this.shouldShowZeroIndirectTaxRate(finance) && indirectTaxRate === 0)) {
|
|
3311
|
+
if (this.isSalesTaxes(finance)) {
|
|
3312
|
+
return {
|
|
3313
|
+
key: SalesTaxDetailsKey.salesTaxPercent,
|
|
3314
|
+
content: `Sales tax ${indirectTaxRate}%`,
|
|
3315
|
+
rate: indirectTaxRate,
|
|
3316
|
+
};
|
|
3317
|
+
}
|
|
3318
|
+
if (this.isIndia(finance)) {
|
|
3319
|
+
return {
|
|
3320
|
+
key: VatDetailsKey.vatIndiaPercent,
|
|
3321
|
+
content: `GST ${indirectTaxRate}%`,
|
|
3322
|
+
rate: indirectTaxRate,
|
|
3323
|
+
};
|
|
3324
|
+
}
|
|
3325
|
+
if (this.isGhana(finance)) {
|
|
3326
|
+
return {
|
|
3327
|
+
key: VatDetailsKey.vatGhana,
|
|
3328
|
+
content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
|
|
3329
|
+
rate: indirectTaxRate,
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
return {
|
|
3333
|
+
key: VatDetailsKey.vatPercent,
|
|
3334
|
+
content: `VAT ${indirectTaxRate}%`,
|
|
3335
|
+
rate: indirectTaxRate,
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
return null;
|
|
3339
|
+
}
|
|
3340
|
+
getSubtotalDetails(finance) {
|
|
3341
|
+
if (!finance) {
|
|
3342
|
+
return [];
|
|
3343
|
+
}
|
|
3344
|
+
// subtotal details fields
|
|
3345
|
+
const subtotalDetailsSorting = [
|
|
3346
|
+
{
|
|
3347
|
+
key: 'discount',
|
|
3348
|
+
responseKey: 'discount',
|
|
3349
|
+
title: 'Discount',
|
|
3350
|
+
},
|
|
3351
|
+
{
|
|
3352
|
+
key: 'fee',
|
|
3353
|
+
responseKey: 'fee',
|
|
3354
|
+
title: 'Payment system fee',
|
|
3355
|
+
},
|
|
3356
|
+
{
|
|
3357
|
+
key: 'user-balance',
|
|
3358
|
+
responseKey: 'user_balance',
|
|
3359
|
+
title: 'Balance',
|
|
3360
|
+
},
|
|
3361
|
+
];
|
|
3362
|
+
return subtotalDetailsSorting.map((sorting) => {
|
|
3363
|
+
const field = finance[sorting.responseKey];
|
|
3364
|
+
if (field) {
|
|
3365
|
+
return {
|
|
3366
|
+
key: sorting.key,
|
|
3367
|
+
title: sorting.title,
|
|
3368
|
+
money: {
|
|
3369
|
+
amount: sorting.key === 'discount' && field.amount
|
|
3370
|
+
? -field.amount
|
|
3371
|
+
: field.amount,
|
|
3372
|
+
currency: field.currency,
|
|
3373
|
+
},
|
|
3374
|
+
};
|
|
3375
|
+
}
|
|
3376
|
+
return sorting;
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
getTaxesForSubtotalDetails(finance) {
|
|
3380
|
+
var _a, _b, _c, _d;
|
|
3381
|
+
const ret = [];
|
|
3382
|
+
// subtotal. VAT %p
|
|
3383
|
+
if ((finance === null || finance === void 0 ? void 0 : finance.vat_user) &&
|
|
3384
|
+
((_b = (_a = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : (_c = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _c === void 0 ? void 0 : _c.visible)) {
|
|
3385
|
+
ret.push({
|
|
3386
|
+
key: this.getVatNotIncludingKeyForDetails(finance),
|
|
3387
|
+
title: this.getVatLabelForSubtotalDetails(finance),
|
|
3388
|
+
money: extractMoneyCurrency(finance === null || finance === void 0 ? void 0 : finance.vat_user),
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3391
|
+
if ((_d = finance === null || finance === void 0 ? void 0 : finance.sales_tax_user) === null || _d === void 0 ? void 0 : _d.amount) {
|
|
3392
|
+
ret.push({
|
|
3393
|
+
key: SalesTaxDetailsKey.salesTax,
|
|
3394
|
+
title: 'Sales tax',
|
|
3395
|
+
money: extractMoneyCurrency(finance === null || finance === void 0 ? void 0 : finance.sales_tax_user),
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
return ret;
|
|
3399
|
+
}
|
|
3400
|
+
getVatLabelForSubtotalDetails(finance) {
|
|
3401
|
+
var _a, _b, _c, _d;
|
|
3402
|
+
if (this.isIndia(finance)) {
|
|
3403
|
+
return `GST ${(_b = (_a = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : ''}%`;
|
|
3404
|
+
}
|
|
3405
|
+
if (this.isGhana(finance)) {
|
|
3406
|
+
return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
|
|
3407
|
+
}
|
|
3408
|
+
return `VAT ${(_d = (_c = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : ''}%`;
|
|
3409
|
+
}
|
|
3410
|
+
getTaxesForTotalDetails(finance) {
|
|
3411
|
+
var _a, _b, _c, _d, _e;
|
|
3412
|
+
const ret = [];
|
|
3413
|
+
// for totalDetails. VAT
|
|
3414
|
+
if ((((_a = finance === null || finance === void 0 ? void 0 : finance.vat) === null || _a === void 0 ? void 0 : _a.amount) || ((_b = finance === null || finance === void 0 ? void 0 : finance.vat) === null || _b === void 0 ? void 0 : _b.visible)) &&
|
|
3415
|
+
!((_c = finance === null || finance === void 0 ? void 0 : finance.vat_user) === null || _c === void 0 ? void 0 : _c.amount)) {
|
|
3416
|
+
ret.push({
|
|
3417
|
+
key: this.getVatIncludingKeyForDetails(finance),
|
|
3418
|
+
title: this.getVatLabelForTotalDetails(finance),
|
|
3419
|
+
money: extractMoneyCurrency(finance === null || finance === void 0 ? void 0 : finance.vat),
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
if (((_d = finance === null || finance === void 0 ? void 0 : finance.sales_tax) === null || _d === void 0 ? void 0 : _d.amount) && !((_e = finance === null || finance === void 0 ? void 0 : finance.sales_tax_user) === null || _e === void 0 ? void 0 : _e.amount)) {
|
|
3423
|
+
ret.push({
|
|
3424
|
+
key: SalesTaxDetailsKey.salesTaxIncluding,
|
|
3425
|
+
title: 'Sales tax included',
|
|
3426
|
+
money: extractMoneyCurrency(finance === null || finance === void 0 ? void 0 : finance.sales_tax),
|
|
3427
|
+
});
|
|
3428
|
+
}
|
|
3429
|
+
return ret;
|
|
3430
|
+
}
|
|
3431
|
+
getVatNotIncludingKeyForDetails(finance) {
|
|
3432
|
+
if (this.isIndia(finance)) {
|
|
3433
|
+
return VatDetailsKey.vatIndiaPercent;
|
|
3434
|
+
}
|
|
3435
|
+
if (this.isGhana(finance)) {
|
|
3436
|
+
return VatDetailsKey.vatGhana;
|
|
3437
|
+
}
|
|
3438
|
+
return VatDetailsKey.vatPercent;
|
|
3439
|
+
}
|
|
3440
|
+
getVatIncludingKeyForDetails(finance) {
|
|
3441
|
+
if (this.isIndia(finance)) {
|
|
3442
|
+
return VatDetailsKey.vatIndiaPercentIncluding;
|
|
3443
|
+
}
|
|
3444
|
+
if (this.isGhana(finance)) {
|
|
3445
|
+
return VatDetailsKey.vatGhanaIncluding;
|
|
3446
|
+
}
|
|
3447
|
+
return VatDetailsKey.vatPercentIncluding;
|
|
3448
|
+
}
|
|
3449
|
+
getVatLabelForTotalDetails(finance) {
|
|
3450
|
+
var _a, _b;
|
|
3451
|
+
if (this.isIndia(finance)) {
|
|
3452
|
+
return `Including ${(_a = finance === null || finance === void 0 ? void 0 : finance.vat.percent) !== null && _a !== void 0 ? _a : ''}% GST`;
|
|
3453
|
+
}
|
|
3454
|
+
if (this.isGhana(finance)) {
|
|
3455
|
+
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
3456
|
+
}
|
|
3457
|
+
return `Including ${(_b = finance === null || finance === void 0 ? void 0 : finance.vat.percent) !== null && _b !== void 0 ? _b : ''}% VAT`;
|
|
3458
|
+
}
|
|
3459
|
+
isIndia(finance) {
|
|
3460
|
+
return (finance === null || finance === void 0 ? void 0 : finance.payment_country.iso) === 'IN';
|
|
3461
|
+
}
|
|
3462
|
+
isGhana(finance) {
|
|
3463
|
+
return (finance === null || finance === void 0 ? void 0 : finance.payment_country.iso) === 'GH';
|
|
3464
|
+
}
|
|
3465
|
+
isDefaultImage(url) {
|
|
3466
|
+
return defaultImagePatterns.some((regex) => regex.test(url));
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
SummaryFinanceDetailsAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SummaryFinanceDetailsAdapterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3470
|
+
SummaryFinanceDetailsAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SummaryFinanceDetailsAdapterService, providedIn: 'root' });
|
|
3471
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SummaryFinanceDetailsAdapterService, decorators: [{
|
|
3472
|
+
type: Injectable,
|
|
3473
|
+
args: [{ providedIn: 'root' }]
|
|
3474
|
+
}] });
|
|
3475
|
+
|
|
3476
|
+
const fieldsWithCurrency = new Set([
|
|
3477
|
+
'sum',
|
|
3478
|
+
'commissionUserVatPrc',
|
|
3479
|
+
'salesTaxCommission',
|
|
3480
|
+
'vatUserNotIncluded',
|
|
3481
|
+
'xsollaTipsAmount',
|
|
3482
|
+
'paymentSystemFee',
|
|
3483
|
+
'discount',
|
|
3484
|
+
'userWallet',
|
|
3485
|
+
'subtotal',
|
|
3486
|
+
'subtotalSummaryBeforeConversion',
|
|
3487
|
+
'grandTotal',
|
|
3488
|
+
'subtotalBeforeDiscount',
|
|
3489
|
+
'redeemedPoints',
|
|
3490
|
+
]);
|
|
3491
|
+
|
|
3492
|
+
var CountryIsoCode;
|
|
3493
|
+
(function (CountryIsoCode) {
|
|
3494
|
+
CountryIsoCode["India"] = "IN";
|
|
3495
|
+
CountryIsoCode["Ghana"] = "GH";
|
|
3496
|
+
})(CountryIsoCode || (CountryIsoCode = {}));
|
|
3497
|
+
|
|
3498
|
+
class StatusFinanceDetailsAdapterService {
|
|
3499
|
+
constructor(summarFinanceDetailsAdapterService) {
|
|
3500
|
+
this.summarFinanceDetailsAdapterService = summarFinanceDetailsAdapterService;
|
|
3501
|
+
}
|
|
3502
|
+
getFinanceDetails(status, purchase) {
|
|
3503
|
+
var _a;
|
|
3504
|
+
const financeInfo = this.fillFinanceInfo(status.financeInfo);
|
|
3505
|
+
const country = status.paymentCountryIso;
|
|
3506
|
+
const order = (_a = status.order) !== null && _a !== void 0 ? _a : null;
|
|
3507
|
+
const summaryFinance = this.convertStatusFinanceToSummaryFinance(purchase, order, country);
|
|
3508
|
+
return {
|
|
3509
|
+
purchase,
|
|
3510
|
+
finance: summaryFinance,
|
|
3511
|
+
cartItems: this.getCartItems(purchase, summaryFinance),
|
|
3512
|
+
cartSummary: this.getCartSummary(status, financeInfo, country),
|
|
3513
|
+
paymentCountry: country,
|
|
3514
|
+
};
|
|
3515
|
+
}
|
|
3516
|
+
fillFinanceInfo(financeInfo) {
|
|
3517
|
+
return Object.keys(financeInfo).reduce((financeInfoWithAmountAndCurrency, key) => {
|
|
3518
|
+
const field = financeInfo[key];
|
|
3519
|
+
if ((field === null || field === void 0 ? void 0 : field.key) && fieldsWithCurrency.has(field === null || field === void 0 ? void 0 : field.key)) {
|
|
3520
|
+
this.addAmountAndCurrencyToField(field);
|
|
3521
|
+
}
|
|
3522
|
+
return Object.assign(Object.assign({}, financeInfoWithAmountAndCurrency), { [key]: field });
|
|
3523
|
+
}, {});
|
|
3524
|
+
}
|
|
3525
|
+
addAmountAndCurrencyToField(field) {
|
|
3526
|
+
var _a;
|
|
3527
|
+
const amountAndCurrency = /(^[-\d.]+) ([A-Z]{3})$/;
|
|
3528
|
+
const currencyParts = (_a = field.value) === null || _a === void 0 ? void 0 : _a.trim().match(amountAndCurrency);
|
|
3529
|
+
if (currencyParts) {
|
|
3530
|
+
const amountPosition = 1;
|
|
3531
|
+
const currencyPosition = 2;
|
|
3532
|
+
field.amount = Number(currencyParts[amountPosition]);
|
|
3533
|
+
field.currency = currencyParts[currencyPosition];
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
getCartItems(purchase, summaryFinance) {
|
|
3537
|
+
if (!purchase) {
|
|
3538
|
+
return null;
|
|
3539
|
+
}
|
|
3540
|
+
const financeDetails = this.summarFinanceDetailsAdapterService.getFinanceDetails({
|
|
3541
|
+
purchase,
|
|
3542
|
+
finance: summaryFinance,
|
|
3543
|
+
});
|
|
3544
|
+
return financeDetails.cartItems;
|
|
3545
|
+
}
|
|
3546
|
+
convertStatusFinanceToSummaryFinance(purchase, order, country) {
|
|
3547
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3548
|
+
if (!order || !((_a = purchase === null || purchase === void 0 ? void 0 : purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3549
|
+
return null;
|
|
3550
|
+
}
|
|
3551
|
+
const finance = {
|
|
3552
|
+
payment_country: {
|
|
3553
|
+
iso: country,
|
|
3554
|
+
},
|
|
3555
|
+
};
|
|
3556
|
+
const firstCheckoutItem = purchase === null || purchase === void 0 ? void 0 : purchase.checkout_items[0];
|
|
3557
|
+
const firstCheckoutItemAmount = (_b = firstCheckoutItem === null || firstCheckoutItem === void 0 ? void 0 : firstCheckoutItem.amount) !== null && _b !== void 0 ? _b : 0;
|
|
3558
|
+
const oneHundredPercent = 100;
|
|
3559
|
+
const taxAmount = (firstCheckoutItemAmount * (firstCheckoutItem === null || firstCheckoutItem === void 0 ? void 0 : firstCheckoutItem.indirect_tax_rate)) /
|
|
3560
|
+
oneHundredPercent;
|
|
3561
|
+
if ((_c = order.contained_taxes) === null || _c === void 0 ? void 0 : _c.sales_tax) {
|
|
3562
|
+
finance.sales_tax = {
|
|
3563
|
+
amount: taxAmount,
|
|
3564
|
+
percent: firstCheckoutItem === null || firstCheckoutItem === void 0 ? void 0 : firstCheckoutItem.indirect_tax_rate,
|
|
3565
|
+
currency: (_e = (_d = purchase === null || purchase === void 0 ? void 0 : purchase.checkout) === null || _d === void 0 ? void 0 : _d.currency) !== null && _e !== void 0 ? _e : '',
|
|
3566
|
+
};
|
|
3567
|
+
}
|
|
3568
|
+
if ((_f = order.contained_taxes) === null || _f === void 0 ? void 0 : _f.user_vat) {
|
|
3569
|
+
finance.vat = {
|
|
3570
|
+
amount: taxAmount,
|
|
3571
|
+
percent: firstCheckoutItem === null || firstCheckoutItem === void 0 ? void 0 : firstCheckoutItem.indirect_tax_rate,
|
|
3572
|
+
currency: (_h = (_g = purchase === null || purchase === void 0 ? void 0 : purchase.checkout) === null || _g === void 0 ? void 0 : _g.currency) !== null && _h !== void 0 ? _h : '',
|
|
3573
|
+
visible: true,
|
|
3574
|
+
};
|
|
3575
|
+
}
|
|
3576
|
+
return finance;
|
|
3577
|
+
}
|
|
3578
|
+
getCartSummary(status, financeInfo, country) {
|
|
3579
|
+
var _a, _b;
|
|
3580
|
+
const cart = {
|
|
3581
|
+
total: this.getTotal(financeInfo),
|
|
3582
|
+
totalDetails: this.getTotalDetails(financeInfo, country),
|
|
3583
|
+
subtotalDetails: [
|
|
3584
|
+
...this.getSubtotalDetails(financeInfo),
|
|
3585
|
+
...this.getTaxesForSubtotalDetails(financeInfo, country),
|
|
3586
|
+
],
|
|
3587
|
+
transactionDetails: this.getTransactionDetails(status, financeInfo),
|
|
3588
|
+
subtotal: (_a = this.getInitialCurrencySubtotal(financeInfo)) !== null && _a !== void 0 ? _a : null,
|
|
3589
|
+
subtotalPayment: (_b = this.getSubtotalPayment(financeInfo)) !== null && _b !== void 0 ? _b : null,
|
|
3590
|
+
};
|
|
3591
|
+
return cart;
|
|
3592
|
+
}
|
|
3593
|
+
getTotal(financeInfo) {
|
|
3594
|
+
return {
|
|
3595
|
+
title: 'Total',
|
|
3596
|
+
money: extractMoneyCurrency(financeInfo.sum),
|
|
3597
|
+
};
|
|
3598
|
+
}
|
|
3599
|
+
getSubtotalPayment(financeInfo) {
|
|
3600
|
+
if (!(financeInfo === null || financeInfo === void 0 ? void 0 : financeInfo.subtotal)) {
|
|
3601
|
+
return null;
|
|
3602
|
+
}
|
|
3603
|
+
return {
|
|
3604
|
+
title: 'Subtotal',
|
|
3605
|
+
money: extractMoneyCurrency(financeInfo.subtotal),
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
getInitialCurrencySubtotal(financeInfo) {
|
|
3609
|
+
if (!(financeInfo === null || financeInfo === void 0 ? void 0 : financeInfo.subtotalSummaryBeforeConversion)) {
|
|
3610
|
+
return null;
|
|
3611
|
+
}
|
|
3612
|
+
return {
|
|
3613
|
+
title: '',
|
|
3614
|
+
money: extractMoneyCurrency(financeInfo.subtotalSummaryBeforeConversion),
|
|
3615
|
+
};
|
|
3616
|
+
}
|
|
3617
|
+
getTotalDetails(financeInfo, country) {
|
|
3618
|
+
var _a, _b, _c, _d;
|
|
3619
|
+
const totalDetails = [];
|
|
3620
|
+
const salesTaxCommissionField = financeInfo['salesTaxCommission'];
|
|
3621
|
+
if (salesTaxCommissionField) {
|
|
3622
|
+
totalDetails.push({
|
|
3623
|
+
title: salesTaxCommissionField.pref,
|
|
3624
|
+
money: {
|
|
3625
|
+
amount: (_a = salesTaxCommissionField.amount) !== null && _a !== void 0 ? _a : null,
|
|
3626
|
+
currency: (_b = salesTaxCommissionField.currency) !== null && _b !== void 0 ? _b : '',
|
|
3627
|
+
},
|
|
3628
|
+
});
|
|
3629
|
+
}
|
|
3630
|
+
const commissionUserVatPrcField = financeInfo['commissionUserVatPrc'];
|
|
3631
|
+
if (commissionUserVatPrcField === null || commissionUserVatPrcField === void 0 ? void 0 : commissionUserVatPrcField.pref) {
|
|
3632
|
+
const percents = this.getPercents(commissionUserVatPrcField.pref);
|
|
3633
|
+
totalDetails.push({
|
|
3634
|
+
key: this.getVatIncludingKeyDetails(percents, country),
|
|
3635
|
+
title: this.geVatIncludingTitleDetails(percents, country),
|
|
3636
|
+
money: {
|
|
3637
|
+
amount: (_c = commissionUserVatPrcField.amount) !== null && _c !== void 0 ? _c : null,
|
|
3638
|
+
currency: (_d = commissionUserVatPrcField.currency) !== null && _d !== void 0 ? _d : '',
|
|
3639
|
+
},
|
|
3640
|
+
});
|
|
3641
|
+
}
|
|
3642
|
+
return totalDetails;
|
|
3643
|
+
}
|
|
3644
|
+
getSubtotalDetails(financeInfo) {
|
|
3645
|
+
const subtotalDetailsSorting = [
|
|
3646
|
+
{
|
|
3647
|
+
key: 'discount',
|
|
3648
|
+
responseKey: 'discount',
|
|
3649
|
+
title: 'Discount',
|
|
3650
|
+
},
|
|
3651
|
+
{
|
|
3652
|
+
key: 'fee',
|
|
3653
|
+
responseKey: 'paymentSystemFee',
|
|
3654
|
+
title: 'Payment system fee',
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
key: 'user-balance',
|
|
3658
|
+
responseKey: 'userWallet',
|
|
3659
|
+
title: 'Balance',
|
|
3660
|
+
},
|
|
3661
|
+
];
|
|
3662
|
+
const redeemedPoints = financeInfo['redeemedPoints'];
|
|
3663
|
+
if (redeemedPoints === null || redeemedPoints === void 0 ? void 0 : redeemedPoints.pref) {
|
|
3664
|
+
subtotalDetailsSorting.push({
|
|
3665
|
+
key: 'redeem-points',
|
|
3666
|
+
responseKey: 'redeemedPoints',
|
|
3667
|
+
title: redeemedPoints.pref,
|
|
3668
|
+
});
|
|
3669
|
+
}
|
|
3670
|
+
return subtotalDetailsSorting.reduce((subTotalDetails, sorting) => {
|
|
3671
|
+
var _a, _b;
|
|
3672
|
+
const field = financeInfo[sorting.responseKey];
|
|
3673
|
+
if (field) {
|
|
3674
|
+
subTotalDetails.push({
|
|
3675
|
+
title: sorting.title,
|
|
3676
|
+
money: {
|
|
3677
|
+
amount: (_a = field.amount) !== null && _a !== void 0 ? _a : null,
|
|
3678
|
+
currency: (_b = field.currency) !== null && _b !== void 0 ? _b : '',
|
|
3679
|
+
},
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3682
|
+
return subTotalDetails;
|
|
3683
|
+
}, []);
|
|
3684
|
+
}
|
|
3685
|
+
getTaxesForSubtotalDetails(financeInfo, country) {
|
|
3686
|
+
var _a, _b;
|
|
3687
|
+
const taxesForSubtotalDetails = [];
|
|
3688
|
+
const vatUserNotIncludedField = financeInfo['vatUserNotIncluded'];
|
|
3689
|
+
if (vatUserNotIncludedField === null || vatUserNotIncludedField === void 0 ? void 0 : vatUserNotIncludedField.pref) {
|
|
3690
|
+
const percents = this.getPercents(vatUserNotIncludedField.pref);
|
|
3691
|
+
taxesForSubtotalDetails.push({
|
|
3692
|
+
key: this.getVatNotIncludingKeyDetails(percents, country),
|
|
3693
|
+
title: this.getVatNotIncludingTitleDetails(percents, country),
|
|
3694
|
+
money: {
|
|
3695
|
+
amount: (_a = vatUserNotIncludedField.amount) !== null && _a !== void 0 ? _a : null,
|
|
3696
|
+
currency: (_b = vatUserNotIncludedField.currency) !== null && _b !== void 0 ? _b : '',
|
|
3697
|
+
},
|
|
3698
|
+
});
|
|
3699
|
+
}
|
|
3700
|
+
return taxesForSubtotalDetails;
|
|
3701
|
+
}
|
|
3702
|
+
getVatNotIncludingKeyDetails(percents, country) {
|
|
3703
|
+
if (this.isIndia(country)) {
|
|
3704
|
+
return percents ? VatDetailsKey.vatIndiaPercent : VatDetailsKey.vatIndia;
|
|
3705
|
+
}
|
|
3706
|
+
if (this.isGhana(country)) {
|
|
3707
|
+
return VatDetailsKey.vatGhana;
|
|
3708
|
+
}
|
|
3709
|
+
return percents ? VatDetailsKey.vatPercent : VatDetailsKey.vat;
|
|
3710
|
+
}
|
|
3711
|
+
getVatNotIncludingTitleDetails(percents, country) {
|
|
3712
|
+
if (this.isIndia(country)) {
|
|
3713
|
+
return percents ? `GST ${percents}%` : 'GST';
|
|
3714
|
+
}
|
|
3715
|
+
if (this.isGhana(country)) {
|
|
3716
|
+
return 'VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
3717
|
+
}
|
|
3718
|
+
return percents ? `VAT ${percents}%` : 'VAT';
|
|
3719
|
+
}
|
|
3720
|
+
getVatIncludingKeyDetails(percents, country) {
|
|
3721
|
+
if (this.isIndia(country)) {
|
|
3722
|
+
return percents
|
|
3723
|
+
? VatDetailsKey.vatIndiaPercentIncluding
|
|
3724
|
+
: VatDetailsKey.vatIndiaIncluding;
|
|
3725
|
+
}
|
|
3726
|
+
if (this.isGhana(country)) {
|
|
3727
|
+
return VatDetailsKey.vatGhanaIncluding;
|
|
3728
|
+
}
|
|
3729
|
+
return percents
|
|
3730
|
+
? VatDetailsKey.vatPercentIncluding
|
|
3731
|
+
: VatDetailsKey.vatIncluding;
|
|
3732
|
+
}
|
|
3733
|
+
geVatIncludingTitleDetails(percents, country) {
|
|
3734
|
+
if (this.isIndia(country)) {
|
|
3735
|
+
return percents ? `Including ${percents}% GST` : 'Including GST';
|
|
3736
|
+
}
|
|
3737
|
+
if (this.isGhana(country)) {
|
|
3738
|
+
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
3739
|
+
}
|
|
3740
|
+
return percents ? `Including ${percents}% VAT` : `Including VAT`;
|
|
3741
|
+
}
|
|
3742
|
+
isGhana(country) {
|
|
3743
|
+
return country === CountryIsoCode.Ghana;
|
|
3744
|
+
}
|
|
3745
|
+
isIndia(country) {
|
|
3746
|
+
return country === CountryIsoCode.India;
|
|
3747
|
+
}
|
|
3748
|
+
getTransactionDetails(status, financeInfo) {
|
|
3749
|
+
var _a, _b;
|
|
3750
|
+
const transactionDetails = [];
|
|
3751
|
+
if ((_a = financeInfo.invoice) === null || _a === void 0 ? void 0 : _a.value) {
|
|
3752
|
+
transactionDetails.push({
|
|
3753
|
+
key: 'invoice',
|
|
3754
|
+
title: 'Transaction',
|
|
3755
|
+
content: financeInfo.invoice.value,
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
const isCompleted = status.isCancelUser ||
|
|
3759
|
+
(status.statusState !== StatusEnum.processing &&
|
|
3760
|
+
status.statusState !== StatusEnum.created &&
|
|
3761
|
+
status.statusState !== StatusEnum.held);
|
|
3762
|
+
if (isCompleted && ((_b = financeInfo.time) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
3763
|
+
transactionDetails.push({
|
|
3764
|
+
key: 'time',
|
|
3765
|
+
title: 'Date',
|
|
3766
|
+
content: financeInfo.time.value,
|
|
3767
|
+
isDateLine: true,
|
|
3768
|
+
});
|
|
3769
|
+
}
|
|
3770
|
+
return transactionDetails;
|
|
3771
|
+
}
|
|
3772
|
+
getPercents(value) {
|
|
3773
|
+
const percentsTemplate = /(\d+(.\d+)?)/;
|
|
3774
|
+
const percentsMatchResult = percentsTemplate.exec(value);
|
|
3775
|
+
if (!percentsMatchResult) {
|
|
3776
|
+
return null;
|
|
3777
|
+
}
|
|
3778
|
+
return percentsMatchResult[0];
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
StatusFinanceDetailsAdapterService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusFinanceDetailsAdapterService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3782
|
+
StatusFinanceDetailsAdapterService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusFinanceDetailsAdapterService, providedIn: 'root' });
|
|
3783
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusFinanceDetailsAdapterService, decorators: [{
|
|
3784
|
+
type: Injectable,
|
|
3785
|
+
args: [{ providedIn: 'root' }]
|
|
3786
|
+
}], ctorParameters: function () { return [{ type: SummaryFinanceDetailsAdapterService }]; } });
|
|
3787
|
+
|
|
3788
|
+
class FinanceDetailsService extends EmitDataService {
|
|
3789
|
+
constructor(sessionService, summaryFinanceDetailsAdapterService, statusFinanceDetailsAdapterService) {
|
|
3790
|
+
super();
|
|
3791
|
+
this.sessionService = sessionService;
|
|
3792
|
+
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
3793
|
+
this.statusFinanceDetailsAdapterService = statusFinanceDetailsAdapterService;
|
|
3794
|
+
this.purchaseSessionKey = 'purchase';
|
|
3004
3795
|
}
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
pid: params.pid,
|
|
3014
|
-
signature: params.signature,
|
|
3015
|
-
};
|
|
3796
|
+
emitWithSummary(summary) {
|
|
3797
|
+
if (summary) {
|
|
3798
|
+
const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
|
|
3799
|
+
if (financeDetails.purchase) {
|
|
3800
|
+
this.sessionService.set(this.purchaseSessionKey, financeDetails.purchase);
|
|
3801
|
+
}
|
|
3802
|
+
super.emit(financeDetails);
|
|
3803
|
+
}
|
|
3016
3804
|
}
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
}
|
|
3023
|
-
.then((response) => {
|
|
3024
|
-
const statusResponse = this.responseFactory({
|
|
3025
|
-
status: response.status,
|
|
3026
|
-
errors: response.errors,
|
|
3027
|
-
form: response.form,
|
|
3028
|
-
});
|
|
3029
|
-
this.emitResponse(statusResponse);
|
|
3030
|
-
})
|
|
3031
|
-
.catch((e) => {
|
|
3032
|
-
throw new TerminalError(e.message, e.code);
|
|
3033
|
-
});
|
|
3805
|
+
emitWithStatus(status) {
|
|
3806
|
+
if (status) {
|
|
3807
|
+
const purchase = this.sessionService.get(this.purchaseSessionKey);
|
|
3808
|
+
const financeDetails = this.statusFinanceDetailsAdapterService.getFinanceDetails(status, purchase);
|
|
3809
|
+
super.emit(financeDetails);
|
|
3810
|
+
}
|
|
3034
3811
|
}
|
|
3035
3812
|
}
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type:
|
|
3813
|
+
FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: SessionService }, { token: SummaryFinanceDetailsAdapterService }, { token: StatusFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3814
|
+
FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
|
|
3815
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
|
|
3039
3816
|
type: Injectable,
|
|
3040
|
-
args: [{
|
|
3041
|
-
|
|
3042
|
-
}]
|
|
3043
|
-
}], ctorParameters: function () {
|
|
3044
|
-
return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
3045
|
-
type: Inject,
|
|
3046
|
-
args: [statusRequestFactoryToken]
|
|
3047
|
-
}] }, { type: undefined, decorators: [{
|
|
3048
|
-
type: Inject,
|
|
3049
|
-
args: [statusResponseFactoryToken]
|
|
3050
|
-
}] }];
|
|
3051
|
-
} });
|
|
3817
|
+
args: [{ providedIn: 'root' }]
|
|
3818
|
+
}], ctorParameters: function () { return [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }]; } });
|
|
3052
3819
|
|
|
3053
3820
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3054
3821
|
class CheckStatusRequest extends XpsApiPartRequest {
|
|
@@ -3796,9 +4563,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3796
4563
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
3797
4564
|
|
|
3798
4565
|
class StatusService {
|
|
3799
|
-
constructor(urlService, statusRequestService, listenStatusService, nextActionService) {
|
|
4566
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
3800
4567
|
this.urlService = urlService;
|
|
3801
4568
|
this.statusRequestService = statusRequestService;
|
|
4569
|
+
this.financeDetailsService = financeDetailsService;
|
|
3802
4570
|
this.listenStatusService = listenStatusService;
|
|
3803
4571
|
this.nextActionService = nextActionService;
|
|
3804
4572
|
}
|
|
@@ -3808,6 +4576,7 @@ class StatusService {
|
|
|
3808
4576
|
this.startWaitingStatusUpdates(params.invoice);
|
|
3809
4577
|
this.statusRequestService.request();
|
|
3810
4578
|
const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
|
|
4579
|
+
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
3811
4580
|
return statusResponse.status;
|
|
3812
4581
|
});
|
|
3813
4582
|
}
|
|
@@ -3837,316 +4606,19 @@ class StatusService {
|
|
|
3837
4606
|
this.listenStatusService.statusUpdated$
|
|
3838
4607
|
.pipe(skip(1))
|
|
3839
4608
|
.subscribe(({ statusResponse }) => {
|
|
4609
|
+
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
3840
4610
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(statusResponse));
|
|
3841
4611
|
});
|
|
3842
4612
|
}
|
|
3843
4613
|
}
|
|
3844
|
-
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 });
|
|
4614
|
+
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3845
4615
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
3846
4616
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
3847
4617
|
type: Injectable,
|
|
3848
4618
|
args: [{
|
|
3849
4619
|
providedIn: 'root',
|
|
3850
4620
|
}]
|
|
3851
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
3852
|
-
|
|
3853
|
-
/**
|
|
3854
|
-
* default image for purchase item is set on Publisher Account side.
|
|
3855
|
-
* for purchase checkout items the image url is converted into base64 string.
|
|
3856
|
-
* to determine default image fixed templates are used
|
|
3857
|
-
*/
|
|
3858
|
-
const defaultImagePatterns = [
|
|
3859
|
-
/^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
|
|
3860
|
-
/virtual_item_default_image/,
|
|
3861
|
-
];
|
|
3862
|
-
|
|
3863
|
-
function extractMoneyCurrency(money, allowZero = true) {
|
|
3864
|
-
var _a, _b;
|
|
3865
|
-
return {
|
|
3866
|
-
amount: (_a = money === null || money === void 0 ? void 0 : money.amount) !== null && _a !== void 0 ? _a : (allowZero ? 0 : null),
|
|
3867
|
-
currency: (_b = money === null || money === void 0 ? void 0 : money.currency) !== null && _b !== void 0 ? _b : '',
|
|
3868
|
-
};
|
|
3869
|
-
}
|
|
3870
|
-
function createPriceOrUndefined(amount, currency) {
|
|
3871
|
-
return amount !== undefined && amount !== null
|
|
3872
|
-
? {
|
|
3873
|
-
amount,
|
|
3874
|
-
currency,
|
|
3875
|
-
}
|
|
3876
|
-
: undefined;
|
|
3877
|
-
}
|
|
3878
|
-
|
|
3879
|
-
class FinanceDetails {
|
|
3880
|
-
get shouldShowZeroIndirectTaxRate() {
|
|
3881
|
-
var _a, _b, _c, _d;
|
|
3882
|
-
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));
|
|
3883
|
-
}
|
|
3884
|
-
get isSalesTaxes() {
|
|
3885
|
-
var _a, _b, _c, _d;
|
|
3886
|
-
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));
|
|
3887
|
-
}
|
|
3888
|
-
constructor(parameters) {
|
|
3889
|
-
this.purchase = parameters.purchase;
|
|
3890
|
-
this.finance = parameters.finance;
|
|
3891
|
-
this.cartItems = this.getFormattedPurchaseForCart();
|
|
3892
|
-
this.cartSummary = this.getFormattedPricingForCart();
|
|
3893
|
-
this.paymentCountry = this.getPaymentCountry();
|
|
3894
|
-
}
|
|
3895
|
-
getFormattedPurchaseForCart() {
|
|
3896
|
-
var _a, _b, _c, _d;
|
|
3897
|
-
const checkouts = (_a = this.purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
3898
|
-
return {
|
|
3899
|
-
imgSrc: item.image_url,
|
|
3900
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3901
|
-
title: item.name,
|
|
3902
|
-
price: extractMoneyCurrency(item, false),
|
|
3903
|
-
priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
|
|
3904
|
-
quantity: item.quantity,
|
|
3905
|
-
description: item.description,
|
|
3906
|
-
tax: this.getTaxForItem(item.indirect_tax_rate),
|
|
3907
|
-
isBonus: item.is_bonus,
|
|
3908
|
-
};
|
|
3909
|
-
});
|
|
3910
|
-
const virtualCurrencies = (_b = this.purchase.virtual_currency) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
3911
|
-
return {
|
|
3912
|
-
imgSrc: item.image_url,
|
|
3913
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3914
|
-
title: `${item.quantity} ${item.name}`,
|
|
3915
|
-
price: extractMoneyCurrency(item),
|
|
3916
|
-
description: item.description,
|
|
3917
|
-
isBonus: item.is_bonus,
|
|
3918
|
-
};
|
|
3919
|
-
});
|
|
3920
|
-
const virtualItems = (_c = this.purchase.virtual_items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
3921
|
-
return {
|
|
3922
|
-
imgSrc: item.image_url,
|
|
3923
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3924
|
-
title: item.name,
|
|
3925
|
-
price: extractMoneyCurrency(item),
|
|
3926
|
-
description: item.description,
|
|
3927
|
-
quantity: item.quantity,
|
|
3928
|
-
isBonus: item.is_bonus,
|
|
3929
|
-
};
|
|
3930
|
-
});
|
|
3931
|
-
let checkoutArray = undefined;
|
|
3932
|
-
if (this.purchase.checkout) {
|
|
3933
|
-
checkoutArray = [
|
|
3934
|
-
{
|
|
3935
|
-
key: 'checkout',
|
|
3936
|
-
title: this.purchase.checkout.description,
|
|
3937
|
-
price: extractMoneyCurrency(this.purchase.checkout),
|
|
3938
|
-
isBonus: (_d = this.purchase.checkout.is_bonus) !== null && _d !== void 0 ? _d : false,
|
|
3939
|
-
},
|
|
3940
|
-
];
|
|
3941
|
-
}
|
|
3942
|
-
return [
|
|
3943
|
-
...(checkouts !== null && checkouts !== void 0 ? checkouts : []),
|
|
3944
|
-
...(virtualCurrencies !== null && virtualCurrencies !== void 0 ? virtualCurrencies : []),
|
|
3945
|
-
...(virtualItems !== null && virtualItems !== void 0 ? virtualItems : []),
|
|
3946
|
-
...(checkoutArray !== null && checkoutArray !== void 0 ? checkoutArray : []),
|
|
3947
|
-
];
|
|
3948
|
-
}
|
|
3949
|
-
getFormattedPricingForCart() {
|
|
3950
|
-
// subtotal details fields
|
|
3951
|
-
const subtotalDetailsSorting = [
|
|
3952
|
-
{
|
|
3953
|
-
key: 'discount',
|
|
3954
|
-
responseKey: 'discount',
|
|
3955
|
-
title: 'Discount',
|
|
3956
|
-
},
|
|
3957
|
-
{
|
|
3958
|
-
key: 'fee',
|
|
3959
|
-
responseKey: 'fee',
|
|
3960
|
-
title: 'Payment system fee',
|
|
3961
|
-
},
|
|
3962
|
-
{
|
|
3963
|
-
key: 'user-balance',
|
|
3964
|
-
responseKey: 'user_balance',
|
|
3965
|
-
title: 'Balance',
|
|
3966
|
-
},
|
|
3967
|
-
];
|
|
3968
|
-
return {
|
|
3969
|
-
subtotal: {
|
|
3970
|
-
title: 'Subtotal',
|
|
3971
|
-
money: createPriceOrUndefined(this.finance.sub_total.amount, this.finance.sub_total.currency),
|
|
3972
|
-
},
|
|
3973
|
-
subtotalPayment: {
|
|
3974
|
-
title: '',
|
|
3975
|
-
money: createPriceOrUndefined(this.finance.sub_total.payment_amount, this.finance.sub_total.payment_currency),
|
|
3976
|
-
},
|
|
3977
|
-
total: {
|
|
3978
|
-
title: 'Total',
|
|
3979
|
-
money: extractMoneyCurrency(this.finance.total),
|
|
3980
|
-
},
|
|
3981
|
-
totalDetails: this.getTaxesForTotalDetails(),
|
|
3982
|
-
subtotalDetails: [
|
|
3983
|
-
...subtotalDetailsSorting.map((sorting) => {
|
|
3984
|
-
const field = this.finance[sorting.responseKey];
|
|
3985
|
-
if (field) {
|
|
3986
|
-
return {
|
|
3987
|
-
key: sorting.key,
|
|
3988
|
-
title: sorting.title,
|
|
3989
|
-
money: {
|
|
3990
|
-
amount: sorting.key === 'discount' && field.amount
|
|
3991
|
-
? -field.amount
|
|
3992
|
-
: field.amount,
|
|
3993
|
-
currency: field.currency,
|
|
3994
|
-
},
|
|
3995
|
-
};
|
|
3996
|
-
}
|
|
3997
|
-
return sorting;
|
|
3998
|
-
}),
|
|
3999
|
-
...this.getTaxesForSubtotalDetails(),
|
|
4000
|
-
],
|
|
4001
|
-
};
|
|
4002
|
-
}
|
|
4003
|
-
getPaymentCountry() {
|
|
4004
|
-
return this.finance.payment_country.iso;
|
|
4005
|
-
}
|
|
4006
|
-
getTaxForItem(indirectTaxRate) {
|
|
4007
|
-
if (indirectTaxRate ||
|
|
4008
|
-
(this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
|
|
4009
|
-
if (this.isSalesTaxes) {
|
|
4010
|
-
return {
|
|
4011
|
-
key: 'sales-tax',
|
|
4012
|
-
content: `Sales tax ${indirectTaxRate}%`,
|
|
4013
|
-
rate: indirectTaxRate,
|
|
4014
|
-
};
|
|
4015
|
-
}
|
|
4016
|
-
if (this.isIndia()) {
|
|
4017
|
-
return {
|
|
4018
|
-
key: 'vat-india',
|
|
4019
|
-
content: `GST ${indirectTaxRate}%`,
|
|
4020
|
-
rate: indirectTaxRate,
|
|
4021
|
-
};
|
|
4022
|
-
}
|
|
4023
|
-
if (this.isGhana()) {
|
|
4024
|
-
return {
|
|
4025
|
-
key: 'vat-ghana',
|
|
4026
|
-
content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
|
|
4027
|
-
rate: indirectTaxRate,
|
|
4028
|
-
};
|
|
4029
|
-
}
|
|
4030
|
-
return {
|
|
4031
|
-
key: 'vat',
|
|
4032
|
-
content: `VAT ${indirectTaxRate}%`,
|
|
4033
|
-
rate: indirectTaxRate,
|
|
4034
|
-
};
|
|
4035
|
-
}
|
|
4036
|
-
return null;
|
|
4037
|
-
}
|
|
4038
|
-
getTaxesForSubtotalDetails() {
|
|
4039
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4040
|
-
const ret = [];
|
|
4041
|
-
// subtotal. VAT %p
|
|
4042
|
-
if (this.finance.vat_user &&
|
|
4043
|
-
((_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)) {
|
|
4044
|
-
ret.push({
|
|
4045
|
-
key: this.getVatKeyForDetails(),
|
|
4046
|
-
title: this.getVatLabelForSubtotalDetails(),
|
|
4047
|
-
money: extractMoneyCurrency(this.finance.vat_user),
|
|
4048
|
-
});
|
|
4049
|
-
}
|
|
4050
|
-
if ((_f = this.finance.sales_tax_user) === null || _f === void 0 ? void 0 : _f.amount) {
|
|
4051
|
-
ret.push({
|
|
4052
|
-
key: 'sales-tax',
|
|
4053
|
-
title: 'Sales tax',
|
|
4054
|
-
money: extractMoneyCurrency(this.finance.sales_tax_user),
|
|
4055
|
-
});
|
|
4056
|
-
}
|
|
4057
|
-
return ret;
|
|
4058
|
-
}
|
|
4059
|
-
getVatLabelForSubtotalDetails() {
|
|
4060
|
-
var _a, _b, _c, _d;
|
|
4061
|
-
if (this.isIndia()) {
|
|
4062
|
-
return `GST ${(_b = (_a = this.finance.vat_user) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : ''}%`;
|
|
4063
|
-
}
|
|
4064
|
-
if (this.isGhana()) {
|
|
4065
|
-
return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
|
|
4066
|
-
}
|
|
4067
|
-
return `VAT ${(_d = (_c = this.finance.vat_user) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : ''}%`;
|
|
4068
|
-
}
|
|
4069
|
-
getTaxesForTotalDetails() {
|
|
4070
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4071
|
-
const ret = [];
|
|
4072
|
-
// for totalDetails. VAT
|
|
4073
|
-
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)) &&
|
|
4074
|
-
!((_f = (_e = this.finance) === null || _e === void 0 ? void 0 : _e.vat_user) === null || _f === void 0 ? void 0 : _f.amount)) {
|
|
4075
|
-
ret.push({
|
|
4076
|
-
key: this.getVatKeyForDetails(),
|
|
4077
|
-
title: this.getVatLabelForTotalDetails(),
|
|
4078
|
-
money: extractMoneyCurrency(this.finance.vat),
|
|
4079
|
-
});
|
|
4080
|
-
}
|
|
4081
|
-
if (((_h = (_g = this.finance) === null || _g === void 0 ? void 0 : _g.sales_tax) === null || _h === void 0 ? void 0 : _h.amount) &&
|
|
4082
|
-
!((_k = (_j = this.finance) === null || _j === void 0 ? void 0 : _j.sales_tax_user) === null || _k === void 0 ? void 0 : _k.amount)) {
|
|
4083
|
-
ret.push({
|
|
4084
|
-
key: 'sales-tax',
|
|
4085
|
-
title: 'Sales tax included',
|
|
4086
|
-
money: extractMoneyCurrency(this.finance.sales_tax),
|
|
4087
|
-
});
|
|
4088
|
-
}
|
|
4089
|
-
return ret;
|
|
4090
|
-
}
|
|
4091
|
-
getVatKeyForDetails() {
|
|
4092
|
-
if (this.isIndia()) {
|
|
4093
|
-
return 'vat-india';
|
|
4094
|
-
}
|
|
4095
|
-
if (this.isGhana()) {
|
|
4096
|
-
return 'vat-ghana';
|
|
4097
|
-
}
|
|
4098
|
-
return 'vat';
|
|
4099
|
-
}
|
|
4100
|
-
getVatLabelForTotalDetails() {
|
|
4101
|
-
if (this.isIndia()) {
|
|
4102
|
-
return `Including ${this.finance.vat.percent}% GST`;
|
|
4103
|
-
}
|
|
4104
|
-
if (this.isGhana()) {
|
|
4105
|
-
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
4106
|
-
}
|
|
4107
|
-
return `Including ${this.finance.vat.percent}% VAT`;
|
|
4108
|
-
}
|
|
4109
|
-
isIndia() {
|
|
4110
|
-
var _a;
|
|
4111
|
-
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'IN';
|
|
4112
|
-
}
|
|
4113
|
-
isGhana() {
|
|
4114
|
-
var _a;
|
|
4115
|
-
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'GH';
|
|
4116
|
-
}
|
|
4117
|
-
isDefaultImage(url) {
|
|
4118
|
-
return defaultImagePatterns.some((regex) => regex.test(url));
|
|
4119
|
-
}
|
|
4120
|
-
}
|
|
4121
|
-
|
|
4122
|
-
const financeDetailsResponseFactoryToken = new InjectionToken('FinanceDetails');
|
|
4123
|
-
const financeDetailsResponseFactoryProvider = {
|
|
4124
|
-
provide: financeDetailsResponseFactoryToken,
|
|
4125
|
-
useValue: (...args) => new FinanceDetails(...args),
|
|
4126
|
-
};
|
|
4127
|
-
|
|
4128
|
-
class FinanceDetailsService extends EmitDataService {
|
|
4129
|
-
constructor(responseFactory) {
|
|
4130
|
-
super();
|
|
4131
|
-
this.responseFactory = responseFactory;
|
|
4132
|
-
}
|
|
4133
|
-
emit(summary) {
|
|
4134
|
-
if (summary) {
|
|
4135
|
-
super.emit(this.responseFactory(summary));
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
}
|
|
4139
|
-
FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: financeDetailsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4140
|
-
FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
|
|
4141
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
|
|
4142
|
-
type: Injectable,
|
|
4143
|
-
args: [{ providedIn: 'root' }]
|
|
4144
|
-
}], ctorParameters: function () {
|
|
4145
|
-
return [{ type: undefined, decorators: [{
|
|
4146
|
-
type: Inject,
|
|
4147
|
-
args: [financeDetailsResponseFactoryToken]
|
|
4148
|
-
}] }];
|
|
4149
|
-
} });
|
|
4621
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4150
4622
|
|
|
4151
4623
|
class CreditCardStateService extends EmitDataService {
|
|
4152
4624
|
}
|
|
@@ -4740,7 +5212,7 @@ class PaymentService {
|
|
|
4740
5212
|
this.threeDsService.stopChecking();
|
|
4741
5213
|
}
|
|
4742
5214
|
emitFinanceDetails(summary) {
|
|
4743
|
-
this.financeDetailsService.
|
|
5215
|
+
this.financeDetailsService.emitWithSummary(summary);
|
|
4744
5216
|
}
|
|
4745
5217
|
emitCreditCardState(idCardType) {
|
|
4746
5218
|
this.creditCardStateService.emit({ idCardType });
|
|
@@ -4936,6 +5408,9 @@ class CoreLibraryService {
|
|
|
4936
5408
|
setCountry(country) {
|
|
4937
5409
|
this.countryService.setCountry(country);
|
|
4938
5410
|
}
|
|
5411
|
+
getCountry() {
|
|
5412
|
+
return this.countryService.getCountry();
|
|
5413
|
+
}
|
|
4939
5414
|
createPayment(config) {
|
|
4940
5415
|
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
4941
5416
|
return {
|
|
@@ -5080,6 +5555,8 @@ FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15
|
|
|
5080
5555
|
PricepointConverter,
|
|
5081
5556
|
PricepointConverter,
|
|
5082
5557
|
CouponConverter,
|
|
5558
|
+
TextConverter,
|
|
5559
|
+
PhoneConverter,
|
|
5083
5560
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
5084
5561
|
], imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
5085
5562
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
@@ -5111,6 +5588,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
5111
5588
|
PricepointConverter,
|
|
5112
5589
|
PricepointConverter,
|
|
5113
5590
|
CouponConverter,
|
|
5591
|
+
TextConverter,
|
|
5592
|
+
PhoneConverter,
|
|
5114
5593
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
5115
5594
|
],
|
|
5116
5595
|
}]
|
|
@@ -5139,7 +5618,6 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
5139
5618
|
statusResponseFactoryProvider,
|
|
5140
5619
|
checkStatusRequestFactoryProvider,
|
|
5141
5620
|
checkStatusResponseFactoryProvider,
|
|
5142
|
-
financeDetailsResponseFactoryProvider,
|
|
5143
5621
|
statusThreeDsRequestFactoryProvider,
|
|
5144
5622
|
statusThreeDsResponseFactoryProvider,
|
|
5145
5623
|
notifyDfpStatusRequestFactoryProvider,
|
|
@@ -5173,7 +5651,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
5173
5651
|
statusResponseFactoryProvider,
|
|
5174
5652
|
checkStatusRequestFactoryProvider,
|
|
5175
5653
|
checkStatusResponseFactoryProvider,
|
|
5176
|
-
financeDetailsResponseFactoryProvider,
|
|
5177
5654
|
statusThreeDsRequestFactoryProvider,
|
|
5178
5655
|
statusThreeDsResponseFactoryProvider,
|
|
5179
5656
|
notifyDfpStatusRequestFactoryProvider,
|