Skip to content

Commit

Permalink
Use the first active pricing in the product. (#3951)
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd authored Feb 26, 2024
1 parent bc4f07d commit 5827100
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions front/lib/plans/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ const stripe = new Stripe(STRIPE_SECRET_KEY, {
*/
async function getPriceId(productId: string): Promise<string | null> {
const prices = await stripe.prices.list({ product: productId });
if (prices.data.length > 0) {
const priceId = prices.data[0].id;
return priceId;
const activePrice = prices.data.find((p) => p.active === true);

if (activePrice) {
return activePrice.id;
}
return null;
}
Expand Down

0 comments on commit 5827100

Please sign in to comment.