Recurring billing with Stripe - will Subscriptions suffice? - stripe-payments

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 :)

Related

Stripe Refund Prorated on Quantity of Days Subscriptions

My goal is this: sub service started to experience issues on 11/9. Instead of pausing payments immediately, I let a few weeks go by. I now want to refund the cost incurred to each user based on the prorated cost for the number of days of bad service. So refund each user 19 or 20 days based on their current subscription. Is there a way to do this via API?
It get's so complex with the past month's proration on the bill. It's a nightmare and this would save me so much time. Willing to compensate. Thank you.
I havent been able to try anything yet.
You can issue a partial refund by specifying an amount less than the original amount of the payment being refunded using the Stripe API. You would specify the payment_intent belonging to the Subscription Invoice in question (which you can find on the Invoice object).
However, you need to calculate the amount you wish to refund on your end based on the amount you want to refund for each Subscription.

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).

How to reset monthly SaaS usage on an annual Stripe plan?

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.

Programatic shipping and taxes with Stripe Subscription

I would like to use Stripe for a physical subscription site.
Small number of SKUs
Some customers pick up instead of ship
Customers whose addresses are in one state are charged state and local sales tax
I'd like to use Stripe Subscriptions to do this but shipping costs and state/local taxes will be slightly different for every single customer and but unlike in the Stripe Orders API, it does not look like Subscriptions allows for me to dynamically calculate shipping and taxes. Is my reading of this correct, or is there a way for me to programatically edit recurring shipping and taxes on a per-subscription basis?
Thank you!
Answer via #mattwc in #stripe freenode: An invoice is created by the subscription each period 1 hour before it is charged. You can subscribe to this event via webhook and edit the invoice to add shipping and tax information.

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.

Resources