PHPackages                             ayangzy/laravel-sales-commission - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ayangzy/laravel-sales-commission

ActiveLibrary[API Development](/categories/api)

ayangzy/laravel-sales-commission
================================

A comprehensive sales commission calculation and management package for Laravel

v2.0.2(5mo ago)436MITPHPPHP ^8.2CI passing

Since Jan 10Pushed 5mo agoCompare

[ Source](https://github.com/ayangzy/laravel-sales-commission)[ Packagist](https://packagist.org/packages/ayangzy/laravel-sales-commission)[ GitHub Sponsors](https://github.com/ayangzy)[ RSS](/packages/ayangzy-laravel-sales-commission/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (7)Used By (0)

Laravel Sales Commission
========================

[](#laravel-sales-commission)

[![Tests](https://github.com/ayangzy/laravel-sales-commission/actions/workflows/tests.yml/badge.svg)](https://github.com/ayangzy/laravel-sales-commission/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/b0d67137c697f7fb19f65a5abaf37ddfb87f291458eca0cab5eb7190c531b08f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6179616e677a792f6c61726176656c2d73616c65732d636f6d6d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ayangzy/laravel-sales-commission)[![Total Downloads](https://camo.githubusercontent.com/9e5776793d1fec894a2d7f2e5f0875d146806f6aac0face791e3ab49c6d29d58/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6179616e677a792f6c61726176656c2d73616c65732d636f6d6d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ayangzy/laravel-sales-commission)[![License](https://camo.githubusercontent.com/c3eb0e012cf8f5069c84232c327ea273dd99d83496619c8fbf2fefa27fa65a75/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6179616e677a792f6c61726176656c2d73616c65732d636f6d6d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

What is Laravel Sales Commission?
---------------------------------

[](#what-is-laravel-sales-commission)

**Laravel Sales Commission** is a comprehensive, enterprise-grade commission calculation and management package designed specifically for Laravel SaaS applications. It provides a complete solution for businesses that need to track, calculate, and pay commissions to sales representatives, affiliates, partners, or any type of agent.

Unlike simple percentage calculators, this package handles the **entire commission lifecycle** — from initial calculation through clawbacks (refunds) to final payout processing. It's built to handle real-world complexity including team-based sales, tiered commission structures, and flexible payout schedules.

Whether you're building an e-commerce platform with sales reps, a SaaS with an affiliate program, or a network marketing application, this package provides the foundation you need without reinventing the wheel.

---

Key Features
------------

[](#key-features)

### 🎯 Flexible Commission Plans

[](#-flexible-commission-plans)

Create unlimited commission plans tailored to different agent types, products, or sales channels. Each plan can have its own rules, tiers, and payout settings. Perfect for businesses with diverse sales structures — one plan for in-house sales reps, another for external affiliates.

### 📊 Multi-Tier Commission Structures

[](#-multi-tier-commission-structures)

Implement progressive commission rates that reward high performers. Agents automatically move through tiers (e.g., Bronze → Silver → Gold) as their cumulative sales increase, unlocking higher commission percentages. This incentivizes continuous performance improvement.

### 👥 Team Split Commissions

[](#-team-split-commissions)

Handle complex team sales where multiple agents contribute to a deal. Split commissions by percentage with role tracking (primary closer, supporting rep, manager override). Ensures fair attribution when sales involve collaboration.

### 🔄 Clawback Support

[](#-clawback-support)

Protect your business when sales are refunded or charged back. The clawback system reverses commissions proportionally with configurable grace periods. Supports full clawbacks, partial clawbacks, and automatic clawbacks on refund events.

### 💰 Payout Management

[](#-payout-management)

Complete payout lifecycle management — generate payout batches, require approval workflows, process payments, and track payment status. Supports configurable payout schedules (weekly, bi-weekly, monthly) and minimum payout thresholds.

### 📈 Performance Bonuses

[](#-performance-bonuses)

Reward agents for hitting milestones with bonus rules. Configure one-time or recurring bonuses when agents reach sales targets, close their first deal, or achieve tier upgrades.

### 🎛️ Extensible Rule Engine

[](#️-extensible-rule-engine)

The modular rule system supports percentage-based, flat-rate, tiered, and conditional commissions out of the box. Need custom logic? Extend the base rule class to implement any commission formula your business requires.

### 📅 Period-Based Tracking

[](#-period-based-tracking)

All earnings are tracked by period (week, month, quarter) enabling accurate reporting, forecasting, and historical analysis. Easily query earnings for any time range.

### ⚡ Event-Driven Architecture

[](#-event-driven-architecture)

Hooks into Laravel's event system. Listen to `CommissionEarned`, `CommissionClawedBack`, `PayoutProcessed`, and `TierAchieved` events to trigger notifications, update leaderboards, or integrate with external systems.

---

Use Cases
---------

[](#use-cases)

### Who Needs This Package?

[](#who-needs-this-package)

Platform TypeWhy You Need It**E-commerce with Sales Reps**Track commissions per order, handle returns/refunds, pay reps monthly**SaaS with Affiliate Programs**Recurring commissions on subscriptions, clawback on cancellations**Marketplace Platforms**Split commissions between sellers, platform, and referrers**Insurance &amp; Real Estate**Complex tiered structures, team overrides, compliance-ready**Network Marketing / MLM**Multi-level commission trees, performance tiers, bonus structures**Recruitment Agencies**Placement fees, split commissions, clawback on early termination**Freelance Platforms**Platform fees, referral bonuses, milestone payments---

How It's Different
------------------

[](#how-its-different)

FeatureLaravel Sales CommissionOther Packages**Full Lifecycle Management**Calculation → Clawback → PayoutCalculation only**Team Split Commissions**✅ Built-in with roles❌ Not supported**Clawback System**✅ Full, partial, grace periods❌ Not supported**Payout Processing**✅ Generate, approve, process❌ Not supported**Multi-Tier Structures**✅ Automatic tier progression⚠️ Basic tiers**Conditional Rules**✅ Any condition (category, amount, etc.)⚠️ Limited**Event System**✅ 4 lifecycle events⚠️ Minimal**Period Tracking**✅ Weekly/Monthly/Quarterly❌ Not supported**Production Ready**✅ 31 tests, CI/CD, documented⚠️ Varies---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10.x or 11.x

Installation
------------

[](#installation)

```
composer require ayangzy/laravel-sales-commission
```

Publish the configuration and migrations:

```
php artisan vendor:publish --tag="sales-commission-config"
php artisan vendor:publish --tag="sales-commission-migrations"
php artisan migrate
```

Quick Start
-----------

[](#quick-start)

### 1. Add Traits to Your Models

[](#1-add-traits-to-your-models)

**User/Agent Model:**

```
use SalesCommission\Traits\HasCommissions;

class User extends Model
{
    use HasCommissions;
}
```

**Order/Sale Model:**

```
use SalesCommission\Traits\Commissionable;

class Order extends Model
{
    use Commissionable;

    public function getCommissionableAmount(): float
    {
        return $this->total;
    }

    public function getCommissionAgent(): ?Model
    {
        return $this->salesRep;
    }
}
```

### 2. Create a Commission Plan

[](#2-create-a-commission-plan)

```
use SalesCommission\Models\CommissionPlan;
use SalesCommission\Models\CommissionTier;
use SalesCommission\Models\CommissionRule;

// Create a plan
$plan = CommissionPlan::create([
    'name' => 'Standard Sales Plan',
    'slug' => 'standard',
    'is_active' => true,
    'is_default' => true,
]);

// Add tiers
$plan->tiers()->createMany([
    ['name' => 'Bronze', 'min_threshold' => 0, 'max_threshold' => 10000, 'rate' => 5],
    ['name' => 'Silver', 'min_threshold' => 10001, 'max_threshold' => 50000, 'rate' => 7.5],
    ['name' => 'Gold', 'min_threshold' => 50001, 'max_threshold' => null, 'rate' => 10],
]);

// Add a rule
$plan->rules()->create([
    'name' => 'Standard Commission',
    'type' => 'percentage',
    'value' => 10, // 10%
    'is_active' => true,
]);
```

### 3. Calculate Commissions

[](#3-calculate-commissions)

```
use SalesCommission\Facades\Commission;

// Calculate commission for a sale
$earning = Commission::calculate($order);

// Or with a specific agent
$earning = Commission::calculate($order, $salesRep);

// Use a specific plan
$earning = Commission::forPlan('enterprise')
    ->calculate($order);

// Bulk calculation
$earnings = Commission::calculateBatch($orders);
```

### 4. Team Split Commissions

[](#4-team-split-commissions)

```
Commission::split($order)
    ->between([
        $primaryRep => ['percentage' => 60, 'role' => 'primary'],
        $supportRep => ['percentage' => 25, 'role' => 'support'],
        $manager => ['percentage' => 15, 'role' => 'manager'],
    ])
    ->calculate();
```

### 5. Handle Clawbacks

[](#5-handle-clawbacks)

```
use SalesCommission\Services\ClawbackService;

$clawbackService = app(ClawbackService::class);

// Full clawback
$clawback = $clawbackService->clawback($earning, 'refund');

// Partial clawback
$clawback = $clawbackService->partialClawback($earning, 50.00, 'partial_refund');

// Clawback all commissions for an order
$clawbacks = $clawbackService->clawbackForCommissionable($order, 'chargeback');
```

### 6. Process Payouts

[](#6-process-payouts)

```
use SalesCommission\Models\Payout;

// Generate payout for current period
$payout = Payout::generate('2026-01');

// Approve and process
$payout->approve(auth()->id());
$payout->markAsPaid([
    'reference' => 'PAY-12345',
    'method' => 'stripe',
]);
```

Or use the artisan command:

```
php artisan commission:process-payouts --period=2026-01
```

Events
------

[](#events)

Listen to commission events in your application:

```
// EventServiceProvider
protected $listen = [
    \SalesCommission\Events\CommissionEarned::class => [
        NotifySalesRep::class,
        UpdateLeaderboard::class,
    ],
    \SalesCommission\Events\CommissionClawedBack::class => [
        NotifyFinanceTeam::class,
    ],
    \SalesCommission\Events\PayoutProcessed::class => [
        SendPayoutConfirmation::class,
    ],
    \SalesCommission\Events\TierAchieved::class => [
        CelebrateTierUpgrade::class,
    ],
];
```

Artisan Commands
----------------

[](#artisan-commands)

```
# Process payouts
php artisan commission:process-payouts --period=2024-01
php artisan commission:process-payouts --dry-run

# Recalculate tiers
php artisan commission:recalculate-tiers --all
php artisan commission:recalculate-tiers --plan=standard
```

Configuration
-------------

[](#configuration)

See `config/sales-commission.php` for all options:

```
return [
    'models' => [
        'agent' => App\Models\User::class,
    ],

    'clawback' => [
        'enabled' => true,
        'grace_period_days' => 30,
        'auto_on_refund' => true,
    ],

    'payout' => [
        'min_threshold' => 50.00,
        'auto_approve' => false,
        'schedule' => 'monthly',
        'hold_period_days' => 14,
    ],

    'currency' => 'USD',
];
```

Custom Rules
------------

[](#custom-rules)

Create custom commission rules:

```
use SalesCommission\Rules\BaseRule;
use SalesCommission\Contracts\Commissionable;
use SalesCommission\Contracts\CommissionAgent;

class FirstSaleBonusRule extends BaseRule
{
    public function getType(): string
    {
        return 'first_sale_bonus';
    }

    public function calculate(Commissionable $commissionable, CommissionAgent $agent, array $context = []): float
    {
        // Check if this is the agent's first sale
        if ($agent->commissionEarnings()->count() === 0) {
            return 100.00; // $100 bonus
        }

        return 0;
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Admin Dashboard (Filament)
--------------------------

[](#admin-dashboard-filament)

This package includes a beautiful admin panel powered by Filament:

```
// In your Filament PanelProvider
use SalesCommission\Pro\Filament\SalesCommissionPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            SalesCommissionPlugin::make(),
        ]);
}
```

Features include:

- View all commission plans and tiers
- Track earnings by agent, period, status
- Approve and process payouts
- Generate reports
- Manage clawbacks

API Endpoints
-------------

[](#api-endpoints)

RESTful API endpoints are available at `/api/commissions`:

- `GET/POST /api/commissions/plans` - Manage commission plans
- `GET /api/commissions/earnings` - View earnings
- `POST /api/commissions/calculate` - Calculate commissions
- `GET/POST /api/commissions/payouts` - Manage payouts
- `GET /api/commissions/stats/overview` - Get stats

API documentation available at `/api/commissions/docs`.

Support the Project
-------------------

[](#support-the-project)

If this package helps you, please consider giving it a ⭐ on GitHub - it helps others discover the project!

Author
------

[](#author)

**Ayangzy** - [GitHub](https://github.com/ayangzy)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

6

Last Release

150d ago

Major Versions

v1.2.0 → v2.0.02026-02-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38384570?v=4)[Felix Ayange](/maintainers/ayangzy)[@ayangzy](https://github.com/ayangzy)

---

Top Contributors

[![ayangzy](https://avatars.githubusercontent.com/u/38384570?v=4)](https://github.com/ayangzy "ayangzy (71 commits)")

---

Tags

apicomposer-packagelaravelpackagephplaravelsaaspayoutsalescommissionearnings

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ayangzy-laravel-sales-commission/health.svg)

```
[![Health](https://phpackages.com/badges/ayangzy-laravel-sales-commission/health.svg)](https://phpackages.com/packages/ayangzy-laravel-sales-commission)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M164](/packages/spatie-laravel-health)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
