#Filip-subscription

1 messages ยท Page 1 of 1 (latest)

swift crescent
#

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'}
);
obsidian sierra
#

No FE included, only BE. Just to be clear.

swift crescent
obsidian sierra
#

nice, got it.

low kite
#

hello there

obsidian sierra
#

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.

low kite
#

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.

obsidian sierra
#

Cool, just payment_intent is not present in subscription I fetch.

low kite
#

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