Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jannevuori's avatar

Cashier subscriptions and changing VAT rate

I am trying to figure out what to do for subscription based Laravel application which uses the Stripe via Cashier. There are subscriptions that are monthly billed and some of them has been running for many years. The tax has been added to the subscriptions via User-model taxRates() method.

Now the VAT rate will be changed at the beginning of the September. I am wondering if I have understood correctly what should I do to get the current subscriptions to use the correct tax rate when September starts.

  1. We need to start using the Stripe tax (it is not in use yet)
  2. Then we will follow the instructions here: https://docs.stripe.com/tax/subscriptions/update to get all the needed prices, products and subscriptions updated

If someone has done this previously you may help me. Most or maybe all of the users locations are known so hey should be able to be taxed. Will this be automatically done once the Stripe Tax is activated for the given subscriptions/prices in Stripe or should we still do something via the Stripe API for each existing subscription?

Currently the prices are defined as tax exclusive. I think that this point it would be reasonable to change to use the inclusive version as it will be much more easier to understand for the Stripe admin. When that is taken into use the taxRates() method in the User model will be obsolete in our case I think.

Any comments or experiences are welcomed!

0 likes
2 replies
LaryAI's avatar
Level 58

To handle the change in VAT rate for your subscription-based Laravel application using Stripe via Cashier, you need to follow a few steps to ensure that the new tax rate is applied correctly to all existing and new subscriptions. Here’s a step-by-step guide to help you through the process:

Step 1: Enable Stripe Tax

First, you need to enable Stripe Tax in your Stripe dashboard. This will allow Stripe to automatically calculate and apply the correct tax rates based on your customers' locations.

Step 2: Update Your Prices and Products

You need to update your existing prices and products to use the new tax rates. Follow the instructions provided by Stripe in their documentation: Stripe Tax - Update Subscriptions.

Step 3: Update Your Laravel Cashier Configuration

In your Laravel application, you need to update the taxRates method in your User model to reflect the new tax rate. However, if you are switching to using Stripe Tax, you might not need this method anymore. Instead, you can rely on Stripe to handle the tax calculations.

Step 4: Apply the New Tax Rate to Existing Subscriptions

You need to update the existing subscriptions to use the new tax rate. This can be done using the Stripe API. Here’s an example of how you can do this in Laravel:

use Stripe\Stripe;
use Stripe\Subscription;

Stripe::setApiKey(env('STRIPE_SECRET'));

$subscriptions = Subscription::all(['status' => 'active']);

foreach ($subscriptions as $subscription) {
    Subscription::update($subscription->id, [
        'default_tax_rates' => ['new_tax_rate_id'], // Replace with your new tax rate ID
    ]);
}

Step 5: Change Prices to Tax Inclusive (Optional)

If you decide to change your prices to be tax inclusive, you need to update your pricing logic accordingly. This means that the prices you set in Stripe should include the tax amount.

Step 6: Test the Changes

Before rolling out the changes to all your customers, make sure to test the new tax rates and pricing logic in a staging environment. This will help you catch any issues before they affect your live customers.

Step 7: Communicate with Your Customers

It’s a good practice to inform your customers about the upcoming changes in the VAT rate and how it will affect their subscriptions. This can help avoid any confusion or disputes.

Example of Updating the User Model

If you decide to keep the taxRates method for any reason, here’s an example of how you might update it:

class User extends Authenticatable
{
    use Billable;

    public function taxRates()
    {
        // Return the new tax rate ID
        return ['new_tax_rate_id']; // Replace with your new tax rate ID
    }
}

By following these steps, you should be able to smoothly transition to the new VAT rate and ensure that all your subscriptions are correctly taxed. If you have any specific questions or run into issues, feel free to ask for further assistance.

jannevuori's avatar

Larrys answer was somewhere in between. What actually needed to do was this:

Cashier needed to be updated to version 13 from 12. This has been the main reason why the Laravel is now at version 9. Now we can proceed with the Laravel upgrade as well. The cashier update has been pending because I knew that there were old stuff out there with the taxes etc.

The Stripe Tax was forced to be taken into use as there were no chance to add new prices with the tax configuration the same way it used to be. Or at least I did not find a way to do it.

Those above steps meaning that the taxRates-method was removed from the user model and th calculateTaxes() was added to the appServiceProviders boot method.

And what happened to the old subscriptions. I created a command that used Stripe API to fetch all the active subscriptions and then updated the country to every subscriber on Stripe and then cleared out all the tax rates from the existing susbscriptions (as well as from all of the $subscription->items->data) Then updated the subscription with the new price and removed the default tax rate and enabled the automatic tax behavior (and proration was set to none at this point as it gave odd results on staging when testing this script)

This seemed to do the job correctly. Countless tries and errors on the way to the solution. The hard part seemed to be the ongoing subscriptions with the manual tax rate that prevented the automated tax to be taken into use. If you face one of these errors then this might help: "Error: One or more prices has a tax_behavior that conflicts with the tax rates that apply to the corresponding line item." "Error: Manual tax rates cannot be used when automatic_tax[enabled]=true."

Hopefully this helps someone who is juggling with the same issue.

Please or to participate in this conversation.