#rishikhan-failed-payment
1 messages ยท Page 1 of 1 (latest)
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
hi
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
It can be, how are you creating these subscriptions?
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.
Since it sounds like you've separated the collection of the customer's payment method and the subscription creation, you'll want to either:
- Set the customer's
invoice_settings.default_payment_methodto the created payment method
or - Set the
default_payment_methodon to the created payment method when you're creating the subscription:
https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
For the first question, it depends on what the customer selects as their default method as mentioned here:
https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#update-payment-method
ok. thanks!
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.