#ingeniousambivert-webhook-update
1 messages · Page 1 of 1 (latest)
hey there, can you explain more what the issue is here? If you update a Stripe object in response t a webhook (make sure you respond with the 200 first!), you should get the updated object in the response to that update.
Hi, so I am not sure if I am doing this right, but this is how my app works currently -
User signs up - selects a plan - subscribes
In the server the webhooks listen to - "invoice.payment_succeeded" and "customer.subscription.updated" events and updates the data in my db
So when the user makes a request nothing is written in the db, only stripe api calls, then the webhook updates the appropriate data when it captures the events.
Now when the client makes a request nothing is sent back except client secret (for confirming the payment in the frontend).
My webhook code - https://hastebin.com/wipolewami.js
My client code - https://hastebin.com/ataxonamod.js
My server code - https://hastebin.com/ribowetafa.kotlin
If this helps
hey @sharp bane can you help me out with this ?
yep, will get back to you
Okay thank you
YOu're talking about getting the updated objects from the client after synchronous payment success / checkout completion?
Yes exactly
In that case you'd make a call to your own server to retrieve the latest object state, and if necessary either wait or indicate the object isnt ready for the client yet
Client makes payment - server (webhooks) checks events (success condition) - updates the db with data.
Yes but thats the thing, I am already returning the clientSecret when I make initial call, so I guess I will have to implement some sort of short polling until the updated data is received ?
This a common scenario almost every saas app faces so there must be a common pattern with how this is accomplished ? if I am not wrong. Also is my approach correct ? I chose to update data on webhook captured events because I thought of this approach to be the most secure one. Please let me know if I am wrong
I am not sure how is this scenario handled ?
Well its as I already described -- if you're handling the synchronous flow from the client, you need to retrieve the latest object from your server. The Stripe objects will already be updated (aside from any additional updates you make), so you are in control of the timing and sequence here.
When your client checks with your server, your server should know whether it has set up any other objects or not, and either send them to the client, or tell the client to wait/check again in a few seconds
Okay, I guess I will try short polling. Thank you so much for the help.