Stripe working in production but user credits don't update
Hi guys,
Today I tried to make a payment on my SaaS https://www.fueltrackerapp.com and everything worked fine except for one thing, the user credits didn't update! I'm not so sure what's happening because in dev mode everything works fine. Anybody knows what could be happening?
36 Replies
Hi @jordi0lle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, based on the knowledge sources, it seems like other users have experienced similar issues with Stripe and user credits not updating. Here are a few things you could check:
1. Make sure you're running the Stripe CLI and that you're receiving events to the webhook. You can check this in the Stripe testing section of the open SaaS docs.
2. Check if you're importing the correct action on the client. For example, you should be importing
stripeCreditsPayment
.
3. Try to debug by adding console.log lines in your code to see where the issue might be occurring.
4. Ensure that your Stripe product configuration is correct. You should have a one-time payment product set up for buying credits.
5. Check if there's a difference between your development and production environments that could be causing the issue.
If you're still having trouble, it might be helpful to look at the Wasp Discord (https://discord.com/channels/686873244791210014) for more specific advice or to ask the community for help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @jordi0lle, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?@Vinny (@Wasp) please take a look 🙃
It’s working in dev but not prod — this sounds like some env variables or configuration got messed up along the way.
Is the webhook configured correctly for prod? Did you create a product for a credits payment just as you did when testing (but not in stripe test mode obviously)?
Also can you check your stripe dashboard and under webhooks look for the webhook event that was sent by stripe when the payment was made?
Stripe Login | Sign in to the Stripe Dashboard
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Successful events will look like this
If the event isn’t even being sent, then you didn’t configure your webhook to listen for it
@jordi0lle
I'll try this later today because I just checked and I only have it set in test mode. I'll inform here if the problem is solved after checking it 😄
THX @Vinny (@Wasp)
Hi @Vinny (@Wasp),
I changed added the correct key and the 4 events used for purchasing credits and now I'm not so sure how to solve this:
Any idea?
Hmm. If it was working in development than there is some configuration step that you’re missing in production. Did you get the production webhook signing secret? Is the webhook on stripe pointing to the correct url? Are other aspects of your app working? If not maybe you forgot an env variable somewhere else
I got the weebhook signing secret from here
You deployed to fly.io I guess? Can you run
wasp deploy fly cmd secrets list --context server
and check that all your necessary en vats are set (https://docs.opensaas.sh/guides/deploying/)?I deployed on railway
And I checked that the keys I placed from stripe were all correct
All these keys in red match Stripe correctly for "production" mode
Changed the webhook this morning as you were right yesterday (the one I was using was the test key) and now it's correct as you can see
What could be different between your development environment and production?
Can you check your server logs and see if any events were coming through at all?
Yeah so the stripe redirect is working but the webhook events aren’t being captured. Did you redeploy/restart the server since updating the env vars?
I did redeploy straight from railway
Is that okay or should I build the app again and deploy it from my computer?
This should be ok.
All I can think of at the moment is to double check your endpoint url and all the configuration settings. Go back and look at your development set up and try to find what’s different between that and your production setup
@jordi0lle can you share the webhook definition in your wasp file as well as your webhook URL you’ve entered in the stripe dashboard (don’t worry you can share this publicly)?
You mean this?
And this
Is what you mean? @Vinny (@Wasp)
You need to add
/stripe-webhook
to the end of your URL
There’s the problemso should be
https://server-production-153a.up.railway.app/stripe-webhook
??Wohooo @jordi0lle, you just became a Waspeteer level 5!
Yep
It’s outlined here for example https://docs.opensaas.sh/guides/deploying/#setting-up-your-stripe-webhook
OpenSaaS.sh
Deploying
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
Nice!
This and the key where the only thing missing 🙃
Thanks a lot for your help!
Awesome! Glad you got it working now
Nice good job guys 🤗