Reputation: 13
My site was down for a week, and few subscription installment was done during the week. But my website did not capture this(using web hook for invoice.payment_succeeded).
I have queried my database and have subscription ids with me. But how do I get the event that triggered invoice.payment_succeeded. So that I can pass the same to web-hook method and database will be updated.
First I queried with subscription id.
https://api.stripe.com/v1/subscriptions/sub_XXXXXX
I get invoice id
Second I queried with invoice id.
https://api.stripe.com/v1/invoices/in_XXXXXX
and gets
"status_transitions": {
"finalized_at": 1565706891,
"marked_uncollectible_at": null,
"paid_at": 1565706893,
"voided_at": null
},
This shows payment was made.
Third I then queried with paid date (Timestamp)
https://api.stripe.com/v1/events?created=1565706893&type=invoice.payment_succeeded
and gets event triggered for invoice.payment_succeeded response during that date.
But at times, I can find no events created during the "paid_at": 1565706893, value. What am I missing here. Or is there any alternate solution to find event id for type invoice.payment_succeeded using subscription id.
Upvotes: 1
Views: 450
Reputation: 755
https://api.stripe.com/v1/subscriptions/sub_XXXXXX will fetch only latest_invoice id. Are you sure that you take the correct invoice id.
You can also try this if you only want event id associated https://api.stripe.com/v1/events?related_object= SUBSCRIPTIONID&type=invoice.payment_succeeded
Here you can find all the success events created for particular subscription. Hope this helps.(Dosen't know if its official, couldn't find, but you can try)
Upvotes: 2