Pausing and unpausing a payment collection on stripe - stripe-payments

I'm working on stripe subscription and trying to build a flow using which admin can pause and unpause the payment collection of customers.
To achieve this I'm using this from stripe documentations.
Now the major issue which I'm facing with this method is.
Suppose a customer is on monthly subscription and is billed on 1st of every month.
Admin has paused the customer's billing on 15th October and Unpaused it on 15th November.
Now the upcoming invoice shows that customer will be billed on 1st December for the upcoming cycle.
My questions are:
Is there any way I can charge customer for the period of 16th-30th November which customer used.(Somehow adjusting amount on the 1st December invoice)
And the period of 16th-31st October, for which Customer has already paid on 1st October, can be uncharged/adjusted somehow.
Thanks

Instead of pausing, which does not take into account prorated amounts or credits, I recommend canceling the Subscription instead of pausing it. You can use the prorate parameter when canceling Subscriptions to issue a credit to the Customer for the unused time.
Later, when you want to resume payments, create a new Subscription for the Customer and specify a billing_cycle_anchor set to the first of the month. That will charge them for the partial month up front followed by full monthly Invoices starting on the first of every month.

Related

Stripe subscription set billing date as first of each month

I'm using Stripe Checkout flow to collect the users' payment details and automatically collect the subscription. I have also implemented webhooks to listen to checkout.session.completed so that I can edit the subscription. What I want is as follows:
Say, the user registers on January 15th. I'm using metered billing, so the user pays $0.00 on the first invoice.
In webhooks, I apply a trial period of 7 days to the subscription like so stripe.subscriptions.update([id], {trial_end: [seven_days_into_future]}). So the billing anchor date on the subscription becomes the 22nd of each month.
However, I would like to set the billing anchor date as the first day of each month. So I would like the user to receive the first invoice for January 22-31 (prorated), and then get invoices for full calendar months onwards.
How do I achieve that?
I cannot set the billing_cycle_anchor to the desired date because it accepts only now and unchanged values...
If you're working with already created subscriptions, then you'll need to add trial periods to shift the billing_cycle_anchor:
https://stripe.com/docs/billing/subscriptions/billing-cycle#using-a-trial-to-change-the-billing-cycle
If you know exactly how you want to structure your trial and billing_cycle_anchor at the time the subscription is being created, then you can future-date the billing_cycle_anchor during creation:
https://stripe.com/docs/billing/subscriptions/billing-cycle#new-subscriptions

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.

Stripe - after changing plan, don't bill for the new subscription until current cycle ends

I want to let user to change their subscription plan. However, they won't be refunded after switching. If i set the prorate to false, stripe will bill for the new subscription right away.
For example, if the user is subscribed to a yearly plan in Jun 2018, and wants to change to monthly in Oct 2018. They will be charged with monthly plan after Jun2019, as current cycle hasn't ended yet.
How can I do with stripe api when i am updating the current subscription?
in the stripe api docs (https://stripe.com/docs/api/subscriptions/update)
"if you set prorate to false when switching between different billing intervals (monthly to yearly, for example), we won't generate any credits for the old subscription's unused time—although we will still reset the billing date and will bill immediately for the new subscription."
In 2019 Stripe shipped support for Subscription Schedules which allow you to control multiple sequential phases on a Subscription. You can read more about this in the docs: https://stripe.com/docs/billing/subscriptions/subscription-schedules
With this API, you can now explicitly schedule a future change of a Subscription. The idea would be to use the Create SubscriptionSchedule API a schedule from your Subscription and plan a second phase to move the Subscription to the new price on the next billing cycle.
Past answer, which still work but less optimized:
One solution for this would be to follow those steps:
Mark the current subscription to cancel at the end of the current period so that you don't attempt to charge that customer again.
Create a new subscription to the monthly plan but put the customer on a trial period until the end of the current subscription (June 2019 in your example). This allows you to not charge him until the other subscription ends so that you switch the customer to the monthly plan as expected.

Stripe Start Date

How do you set the start date for a subscription? Many of our customers began using our service a few days before we could collect their payment information so we'd like to charge them for these additional days.
This is not something that the Subscriptions API supports today. You would need to charge your customer the full amount and then put them on a trial period until their next billing date.
The flow would look like this:
Create a Customer with the card token
Create an invoice item for the plan amount
Create a subscription and set them on a trial period until their next billing date using trial_end
The last step will create an invoice for the trial, automatically pull the pending invoice item into the invoice and charge the customer for that amount. Then, they won't be charged until the date you set in trial_end and each month moving forward on that date.

Stripe annual billing but different set of months

I want to bit a customer on an annual basis but the billing should happen between August current year - July of the next year. Can this be done via webhooks or some other method on Stripe ?
You can update the subscription with the trial_end parameter to choose the next billing date (and prorate set to false).
When the "trial" ends, a new billing cycle will start and Stripe will attempt to bill the customer for the plan's amount.
More info about this: https://stripe.com/docs/subscriptions/billing-cycle#api

Resources