* Build HitPay app * Deleted a lint comment * Add redirect for iframe * Fix type check error * Fixed issue of payment pending * Update hitpay package.json * fix: fix lint issue in KeyInput and update zod * fix: fix issue of parsing string to number * fix: add default hitpay API links * fix: resolve atoms build error --------- Co-authored-by: kutsaniuk <kutsaniuk@gmail.com>
33 lines
604 B
TypeScript
33 lines
604 B
TypeScript
const zeroDecimalCurrencies = [
|
|
"BIF",
|
|
"CLP",
|
|
"DJF",
|
|
"GNF",
|
|
"JPY",
|
|
"KMF",
|
|
"KRW",
|
|
"MGA",
|
|
"PYG",
|
|
"RWF",
|
|
"UGX",
|
|
"VND",
|
|
"VUV",
|
|
"XAF",
|
|
"XOF",
|
|
"XPF",
|
|
];
|
|
|
|
export const convertToSmallestCurrencyUnit = (amount: number, currency: string) => {
|
|
if (zeroDecimalCurrencies.includes(currency.toUpperCase())) {
|
|
return amount;
|
|
}
|
|
return Math.round(amount * 100);
|
|
};
|
|
|
|
export const convertFromSmallestToPresentableCurrencyUnit = (amount: number, currency: string) => {
|
|
if (zeroDecimalCurrencies.includes(currency.toUpperCase())) {
|
|
return amount;
|
|
}
|
|
return amount / 100;
|
|
};
|