#rishikhan-failed-payment

1 messages ยท Page 1 of 1 (latest)

clever plume
#

Hi there ๐Ÿ‘‹ pasting your additional information for context

and on the website, it says the billiing method is 'default billing method'
but the customer has no default billing method

wicked gull
#

hi

clever plume
#

So it sounds like you have a customer that has a payment method attached to them, but that the payment method is not set as their default.

There is a parameter on the customer object that allows you to specify the default payment method for invoices:
https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method

wicked gull
#

is it usual to set the default method on a user? or is there a 'best practices' way to do this?

#

why wouldn't the payment method be attached to the subscription when it is first setup?

clever plume
#

It can be, how are you creating these subscriptions?

wicked gull
#

we go through a checkout session to get the customer payment info. Then we create a subscription like this:

// create subscription
s_params := &stripe.SubscriptionParams{
BillingCycleAnchor: stripe.Int64(billingAnchorDate.Unix()),
Customer: &stripeCustomer.StripeCustomerID,
Items: []*stripe.SubscriptionItemsParams{
{
Price: stripe.String(price_id),
},
},
PaymentBehavior: stripe.String("allow_incomplete"),
}
s, err := sub.New(s_params)

#

billingAnchorDate is the first of the month.

clever plume
#

Since it sounds like you've separated the collection of the customer's payment method and the subscription creation, you'll want to either:

  1. Set the customer's invoice_settings.default_payment_method to the created payment method
    or
  2. Set the default_payment_method on to the created payment method when you're creating the subscription:
    https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
wicked gull
#

ok. So I'm thinking the former is more robust. What happens if the customer goes iinto the customer portal and deletes the payment method and creates a new one?

#

And why is it that when there is only one payment method for a customer, it is not the default payment method?

clever plume
wicked gull
#

ok. thanks!

clever plume
#

The second part is a bit trickier to answer, but my assumption is that it's usually safer to avoid doing too many things 'automatically' and to allow our users to build the flow that is right for them.