🐛 (payment) Round the amount to avoid weird Js long decimals
This commit is contained in:
@@ -56,9 +56,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
: stripeKeys.live.secretKey,
|
: stripeKeys.live.secretKey,
|
||||||
{ apiVersion: '2022-11-15' }
|
{ apiVersion: '2022-11-15' }
|
||||||
)
|
)
|
||||||
const amount =
|
const amount = Math.round(
|
||||||
Number(parseVariables(variables)(inputOptions.amount)) *
|
Number(parseVariables(variables)(inputOptions.amount)) *
|
||||||
(isZeroDecimalCurrency(inputOptions.currency) ? 1 : 100)
|
(isZeroDecimalCurrency(inputOptions.currency) ? 1 : 100)
|
||||||
|
)
|
||||||
if (isNaN(amount)) return badRequest(res)
|
if (isNaN(amount)) return badRequest(res)
|
||||||
// Create a PaymentIntent with the order amount and currency
|
// Create a PaymentIntent with the order amount and currency
|
||||||
const receiptEmail = parseVariables(variables)(
|
const receiptEmail = parseVariables(variables)(
|
||||||
|
|||||||
Reference in New Issue
Block a user