You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
634 B

import Stripe from "stripe";
// Initialize Stripe with your secret key from environment variables
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
apiVersion: "2024-11-20.acacia",
typescript: true,
});
// Helper function to format amount for Stripe (convert to cents)
export function formatAmountForStripe(
amount: number,
currency: string = "usd"
): number {
return Math.round(amount * 100);
}
// Helper function to format amount from Stripe (convert from cents)
export function formatAmountFromStripe(
amount: number,
currency: string = "usd"
): number {
return Math.round(amount) / 100;
}