mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
18 lines
438 B
TypeScript
18 lines
438 B
TypeScript
import { stripe } from '@documenso/lib/server-only/stripe';
|
|
|
|
export type GetProductByPriceIdOptions = {
|
|
priceId: string;
|
|
};
|
|
|
|
export const getProductByPriceId = async ({ priceId }: GetProductByPriceIdOptions) => {
|
|
const { product } = await stripe.prices.retrieve(priceId, {
|
|
expand: ['product'],
|
|
});
|
|
|
|
if (typeof product === 'string' || 'deleted' in product) {
|
|
throw new Error('Product not found');
|
|
}
|
|
|
|
return product;
|
|
};
|