Cashier Stripe: Metered Billing and Stripe Checkout Support

Feb, 8 2021

Today we are excited to announce that Cashier Stripe has received some long anticipated updates, including support for Stripe Checkout as well as support for Metered Billing subscription plans.

Stripe Checkout

Stripe Checkout makes it a cinch to implement a way to bill your customers in without writing the billing UI implementation yourself. Simply define the products and prices in your Stripe dashboard and let your customer go through the checkout flow using Stripe's hosted checkout page:

$checkout = Auth::user()
        ->newSubscription('default', 'price_xxx')
        ->checkout();

return view('your-checkout-view', [
    'checkout' => $checkout,
]);

More information about using Stripe Checkout with Cashier can be found in Cashier's documentation.

Metered Billing

Using Metered Billing, you can invoice customers based on their usage, rather than a fixed recurring amount. For example, an email delivery service might charge customers per 10,000 emails sent by their account.

To get started, you simply start a new subscription:

$subscription = Auth::user()->newSubscription('default', [])
                    ->meteredPlan('price_metered')
                    ->create($request->paymentMethodId);

Then, you may report the customer's account usage via the reportUsage method:

Auth::user()->subscription('default')->reportUsage(15);

More information regarding metered billing can be found in Cashier's documentation.

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.