#corollamango74
1 messages · Page 1 of 1 (latest)
HI 👋
Many actions will trigger multiple events in Stripe and so we will send multiple event notifications
We send the checkout.session.completed because the session did conplete and the invoice.paid because the invoice was paid.
If you only want to track the first invoice of a subscription you can do that with the invoice.paid event
Right, and that makes sense why both are sent.
I would like to track every payment made by a customer
Is there a specific endpoint I should use that will track all payments made after the initial checkout.session.completed webhook but won’t also send when the initial payment succeeds?
You would change what events your webhook endpoint listens for
So if you can just listen to invoice.paid if you want
So remove the checkout.session.completed webhook completely and only use invoice.paid?
Unless you need checkout.session.completed for something else
I was looking but couldn't find it. Is there some documentation that says what each endpoint can receive what information?
I can use a checkout session API call and just listen for an invoice.paid webhook right?
I assume the answer is yes, but will the invoice.paid webhook also trigger if it is a one-time payment?
will the invoice.paid webhook also trigger if it is a one-time payment?
Only if you configure the Checkout to generate an invoice
I did not configure the checkout to generate an invoice but I did receive the invoice.paid webhook when I completed a checkout session
Because it was for a subscripton
But we do allow Checkout to create invoices for one-off payments as well
But if you don't configure Checkout to do that then you won't get the invoice.paid event for one-off purchases
Oh, is a invoice generated automatically when the mode = subscription in a checkout session API call?
Yes because Subscriptions use Invoices to collect payment
I see. Is this the parameter I woudl use to generate an invoice for a one-time payment? invoice_creation.enabled
and set it to true
Yup
Great, I'll give that a go. Thank you!
Happy to help 🙂
What would be the best way to receive metadata from an invoice.paid webhook? I created the checkout session API call with it, but from my first test I don't see the metadata within the invoice.paid payload
No, that data does not propagate down to the Invoice
The best way would be to set the metadata on the Subscription itself using the subscription_data parameter when creating the Checkout Session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
Then when you receive the Invoice in the webhook you can retrieve the Subscription to look at the metadata
https://stripe.com/docs/api/invoices/object#invoice_object-subscription
I'll look into that, thank you. What about when it is a one-time payment?
Well in that case you would use the Payment Intent ID on the Invoice https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent and look up the Checkout Session with that https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
If I am generating the invoice in the checkout session API call, is the payment intent created automatically because the invoice is generated?
Correct. Invoices create Payment Intents to capture funds
There is actually a pretty cool explainer video how all this works together here: https://www.youtube.com/watch?v=CUAY6IQcVQM
Thank you. I understand everything you’ve said.
Unfortunately, with the way my app is set up, I need to be able to get the metadata from the inbound webhook payload so that I can attribute the payload to the specific customer that made the payment.
I include the user’s unique user id in the metadata.
So I don’t think this is going to work because I would need to receive the information in one step, and figure out who to send it to in the second step.
It seems like I need to continue using the checkout.session.completed webhook so I can receive the metadata (user id).
Is there any other webhook endpoint I can listen for when a customer pays after the initial payment that would allow me to also receive the metadata like a checkout.session.completed webhook?
You create webhook endpoints. You listen to webhook event types
Ah, my bad. Thank you for explaining that. This is my first time building with APIs
I think you will need to listen to the checkout.session.completed and just examine the Session object for details
When a subscription payment is billed for the second time, the checkout.session.completed webhook does not send anything right?
Correct. That would just be the invoice.paid
Okay, thank you.
Happy to help