#storm-default-paymentmethod

1 messages · Page 1 of 1 (latest)

native caveBOT
mild isle
#

Hi 👋

Do you have an example Payment Intent I can review? The Payment Intent ID is all I need. They start with pi_.

median isle
#

pi_3MUvSbKi1arGZw8p0IC8GiKZ

mild isle
#

Thanks, taking a look

median isle
#

Thanks so much

mild isle
#

Okay this one is odd

median isle
#

Yeah... I had a feeling...

mild isle
median isle
#

Yes. We set it up to set the default payment method when the payment intent for a subscription purchase succeeds via webhooks

mild isle
#

Yes that's generally a reliable approach. Is this invoice the first for this subscription?

median isle
#

No. The subscription invoice is this one: pi_3MUvJmKi1arGZw8p0gnjxS0S

mild isle
#

But then how is it that the Customer's payment methods were only updated ~10 minutes before the Invoice was created?

median isle
#

The subscription invoice succeeding is what we look for in the webhooks to set the default payment method. The new invoice that happened roughly 10 min later is a new charge that we were trying to do to test the default payment method

#

The two invoices are separate/unrelated

mild isle
#

Oh okay

median isle
#

Yes, sorry for the confusion

mild isle
median isle
#

Yes, correct

mild isle
#

Okay but that should have done it by itself, without the webhook

median isle
#

Right... So the payment method was being stored to use for the subscription without an issue from what we could tell, but the payment method could not be used for any additional charges that were unrelated to the subscription. From what we could tell, we needed to store the payment method in another field of the customer object as the default payment method which is what we were trying to do with the webhooks

#

We are using the invoice_settings.default_payment_method field because we will be working with the Payment Method API in the near future

#

Or at least we are trying to use the invoice_settings.default_payment_method field

agile fulcrum
#

storm-default-paymentmethod

#

but the payment method could not be used for any additional charges that were unrelated to the subscription
@median isle what do you mean by that? Like what was the exact error you got?

median isle
#

The status of any new payment intents become "requires payment method"

agile fulcrum
#

Sure but that can mean many different things. Can you give me a concrete example?

median isle
agile fulcrum
#

Okay, sorry I'm struggling a bit to follow your train of thoughts. So you aren't doing any one-time payment via the PaymentIntents API yourself. Instead you always use Subscriptions or Invoices?

#

the request you mentioned is simply an Invoice creation. That has no payment attempt, the invoice is not even finalized yet, so this is all expected

median isle
#

Understood. It is a rather confusing issue. Yes, that is what we are doing. Okay so for a customer to make a purchase for something unrelated to their subscription in real time, we would instead have to use payment intents?

agile fulcrum
#

No you don't have to, using Invoices is totally fine. But you have to understand the lifecycle of an Invoice first

median isle
#

Okay. I suppose that's the issue then. Okay so based on this invoice lifecycle, is it normal for the default payment to be null when an invoice is finalized? We have been able to finalize the invoice but payment is failing

agile fulcrum
#

yeah sorry you're mixing up many small things all together here. An Invoice can have a specific default payment method set up in the API. You can pass default_payment_method: 'pm_123' on creation if you want and in that case in the response it will have default_payment_method: 'pm_123' too. If you don't pass it, then it's null.
If it's null (most common case), it will attempt to use the Customer's global default payment method for Invoices as set up in invoice_settings[default_payment_method]

median isle
#

Oh okay. Understood

#

So once the invoice is in step 3 (status is open), how do we get the payment to go through? We set the option for charge_automatically but the invoice in question has remained open

agile fulcrum
median isle
#

Ah okay. Thank you so much for your help. Following your advice, we were able to get it to work using the CLI. Thank you so much for all of your help. Both you @agile fulcrum and @mild isle, I truly appreciate it