Giter VIP home page Giter VIP logo

Comments (7)

thorwebdev avatar thorwebdev commented on May 16, 2024

@alaq this is likely due to an incorrect webhook secret env var (https://github.com/vercel/nextjs-subscription-payments/blob/main/.env.local.example#L9) Can you double check that you've set that correctly? If you've deployed via the deploy button in the README, then this should have been automatically set.

from nextjs-subscription-payments.

alaq avatar alaq commented on May 16, 2024

Thank you for your response @thorwebdev!

I re-deployed once more via the deploy button in the README, to have a clean slate. After the completing the wizard I went to check the environment variables on Vercel.

I noticed that STRIPE_WEBHOOK_SECRET was indicating me to run stripe --listen (see screenshot below), which I did (./stripe listen --forward-to=localhost:3000/api/webhooks to be precise) and obtained the secret.

Screen Shot 2021-04-28 at 8 19 12 PM

Same thing for the SUPABASE_SERVICE_ROLE_KEY which I retrieved from Supabase's dashboard.

After that I created my first product but got the same error. I went to the webhook on the Stripe dashboard and noticed that the secret was different, so I copy/pasted the one from the Stripe dashboard and finally re-sent the webhook, which failed again. I also tried re-deploying to see if it would update the secrets, but there was no difference.

It seems to be a me problem here, so there must be something I'm doing wrong?
Before updating these environment variables, I have tried not touching anything and running the webhook, which didn't work either.

I also tried to use the stripe CLI tool to trigger a product.create event. I receive the webhook, but still get the same error.
Screen Shot 2021-04-28 at 11 39 34 PM

This is where stripe-node seems to be tripping: https://github.com/stripe/stripe-node/blob/c85a597f15a225c3b52f90224b4749ad138a9a8c/lib/Webhooks.js#L116

Any help debugging this is appreciated!!

from nextjs-subscription-payments.

thorwebdev avatar thorwebdev commented on May 16, 2024

Stripe listen is only for local development. You can actually see that the secret was correctly set up for preview and production mode:
image

To run this locally, you will need to first pull the env vars from vercel: https://github.com/vercel/nextjs-subscription-payments#setting-up-the-env-vars-locally and then set the missing secrets in your .env.local file.

But your preview and production webhook should be working. What do you see in your Stripe account under https://dashboard.stripe.com/test/webhooks? It should look something like this:
image

And when you click on your webhook endpoint, you should see
image

from nextjs-subscription-payments.

alaq avatar alaq commented on May 16, 2024

I've only been using stripe listen to try to debug this locally.

Unfortunately it has never worked on the production environment. I have gone through the installation process a few times.

Screen Shot 2021-04-29 at 1 11 48 AM
Screen Shot 2021-04-29 at 1 13 30 AM

from nextjs-subscription-payments.

alaq avatar alaq commented on May 16, 2024

I just re-ran everything from scratch, like the previous times, but I deleted all my Stripe accounts. This time it worked! No hiccup, this is fantastic. Thank you for your help @thorwebdev!

from nextjs-subscription-payments.

joyahmed avatar joyahmed commented on May 16, 2024

I added envrionment variables these way in vercel:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: '....'
STRIPE_SECRET_KEY: '...'
STRIPE_WEBHOOK_SECRET: '...'

couldn't get it work ever

commented out my local listener webhook secret and added the one for vercel endpoint in next.config.js, and it worked

image

from nextjs-subscription-payments.

belikebrahma avatar belikebrahma commented on May 16, 2024

anything on this?

from nextjs-subscription-payments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.