#Nadiya-subscription
1 messages · Page 1 of 1 (latest)
Hi! If you set the default_payment_method for the customer or subscription, then the following payments for the subscription should be done automatically.
Could you share a subscription ID where this happened (sub_xxx)?
sub_1KRaGQKWW6Esfew4fZnDXsVx
This subscription belongs to a customer without a default payment method set, so it's expected that the following payment will fail.
So you need to set invoice_settings.default_payment_method on the customer 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.
should i set 'default_payment_method' here?
You can either set the default payment method on the customer or on the subscription.
You can see an example of this in the documentation here: https://stripe.com/docs/billing/subscriptions/build-subscription?ui=elements#default-payment-method
actually its ok to fail for the past subscriptions (as we're on test mode now). but would like to have future subscriptions work properly
thanks, let me check
Yes, everything is explained in the doc I shared above.
To summarize:
- listen to the
invoice.payment_succeededwebhook event - update the
default_payment_methodof the subscription
well.. i'm in a situation where i can't use webhook
In that case I would recommend to create subscriptions with Checkout Session, that will automatically set the default payment method for you.
Here's the documentation: https://stripe.com/docs/billing/subscriptions/build-subscription?ui=checkout
The other option would be to run a cron at the end of every day, to find all new active subscriptions, and set their default payment method.