My basic setup is creating a session and completing a payment with a Stripe webhook sent when checkout.session.complete is true.
But to be able to update the current_period_end in my database, I have to use a webhook for when invoice.payment_succeeded is true.
This works together, but, I have a problem!
Problem: When a user subscribes for the first time, Stripe sends a webhook of both checkout.session.complete and invoice.payment_succeeded.
I want to receive only the checkout.session.complete when a user first subscribes, so is it possible to prevent the invoice.payment_succeeded from being sent the first time / when checkout.session.complete is sent?
The invoice object has the attribute billing_reason. If the invoice.payment_succeeded webhook event is triggered by creating a new subscription, the value of billing_reason will be "subscription_create".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With