#ahjaydog-expand
1 messages ยท Page 1 of 1 (latest)
For event.type == 'invoice.payment_failed': I was wondering to expand on subscription
Or should I just make another API call using stripe.Subscription.retrieve(event.data.object.subscription) or stripe.Invoice.retrieve(event.data.object.id,expand=[subscription]) ?
In the invoice.* event, its object will contain invoice ID (in_xxx), which you can use a retrieve invoice call: https://stripe.com/docs/api/invoices/retrieve with subscription field expanded
ok so there is no way to do stripe.Event.retrieve("evt_1LCxSgIeTJrsS1rekQWa7dWn",expand=[subscription]) ?
let me check
ok
that's currently not possible; the expand will only be on invoice retrieval call
ok thanks
is there a test card to test for failed invoices?
or this event.type == 'invoice.payment_failed'
are you looking to have invoice event with subscription failed or just normal invoice without subscription?
both
I will probably do if invoice_id == None: and if invoice_id != None: to tell the difference between subscription and one time invoice
If no subscription invoice, you can use CLI to trigger: stripe trigger <event>: https://stripe.com/docs/webhooks/test
What would the command be?
For example, stripe trigger invoice.payment_failed
I don't provide an invoice id?
I want to see it in action on the dashboard to see what happens if possible
or how would i do it in test clocks?
I was able to do it for a subscription in test clock by removing the card then fast forwarding time
CLI is the quickest without setting up an invoice on your own; otherwise, you can use declined test card: https://stripe.com/docs/testing#declined-payments
ok hold on let me see
For subscription invoice, you can use the test card with "Decline after attaching"
For non-subscription invoice, you can use any decline test card
No problem! Happy to help ๐