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

Products from Stripe Dashboard are not getting pulled in.

Open cmarabate opened this issue 2 years ago • 38 comments

I swear I followed all the steps in the README exactly and I even used the stripe API to pull in all of the test products. image

And I made sure that I used my test mode API keys. And for the STRIPE_WEBHOOK_SECRET I used the key given to me after running step 2 in the project locally... image

image

image

I do not understand what I could have done wrong, Has anyone else had a similar experience when trying this starter? Or is anyone able to help me figure out what my issue is?

Thanks,

Chris

cmarabate avatar Jan 31 '23 20:01 cmarabate

Im having the exact same problem.

fedster99 avatar Feb 01 '23 18:02 fedster99

YAY, it is not just me!

cmarabate avatar Feb 01 '23 21:02 cmarabate

I'm also having a similar issue.

awhrah avatar Feb 02 '23 18:02 awhrah

I am also having the same issue.

SalahBioPhysics2 avatar Feb 04 '23 15:02 SalahBioPhysics2

Still no ideas? Does anybody know an alternative starter?

keremduran avatar Feb 04 '23 20:02 keremduran

I had the same problem and I solved it doing this: Products on this template are being retrieved from supabase. If you have RLS enabled in your tables, make sure you have at least a policy that allows read for all users. Here you have a link that mentions this problem: https://github.com/supabase/supabase/discussions/3780#discussioncomment-4095624

dreazz avatar Feb 04 '23 21:02 dreazz

i solved the problem by putting the schema.sql into the supabase SQL-editor in order to generated the sql-tables. Somehow there were no Tables after installation of supabase. Afterwords you need to reconfig the product at stripe to get synced with supabase

karloscampus avatar Feb 08 '23 22:02 karloscampus

Check supabase if you have tables: https://app.supabase.com/project/[YOUR_PROJECT_ID]/database/tables If not go to the sql editor: https://app.supabase.com/project/[YOUR_PROJECT_ID]/sql And run the contents of: https://github.com/vercel/nextjs-subscription-payments/blob/main/schema.sql

The integration is not running schema.sql like it should have

DustinRobison avatar Feb 10 '23 20:02 DustinRobison

I ended up copying the contents of schema.sql and putting them into a migration file.

I ran yarn supabase migration new initial and yarn supabase db push to do this.

alexkates avatar Feb 11 '23 11:02 alexkates

I still haven't figure this one out. Did anyone solve it? I am using google cloud for hosting :)

SalahBioPhysics2 avatar Feb 24 '23 18:02 SalahBioPhysics2

Hello, I'd like to help you get resolved if you have time to chat. I deployed yesterday, had working then decided after all the tips regarding webhooks, api on supabase and user profile additions to schema .db i would set out today from a fresh deployment. I have successful deployed and publishing products directly from stripe to project-name-vercel.com deployment.

I wanted to test the options needed to publish products from start to proof as quick as possible..

  1. I deployed from vercel dashboard
  2. checked all required api auth info: (see stripe dashboard)
  • webhooks url = your-project-name.vercel.com
  • webhooks Signing Secrets (whsec_***)
  • Pub Key
  • Secret Key
  • url wildcard redirect - [ https://**vercel.app// ] added to (supabase.com/project/your-db-id-here/auth/URL-configuration)
  • What I did different from instructions: I added supabase API Quick start to Stripe APi endpoint. I wanted to test updating from stripe to website. After successful connection of all dbs I'd move into local setup. FYI, I'd rather not modify products outside stripe..."if possible."
  1. Copied schema data from local clone/ git-repo (for me it was easier to do in local clone) needed for supabase tables to communicate with stripe) note* I didn't make any local changes, no install or pushed to git repo.

  2. Time to RE-Deploy & confirm environment was able to deploy with updated settings. Head to vercel dashboard and set to redeploy. (I watched the build steps for better understanding)

  3. Successfully re-deployed!!!!

Now that the environment checks I added Profiles to supabase table editor. tip see supbase_docs

  1. Create table create table profiles ( id uuid references auth.users, avatar_url text );
  1. Enable RLS alter table profiles enable row level security;
  1. Create Policy create policy "Users can update their own profiles." on profiles for update using ( auth.uid() = id );`
  1. Head over to stripe dashboard Here you should make sure developer and test button are active.
  • add 4 simple products with recurring pricing - simple data for testing, don't get fancy yet.
  1. refresh your domain ... https://your_project__name_here.vercel.app/

wahlah.. you should see products populated now.

Happy Coding -- if this helps please give me a star @mworks-proj
Together we are achieving more!

mworks-proj avatar Mar 01 '23 06:03 mworks-proj

  • webhooks url = your-project-name.vercel.com

should this be your-project-name.vercel.com/api/webhooks ?

aleskozelsky avatar Mar 04 '23 22:03 aleskozelsky

I also had the same issue and ran schema.sql in the supabase sql editor, worked for me.

rannikkopyry avatar Mar 06 '23 06:03 rannikkopyry

I ran the project on a different port (3001 instead of 3000) and that ended up working for me. I think its because I had cloned the project previously and listened for webhooks on port 3000. This is what worked for me, hope it helps. image

grannybter avatar Mar 09 '23 21:03 grannybter

I ran into the same issue.

I had the schema and RLS in Supabase fine.

I just went and updated the prices in Stripe and they showed up in my app. I think the order of the instructions is wrong, schema first, then local stripe webhooks, then set pricing with the Stripe cli.

OrionSeven avatar Apr 01 '23 04:04 OrionSeven

Hi @mworks-proj I am struggling with this. Do you have time for a quick chat? Hi all, anyone who can help me? I still cant get the products to supabase Aswin

masapasa avatar Apr 18 '23 16:04 masapasa

@OrionSeven's comment solved it for me.

The way the setup works, you need to have Supabase database spun up and the service running locally (or live) so that the Stripe webhook that is triggered when you create / update a product and product price hits your service and adds the product/prices to your Supabase database so it can be displayed.

You should see this: image

Ideally, the server (on startup) would pull the most up to date products/prices and update the DB , in case products/prices were updated while the server was not running and missed the webhook.

vimota avatar May 28 '23 22:05 vimota

Was banging my head against the desk over this issue, but the preceding comment nailed it, and I've got it working now. The problem is that the function to upsert products to the Supabase db is only being run when a POST is received from Stripe, and there's no logic to trigger a Stripe POST on initial page load. Instead, you have to trigger a post manually by editing your product on Stripe while your development server is running.

  1. Make sure your Stripe and Supabase are set up, you have run schema.sql on the Stripe dashboard to create tables, and your .env.local is populated.

  2. Run stripe listen --forward-to=localhost:3000/api/webhooks in one terminal.

  3. In a second terminal, run npm run dev to start the development server. Wait for the development server to initialize and navigate to http://localhost:3000.

  4. Then, with both the listener and dev server running, you have to edit your Stripe product information. You can either: a) run stripe fixtures fixtures/stripe-fixtures.json in a third terminal, or b) change your products manually on the Stripe dashboard.

You should now see the products populate on-page.

chriscarrollsmith avatar Jun 16 '23 19:06 chriscarrollsmith

Hello @masapasa , were you able to get db working?

mworks-proj avatar Jul 19 '23 05:07 mworks-proj

@mworks-proj yes, thanks

masapasa avatar Jul 28 '23 14:07 masapasa

Was banging my head against the desk over this issue, but the preceding comment nailed it, and I've got it working now. The problem is that the function to upsert products to the Supabase db is only being run when a POST is received from Stripe, and there's no logic to trigger a Stripe POST on initial page load. Instead, you have to trigger a post manually by editing your product on Stripe while your development server is running.

  1. Make sure your Stripe and Supabase are set up, you have run schema.sql on the Stripe dashboard to create tables, and your .env.local is populated.
  2. Run stripe listen --forward-to=localhost:3000/api/webhooks in one terminal.
  3. In a second terminal, run npm run dev to start the development server. Wait for the development server to initialize and navigate to http://localhost:3000.
  4. Then, with both the listener and dev server running, you have to edit your Stripe product information. You can either: a) run stripe fixtures fixtures/stripe-fixtures.json in a third terminal, or b) change your products manually on the Stripe dashboard.

You should now see the products populate on-page.

Thank you this really helped me.

stackaccount1 avatar Sep 19 '23 04:09 stackaccount1

This is still an issue. If someone updates their app and keeps the same Stripe account, the deploy does not allow Stripe to update Supabase. And you cannot run the schema again as there are conflicts. Any solutions would be greatly appreciated. thx

guylepage3 avatar Feb 16 '24 16:02 guylepage3

This is still an issue. If someone updates their app and keeps the same Stripe account, the deploy does not allow Stripe to update Supabase. And you cannot run the schema again as there are conflicts. Any solutions would be greatly appreciated. thx

What exactly is happening when you run the stripe listener and then update a product from Stripe? What do you see in your CLI, and what do you see in your Stripe dashboard logs?

Instead of running the schema.sql file, try running the migrations.

chriscarrollsmith avatar Feb 16 '24 19:02 chriscarrollsmith

@chriscarrollsmith so I just updated my products and prices in order to get things working. But this method is not wise say later down the road. But for now, I am good.

What needs to happen is an event from Stripe needs to take place in order to propagate the Supabase DB.

What we need to figure out is how to trigger an event from Stripe that will send the product and pricing information from Stripe to the Supabase DB without having to update current product/prices and without having to create new product/prices as well.

guylepage3 avatar Feb 16 '24 21:02 guylepage3

Yes, that's exactly how it works if you have your webhook and webhook listener set up correctly. Make sure to follow the instructions for webhook setup in the README.

On Fri, Feb 16, 2024, 4:40 PM Guy Lepage @.***> wrote:

@chriscarrollsmith https://github.com/chriscarrollsmith so I just updated my products and prices in order to get things working. But this method is not wise say later down the road. But for now, I am good.

What needs to happen is an event from Stripe needs to take place in order to propagate the Supabase DB.

What we need to figure out is how to trigger an event from Stripe that will send the product and pricing information from Stripe to the Supabase DB without having to update current product/prices and without having to create new product/prices as well.

— Reply to this email directly, view it on GitHub https://github.com/vercel/nextjs-subscription-payments/issues/168#issuecomment-1949372825, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASCYPGOQECTDO3LKIRSFTX3YT7G6BAVCNFSM6AAAAAAUM4RCJOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBZGM3TEOBSGU . You are receiving this because you were mentioned.Message ID: @.***>

chriscarrollsmith avatar Feb 16 '24 21:02 chriscarrollsmith

Yeah. But we definitely need to figure out an alternative to be able to trigger an event from Stripe that will send the product and pricing information from Stripe to the Supabase DB without having to update current product/prices and without having to create new product/prices as well.

guylepage3 avatar Feb 16 '24 22:02 guylepage3

That's what I'm saying: the template already does that. As long as you have your webhook set up and are subscribed to the relevant events through the Stripe dashboard, and your template is deployed and listening for Stripe webhook events, any changes you make to products and prices from the Stripe dashboard will be automatically propagated to your Supabse database without any manual effort on your part. But you have to get both that webhook and the listener set up correctly, or it won't just be the price and product propagation that fails. You won't be able to process any transactions at all.

chriscarrollsmith avatar Feb 17 '24 01:02 chriscarrollsmith

Unless you're saying you already have products and prices set up in Stripe but they're not propagated to Supabase, and you want to copy them over without making any changes to them? If you just missed the webhook events that created them, you can always go into the webhook logs on the Stripe dashboard and retrigger those events. But we don't currently have a way to do this programmatically. You could get then through the Stripe CLI and write a short script to copy them to Supabase. Eventually I'd love to add foreign data wrappers to this template, which would do what you want. But that's a big change to the architecture I think.

chriscarrollsmith avatar Feb 17 '24 01:02 chriscarrollsmith

i keep getting invalid API Key, followed all other suggestions, my tables where automatically created upon installation too 😣

i've checked the API keys 1000 times. used stripe CLI for local webhook key and stripe in test mode for: STRIPE_SECRET_KEY NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY

Authentication works and tables are updated, its just Stripe, main error: Error: Price insert/update failed: Invalid API key Supabase customer lookup failed: Invalid API key

hilyas786786 avatar Mar 08 '24 11:03 hilyas786786

i keep getting invalid API Key, followed all other suggestions, my tables where automatically created upon installation too 😣

i've checked the API keys 1000 times. used stripe CLI for local webhook key and stripe in test mode for: STRIPE_SECRET_KEY NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY

Authentication works and tables are updated, its just Stripe, main error: Error: Price insert/update failed: Invalid API key Supabase customer lookup failed: Invalid API key

That sounds like a Supabase key problem rather than a Stripe key problem, but if authentication works and the tables are being updated then your Supabase key should be okay. (Maybe this is using service role key rather than anon key? I will check later today. In the meantime, try verifying that your Supabase service role key is correct.)

chriscarrollsmith avatar Mar 08 '24 12:03 chriscarrollsmith