adamgy
adamgy

Reputation: 5583

Is there a way to avoid creating "status: incomplete" subscriptions during Stripe Checkout?

Background:

When creating subscriptions through the Stripe API, you can use payment_behavior: error_if_incomplete when you want Stripe to return an HTTP 402 status code in case a subscription’s first invoice cannot be paid. In this case Stripe does not create a subscription at all if the payment fails.

Question:

Is there a way to achieve the same behavior when using Stripe Checkout?

My experience is that even if the payment fails, Stripe creates a subscription with status: incomplete which is then expired if no successful payment is made within 23 hours. I've checked the parameters for creating Checkout Sessions but found no option to set payment_behavior there.

Sources:

https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior https://stripe.com/docs/api/checkout/sessions/create

Upvotes: 2

Views: 3922

Answers (1)

RyanM
RyanM

Reputation: 2960

Bad News

Unfortunately this is not something that can be configured presently. When Checkout creates a subscription, all the parameters not provided directly are set to the Subscription default. The default payment_behavior for a Subscription is default_incomplete.

Good News

You can achieve this behavior using Webhooks. You would listen for the invoice.payment_failed event, check the billing_reason property of the invoice is subscription_create (identifies the first invoice of a new subscription), and then cancel the related subscription.

If you are using Subscriptions and Invoices, it is recommended you use webhooks anyway to keep track of changes in status.

Upvotes: 2

Related Questions