mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #28270 from overleaf/kh-add-stripe-payment-context
[web] add stripe payment context GitOrigin-RevId: 79dfbb1da0dd6b1d36c68c86debffc1edb169961
This commit is contained in:
@@ -26,3 +26,19 @@ export function formatCurrency(
|
||||
|
||||
return `${currency} ${amount}`
|
||||
}
|
||||
|
||||
export function convertToMinorUnits(amount: number, currency: string): number {
|
||||
const isNoCentsCurrency = ['clp', 'jpy', 'krw', 'vnd'].includes(
|
||||
currency.toLowerCase()
|
||||
)
|
||||
|
||||
// Determine the multiplier based on currency
|
||||
let multiplier = 100 // default for most currencies (2 decimal places)
|
||||
|
||||
if (isNoCentsCurrency) {
|
||||
multiplier = 1 // no decimal places
|
||||
}
|
||||
|
||||
// Convert and round to an integer
|
||||
return Math.round(amount * multiplier)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user