#rbole
1 messages · Page 1 of 1 (latest)
+1 was just about to ask the same question
You can use Payment Intent Retrieval API and expand latest_charge.invoice field to expand invoice object. You should be able to find the subscription ID in latest_charge.invoice.subscription.
- Payment Intent retrieval API: https://stripe.com/docs/api/payment_intents/retrieve
- Expand an object: https://stripe.com/docs/api/expanding_objects
very cool
If the objective is to track whether the subscription is successful paid, I'd recommend using invoice.paid event instead: https://stripe.com/docs/billing/subscriptions/webhooks#events
It'll include subscription ID and doesn't require to make additional request
can we also find metadata from the subscription inside the latest_charge attr?
You should be able to find the metadata of the subscription by further expanding the subscription object under the invoice with expanding latest_charge.invoice.subscription field
also one last question, whats the best way to check if a payment intent is a payment or subscription? Is there field to check payment type?
You can either check whether latest_charge.invoice.subscription is present or look for the description of the payment intent.
If I use stripe trigger invoice.paid for local development, in the result the subscriptions seems to be null. the subscription: null,
I see invoice field outside of latest charge, can't I just retrieve and expand tha directly?
If I use stripe trigger invoice.paid for local development, in the result the subscriptions seems to be null. the subscription: null
Can you share the event ID (evt_xxx)?
I see invoice field outside of latest charge, can't I just retrieve and expand tha directly?
invoicefield is under thelatest_charge. What do you want to retrieve?
I'm printing the payment intent object, this is what I see.
what does the invoice field on top referer to? Isn't it the same as the one from latest_charge?
Ah I see! Then it's possible to expand invoice.subscription directly