#Filip-subscription
1 messages ยท Page 1 of 1 (latest)
Hi! If you have a Subscription, you should also have a PaymentIntent in subscription.latest_invoice.payment_intent. So you could just confirm this PaymentIntent on the backend with a test card. Something like this:
const paymentIntent = await stripe.paymentIntents.confirm(
'pi_xxx',
{payment_method: 'pm_card_visa'}
);
Not sure if I can find that part... ๐ค
No FE included, only BE. Just to be clear.
Subscription has a latest_invoice field https://stripe.com/docs/api/subscriptions/object#subscription_object-latest_invoice
And in the invoice there's a payment_intent field https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
FYI you could use expand to retrieve the payment_intent from the subscription in one API call https://stripe.com/docs/expand
nice, got it.
hello there
Hey ๐
I've tried to execute what @swift crescent mentioned above.
But i get this error message when I try to confirm latest invoice with test card (...4242)
No such payment_intent: 'in_1KMsRzK1YE4Y6l3sDABJAkMj'
I would be gratefull if there is any blog about this to eliminate back and forth.
in_xxx is an Invoice, not a PaymentIntent
like Soma mentioned, the path to follow is subscription->latest_invoice->payment_intent->id , that is the ID that you pass to paymentIntents.confirm()
sounds like you passed subscription->latest_invoice->id instead.
Cool, just payment_intent is not present in subscription I fetch.
yep because it belongs to the Invoice
the PaymentIntent is what processes the payments, the subscription is an object describing how and on what cadences an invoice should be issued for a specific customer, the invoices own the PaymentIntent since each invoice is its own separate payment, to explain the data model
or are you saying that the invoice you use doesn't have a PaymentIntent?
ok no, I checked that Invoice you mentioned and it does have one. Sometimes the Invoice won't have a PaymentIntent โ if it is for $0, which happens for trial periods or with coupons/customer credit balances, but is not the case here at least