Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Plans Laravel Package

lacodix/laravel-plans

Laravel package to manage SaaS plans, addons, subscriptions, and optional features. Supports countable/uncountable features with limits, resets, and consumption across plans, plus translations, ordering, and metadata—billing/invoicing not included.

View on GitHub
Deep Wiki
Context7

title: Billing weight: 10

As mentioned multiple times, this package doesn't care about billing. It doesn't create invoices nor takes care about payment. But you can use all information of this package to feed the invoice and billing system of your choice.

First of all you can use our events to get information about new and renewed subscriptions. When receiving such an event you can react on it.

// Create a Listener for the SubscriptionRenewed event

class CreateInvoice
{
    /**
     * [@param](https://github.com/param) Subscription $subscription
     */
    public function handle(Subscription $subscription): void
    {
        // Get Period start
        $subscription->perid_starts_at;
        
        // Get Period end
        $subscription->period_ends_at;
        
        // Get Prices
        $subscription->plan->price;
        $subscription->plan->signup_fee;
        
        // Optional usages with meta-data of plan
        $subscription->plan->meta['price_per_token'];
        
        // Optional usage with meta-data of subscription
        $subscription->meta['price_per_token'];
        $subscription->meta['discount'];
        
        ...
    }
}

You are free to use all this data to do your calculation and create an invoice for your users.

Sugar

Usually there is a simple use case. All your plans have a price, and you want to bill this price everytime the subscriptions are renewed with one single exception: the beginning of the subscription when you might need to bill only a partial month.

This package provides you with the necessary functionality to receive all this information.

    $subscription->calculatePeriodPrice();

This function returns the price for the current period. In a normal renewal this will just be the price given by your plan. But on the first month it will calculate the percentage depending on the real usage of the month. By default prices are calculated with 2 decimals but you can change that by configuration.

This function also takes in account possible trial periods - so if a trial ends in the middle of the period or even after it, you will receive 0 or a partial price.

Calculate on your own

In some cases you might have your own type of calculation based on metadata or other information. In such cases you can just receive the percentage of the period (it will also take in account potentially given trial times):

    $part = $subscription->calculatePeriodLengthInPercent();
    
    // Now you can calculate your own price
    $plan = $subscription->plan;
    $fullPrice = $plan->price + ($userCount * $plan->meta['price_per_user']);
    $amountToPay = round($fullPrice * $part / 100, config('plans.price_precision', 2));
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours