Change Stripe Subscription Price at end of current period - stripe-payments

I have a subscription setup for a user that has subscribed to the "pro" plan at $5 per month.
Halfway through the period, they decide they want to downgrade to the "basic" plan at $1 per month.
Current behavior immediately changes the subscription.
Does stripe have the functionality that would allow the actual change of plan to occur when the next billing cycle begins?
This would be similar to the cancel at billing period end when a subscription is cancelled.
From what I can tell, my application might have to handle this logic and make a no proration change close to but not after the billing period change.

You can update the subscription and set proration_behavior to none. This should keep the same billing cycle and charge the customer $1/month at the start of the next cycle: https://stripe.com/docs/api/subscriptions/update
You could also use Subscription Schedules, though that might be more useful if you had a few different phases to account for instead of a one-off update like this one: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#downgrading-subscriptions

Related

Finishing trial early in Stripe

I have a thirty-day free trial of my subscription in Stripe.
I want users to have the option of paying early, at which point their remaining trial days will be added to the end of their first billing term.
If I set the subscription's trial_end and billing_cycle_anchor to the current timestamp, will the user be invoiced immediately? Or would it be best to cancel their existing subscription and create another without a trial?
Then, I guess, put the remaining trial days on to the newly created billing_cycle_anchor and prorate=false?
Thanks

Stripe Proration - Pay Upfront?

Problem:
I had my first user upgrade to a higher priced subscription plan, under the proration settings, the user is set to be charged a higher amount next month ($84.95 instead of $67).
Question:
How can I charge the user the difference ($17.95) upfront, so they are charged this amount when they press upgrade, and then on the next billing cycle get charged just the normal amount ($67)
Is there an option to enable this in Stripe?
As ceejayoz mentioned, the solution here is to generate a one off invoice right after the upgrade.
Generating a one-off invoice pulls in any pending invoice items that would have been added to the regularly scheduled invoice.

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: Plan change after period ends

I have several customers subscribed to many other several Stripe plans on my website: These plans are all 'yearly' and have different subscribing amounts. Notice that I also have customers with a subscription status "active" and many others with "trialing".
Now, I need to automatically change their subscription plans to an unique new yearly plan, with a different subscription amount, at the end of their respective billing cycles.
I was looking for the properly event in order to do the change of plan programmatically within a webhook, but I don't know which to choose having both 'active' and 'trialing' subscriptions.
Any ideas?
I think invoice.upcoming the event will work for both trailing and active. subscription.
you can configure invoice.upcoming webhook to arrive 1 day before and modify customer's subscription and invoice.
invoice.upcoming : Occurs X number of days before a subscription is
scheduled to create an invoice that is charged automatically, where X
is determined by your subscriptions settings. Note the received
invoice object will not have an invoice ID.
Hope this helps you

Resuming a subscription with Stripe (and charging for previously unpaid service)

I have a web service which publishes and hosts certain information for my users. Each user's editing interface is separate from the information they've published. I'm billing for it using Stripe subscriptions, but I'm having trouble coming up with a workable way of handling unpaid subscriptions. Here's the logic I want to implement:
Upon the first failed billing attempt, my app should lock down the user's editing interface; instead, it should present them with a page with options for resolving their payment problem. However, information they've published will still be published, so a late payment doesn't interrupt things for their visitors.
Upon the last failed billing attempt, 15 days later, my app should remove information they've published as well. At this point, the user's editing interface is replaced with one that allows them to either re-activate their account with a new credit card, or completely delete the account.
If the user chooses to re-activate the account, they should not get a trial period
If the user re-activates, they should also have to pay for the 15 days they previously skipped out on, either by having their first billing period shortened by 15 days or by having a charge equal to 15 days' service added to their first bill.
#1 and #2 are very easy to implement if I watch for the right webhooks—just redirect requests for a delinquent customer, or a customer with a deleted or unpaid subscription, to a "fix this problem" page. #3 is pretty easy too—just create the subscription with trial_end set to now.
It's #4 that's tricky. How do I determine exactly how long the user's last invoice went unpaid before their subscription was canceled? How do I shorten the first billing period of the new subscription? Alternately, how do I pro-rate the customer's last invoice total to represent the portion that I actually provided to them, so I can add that amount to the new invoice? (I know I can create an Invoice Item to charge for the amount before I start the new subscription, so at least that's a possibility.)
Finally, does Stripe's "Mark Subscription Unpaid" option help with any of this? It looks like it keeps creating invoices but doesn't try to charge for them; I don't think that's what I want here.
You can definitely do all of that with Stripe's subscriptions. As you mentioned, the first two questions should be solved with webhooks. You would listen for invoice.payment_failedon your end to detect when a payment fails and immediately block you UI asking your customer to update their card details.
To update their card details you can use Stripe Checkout and just not set the data-amount parameter so that it doesn't display a price to your customer. Here is an example for this:
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_XXXX"
data-image="/square-image.png"
data-name="Demo Site"
data-description="Update Card Details"
data-panel-label="Update Card Details"
data-label="Update Card Details">
</script>
</form>
Each time your customer tries to update his card, you would use the Update Customer API and pass the new card token in the card parameter. This will delete the default card on the customer and replace it with the new one. It will also try and pay the latest invoice of each subscription in the "Past Due" state. In your case it means that the latest invoice still in retry mode will be attempted to be paid. This does not count as a retry and can be seen as independent. If it succeeds, you just reenable the UI otherwise you continue asking the customer to update his card details.
When you reach the fourth failed payment you will get a customer.subscription.canceled if that's what you set up in your retry settings in the dashboard. You can detect that it's an automatic cancelation by checking the request key on the event and making sure it's null. In that case you block the UI/account completely for your customer.
For the last 15 days, if I understood your flow correctly, the customer hasn't really been able to use your application since you locked down the UI partially. But if you still want him to pay for that amount, you should store in your database that the customer owes you $X for the 15 days he couldn't use the subscription.
Later on, your customer finally comes back and want to reenable his account. At that point you inform him that the payment flow will restart from today and that you will charge him for the extra 15 days he missed before. To do that, I would use Invoice Items which will allow you to add an extra amount to the first invoice automatically. You would follow those steps:
Create the invoice item for $X for your customer.
Create a new subscription to your plan setting trial_end to "now" in case you have a trial period set by default on your plan.
This will automatically create the first invoice for the plan amount and add the invoice item created before.
Another solution here would be to reopen their latest closed invoice that wasn't paid and use the Pay Invoice API. When this happens you know your customer paid you for a full month now instead of just the 15 days he owed you. In that case you would create a new subscription and set a trial period of 15 days so that he starts paying again after that trial.
I wouldn't use the "Mark as unpaid" option here because you completely lock the customer out of your application. This feature for me is to be used when you let your customer use your application and plan to charge him in a few months for each of the invoices. This would be used for an electricity provider for example who would keep your electricity on for multiple billing cycles and continue to try charging you for each invoice.
The amount your customer really owes you in that case is dependent on the number of retries you allow and the days between each retry. What you can do here is use the created value on the invoice and compare it to the current time when you get the customer.subscription.canceled to determine how much time passed and calculate the proration of how much your customer owes you at that point.

Resources