Cashier v11

Apr, 7 2020

We're very excited to announce the immediate availability of Cashier v11. This release of Cashier introduces support for Multiplan Subscriptions as well as Stripe's new Tax Rates feature.

Multiplan Subscriptions

Multiplan subscriptions allow you to assign multiple billing plans to a single subscription. For example, imagine you are building a customer service "helpdesk" application that has a base subscription of $10 per month, but offers a live chat add-on plan for an additional $15 per month:

$user = User::find(1);

$user->subscription('default')->addPlan('chat-plan');

Now the customer will have two plans on their default subscription. The example above will add the new plan and the customer will be billed for it on their next billing cycle. If you would like to bill the customer immediately you may use the `addPlanAndInvoice` method:

$user->subscription('default')->addPlanAndInvoice('chat-plan');

You may remove plans from subscriptions using the `removePlan` method:

$user->subscription('default')->removePlan('chat-plan');

If you would like to update quantities on individual subscription plans, you may do so using the existing quantity methods and passing the name of the plan as an additional argument to the method:

$user = User::find(1);

$user->subscription('default')
     ->incrementQuantity(5, 'chat-plan');
    
$user->subscription('default')
     ->decrementQuantity(3, 'chat-plan');
        
$user->subscription('default')
     ->updateQuantity(10, 'chat-plan');

Tax Rates

To specify the tax rates a user pays on a subscription, implement the `taxRates` method on your billable model, and return an array with the Tax Rate IDs. You can define these tax rates in your Stripe dashboard:

public function taxRates()
{
  return ['tax-rate-id'];
}

The `taxRates` method enables you to apply a tax rate on a model-by-model basis, which may be helpful for a user base that spans multiple countries and tax rates. If you're working with multiplan subscriptions you can define different tax rates for each plan by implementing a `planTaxRates` method on your billable model:

public function planTaxRates()
{
  return [
    'plan-id' => ['tax-rate-id'],
  ];
}

For more thorough information and examples of using these new features, please consult the Cashier upgrade guide as well as the Cashier documentation.

We hope you enjoy this release and use it build amazing applications!

By Dries Vints

Developer at Laravel working on the first-party open source libraries. Find me on TwitterGitHub or my website.

Follow the RSS Feed.