#Gadbit

1 messages · Page 1 of 1 (latest)

deep brambleBOT
silk cape
warm kernel
#

OK. Thank you.

#

I have a new question...

#

how can i associate the setup intent that updates the customer's default payment method with the invoice.pay?

silk cape
#

What do you need the Setup Intent for? If the Customer has updated their default Payment Method to a valid one, then you should be able to just pay the Invoice using only the Invoice ID (since the Customer is already attached).

#

Feel free to clarify if I'm missing something

warm kernel
#

OK, let me be a little more specific. Currentle, when a customer's subscription is past_due i show them a form to update their payment method, so i create a setup intent to validate their card and then i update their subscription default_payment_method. Then, the retry schedule makes the automatic charge according to the MANAGE FAILED PAYMENTS configuration.

#

But now, i'd like to charge the customer immediatly, once the setup intent is confirmed.

#

Currently, the setup intent is not associated to the subscription, since i'm only using the setup intent to update their default payment method.

#

If the customer's card is a valid one, and the setup intent is confirmed succesfully i'm only updating their subscription's default_payment_method (waiting for retry schedule to do the automatic charge)

#

After x days passed from the previous attempt

silk cape
#

But now, i'd like to charge the customer immediatly, once the setup intent is confirmed.
Currently, the setup intent is not associated to the subscription, since i'm only using the setup intent to update their default payment method.
The Setup Intent is not needed on the Subscription. The Setup Intent just makes the Payment Method available to use for future charges. When your Subscription is past_due, I'm assuming you're leaving the Invoice open so that it can be paid once the Customer adds a new Payment Method, correct?

If so, you just need to make sure the new Payment Method is also attached to the Customer object, so you can reattempt payment on the overdue Invoice.

#

Does that help?

warm kernel
#

OK, but how can i attach the new payment method to the customer if it's not through the setup intent?

silk cape
#

You said you're updating the subscription default_payment_method, right? How are you doing that? I assume you're getting a Payment Method ID somewhere, correct?

warm kernel
#

Yes, i was updating the default_payment_method on the setupIntent.confirm()

#

Because i was using setup intent to save the payment method

#

Just for save the payment method, and when the setup intent was confirmed, i set that as default_paymet_method

#

The setupIntent.confirm() was returning me a setupIntent.paymentMethodId and then i send that to update the subscription default_payment_method

#

With what you have told me, I imagine that this is not the correct way to implement it

#

So I was just describing the implementation that I am currently using.

silk cape
#

I see, alright. So once you create the Setup Intent, are you also confirming it and prompting your customer for authentication? In other words, what happens when they submit the form with their card number, expiration data, CVC, etc.?

warm kernel
#

Once they submit the form with their card data, i do the setupIntent.confirm() and if it's a valid card, i update the subscription default_payment_method for the new one (setupIntent.paymentMethodId)

#

So after x days passed since the previous attempt, the automatic charge is applied on the new default_payment_method

#

But this implies waiting x days to apply the charge automatically according to the retry schedule

#

So i'd like to charge the customer immediatly, changing my implementation if needed

silk cape
#

Okay, so if you want to charge immediately and the Payment Method is attached to the Customer object in that case (since you confirmed the Setup Intent) can't you simply set invoice_settings.default_payment_method instead (see: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method) and then pay the overdue Invoice using: https://stripe.com/docs/api/invoices/pay ?

warm kernel
#

OK, OK. Thanks.

#

So, invoice.pay emulates the payment intent process?

silk cape
#

invoice.pay will attempt to pay the Invoice. At that point, a Payment Intent is created to handle the actual payment itself. So, in a way, it facilitates the Payment Intent process

warm kernel
#

OK OK

#

I really appreciate your help. Thanks a lot.