toneee
2 years ago

Stripe Billing Quantities

Posted 2 years ago by toneee

I am working through updating some of the billing in my application and have got a little stuck.

A user can buy 3 levels:

  • Bronze - Discount 0% - Quantity 1
  • Silver - Discount 10% - Quantity 5
  • Gold - Discount 25% - Quantity 10

If you assume 1 quantity is an email account that is active for that month.

I have 1 plan which is $10 and then its worked out with the quantity

  • Bronze is ($10 * 1qty) - 0% = $50
  • Silver is ($10 * 5qty) - 10% = $45
  • Gold is ($10 * 10qty) - 10% = $75

I understand that the first bill gets paid and discounted as soon as the subscription is selected.

$user->subscription('default')->updateQuantity($quantity);

When I used the updateQuantity it changes the quantity to the new one and prorates the cost but does not charge straight away. This will be prorated in the next billing cycle along with the next months billing at the new quantity.

The part i get stuck around is how do I check how many quantity (email accounts) can be active during the month. If i check the quantity in the db it will only show the updated quantity so if you move from bronze to silver it will show a quantity of 5, but in reality I should be able to have 6 as I have already paid for 1 active upfront, then at the end of the billing cycle for that month it should drop to 5.

This is more of an issue when a customer wants to downgrade and I am really not sure how to handle this.

I hope someone can help and I have explained it well enough :) Thanks!

Please sign in or create an account to participate in this conversation.