W
Wasp-lang•3mo ago
Wix

Stripe production does not update user after purchase

For some reason when i moved over to production i chnaged my webhook to a production wbhook which i know works because it lets the user purchase things. it does not accuratly update the user to having an active subscription.
20 Replies
kapa.ai
kapa.ai•3mo ago
Hi @Wix. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, it seems like you might be facing an issue with the webhook events not being properly handled in your production environment. Here are a few things you could check: 1. Webhook Events: Ensure that your webhook is listening for the correct events. In the context of Stripe, these could be 'checkout.session.completed', 'invoice.paid', or 'customer.subscription.updated' events. If these events are not being listened to, the user's subscription status might not get updated. 2. Webhook Endpoint: In your Stripe Dashboard, you can set the webhook endpoint to your server domain. It should look something like {your-fly-server-domain}/stripe-webhook. Make sure this is correctly set up in your production environment. 3. Webhook Secret: When you move to production, you need to change the webhook secret in the Stripe -> Dev -> Webhooks section. Create a new webhook by URL pointing to your server url/stripe-webhook endpoint, and then add the Webhook Secret found on the stripe dashboard to your .env settings. 4. API Version: Ensure that you are using the correct API version. There might be differences in how different versions of the API handle webhooks. If you've checked all of these and the issue persists, it might be helpful to add some logging to your webhook handling code to help debug the issue. You can log the event.type and userStripeId to get more insight into what's happening when a webhook event is received. For more detailed information, you can refer to the OpenSaaS documentation (https://docs.opensaas.sh/guides/deploying/#setting-up-your-stripe-webhook) on setting up your Stripe webhook. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Wix, 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?
martinsos
martinsos•3mo ago
@Wix so updating to active subscription works locally but on in production -> how does it manifest in production, active subscription is just never updated and that is it? Have you done any debugging, maybe logging stuff in the webhook in the production? I am adding @Vinny (@Wasp) to this convo he know the most about this topic.
Wix
Wix•3mo ago
Yeah basiclly it worked just fine with a test webhook and now when trying to use the new generated webhook in production it is not updating users subscription status when a subscription is bough despite the subscription purchase being reflected in stripe as well as the right event listerners being active on the webhook. I also followed the exact steps from teh docs
Wix
Wix•3mo ago
No description
No description
Wix
Wix•3mo ago
This problem only would happen in development when I wasn't running stripe listen --forward-to localhost:4242/webhook so not sure if i am doing something wrong and that needs to be running on my server i guess in other words the local listener in dev works but the hosted endpoint in prod doesnt
MEE6
MEE6•3mo ago
Wohooo @Wix, you just became a Waspeteer level 1!
Wix
Wix•3mo ago
@martinsos @Vinny (@Wasp)
martinsos
martinsos•3mo ago
The thing that you are running locally is just enabling stripe to reach your local server when trying to post to the webhook, so if it works locally it should indeed work in production. Sounds to me like some kind of misconfiguration most likely. You said you followed the steps from https://docs.opensaas.sh/guides/deploying/#setting-up-your-stripe-webhook exactly as written? Are you sure you picked the correct events? Also, provided the correct secret under STRIPE_WEBHOOK_SECRET=? Btw where are you deploying, which provider?
OpenSaaS.sh
Deploying
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
Wix
Wix•3mo ago
i am using the token from where it says reveal and i picked all of the listeners that it said to in the documentation is that okay?
No description
Wix
Wix•3mo ago
im going to try maybe just selecting all events? may be one i left off
martinsos
martinsos•3mo ago
Check that you have account.updated also under those events! I don't have any more good ideas at the moment, but @Vinny (@Wasp) will certainly have more in the morning. One thing you can also do is add a console.log to the webhook logic on the server to see what is happening in there.
Wix
Wix•3mo ago
Yeah that didnt seem to work. FIXED IT: When you are setting up your webhook make sure it is pointed at the server URL not the client.... I dont wanna talk about it hahaha
Vinny (@Wasp)
Vinny (@Wasp)•3mo ago
haha don't worry. It happens to the best of us. Glad you got it configured correctly 🙂
martinsos
martinsos•3mo ago
Haha ok I am glad it is nothing worse :D. And now I also see bit fat "client" in that image above, but I haven't seen that yesterday :D. Anything we could have done better in the docs to prevent this?
Wix
Wix•3mo ago
Maybe just say if you are deploying to fly.io make sure its pointed at your server URL. But, the docs for wasp are amazing! Getting ready to go into beta testing for my first saas Lecture Lab! https://lecturelab-client.fly.dev/
Lecture Lab
Ai Lecture Chat
Want results from more Discord servers?
Add your server