#sergx_webhooks

1 messages ¡ Page 1 of 1 (latest)

royal orioleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1229372523104440330

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

shut frostBOT
vast rover
#

Basically in that example I would like to know and be sure that the user updated quantity in 2, so 2 records are going to be created in my database

shell sail
#

Hi, let me help you with this.

vast rover
#

Hi! Thank you very much @shell sail

shell sail
vast rover
#

I'm not able to find it in invoice.payment_succeeded webhook

shell sail
#

Yes, it only applies to webhooks related to updates, like the one you shared, customer.subscription.updated.

vast rover
#

I see! The problem is, a user can update their quantity but maybe their card is declined right?

#

If I use customer.subscription.updated and user increments quantity in 3. That means, 3 records are going to be automatically created in my database, listening that webhook. But if the card is declined or there's some problem with the payment the user is going to have that 3 extra things without haven't paid.

#

For that reason, I'm dealing too that I would like to listening to the webhook and create the records when the payment for updating subscription is successful

shell sail
#

I guess a better approach would be not to use previous_attributes, but, compare the new quantity from the webhook event to the information in your database. If there's a misalignment, you will then create/remove the objects in the database.

#

Then you can use any webhook event you want.

vast rover
#

You mean for example, having quantity row in stripe subscriptions table. And records quantity in users table for example, to compare between data right?

shell sail
#

I don't know how your database is structured, but from your earlier message it seemed like you have some records that correspond to the item quantity, so I figured you could use it for identifying subscription updates.

vast rover
#

Perfect, thank you very much, will try it @shell sail

shell sail
#

Happy to help.