#gracine

1 messages · Page 1 of 1 (latest)

quiet abyssBOT
sonic bobcat
#

Hi, to give more context, I have an update_stripe_subscription function that will check if the subscription needs to be created or updated in my database from the event

#

this function is called on customer.subscription.created, .updated & .deleted and also on invoice.paid, invoice.payment_failed

#

The thing is, depending on the subscription triggers, I get all events at the same millisecond and I end up doing 2-3 times the same update

#

I wonder if I could simply listen to the customer.subscription.updated since it seem to be triggered in all cases

#

also, to make sure I update my db with the latest version of the subscription (working around the fact the the events are not received in order), I do re-fetch the subscription from the event sub id

#

so this is not efficient, I am trying to improve the efficiency of my webhook controller

torpid coyote
#

customer.subscription.updated will only be sent if there's any changes to the subscription such as changing the plan or changing the start date to the next cycle. It doesn't mean that the current cycle is paid.

sonic bobcat
#

ok, so i must keep invoice.paid, invoice.payment_failed

torpid coyote
#

yup! for payment of the invoice on the subscription, invoice.paid and invoice.payment_failed events should be the ones

sonic bobcat
#

On subscription creation, I get invoice.paid and customer.subscription.updated

#

ok

#

that will be all

#

thank you

torpid coyote
#

no problem! happy to help 😄