Search code examples
node.jsstripe-payments

Pay for subscription and one-time item at once in Stripe


A buyer wants to purchase a monthly pass (which is subscription $10/month) and some other item (which is one-time item $5). They get a total of $15, enters their credit card data, frontend gets stripe token, and then backend needs to generate payment. It supposes to charge them $15 this time and $10 every following month.

How to process it as one single purchase? Is it possible? If not, should I disallow to pick subscription and regular item to be in a cart at the same time?


Solution

  • There are a couple ways you can accomplish this. Which one you choose depends on whether or not you want to use Stripe Checkout.

    Checkout

    Checkout allows you to "mix" the items in a single Checkout Session to include both one-off and subscription prices - mixed cart.

    You can even use Checkout Sessions in an embedded form so you don't have to redirect users away from your site.

    Non-Checkout

    However, if you don't want to use Checkout Sessions, then you will need to create Subscriptions with the add_invoice_items parameter. The API reference describes this parameter as

    A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.

    What this means is, the items you add here will only be appended to the next Invoice associated with this Subscription. For new Subscriptions, that's the first Invoice. That way you can bundle recurring prices and one-off prices on the same Invoice.