Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Membership subscription using stripe with dynamic plans

We use stripe for our payment gateway.

We have X products in different currencies that we want to keep for subscription. The user can choose any combination of these X products and pay the membership price (monthly) and use the combinations they have opted for.

Therefore the plan can be any random number with the currency that the customer opts to pay for. The cost for monthly plan will be generated once the user chooses the product. For eg: when choosing 2 different products only the pricing can be X1 + X2 = X3 which could result in any number $5.9, €10, £99.89 etc.

How are plans created in such cases which can handle multiple currencies?

There are couple of options to do this but I am looking for a very elegant way to solve this problem

Options 1: Creating a plan on the fly can be one option but there will be one plan per customer which will end up being too many plans and eventually clutter up the dashboard.

Option 2: Stripe also provides a quantity option but not quiet sure it will be very helpful in this case.

like image 294
girish Avatar asked Feb 07 '23 12:02

girish


1 Answers

What I usually recommend here is to build the logic on your end instead. You keep track of the "plans" the customer is subscribing to so that, each month, you can modify their invoice and charge them the expected amount. The idea is to subscribe all customers to a $0 plan so that you decide that amount each month.

For this, you'd use Invoice Items that can be added to an invoice and appear as a line item on the email receipt. You would then use Stripe's webhooks to be notified about events that happen in your Stripe account. That way you can listen for the invoice.created event and create an invoice item for this invoice to change the amount billed to this customer. You could also create multiple items (one per plan) to clearly outline what's being paid.

You'd need to follow this flow:

  1. Create a customer in Stripe with the card token.
  2. Create the first Invoice Item(s) for the first invoice (always closed by default).
  3. Create the subscription to the $0 monthly plan => automatically bills the Invoice Item(s) created before.
  4. Each month, listen for the invoice.created event and create new Invoice Item(s) for the correct amount.

The caveat is that you have to handle proration on your end in that case but that allows someone to add an extra option without having to figure out how to move them to a new custom plan and all that entails.

like image 113
koopajah Avatar answered Apr 27 '23 14:04

koopajah