Stripe Subscriptions - Create even if first billing attempt fails

486 Views Asked by At

On Stripe's API docs the value returned when attempting to create a subscription on a customer is described as follows:

The newly created subscription object if the call succeeded. If the customer has no card or the attempted charge fails, this call returns an error (unless the specified plan is free or has a trial period).

From this, I am assuming that if the first attempted charge fails (and an error is returned) this means that the subscription has not been created?

I am wanting to be able to create subscriptions on customers who may not yet have any billing sources added and as soon as they add a billing source the first payment will be processed. Is there a way to accomplish this?

1

There are 1 best solutions below

3
On BEST ANSWER

From this, I am assuming that if the first attempted charge fails (and an error is returned) this means that the subscription has not been created?

Yes, that's correct.

I am wanting to be able to create subscriptions on customers who may not yet have any billing sources added and as soon as they add a billing source the first payment will be processed. Is there a way to accomplish this?

You could create a subscription with a plan for $0, or create a sub with a trial using trial_end to create a 'free' subscription.

As far as "as soon as they add a billing source the first payment will be processed." -- you'd need to create logic to handle this on your own. When a user adds a payment source you could update their subscription ending the trial (trial_end=now), or moving them to a paid plan.

https://stripe.com/docs/api#update_subscription