Open cmarabate opened 1 year ago
Im having the exact same problem.
YAY, it is not just me!
I'm also having a similar issue.
I am also having the same issue.
Still no ideas? Does anybody know an alternative starter?
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
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
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
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.
I still haven't figure this one out. Did anyone solve it? I am using google cloud for hosting :)
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..
I deployed from vercel dashboard
checked all required api auth info: (see stripe dashboard)
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.
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)
Successfully re-deployed!!!!
Now that the environment checks I added Profiles to supabase table editor. tip see supbase_docs
Create table create table profiles ( id uuid references auth.users, avatar_url text );
Enable RLS alter table profiles enable row level security;
Create Policy create policy "Users can update their own profiles." on profiles for update using ( auth.uid() = id );`
wahlah.. you should see products populated now.
Happy Coding -- if this helps please give me a star @mworks-proj
Together we are achieving more!
- webhooks url = your-project-name.vercel.com
should this be your-project-name.vercel.com/api/webhooks ?
I also had the same issue and ran schema.sql in the supabase sql editor, worked for me.
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.
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.
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
@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:
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.
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.
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.
Run stripe listen --forward-to=localhost:3000/api/webhooks
in one terminal.
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.
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.
Hello @masapasa , were you able to get db working?
@mworks-proj yes, thanks
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.
- 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.
- Run
stripe listen --forward-to=localhost:3000/api/webhooks
in one terminal.- 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.- 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.
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
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 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.
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: @.***>
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.
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.
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.
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
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.)
Im developing locally, i used the service role key provided from Docker, and the Anon key from my project settings inside Supabase,
Authentication works and the table is updated, however stripe products wont be pulled in and clicking on Open Customer Portal shows: Supabase customer lookup failed: Invalid API key
Update: Used service role key and anon key from supabase project settings, then did supabase link, close restarted eveything and its all working! Seems that the guide was saying to use service role key from Docker which didnt work or partially worked because authentication was working - strange!
When you run pnpm run supabase:start
, you should get something like this output:
API URL: http://127.0.0.1:54321
GraphQL URL: http://127.0.0.1:54321/graphql/v1
DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres
Studio URL: http://127.0.0.1:54323
Inbucket URL: http://127.0.0.1:54324
JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
anon key: ey...
service_role key: ey...
These are the keys you would use for local development, not the keys for your remote project. Auth uses the anon key, but adding prices or products uses the service role key, so it sounds like something was wrong with the service key you were using.
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.
Correct. You got it. That's what I was getting at.
The work around is, like you were suggesting, updating the product description in the Stripe.com interface to produce a new hook.
When you run
pnpm run supabase:start
, you should get something like this output:API URL: http://127.0.0.1:54321 GraphQL URL: http://127.0.0.1:54321/graphql/v1 DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres Studio URL: http://127.0.0.1:54323 Inbucket URL: http://127.0.0.1:54324 JWT secret: super-secret-jwt-token-with-at-least-32-characters-long anon key: ey... service_role key: ey...
These are the keys you would use for local development, not the keys for your remote project. Auth uses the anon key, but adding prices or products uses the service role key, so it sounds like something was wrong with the service key you were using.
Yes your right, is there any way to refresh that server key that was provided from running pnpm run supabase:start? - that was the key i should have been using according to the guide. Currently i'm using the key from supabase as that one doesn't seem to work.
In local development, I believe it will always be the same key:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
(Note: I'm sharing this because the local service role doesn't actually need to be kept secret, which is why it's always the same across projects. However, your remote service role key is a secret and should never be shared!)
I Still facing same problem 😭 Can Anyone please help me .
@Ritulkr, If you follow @chriscarrollsmith's recommendation, the product items and prices will appear. Just make sure you have everything setup correctly.
The folks at Supabase did a great job providing a quick video on getting you up and running quite quickly.
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.
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...
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