Search code examples
stripe-paymentspayment-method

What does the `payment_behavior: 'default_incomplete',` line does to invoices in stripe?


I'm trying to sort out how, when creating a subscription, stripe generates invoices with no payment method attached to them and yet able generate a client_secret through a payment intent. Does the payment_behavior: 'default_incomplete' field in subscription creation affects the invoice in any way ?
I am asking this because I want to understand how one can get a client secret (for payment elements) to pay one-off payments. Would it work to finalize an invoice without a payment method and then retrieves a client secret from the expanded invoice payment intent? Or does the 'default_incomplete' option somehow affects the subscription's first invoice to make it possible to retrieve a client secret?


Solution

  • If you are accepting one-time payments, the simplest option is to create the PaymentIntent directly yourself via the API. You configure the amount and currency and any other relevant information. Then you get the client_secret to your client so that you can collect payment method details client-side securely and confirm the PaymentIntent.

    You can create an Invoice if you prefer and want to use the Invoicing product though. This is definitely compatible. After creating an Invoice and the relevant line item(s) you then would finalize the invoice via the API which would create a PaymentIntent for the correct amount that you could get the client_secret for. It won't attempt payment synchronously on finalization and let you confirm client-side easily.

    There's no relation to the payment_behavior: 'default_incomplete' parameter for subscriptions really. This parameter allows you to create a Subscription without attempting a payment synchronously and defer this first payment attempt to the client. It's specific to subscriptions and has no real impact on the invoice itself.