I need to retrieve data from Stripe using a product key. Is there a solution to achieve this, or is there an error in my method?
export const getProduct = async (productKey: string): Promise<Stripe.Product> => {
const { serverRuntimeConfig } = getConfig();
const stripe = new Stripe(serverRuntimeConfig.STRIPE_KEY!, {
apiVersion: '2020-08-27',
});
try {
const product = await stripe.products.retrieve(productKey);
return product;
} catch (error) {
console.error('Error retrieving product:', error);
throw error;
}
};