#jm - Subscription Payment Method

1 messages ยท Page 1 of 1 (latest)

echo nimbus
#

Hi ๐Ÿ‘‹
The invoice has an associated payment intent with a client secret you can use.

granite dawn
#

Is that the same method to update the subscribed client's default payment method?

echo nimbus
#

If that is not what you are looking for then perhaps you could explain your scenario in more detail?

granite dawn
#

Oh I see... so in order to update the payment method, I need to:

  • Create a new intent with the client id and payment method (backend)
  • Add the new card to the intent (frontend)
  • Update the subscription with the subscription id and the payment intent method (backend)
  • Bill the next cycle using that subscription that has linked the client and payment method, thus creating the new invoice for that billing

Am I right?

echo nimbus
#

It depends on what you want to accomplish. Where in the billing cycle is the customer updating the payment method?

granite dawn
#

It could be at any moment, I plan to add an "update payment method" on their use's portal, so they can update the payment at any moment (without changing the plan)

echo nimbus
#

Yikes, sorry for the delay

#

Okay so you are using the Customer Portal for this update?

granite dawn
#

It's ok.
Nope, I am not using the customer portal, I plan to create a custom one

hexed elk
granite dawn
#

But I am not using the customer portal. Can I change the invoice default payment whenever I see fit?

wise barn
#

Hi ๐Ÿ‘‹ jumping in as my teammate needed to step away. Yes you can. Naturally it makes sense to do so when your customers are expecting you to, but you're in control of the Customer object and can update it as you see fit.

granite dawn
#

Nice, then, what would be the recommended way, updating the customer invoice's default payment method or updating the subscription's default payment method?
stripe.customers.update vs stripe.subscriptions.update
I suppose both require an intent with the payment_method and client attached

wise barn
#

Yes, both require you to provide the ID of a payment method that has already been created (based on the flow you're describing sounds like this will be done via a Setup Intent).

Which to use will depend on your flow. If a subscription has a default_payment_method set, then that takes precedence over the settings on the customer record. So if default_payment_method was previously set on a subscription, then that subscription will explicitly need to be updated.

If a subscription doesn't have a default_payment_method or default_source set, then it will fall back onto information from the customer record. So if your subscriptions don't have a default_payment_method specified then they'd pull from the customer's invoice_settings.default_payment_method.

Which you should use is going to fluctuate depending on your exact scenario and what you're trying to accomplish. For example, setting this at the customer level requires less updates when the payment method is changed if the customer has a large number of subscriptions, but setting it at the subscription level allows for more granular control over how each subscription is paid for.

granite dawn
#

Wow... great info, thank you.
For case, each customer will have only 1 subscription

scenic moth
#

@granite dawn did you have more questions?

granite dawn
#

Not right now, I am reading the links you guys shared. Thank you ๐Ÿ™

#

Oh yes, one more question!
Do I need to retrieve the latest created intent in order to send it to the frontend and setup Elements, so I can update the payment method, or is it ok to just create a new Intent on the fly with the customer's id (backend) and send it to the frontend?

scenic moth
#

you can create it on the fly though it's best to use the one that hasn't been confirmed yet

granite dawn
#

How can I retrieve the last that hasn't been confirmed?