How to reset monthly SaaS usage on an annual Stripe plan? - node.js

I am currently in the process of creating the billing system for my first SaaS. A simple tool to generate videos. There will be a free, mid, and pro tier. The main difference will be the number of minutes you can generate per month.
I created 3 Stripe products for the tiers. The free product consists of one price ($0) with a monthly charge interval. The mid and pro tier consists of 2 prices, a monthly and annual charge interval.
When a user signs up for an account, my backend automatically creates a Stripe customer and subscribe it to a free plan. A user can upgrade their account to a mid or pro tier. The plan will be downgraded to a free tier when the user cancels or if the payment failed.
I reset the number of available render minutes after each successful payment, at the start of the billing month. I do this by listening to the successful payment Stripe webhooks. Even when the user is on the free tier, the webhook still gets fired since it is a plan.
The problem is that this method would not work for annual plans.
Which made me think that the method that I went for may not be the correct one.
Do you know if this is a good method if there is a better one and if there is a workaround for annual subscriptions?
Thank you very much for your time.

I think for the annual billing you'll likely want to just set up a cron job or similar that runs daily, and that looks at which annual subscriptions' 'billing day anniversary' (i.e., billing date is Aug 7, so billing day anniversary is the 7th of each month) and resets the counts - unless it is the billing date, in which case leave it to your webhook.

Related

Best way to model my mixed monthly/yearly subscription with Stripe payments

The subscription plan
I have a subscription plan available at my app which I need to model with Stripe.
The subscription plan details are the following:
A fixed amount of $20/month or $200/year (discounted) that the user must pay.
With the previous fixed amount the user can consume 2500 units of the product per month.
If the user consume more than 2500 units in one month every additional unit has a value of $0,01.
Examples
A user choose the subscription plan with the $20/month option and in the first month he/she consumes 2520 units.
The total amount to pay for the first month of the subscription for this user is:
$20 fixed amount
20 additional units * $0,01 = $0,2
Total to pay: $20 + $0,2 = $20,2
A user choose the subscription plan with the $200/year option. In the first month he/she consumes 500 units. In the second month he/she consumes 5000 units.
For the first month this user needs to pay:
$200 because is starting the subscription
No additional units.
Total to pay: $200
For the second month this user needs to pay:
No fixed amount because the fixed yearly quantity has already been paid.
2500 additional units * $0,01 = $25
Total to pay: $25
Problems
My biggest problem modeling this with Stripe payments is that is not possible to have prices with different intervals in the same subscription.
If the user chooses the yearly fixed price is not possible to create a subscription on Stripe that has a fixed yearly pay (of $200 in this case) and a monthly graduated price (for the additional consumed units).
I have seen that the subscription upsell feature is something very similar to what a I need. But once it's activated I can't find any way on the API to enable it when the subscription is created (I'm not using checkout).
I have seen also that it's possible to create two subscriptions, one for the yearly pay and another one for the monthly units. But creating two subscriptions make everything really difficult, you need to take into account two subscription states and callbacks are more difficult this way too.
Questions
What is the best and simple way to model this subscription plan using Stripe?
Note: I'm doing a custom integration with Stripe, so the subscriptions and customer are created via API. I'm not using Stripe checkout.
My biggest problem modeling this with Stripe payments is that is not possible to have prices with different intervals in the same subscription.
Indeed, you can't combine Price objects with different intervals on a single Subscription. Otherwise, this pricing is possible by combining a flat rate fee with metered usage as outlined here.
Your best option in cases where your customers elect for the annual fixed fee is to roll with a single usage based Price and amend the initial invoice to include that a one-off Invoice Item for the annual fixed fee.
I have seen that the subscription upsell feature is something very similar to what a I need. But once it's activated I can't find any way on the API to enable it when the subscription is created (I'm not using checkout).
Subscription upsells are a Checkout only feature right now. However this is not really related to the problem you're facing (it just provides a UI for your customers to upgrade to an annual Price for the same Product).

Recurring billing with Stripe - will Subscriptions suffice?

My application allows a customer to purchase credits for later in-app use.
I want to enable customers to buy credits throughout the month, and only get billed at the end of the month.
Should I be using a Stripe Subscription at an amount that equals the price of one credit, and change the quantity according to the number of credits the customer purchased?
(After a successful invoice - I'll reset the subscription quantity to 0)
Is there a better solution? Perhaps some clever method of using Stripe Checkout?
Your proposed approach sounds reasonable.
I've not tried it but an alternative I can think of would use a free plan and the Invoice Items part of the API.
Create a free plan with amount with amount field set to 0. As far as I can see from the docs, all the subscription lifecycle webhooks should be triggered for Customers who're subscribed to the plan.
Through the month, create InvoiceItems for the Customer. According to the docs, at the end of the billing cycle, those InvoiceItems are added to the customer's invoice.
Sometimes you want to add a charge or credit to a customer but only actually charge the customer's card at the end of a regular billing cycle. This is useful for combining several charges to minimize per-transaction fees or having Stripe tabulate your usage-based billing totals.
Beyond that, you'll want to consider if you should have Stripe generate/email your invoices.
I don't think this is the way to go, because subscriptions are billed the first time among other things.
The recommanded way is: stripe doc: Place a hold on a card
summary
You first ask authorization for a certain amount (the max amount). Eg: 1000$
Your custommer buy 50 credits in the month
At the end of the month you charge the customer for 50$ (it can not be greater that the maximum you authorized in the first step)
That's all :)

Stripe Payments Charge

Is it possible to control the charge date in Stripe? For example, we need to charge:
One-time charge ($5) that needs to be charged on the purchase date.
One-time set up fee ($99) that is charged after 30 days from the purchase date.
Recurring charge ($79) that needs to be charged at the end of the term (It can be either Monthly or recurring)
Is that possible to have all these charges in the same subscription? If so how to do it with Stripe APIs?
When you set up a subscription with Stripe, you define price and interval they are charged. There is an option to have a trial period, so that you can have the first charge delayed - but beyond that there are not other options. Note that subscription plan details (price, interval, etc.) are, by design, not editable
In order to implement the business rules you have listed, you will need to implement that yourself. You can do so by:
create a subscription plan with X day trial (I'm not 100% sure if that's what you mean by 'to be charged at the end of the term').
creating the customer and saving a card for that customer.
charge the one-time charge on the purchase date.
start the subscription for the user on the purchase date (or 30 days later, depending on what is meant by 'end of the term').
then charge the 'set up fee' charge 30 days later.
There may be some services (such as Azure's Logic App Service) that could help you implement this business process but you won't be able to do it with just Stripe.

Stripe subscription upgrading and downgrading.

This question is for anyone who's experienced with Stripe. I've run into a situation that may be pretty specific, but I'm hoping I could get some help with. I am creating a system where a user can pick from many different options and set up a yearly subscription based on their selections. So there is no set plan cost, the subscription cost is variable.
Now, if someone creates a subscription for $100.00 dollars, then in a month decides next year they'd like to reduce their subscription to $50.00 they can do so. However, they will not receive a prorated refund due to the downgrade for the current subscription period. My issue is, let's say they change their mind and realize the $100.00 service is worth it. So much so they actually want to change their subscription from $50.00 to $120.00 in the current subscription year. I would like to charge them a prorated fee, but if I do that they will be charged for the difference of $50.00 and $120.00, not $100 (which they paid originally) and $120. Is there anything I can do to allow for such a situation to occur?
I'm thinking that in order to make this work I'll have to implement the calculation of a proration amount myself. So in the case a user pays for a $100 subscription, downgrades to $50, and then sometime later in the same year upgrades to $120.
The solution I see is to save the maximum amount they've paid for their subscription in my local database record. When they upgrade, if their new plan cost is greater than the maximum they've paid, I need to set their stripe subscription to the new amount without proration, then calculate the difference between the max they've paid and the new plan amount, prorate the cost and charge them manually using a stripe charge. Kind of a roundabout way to do it but it accomplishes the goal as far as I can see at the moment.

Google wallet annual recurring subscriptions?

According to the documentation Google Wallet seems to only support monthly recurring subscriptions.
I'd to charge users annually for the use of an application hosted on AppEngine (purely to be able to offer the user a better price and reduce administrative costs). Are there any plans to support annually recurring subscriptions?
Or is there a way to configure the current subscription system to behave as an annual subscription system?
Technically there's no way to configure an annual subscription. But I suppose you can work around it: Request an initial payment for the entire first year and then a monthly-recurring payment at a discount.
For example, suppose you offer a monthly plan that costs $100. And you want to offer an annual plan for $900 (25% discount). Instead, you may offer an initial payment of $900 followed by 36 monthly-recurring payments of $75.
What this means for your business is that once a user has paid for and used your service for an entire year then you start treating her as a "loyal customer" and let her keep paying the discount price without committing for another year.
Wallet for Digital Goods currently only supports a monthly frequency for subscriptions.
https://developers.google.com/commerce/wallet/digital/docs/jsreference#jwt
there is no official solution for an annual subscription, but you could implement a solution similar to what #oferei or #EdSF suggested in their posts.

Resources