nextjs-subscription-payments icon indicating copy to clipboard operation
nextjs-subscription-payments copied to clipboard

[BUG FIX] Fixed a Bug Where active subscriptions from stripe are returning null

Open TusharSoni014 opened this issue 11 months ago • 1 comments

I modified the supabase table query from the code little bit, to take the current signed in user id and return its current most latest active subscription data from stripe.

  • Before: image You can see the subscriptions are returning null from stripe but, i have a subscription active on my stripe

Due to being subscriptions returning null in the frontend, there was no manage button instead of subscribe button on home page, and also the accounts page was also saying you are not subscribed to any subscription, the below query is what i did for both, accounts page and home page to fix the null subscription error,

  const { data: subscription, error } = await supabase
  .from('subscriptions')
  .select('*, prices(*, products(*))')
  .eq('user_id', String(user?.id))
  .in('status', ['trialing', 'active'])
  .order('current_period_end', { ascending: false })
  .limit(1)
  .single();

TusharSoni014 avatar Mar 23 '24 10:03 TusharSoni014

@TusharSoni014 is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 23 '24 10:03 vercel[bot]