@xsolla/payment-client-core 0.1.7 → 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/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/fesm2015/xsolla-payment-client-core.mjs +726 -304
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +706 -293
- 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/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/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.7.tgz +0 -0
- /package/lib/core/payment/finance-details/{default-image-patterns.const.d.ts → summary/default-image-patterns.const.d.ts} +0 -0
|
@@ -3098,6 +3098,725 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3098
3098
|
}] }];
|
|
3099
3099
|
} });
|
|
3100
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';
|
|
3795
|
+
}
|
|
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
|
+
}
|
|
3804
|
+
}
|
|
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
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
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: [{
|
|
3816
|
+
type: Injectable,
|
|
3817
|
+
args: [{ providedIn: 'root' }]
|
|
3818
|
+
}], ctorParameters: function () { return [{ type: SessionService }, { type: SummaryFinanceDetailsAdapterService }, { type: StatusFinanceDetailsAdapterService }]; } });
|
|
3819
|
+
|
|
3101
3820
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3102
3821
|
class CheckStatusRequest extends XpsApiPartRequest {
|
|
3103
3822
|
constructor(token, invoice) {
|
|
@@ -3844,9 +4563,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3844
4563
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
3845
4564
|
|
|
3846
4565
|
class StatusService {
|
|
3847
|
-
constructor(urlService, statusRequestService, listenStatusService, nextActionService) {
|
|
4566
|
+
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService) {
|
|
3848
4567
|
this.urlService = urlService;
|
|
3849
4568
|
this.statusRequestService = statusRequestService;
|
|
4569
|
+
this.financeDetailsService = financeDetailsService;
|
|
3850
4570
|
this.listenStatusService = listenStatusService;
|
|
3851
4571
|
this.nextActionService = nextActionService;
|
|
3852
4572
|
}
|
|
@@ -3856,6 +4576,7 @@ class StatusService {
|
|
|
3856
4576
|
this.startWaitingStatusUpdates(params.invoice);
|
|
3857
4577
|
this.statusRequestService.request();
|
|
3858
4578
|
const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
|
|
4579
|
+
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
3859
4580
|
return statusResponse.status;
|
|
3860
4581
|
});
|
|
3861
4582
|
}
|
|
@@ -3885,316 +4606,19 @@ class StatusService {
|
|
|
3885
4606
|
this.listenStatusService.statusUpdated$
|
|
3886
4607
|
.pipe(skip(1))
|
|
3887
4608
|
.subscribe(({ statusResponse }) => {
|
|
4609
|
+
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
3888
4610
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(statusResponse));
|
|
3889
4611
|
});
|
|
3890
4612
|
}
|
|
3891
4613
|
}
|
|
3892
|
-
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 });
|
|
3893
4615
|
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
3894
4616
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
3895
4617
|
type: Injectable,
|
|
3896
4618
|
args: [{
|
|
3897
4619
|
providedIn: 'root',
|
|
3898
4620
|
}]
|
|
3899
|
-
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
3900
|
-
|
|
3901
|
-
/**
|
|
3902
|
-
* default image for purchase item is set on Publisher Account side.
|
|
3903
|
-
* for purchase checkout items the image url is converted into base64 string.
|
|
3904
|
-
* to determine default image fixed templates are used
|
|
3905
|
-
*/
|
|
3906
|
-
const defaultImagePatterns = [
|
|
3907
|
-
/^data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAAAAADmVT4XAAACMUlEQVR4Ae3YgYqdMBSE4fP/,
|
|
3908
|
-
/virtual_item_default_image/,
|
|
3909
|
-
];
|
|
3910
|
-
|
|
3911
|
-
function extractMoneyCurrency(money, allowZero = true) {
|
|
3912
|
-
var _a, _b;
|
|
3913
|
-
return {
|
|
3914
|
-
amount: (_a = money === null || money === void 0 ? void 0 : money.amount) !== null && _a !== void 0 ? _a : (allowZero ? 0 : null),
|
|
3915
|
-
currency: (_b = money === null || money === void 0 ? void 0 : money.currency) !== null && _b !== void 0 ? _b : '',
|
|
3916
|
-
};
|
|
3917
|
-
}
|
|
3918
|
-
function createPriceOrUndefined(amount, currency) {
|
|
3919
|
-
return amount !== undefined && amount !== null
|
|
3920
|
-
? {
|
|
3921
|
-
amount,
|
|
3922
|
-
currency,
|
|
3923
|
-
}
|
|
3924
|
-
: undefined;
|
|
3925
|
-
}
|
|
3926
|
-
|
|
3927
|
-
class FinanceDetails {
|
|
3928
|
-
get shouldShowZeroIndirectTaxRate() {
|
|
3929
|
-
var _a, _b, _c, _d;
|
|
3930
|
-
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));
|
|
3931
|
-
}
|
|
3932
|
-
get isSalesTaxes() {
|
|
3933
|
-
var _a, _b, _c, _d;
|
|
3934
|
-
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));
|
|
3935
|
-
}
|
|
3936
|
-
constructor(parameters) {
|
|
3937
|
-
this.purchase = parameters.purchase;
|
|
3938
|
-
this.finance = parameters.finance;
|
|
3939
|
-
this.cartItems = this.getFormattedPurchaseForCart();
|
|
3940
|
-
this.cartSummary = this.getFormattedPricingForCart();
|
|
3941
|
-
this.paymentCountry = this.getPaymentCountry();
|
|
3942
|
-
}
|
|
3943
|
-
getFormattedPurchaseForCart() {
|
|
3944
|
-
var _a, _b, _c, _d;
|
|
3945
|
-
const checkouts = (_a = this.purchase.checkout_items) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
3946
|
-
return {
|
|
3947
|
-
imgSrc: item.image_url,
|
|
3948
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3949
|
-
title: item.name,
|
|
3950
|
-
price: extractMoneyCurrency(item, false),
|
|
3951
|
-
priceBeforeDiscount: createPriceOrUndefined(item.amount_before_discount, item.currency),
|
|
3952
|
-
quantity: item.quantity,
|
|
3953
|
-
description: item.description,
|
|
3954
|
-
tax: this.getTaxForItem(item.indirect_tax_rate),
|
|
3955
|
-
isBonus: item.is_bonus,
|
|
3956
|
-
};
|
|
3957
|
-
});
|
|
3958
|
-
const virtualCurrencies = (_b = this.purchase.virtual_currency) === null || _b === void 0 ? void 0 : _b.map((item) => {
|
|
3959
|
-
return {
|
|
3960
|
-
imgSrc: item.image_url,
|
|
3961
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3962
|
-
title: `${item.quantity} ${item.name}`,
|
|
3963
|
-
price: extractMoneyCurrency(item),
|
|
3964
|
-
description: item.description,
|
|
3965
|
-
isBonus: item.is_bonus,
|
|
3966
|
-
};
|
|
3967
|
-
});
|
|
3968
|
-
const virtualItems = (_c = this.purchase.virtual_items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
3969
|
-
return {
|
|
3970
|
-
imgSrc: item.image_url,
|
|
3971
|
-
hasDefaultImg: this.isDefaultImage(item.image_url),
|
|
3972
|
-
title: item.name,
|
|
3973
|
-
price: extractMoneyCurrency(item),
|
|
3974
|
-
description: item.description,
|
|
3975
|
-
quantity: item.quantity,
|
|
3976
|
-
isBonus: item.is_bonus,
|
|
3977
|
-
};
|
|
3978
|
-
});
|
|
3979
|
-
let checkoutArray = undefined;
|
|
3980
|
-
if (this.purchase.checkout) {
|
|
3981
|
-
checkoutArray = [
|
|
3982
|
-
{
|
|
3983
|
-
key: 'checkout',
|
|
3984
|
-
title: this.purchase.checkout.description,
|
|
3985
|
-
price: extractMoneyCurrency(this.purchase.checkout),
|
|
3986
|
-
isBonus: (_d = this.purchase.checkout.is_bonus) !== null && _d !== void 0 ? _d : false,
|
|
3987
|
-
},
|
|
3988
|
-
];
|
|
3989
|
-
}
|
|
3990
|
-
return [
|
|
3991
|
-
...(checkouts !== null && checkouts !== void 0 ? checkouts : []),
|
|
3992
|
-
...(virtualCurrencies !== null && virtualCurrencies !== void 0 ? virtualCurrencies : []),
|
|
3993
|
-
...(virtualItems !== null && virtualItems !== void 0 ? virtualItems : []),
|
|
3994
|
-
...(checkoutArray !== null && checkoutArray !== void 0 ? checkoutArray : []),
|
|
3995
|
-
];
|
|
3996
|
-
}
|
|
3997
|
-
getFormattedPricingForCart() {
|
|
3998
|
-
// subtotal details fields
|
|
3999
|
-
const subtotalDetailsSorting = [
|
|
4000
|
-
{
|
|
4001
|
-
key: 'discount',
|
|
4002
|
-
responseKey: 'discount',
|
|
4003
|
-
title: 'Discount',
|
|
4004
|
-
},
|
|
4005
|
-
{
|
|
4006
|
-
key: 'fee',
|
|
4007
|
-
responseKey: 'fee',
|
|
4008
|
-
title: 'Payment system fee',
|
|
4009
|
-
},
|
|
4010
|
-
{
|
|
4011
|
-
key: 'user-balance',
|
|
4012
|
-
responseKey: 'user_balance',
|
|
4013
|
-
title: 'Balance',
|
|
4014
|
-
},
|
|
4015
|
-
];
|
|
4016
|
-
return {
|
|
4017
|
-
subtotal: {
|
|
4018
|
-
title: 'Subtotal',
|
|
4019
|
-
money: createPriceOrUndefined(this.finance.sub_total.amount, this.finance.sub_total.currency),
|
|
4020
|
-
},
|
|
4021
|
-
subtotalPayment: {
|
|
4022
|
-
title: '',
|
|
4023
|
-
money: createPriceOrUndefined(this.finance.sub_total.payment_amount, this.finance.sub_total.payment_currency),
|
|
4024
|
-
},
|
|
4025
|
-
total: {
|
|
4026
|
-
title: 'Total',
|
|
4027
|
-
money: extractMoneyCurrency(this.finance.total),
|
|
4028
|
-
},
|
|
4029
|
-
totalDetails: this.getTaxesForTotalDetails(),
|
|
4030
|
-
subtotalDetails: [
|
|
4031
|
-
...subtotalDetailsSorting.map((sorting) => {
|
|
4032
|
-
const field = this.finance[sorting.responseKey];
|
|
4033
|
-
if (field) {
|
|
4034
|
-
return {
|
|
4035
|
-
key: sorting.key,
|
|
4036
|
-
title: sorting.title,
|
|
4037
|
-
money: {
|
|
4038
|
-
amount: sorting.key === 'discount' && field.amount
|
|
4039
|
-
? -field.amount
|
|
4040
|
-
: field.amount,
|
|
4041
|
-
currency: field.currency,
|
|
4042
|
-
},
|
|
4043
|
-
};
|
|
4044
|
-
}
|
|
4045
|
-
return sorting;
|
|
4046
|
-
}),
|
|
4047
|
-
...this.getTaxesForSubtotalDetails(),
|
|
4048
|
-
],
|
|
4049
|
-
};
|
|
4050
|
-
}
|
|
4051
|
-
getPaymentCountry() {
|
|
4052
|
-
return this.finance.payment_country.iso;
|
|
4053
|
-
}
|
|
4054
|
-
getTaxForItem(indirectTaxRate) {
|
|
4055
|
-
if (indirectTaxRate ||
|
|
4056
|
-
(this.shouldShowZeroIndirectTaxRate && indirectTaxRate === 0)) {
|
|
4057
|
-
if (this.isSalesTaxes) {
|
|
4058
|
-
return {
|
|
4059
|
-
key: 'sales-tax',
|
|
4060
|
-
content: `Sales tax ${indirectTaxRate}%`,
|
|
4061
|
-
rate: indirectTaxRate,
|
|
4062
|
-
};
|
|
4063
|
-
}
|
|
4064
|
-
if (this.isIndia()) {
|
|
4065
|
-
return {
|
|
4066
|
-
key: 'vat-india',
|
|
4067
|
-
content: `GST ${indirectTaxRate}%`,
|
|
4068
|
-
rate: indirectTaxRate,
|
|
4069
|
-
};
|
|
4070
|
-
}
|
|
4071
|
-
if (this.isGhana()) {
|
|
4072
|
-
return {
|
|
4073
|
-
key: 'vat-ghana',
|
|
4074
|
-
content: 'VAT, NHIL, GETFund Levy, and Covid-19 Levy',
|
|
4075
|
-
rate: indirectTaxRate,
|
|
4076
|
-
};
|
|
4077
|
-
}
|
|
4078
|
-
return {
|
|
4079
|
-
key: 'vat',
|
|
4080
|
-
content: `VAT ${indirectTaxRate}%`,
|
|
4081
|
-
rate: indirectTaxRate,
|
|
4082
|
-
};
|
|
4083
|
-
}
|
|
4084
|
-
return null;
|
|
4085
|
-
}
|
|
4086
|
-
getTaxesForSubtotalDetails() {
|
|
4087
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4088
|
-
const ret = [];
|
|
4089
|
-
// subtotal. VAT %p
|
|
4090
|
-
if (this.finance.vat_user &&
|
|
4091
|
-
((_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)) {
|
|
4092
|
-
ret.push({
|
|
4093
|
-
key: this.getVatKeyForDetails(),
|
|
4094
|
-
title: this.getVatLabelForSubtotalDetails(),
|
|
4095
|
-
money: extractMoneyCurrency(this.finance.vat_user),
|
|
4096
|
-
});
|
|
4097
|
-
}
|
|
4098
|
-
if ((_f = this.finance.sales_tax_user) === null || _f === void 0 ? void 0 : _f.amount) {
|
|
4099
|
-
ret.push({
|
|
4100
|
-
key: 'sales-tax',
|
|
4101
|
-
title: 'Sales tax',
|
|
4102
|
-
money: extractMoneyCurrency(this.finance.sales_tax_user),
|
|
4103
|
-
});
|
|
4104
|
-
}
|
|
4105
|
-
return ret;
|
|
4106
|
-
}
|
|
4107
|
-
getVatLabelForSubtotalDetails() {
|
|
4108
|
-
var _a, _b, _c, _d;
|
|
4109
|
-
if (this.isIndia()) {
|
|
4110
|
-
return `GST ${(_b = (_a = this.finance.vat_user) === null || _a === void 0 ? void 0 : _a.percent) !== null && _b !== void 0 ? _b : ''}%`;
|
|
4111
|
-
}
|
|
4112
|
-
if (this.isGhana()) {
|
|
4113
|
-
return `VAT, NHIL, GETFund Levy, and Covid-19 Levy`;
|
|
4114
|
-
}
|
|
4115
|
-
return `VAT ${(_d = (_c = this.finance.vat_user) === null || _c === void 0 ? void 0 : _c.percent) !== null && _d !== void 0 ? _d : ''}%`;
|
|
4116
|
-
}
|
|
4117
|
-
getTaxesForTotalDetails() {
|
|
4118
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4119
|
-
const ret = [];
|
|
4120
|
-
// for totalDetails. VAT
|
|
4121
|
-
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)) &&
|
|
4122
|
-
!((_f = (_e = this.finance) === null || _e === void 0 ? void 0 : _e.vat_user) === null || _f === void 0 ? void 0 : _f.amount)) {
|
|
4123
|
-
ret.push({
|
|
4124
|
-
key: this.getVatKeyForDetails(),
|
|
4125
|
-
title: this.getVatLabelForTotalDetails(),
|
|
4126
|
-
money: extractMoneyCurrency(this.finance.vat),
|
|
4127
|
-
});
|
|
4128
|
-
}
|
|
4129
|
-
if (((_h = (_g = this.finance) === null || _g === void 0 ? void 0 : _g.sales_tax) === null || _h === void 0 ? void 0 : _h.amount) &&
|
|
4130
|
-
!((_k = (_j = this.finance) === null || _j === void 0 ? void 0 : _j.sales_tax_user) === null || _k === void 0 ? void 0 : _k.amount)) {
|
|
4131
|
-
ret.push({
|
|
4132
|
-
key: 'sales-tax',
|
|
4133
|
-
title: 'Sales tax included',
|
|
4134
|
-
money: extractMoneyCurrency(this.finance.sales_tax),
|
|
4135
|
-
});
|
|
4136
|
-
}
|
|
4137
|
-
return ret;
|
|
4138
|
-
}
|
|
4139
|
-
getVatKeyForDetails() {
|
|
4140
|
-
if (this.isIndia()) {
|
|
4141
|
-
return 'vat-india';
|
|
4142
|
-
}
|
|
4143
|
-
if (this.isGhana()) {
|
|
4144
|
-
return 'vat-ghana';
|
|
4145
|
-
}
|
|
4146
|
-
return 'vat';
|
|
4147
|
-
}
|
|
4148
|
-
getVatLabelForTotalDetails() {
|
|
4149
|
-
if (this.isIndia()) {
|
|
4150
|
-
return `Including ${this.finance.vat.percent}% GST`;
|
|
4151
|
-
}
|
|
4152
|
-
if (this.isGhana()) {
|
|
4153
|
-
return 'Including VAT, NHIL, GETFund Levy, and Covid-19 Levy';
|
|
4154
|
-
}
|
|
4155
|
-
return `Including ${this.finance.vat.percent}% VAT`;
|
|
4156
|
-
}
|
|
4157
|
-
isIndia() {
|
|
4158
|
-
var _a;
|
|
4159
|
-
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'IN';
|
|
4160
|
-
}
|
|
4161
|
-
isGhana() {
|
|
4162
|
-
var _a;
|
|
4163
|
-
return ((_a = this.finance) === null || _a === void 0 ? void 0 : _a.payment_country.iso) === 'GH';
|
|
4164
|
-
}
|
|
4165
|
-
isDefaultImage(url) {
|
|
4166
|
-
return defaultImagePatterns.some((regex) => regex.test(url));
|
|
4167
|
-
}
|
|
4168
|
-
}
|
|
4169
|
-
|
|
4170
|
-
const financeDetailsResponseFactoryToken = new InjectionToken('FinanceDetails');
|
|
4171
|
-
const financeDetailsResponseFactoryProvider = {
|
|
4172
|
-
provide: financeDetailsResponseFactoryToken,
|
|
4173
|
-
useValue: (...args) => new FinanceDetails(...args),
|
|
4174
|
-
};
|
|
4175
|
-
|
|
4176
|
-
class FinanceDetailsService extends EmitDataService {
|
|
4177
|
-
constructor(responseFactory) {
|
|
4178
|
-
super();
|
|
4179
|
-
this.responseFactory = responseFactory;
|
|
4180
|
-
}
|
|
4181
|
-
emit(summary) {
|
|
4182
|
-
if (summary) {
|
|
4183
|
-
super.emit(this.responseFactory(summary));
|
|
4184
|
-
}
|
|
4185
|
-
}
|
|
4186
|
-
}
|
|
4187
|
-
FinanceDetailsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, deps: [{ token: financeDetailsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4188
|
-
FinanceDetailsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, providedIn: 'root' });
|
|
4189
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FinanceDetailsService, decorators: [{
|
|
4190
|
-
type: Injectable,
|
|
4191
|
-
args: [{ providedIn: 'root' }]
|
|
4192
|
-
}], ctorParameters: function () {
|
|
4193
|
-
return [{ type: undefined, decorators: [{
|
|
4194
|
-
type: Inject,
|
|
4195
|
-
args: [financeDetailsResponseFactoryToken]
|
|
4196
|
-
}] }];
|
|
4197
|
-
} });
|
|
4621
|
+
}], ctorParameters: function () { return [{ type: UrlService }, { type: StatusRequestService }, { type: FinanceDetailsService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
4198
4622
|
|
|
4199
4623
|
class CreditCardStateService extends EmitDataService {
|
|
4200
4624
|
}
|
|
@@ -4788,7 +5212,7 @@ class PaymentService {
|
|
|
4788
5212
|
this.threeDsService.stopChecking();
|
|
4789
5213
|
}
|
|
4790
5214
|
emitFinanceDetails(summary) {
|
|
4791
|
-
this.financeDetailsService.
|
|
5215
|
+
this.financeDetailsService.emitWithSummary(summary);
|
|
4792
5216
|
}
|
|
4793
5217
|
emitCreditCardState(idCardType) {
|
|
4794
5218
|
this.creditCardStateService.emit({ idCardType });
|
|
@@ -5194,7 +5618,6 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
5194
5618
|
statusResponseFactoryProvider,
|
|
5195
5619
|
checkStatusRequestFactoryProvider,
|
|
5196
5620
|
checkStatusResponseFactoryProvider,
|
|
5197
|
-
financeDetailsResponseFactoryProvider,
|
|
5198
5621
|
statusThreeDsRequestFactoryProvider,
|
|
5199
5622
|
statusThreeDsResponseFactoryProvider,
|
|
5200
5623
|
notifyDfpStatusRequestFactoryProvider,
|
|
@@ -5228,7 +5651,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
5228
5651
|
statusResponseFactoryProvider,
|
|
5229
5652
|
checkStatusRequestFactoryProvider,
|
|
5230
5653
|
checkStatusResponseFactoryProvider,
|
|
5231
|
-
financeDetailsResponseFactoryProvider,
|
|
5232
5654
|
statusThreeDsRequestFactoryProvider,
|
|
5233
5655
|
statusThreeDsResponseFactoryProvider,
|
|
5234
5656
|
notifyDfpStatusRequestFactoryProvider,
|