vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.77k stars 1.18k forks source link

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

Open TusharSoni014 opened 3 months ago

TusharSoni014 commented 3 months ago

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.

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();
vercel[bot] commented 3 months ago

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

A member of the Team first needs to authorize it.