@6thbridge/utils 0.2.1 → 0.2.3-7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/amount.action.d.ts +10 -0
- package/lib/actions/amount.action.js +40 -0
- package/lib/actions/amount.action.js.map +1 -0
- package/lib/actions/charge.action.d.ts +32 -2
- package/lib/actions/charge.action.js +191 -181
- package/lib/actions/charge.action.js.map +1 -1
- package/lib/actions/currency.action.d.ts +11 -2
- package/lib/actions/currency.action.js +71 -33
- package/lib/actions/currency.action.js.map +1 -1
- package/lib/actions/database.action.d.ts +20 -0
- package/lib/actions/database.action.js +90 -0
- package/lib/actions/database.action.js.map +1 -0
- package/lib/actions/database.action.spec.js +208 -0
- package/lib/actions/database.action.spec.js.map +1 -0
- package/lib/actions/file.action.d.ts +24 -0
- package/lib/actions/file.action.js +66 -0
- package/lib/actions/file.action.js.map +1 -0
- package/lib/actions/index.d.ts +9 -0
- package/lib/actions/index.js +10 -0
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/phone-number.action.d.ts +18 -0
- package/lib/actions/phone-number.action.js +50 -2
- package/lib/actions/phone-number.action.js.map +1 -1
- package/lib/actions/queue.action.d.ts +3 -0
- package/lib/actions/queue.action.js +20 -0
- package/lib/actions/queue.action.js.map +1 -0
- package/lib/actions/route.action.d.ts +22 -0
- package/lib/actions/route.action.js +52 -0
- package/lib/actions/route.action.js.map +1 -0
- package/lib/cache/redis.js +1 -1
- package/lib/cache/redis.js.map +1 -1
- package/lib/database/MongoDBRepository.js.map +1 -1
- package/lib/database/MongoDBTypeRepository.d.ts +1 -0
- package/lib/database/MongoDBTypeRepository.js.map +1 -1
- package/lib/database/query.d.ts +3 -1
- package/lib/database/query.js +3 -53
- package/lib/database/query.js.map +1 -1
- package/lib/helpers/errors.d.ts +14 -1
- package/lib/helpers/errors.js +15 -32
- package/lib/helpers/errors.js.map +1 -1
- package/lib/helpers/index.d.ts +7 -0
- package/lib/helpers/index.js +35 -13
- package/lib/helpers/index.js.map +1 -1
- package/lib/http/axios.d.ts +18 -0
- package/lib/http/axios.js +38 -0
- package/lib/http/axios.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +10 -2
- package/lib/index.js.map +1 -1
- package/lib/logger/logger.d.ts +3 -1
- package/lib/logger/logger.js +16 -8
- package/lib/logger/logger.js.map +1 -1
- package/lib/middlewares/common.d.ts +3 -2
- package/lib/middlewares/common.js +19 -8
- package/lib/middlewares/common.js.map +1 -1
- package/lib/middlewares/express.js +2 -2
- package/lib/middlewares/express.js.map +1 -1
- package/lib/monitoring/index.d.ts +3 -3
- package/lib/monitoring/index.js +6 -6
- package/lib/monitoring/index.js.map +1 -1
- package/lib/monitoring/rollbar.d.ts +15 -0
- package/lib/monitoring/rollbar.js +23 -0
- package/lib/monitoring/rollbar.js.map +1 -0
- package/lib/responses/express.d.ts +3 -0
- package/lib/responses/express.js +68 -13
- package/lib/responses/express.js.map +1 -1
- package/lib/test/actions/amount.action.test.d.ts +1 -0
- package/lib/test/actions/amount.action.test.js +81 -0
- package/lib/test/actions/amount.action.test.js.map +1 -0
- package/lib/test/actions/charge.action.test.js +125 -47
- package/lib/test/actions/charge.action.test.js.map +1 -1
- package/lib/test/database/test.spec.js +17 -0
- package/lib/test/database/test.spec.js.map +1 -1
- package/lib/translations/index.js +3 -6
- package/lib/translations/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/broker.entity.d.ts +10 -0
- package/lib/types/custom.exception.d.ts +14 -0
- package/lib/types/custom.exception.js +16 -0
- package/lib/types/custom.exception.js.map +1 -0
- package/lib/types/index.d.ts +20 -83
- package/lib/types/index.js +25 -40
- package/lib/types/index.js.map +1 -1
- package/lib/types/integration.entity.d.ts +97 -0
- package/lib/types/integration.entity.js +61 -0
- package/lib/types/integration.entity.js.map +1 -0
- package/lib/types/wallet.entity.d.ts +34 -0
- package/lib/types/wallet.entity.js +24 -0
- package/lib/types/wallet.entity.js.map +1 -0
- package/package.json +22 -15
- package/readme.md +1 -1
- package/lib/cache/in-memory.d.ts +0 -0
- package/lib/cache/in-memory.js +0 -2
- package/lib/cache/in-memory.js.map +0 -1
- package/lib/logger/test.js +0 -45
- package/lib/logger/test.js.map +0 -1
- package/lib/secrets/aws.d.ts +0 -0
- package/lib/secrets/aws.js +0 -2
- package/lib/secrets/aws.js.map +0 -1
- /package/lib/{logger/test.d.ts → actions/database.action.spec.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const NON_DECIMAL_ACCEPTING_COUNTRIES: string[];
|
|
2
|
+
export declare class AmountAction {
|
|
3
|
+
static validateNonDecimalAmount(amount: number, country: string, NonDecimalCountries?: string[]): {
|
|
4
|
+
error: string;
|
|
5
|
+
data?: undefined;
|
|
6
|
+
} | {
|
|
7
|
+
data: boolean;
|
|
8
|
+
error?: undefined;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AmountAction = exports.NON_DECIMAL_ACCEPTING_COUNTRIES = void 0;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
exports.NON_DECIMAL_ACCEPTING_COUNTRIES = ["XOF", "XAF", "UGX", "RWF"];
|
|
9
|
+
class AmountAction {
|
|
10
|
+
static validateNonDecimalAmount(amount, country, NonDecimalCountries) {
|
|
11
|
+
NonDecimalCountries = NonDecimalCountries || exports.NON_DECIMAL_ACCEPTING_COUNTRIES;
|
|
12
|
+
if (!amount)
|
|
13
|
+
return {
|
|
14
|
+
error: "Amount is required"
|
|
15
|
+
};
|
|
16
|
+
if (!country)
|
|
17
|
+
return {
|
|
18
|
+
error: "Country is required"
|
|
19
|
+
};
|
|
20
|
+
if (!Array.isArray(NonDecimalCountries))
|
|
21
|
+
return {
|
|
22
|
+
error: "NonDecimalCountries is required as an array"
|
|
23
|
+
};
|
|
24
|
+
//check if amount has decimal
|
|
25
|
+
const amountDividedBy100 = new bignumber_js_1.default(amount).dividedBy(100).toNumber();
|
|
26
|
+
if (amountDividedBy100 % 1 === 0)
|
|
27
|
+
return {
|
|
28
|
+
data: true //amount has no decimal place
|
|
29
|
+
};
|
|
30
|
+
if (!NonDecimalCountries.includes(country))
|
|
31
|
+
return {
|
|
32
|
+
data: true
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
error: `${country}: Country Selected is not accepting decimal amount. Countries Not Supporting Decimals are ${NonDecimalCountries.join(", ")}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.AmountAction = AmountAction;
|
|
40
|
+
//# sourceMappingURL=amount.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.action.js","sourceRoot":"","sources":["../../src/actions/amount.action.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AAGxB,QAAA,+BAA+B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAC1E,MAAa,YAAY;IACvB,MAAM,CAAC,wBAAwB,CAAC,MAAc,EAAE,OAAe,EAAE,mBAA8B;QAC7F,mBAAmB,GAAG,mBAAmB,IAAI,uCAA+B,CAAC;QAE7E,IAAG,CAAC,MAAM;YAAE,OAAO;gBACjB,KAAK,EAAE,oBAAoB;aAC5B,CAAA;QAED,IAAG,CAAC,OAAO;YAAE,OAAQ;gBACnB,KAAK,EAAE,qBAAqB;aAC7B,CAAA;QAED,IAAG,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;YAAE,OAAO;gBAC7C,KAAK,EAAE,6CAA6C;aACrD,CAAA;QACD,6BAA6B;QAC7B,MAAM,kBAAkB,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE3E,IAAG,kBAAkB,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO;gBACtC,IAAI,EAAE,IAAI,CAAC,6BAA6B;aACzC,CAAC;QAEF,IAAG,CAAC,mBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,OAAO;gBAChD,IAAI,EAAE,IAAI;aACX,CAAA;QAED,OAAO;YACL,KAAK,EAAE,GAAG,OAAO,6FAA6F,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SAC/I,CAAA;IACH,CAAC;CACF;AA9BD,oCA8BC"}
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import { IntegrationCharge,
|
|
1
|
+
import { IntegrationCharge, IntegrationChargeEntity, TransactionFee } from '../types';
|
|
2
2
|
export declare const FRANCOPHONE_CURRENCY_CODES: string[];
|
|
3
3
|
interface CalculateTransactionFeePayload {
|
|
4
4
|
currency: string;
|
|
5
5
|
amount: number;
|
|
6
6
|
ownIntegration?: boolean;
|
|
7
|
+
chargeBearer?: 'merchant' | 'customer' | string;
|
|
8
|
+
roundUpFinalValue?: boolean;
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
@deprecated
|
|
12
|
+
*/
|
|
9
13
|
export declare const calculateIntegrationCharge: (integrationCharge: IntegrationCharge, payload: CalculateTransactionFeePayload) => TransactionFee;
|
|
14
|
+
/**
|
|
15
|
+
@deprecated
|
|
16
|
+
*/
|
|
17
|
+
export declare function roundUpAmount(amount: number): {
|
|
18
|
+
amount: number;
|
|
19
|
+
extra: number;
|
|
20
|
+
total: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
@deprecated
|
|
24
|
+
*/
|
|
25
|
+
export declare function roundUpFinalValueToClosestInteger(charge: TransactionFee): TransactionFee;
|
|
10
26
|
export declare function processFrancophoneCountries(charge: TransactionFee): TransactionFee;
|
|
27
|
+
export declare class ChargeAction {
|
|
28
|
+
constructor();
|
|
29
|
+
static getChargeValue: (charge: IntegrationChargeEntity | any, amount: number) => {
|
|
30
|
+
percentage: number;
|
|
31
|
+
fixed: number;
|
|
32
|
+
};
|
|
33
|
+
static roundUpFinalValueToClosestInteger(charge: TransactionFee): TransactionFee;
|
|
34
|
+
static roundUpAmount(amount: number): {
|
|
35
|
+
amount: number;
|
|
36
|
+
extra: number;
|
|
37
|
+
total: number;
|
|
38
|
+
};
|
|
39
|
+
static calculateIntegrationCharge(integrationCharge: IntegrationCharge, payload: CalculateTransactionFeePayload): TransactionFee;
|
|
40
|
+
}
|
|
11
41
|
export {};
|
|
@@ -3,84 +3,204 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.processFrancophoneCountries = exports.
|
|
6
|
+
exports.ChargeAction = exports.processFrancophoneCountries = exports.roundUpFinalValueToClosestInteger = exports.roundUpAmount = exports.calculateIntegrationCharge = exports.FRANCOPHONE_CURRENCY_CODES = void 0;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
const types_1 = require("../types");
|
|
9
9
|
const logger_1 = require("../logger/logger");
|
|
10
10
|
exports.FRANCOPHONE_CURRENCY_CODES = ['xaf', 'xof'];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
11
|
+
/**
|
|
12
|
+
@deprecated
|
|
13
|
+
*/
|
|
14
|
+
const getChargeValue = (charge, amount) => {
|
|
15
|
+
return ChargeAction.getChargeValue(charge, amount);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
@deprecated
|
|
19
|
+
*/
|
|
20
|
+
const calculateIntegrationCharge = (integrationCharge, payload) => {
|
|
21
|
+
return ChargeAction.calculateIntegrationCharge(integrationCharge, payload);
|
|
22
|
+
};
|
|
23
|
+
exports.calculateIntegrationCharge = calculateIntegrationCharge;
|
|
24
|
+
/**
|
|
25
|
+
@deprecated
|
|
26
|
+
*/
|
|
27
|
+
function roundUpAmount(amount) {
|
|
28
|
+
return ChargeAction.roundUpAmount(amount);
|
|
29
|
+
}
|
|
30
|
+
exports.roundUpAmount = roundUpAmount;
|
|
31
|
+
/**
|
|
32
|
+
@deprecated
|
|
33
|
+
*/
|
|
34
|
+
function roundUpFinalValueToClosestInteger(charge) {
|
|
35
|
+
return ChargeAction.roundUpFinalValueToClosestInteger(charge);
|
|
36
|
+
}
|
|
37
|
+
exports.roundUpFinalValueToClosestInteger = roundUpFinalValueToClosestInteger;
|
|
38
|
+
function processFrancophoneCountries(charge) {
|
|
39
|
+
return ChargeAction.roundUpFinalValueToClosestInteger(charge);
|
|
40
|
+
}
|
|
41
|
+
exports.processFrancophoneCountries = processFrancophoneCountries;
|
|
42
|
+
class ChargeAction {
|
|
43
|
+
constructor() {
|
|
44
|
+
}
|
|
45
|
+
static roundUpFinalValueToClosestInteger(charge) {
|
|
46
|
+
let chargeInLargestCurrency = charge.total / 100;
|
|
47
|
+
const roundedUpCharge = Math.ceil(chargeInLargestCurrency);
|
|
48
|
+
charge.extra = new bignumber_js_1.default(roundedUpCharge).minus(chargeInLargestCurrency).multipliedBy(100).decimalPlaces(2, bignumber_js_1.default.ROUND_CEIL).toNumber();
|
|
49
|
+
charge.total = new bignumber_js_1.default(roundedUpCharge).multipliedBy(100).toNumber();
|
|
50
|
+
return charge;
|
|
51
|
+
}
|
|
52
|
+
static roundUpAmount(amount) {
|
|
53
|
+
let chargeInLargestCurrency = amount / 100;
|
|
54
|
+
const roundedUpCharge = Math.ceil(chargeInLargestCurrency);
|
|
55
|
+
const extra = new bignumber_js_1.default(roundedUpCharge).minus(chargeInLargestCurrency).multipliedBy(100).decimalPlaces(2, bignumber_js_1.default.ROUND_CEIL).toNumber();
|
|
56
|
+
const total = new bignumber_js_1.default(roundedUpCharge).multipliedBy(100).toNumber();
|
|
57
|
+
return { amount, extra, total };
|
|
58
|
+
}
|
|
59
|
+
static calculateIntegrationCharge(integrationCharge, payload) {
|
|
60
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
61
|
+
let response = {
|
|
62
|
+
chargeBearer: payload.chargeBearer,
|
|
63
|
+
charge: 0,
|
|
64
|
+
provider: 0,
|
|
65
|
+
partner: { clientId: '', value: 0 },
|
|
66
|
+
custom: 0,
|
|
67
|
+
platform: 0,
|
|
68
|
+
tax: 0,
|
|
69
|
+
VAT: 0,
|
|
70
|
+
total: 0,
|
|
71
|
+
merchant: 0,
|
|
72
|
+
customer: 0,
|
|
73
|
+
ownIntegration: (_a = payload.ownIntegration) !== null && _a !== void 0 ? _a : false,
|
|
74
|
+
roundUpFinalValue: (_b = payload.roundUpFinalValue) !== null && _b !== void 0 ? _b : false,
|
|
75
|
+
};
|
|
76
|
+
if (!integrationCharge)
|
|
77
|
+
return response;
|
|
78
|
+
// const amount: number = payload.amount;
|
|
79
|
+
const amount = payload.amount;
|
|
80
|
+
//platform fee
|
|
81
|
+
const platformFee = this.getChargeValue(integrationCharge.platform, amount / 100);
|
|
82
|
+
response.platform = (_c = platformFee.fixed) !== null && _c !== void 0 ? _c : 0;
|
|
83
|
+
if (platformFee.percentage) {
|
|
84
|
+
response.platform += new bignumber_js_1.default(platformFee.percentage)
|
|
85
|
+
.div(100)
|
|
86
|
+
.multipliedBy(amount)
|
|
87
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
88
|
+
.toNumber();
|
|
89
|
+
}
|
|
90
|
+
response.charge += response.platform;
|
|
91
|
+
response.provider = 0;
|
|
92
|
+
//provider
|
|
93
|
+
const providerFee = this.getChargeValue(integrationCharge.provider, amount / 100);
|
|
94
|
+
response.provider = (_d = providerFee.fixed) !== null && _d !== void 0 ? _d : 0;
|
|
95
|
+
if (providerFee.percentage) {
|
|
96
|
+
response.provider += new bignumber_js_1.default(providerFee.percentage)
|
|
97
|
+
.div(100)
|
|
98
|
+
.multipliedBy(amount)
|
|
99
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
100
|
+
.toNumber();
|
|
101
|
+
}
|
|
102
|
+
response.charge += response.provider;
|
|
103
|
+
//partner
|
|
104
|
+
const partnerFee = this.getChargeValue(integrationCharge.partner, amount / 100);
|
|
105
|
+
response.partner.clientId = ((_e = integrationCharge === null || integrationCharge === void 0 ? void 0 : integrationCharge.partner) === null || _e === void 0 ? void 0 : _e.clientId) || undefined;
|
|
106
|
+
response.partner.value = (_f = partnerFee.fixed) !== null && _f !== void 0 ? _f : 0;
|
|
107
|
+
if (partnerFee.percentage) {
|
|
108
|
+
response.partner.value += new bignumber_js_1.default(partnerFee.percentage)
|
|
109
|
+
.div(100)
|
|
110
|
+
.multipliedBy(amount)
|
|
111
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
112
|
+
.toNumber();
|
|
113
|
+
}
|
|
114
|
+
response.charge += (_g = response.partner.value) !== null && _g !== void 0 ? _g : 0;
|
|
115
|
+
//custom
|
|
116
|
+
const customConfig = this.getChargeValue(integrationCharge.custom, amount / 100);
|
|
117
|
+
response.custom = (_h = customConfig.fixed) !== null && _h !== void 0 ? _h : 0;
|
|
118
|
+
if (customConfig === null || customConfig === void 0 ? void 0 : customConfig.percentage) {
|
|
119
|
+
response.custom += new bignumber_js_1.default(customConfig === null || customConfig === void 0 ? void 0 : customConfig.percentage)
|
|
120
|
+
.div(100)
|
|
121
|
+
.multipliedBy(amount)
|
|
122
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
123
|
+
.toNumber();
|
|
124
|
+
}
|
|
125
|
+
response.charge += response.custom;
|
|
126
|
+
//tax
|
|
127
|
+
const taxConfig = this.getChargeValue(integrationCharge.tax, amount / 100);
|
|
128
|
+
response.tax = (_j = taxConfig.fixed) !== null && _j !== void 0 ? _j : 0;
|
|
129
|
+
if (taxConfig.percentage) {
|
|
130
|
+
response.tax += new bignumber_js_1.default(taxConfig.percentage)
|
|
131
|
+
.div(100)
|
|
132
|
+
.multipliedBy(amount)
|
|
133
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
134
|
+
.toNumber();
|
|
135
|
+
}
|
|
136
|
+
response.charge += response.tax;
|
|
137
|
+
response.total = response.charge;
|
|
138
|
+
if (((_k = integrationCharge.cap) === null || _k === void 0 ? void 0 : _k.minimum) && integrationCharge.cap.minimum > response.total) {
|
|
139
|
+
response.total = integrationCharge.cap.minimum;
|
|
140
|
+
}
|
|
141
|
+
if (((_l = integrationCharge.cap) === null || _l === void 0 ? void 0 : _l.maximum) && ((_m = integrationCharge.cap) === null || _m === void 0 ? void 0 : _m.maximum) < response.total) {
|
|
142
|
+
response.total = integrationCharge.cap.maximum;
|
|
143
|
+
}
|
|
144
|
+
//calculate VAT
|
|
145
|
+
const vatConfig = this.getChargeValue(integrationCharge.VATOnChargeAndFees, response.total / 100);
|
|
146
|
+
response.VAT = (_o = vatConfig.fixed) !== null && _o !== void 0 ? _o : 0;
|
|
147
|
+
if (vatConfig.percentage) {
|
|
148
|
+
response.VAT = new bignumber_js_1.default(vatConfig.percentage)
|
|
149
|
+
.div(100)
|
|
150
|
+
.multipliedBy(response.total)
|
|
151
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
152
|
+
.toNumber();
|
|
153
|
+
response.total += response.VAT;
|
|
154
|
+
}
|
|
155
|
+
response.total = Math.ceil(response.total);
|
|
156
|
+
// if (payload.roundUpFinalValue || FRANCOPHONE_CURRENCY_CODES.includes(payload.currency?.toLowerCase())) {
|
|
157
|
+
if (payload.roundUpFinalValue) {
|
|
158
|
+
response = this.roundUpFinalValueToClosestInteger(response);
|
|
159
|
+
}
|
|
160
|
+
if (payload.chargeBearer) {
|
|
161
|
+
if (payload.chargeBearer == 'customer') {
|
|
162
|
+
response.customer = new bignumber_js_1.default(100)
|
|
163
|
+
.div(100)
|
|
164
|
+
.multipliedBy(response.total)
|
|
165
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
166
|
+
.toNumber();
|
|
167
|
+
}
|
|
168
|
+
if (payload.chargeBearer == 'merchant') {
|
|
169
|
+
response.merchant = new bignumber_js_1.default(100)
|
|
170
|
+
.div(100)
|
|
171
|
+
.multipliedBy(response.total)
|
|
172
|
+
.decimalPlaces(0, bignumber_js_1.default.ROUND_CEIL)
|
|
173
|
+
.toNumber();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
response.merchant = new bignumber_js_1.default(((_p = integrationCharge.bearer) === null || _p === void 0 ? void 0 : _p.merchant) || 0)
|
|
178
|
+
.div(100)
|
|
179
|
+
.multipliedBy(response.total)
|
|
180
|
+
// .decimalPlaces(0, BigNumber.ROUND_CEIL)
|
|
181
|
+
.toNumber();
|
|
182
|
+
response.customer = new bignumber_js_1.default(((_q = integrationCharge.bearer) === null || _q === void 0 ? void 0 : _q.customer) || 0)
|
|
183
|
+
.div(100)
|
|
184
|
+
.multipliedBy(response.total)
|
|
185
|
+
// .decimalPlaces(0, BigNumber.ROUND_CEIL)
|
|
186
|
+
.toNumber();
|
|
187
|
+
}
|
|
188
|
+
if (!response.customer || !exports.FRANCOPHONE_CURRENCY_CODES.includes((_r = payload.currency) === null || _r === void 0 ? void 0 : _r.toLowerCase()))
|
|
189
|
+
return response;
|
|
190
|
+
const roundUpResponse = this.roundUpAmount(response.customer);
|
|
191
|
+
response.customer = roundUpResponse.total;
|
|
192
|
+
response.extra = new bignumber_js_1.default((_s = response.extra) !== null && _s !== void 0 ? _s : 0)
|
|
193
|
+
.plus(roundUpResponse.extra)
|
|
59
194
|
.toNumber();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
response.total = response.charge;
|
|
63
|
-
if (((_o = chargeConfiguration.cap) === null || _o === void 0 ? void 0 : _o.minimum) && chargeConfiguration.cap.minimum > response.total) {
|
|
64
|
-
response.total = chargeConfiguration.cap.minimum;
|
|
65
|
-
}
|
|
66
|
-
if (((_p = chargeConfiguration.cap) === null || _p === void 0 ? void 0 : _p.maximum) && ((_q = chargeConfiguration.cap) === null || _q === void 0 ? void 0 : _q.maximum) < response.total) {
|
|
67
|
-
response.total = chargeConfiguration.cap.maximum;
|
|
68
|
-
}
|
|
69
|
-
//calculate VAT
|
|
70
|
-
if (chargeConfiguration.VATOnChargeAndFees) {
|
|
71
|
-
response.VAT = new bignumber_js_1.default(chargeConfiguration.VATOnChargeAndFees)
|
|
72
|
-
.div(100)
|
|
73
|
-
.multipliedBy(response.total)
|
|
195
|
+
response.total = new bignumber_js_1.default((_t = response.total) !== null && _t !== void 0 ? _t : 0)
|
|
196
|
+
.plus(response.extra)
|
|
74
197
|
.toNumber();
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
response.total = Math.ceil(response.total);
|
|
78
|
-
if (!exports.FRANCOPHONE_CURRENCY_CODES.includes((_r = payload.currency) === null || _r === void 0 ? void 0 : _r.toLowerCase()))
|
|
198
|
+
console.log("Rounded up", response);
|
|
79
199
|
return response;
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
exports.
|
|
83
|
-
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.ChargeAction = ChargeAction;
|
|
203
|
+
ChargeAction.getChargeValue = (charge, amount) => {
|
|
84
204
|
var _a, _b;
|
|
85
205
|
try {
|
|
86
206
|
if (!charge)
|
|
@@ -102,114 +222,4 @@ const getChargeValue = (charge, amount) => {
|
|
|
102
222
|
return { percentage: 0, fixed: 0 };
|
|
103
223
|
}
|
|
104
224
|
};
|
|
105
|
-
const calculateIntegrationCharge = (integrationCharge, payload) => {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
107
|
-
let response = {
|
|
108
|
-
charge: 0,
|
|
109
|
-
provider: 0,
|
|
110
|
-
partner: { clientId: "", value: 0 },
|
|
111
|
-
custom: 0,
|
|
112
|
-
platform: 0,
|
|
113
|
-
tax: 0,
|
|
114
|
-
VAT: 0,
|
|
115
|
-
total: 0,
|
|
116
|
-
merchant: 0,
|
|
117
|
-
customer: 0,
|
|
118
|
-
ownIntegration: (_a = payload.ownIntegration) !== null && _a !== void 0 ? _a : false,
|
|
119
|
-
};
|
|
120
|
-
if (!integrationCharge)
|
|
121
|
-
return response;
|
|
122
|
-
const amount = payload.amount;
|
|
123
|
-
//platform fee
|
|
124
|
-
const platformFee = getChargeValue(integrationCharge.platform, amount / 100);
|
|
125
|
-
if (platformFee) {
|
|
126
|
-
}
|
|
127
|
-
response.platform = platformFee.fixed;
|
|
128
|
-
if (platformFee.percentage) {
|
|
129
|
-
response.platform += new bignumber_js_1.default(platformFee.percentage)
|
|
130
|
-
.div(100)
|
|
131
|
-
.multipliedBy(amount)
|
|
132
|
-
.toNumber();
|
|
133
|
-
}
|
|
134
|
-
response.charge += response.platform;
|
|
135
|
-
response.provider = 0;
|
|
136
|
-
//provider
|
|
137
|
-
const providerFee = getChargeValue(integrationCharge.provider, amount / 100);
|
|
138
|
-
response.provider = providerFee.fixed || 0;
|
|
139
|
-
if (providerFee.percentage) {
|
|
140
|
-
response.provider += new bignumber_js_1.default(providerFee.percentage)
|
|
141
|
-
.div(100)
|
|
142
|
-
.multipliedBy(amount)
|
|
143
|
-
.toNumber();
|
|
144
|
-
}
|
|
145
|
-
response.charge += response.provider;
|
|
146
|
-
//partner
|
|
147
|
-
const partnerFee = getChargeValue(integrationCharge.partner, amount / 100);
|
|
148
|
-
response.partner.clientId = ((_b = integrationCharge === null || integrationCharge === void 0 ? void 0 : integrationCharge.partner) === null || _b === void 0 ? void 0 : _b.clientId) || undefined;
|
|
149
|
-
response.partner.value = partnerFee.fixed || 0;
|
|
150
|
-
if (partnerFee.percentage) {
|
|
151
|
-
response.partner.value += new bignumber_js_1.default(partnerFee.percentage)
|
|
152
|
-
.div(100)
|
|
153
|
-
.multipliedBy(amount)
|
|
154
|
-
.toNumber();
|
|
155
|
-
}
|
|
156
|
-
response.charge += response.partner.value || 0;
|
|
157
|
-
//custom
|
|
158
|
-
const customConfig = getChargeValue(integrationCharge.custom, amount / 100);
|
|
159
|
-
response.custom = customConfig.fixed || 0;
|
|
160
|
-
if (customConfig === null || customConfig === void 0 ? void 0 : customConfig.percentage) {
|
|
161
|
-
response.custom += new bignumber_js_1.default(customConfig === null || customConfig === void 0 ? void 0 : customConfig.percentage)
|
|
162
|
-
.div(100)
|
|
163
|
-
.multipliedBy(amount)
|
|
164
|
-
.toNumber();
|
|
165
|
-
}
|
|
166
|
-
response.charge += response.custom;
|
|
167
|
-
//tax
|
|
168
|
-
const taxConfig = getChargeValue(integrationCharge.tax, amount / 100);
|
|
169
|
-
response.tax = taxConfig.fixed || 0;
|
|
170
|
-
if (taxConfig.percentage) {
|
|
171
|
-
response.tax += new bignumber_js_1.default(taxConfig.percentage).div(100).multipliedBy(amount).toNumber();
|
|
172
|
-
}
|
|
173
|
-
response.charge += response.tax;
|
|
174
|
-
response.total = response.charge;
|
|
175
|
-
if (((_c = integrationCharge.cap) === null || _c === void 0 ? void 0 : _c.minimum) && integrationCharge.cap.minimum > response.total) {
|
|
176
|
-
response.total = integrationCharge.cap.minimum;
|
|
177
|
-
}
|
|
178
|
-
if (((_d = integrationCharge.cap) === null || _d === void 0 ? void 0 : _d.maximum) && ((_e = integrationCharge.cap) === null || _e === void 0 ? void 0 : _e.maximum) < response.total) {
|
|
179
|
-
response.total = integrationCharge.cap.maximum;
|
|
180
|
-
}
|
|
181
|
-
//calculate VAT
|
|
182
|
-
const vatConfig = getChargeValue(integrationCharge.VATOnChargeAndFees, response.total / 100);
|
|
183
|
-
response.VAT = (_f = vatConfig.fixed) !== null && _f !== void 0 ? _f : 0;
|
|
184
|
-
if (vatConfig.percentage) {
|
|
185
|
-
response.VAT = new bignumber_js_1.default(vatConfig.percentage)
|
|
186
|
-
.div(100)
|
|
187
|
-
.multipliedBy(response.total)
|
|
188
|
-
.toNumber();
|
|
189
|
-
response.total += response.VAT;
|
|
190
|
-
}
|
|
191
|
-
response.total = Math.ceil(response.total);
|
|
192
|
-
if (exports.FRANCOPHONE_CURRENCY_CODES.includes((_g = payload.currency) === null || _g === void 0 ? void 0 : _g.toLowerCase())) {
|
|
193
|
-
response = processFrancophoneCountries(response);
|
|
194
|
-
}
|
|
195
|
-
response.merchant = new bignumber_js_1.default(((_h = integrationCharge.bearer) === null || _h === void 0 ? void 0 : _h.merchant) || 0)
|
|
196
|
-
.div(100)
|
|
197
|
-
.multipliedBy(response.total)
|
|
198
|
-
.toNumber();
|
|
199
|
-
response.customer = new bignumber_js_1.default(((_j = integrationCharge.bearer) === null || _j === void 0 ? void 0 : _j.customer) || 0)
|
|
200
|
-
.div(100)
|
|
201
|
-
.multipliedBy(response.total)
|
|
202
|
-
.toNumber();
|
|
203
|
-
return response;
|
|
204
|
-
};
|
|
205
|
-
exports.calculateIntegrationCharge = calculateIntegrationCharge;
|
|
206
|
-
function processFrancophoneCountries(charge) {
|
|
207
|
-
console.log('calculateCharge: Processing Francophone currency', charge);
|
|
208
|
-
let chargeInLargestCurrency = charge.total / 100;
|
|
209
|
-
const roundedUpCharge = Math.ceil(chargeInLargestCurrency);
|
|
210
|
-
charge.extra = (roundedUpCharge - chargeInLargestCurrency) * 100;
|
|
211
|
-
charge.total = roundedUpCharge * 100;
|
|
212
|
-
return charge;
|
|
213
|
-
}
|
|
214
|
-
exports.processFrancophoneCountries = processFrancophoneCountries;
|
|
215
225
|
//# sourceMappingURL=charge.action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charge.action.js","sourceRoot":"","sources":["../../src/actions/charge.action.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gEAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"charge.action.js","sourceRoot":"","sources":["../../src/actions/charge.action.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;AAEb,gEAAqC;AACrC,oCAMkB;AAClB,6CAA0C;AAE7B,QAAA,0BAA0B,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAUzD;;GAEG;AACH,MAAM,cAAc,GAAG,CACrB,MAAqC,EACrC,MAAc,EACyB,EAAE;IACzC,OAAO,YAAY,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,0BAA0B,GAAG,CAAC,iBAAoC,EAAE,OAAuC,EAAkB,EAAE;IAC1I,OAAO,YAAY,CAAC,0BAA0B,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC,CAAA;AAFY,QAAA,0BAA0B,8BAEtC;AAGD;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,SAAgB,iCAAiC,CAAC,MAAsB;IACtE,OAAO,YAAY,CAAC,iCAAiC,CAAC,MAAM,CAAC,CAAC;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CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,KAAI,CAAC,CAAC;YAEtC,OAAO,UAAU,IAAI,MAAM,IAAI,MAAM,IAAI,CAAC,CAAC,UAAU,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,UAAU,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,KAAI,CAAC,EAAE,KAAK,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,KAAI,CAAC,EAAE,CAAC;IACtF,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,eAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACrC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -7,10 +7,19 @@ interface AmountLabelPayload {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const createAmountLabel: (payload: AmountLabelPayload) => string;
|
|
9
9
|
export declare const formatAmountAndCurrency: (currency: string, value: any) => string;
|
|
10
|
+
export declare const formatAmountAndCurrencyUsingInBuildIntlNumberFormat: (currency: string, value: any) => string;
|
|
10
11
|
export declare function validateAmount(currency: string, amount: number): string | null;
|
|
12
|
+
export declare const getCurrencySymbol: (currency: string) => string;
|
|
13
|
+
export declare function processAmount(currency: string, amount: number): number;
|
|
11
14
|
export declare const symbols: {
|
|
12
15
|
[x: string]: string;
|
|
13
16
|
};
|
|
14
|
-
export declare
|
|
15
|
-
|
|
17
|
+
export declare class CurrencyAction {
|
|
18
|
+
static createAmountLabel(payload: AmountLabelPayload): string;
|
|
19
|
+
static formatAmountAndCurrency(currency: string, value: any): string;
|
|
20
|
+
static formatAmountAndCurrencyUsingInBuildIntlNumberFormat(currency: string, value: any): string;
|
|
21
|
+
static validateAmount(currency: string, amount: number): "Oops. For XOF and XAF currencies, Please send in whole number amount as we do not allow decimal amounts" | null;
|
|
22
|
+
static getCurrencySymbol(currency: string): string;
|
|
23
|
+
static processAmount(currency: string, amount: number): number;
|
|
24
|
+
}
|
|
16
25
|
export {};
|