misaf / vendra-affiliate
Affiliate and referral management system with commission tracking and user referral capabilities
Package info
github.com/misaf/vendra-affiliate
Type:vendra-module
pkg:composer/misaf/vendra-affiliate
Requires
- php: ^8.3
- misaf/vendra-support: v1.10.0
- misaf/vendra-transaction: v1.10.0
- misaf/vendra-user: v1.10.0
- spatie/laravel-package-tools: ^1.93.1
- spatie/laravel-queueable-action: ^2.17
Requires (Dev)
- fakerphp/faker: ^1.24.1
- larastan/larastan: ^3.10.0
- laravel/boost: ^2.4.12
- laravel/pint: ^1.29.3
- misaf/vendra-testing: v1.10.0
- mockery/mockery: ^1.6.12
- nunomaduro/collision: ^8.9.4
- orchestra/testbench: ^11.1
- pestphp/pest: ^5.0
- pestphp/pest-plugin-arch: ^5.0
- pestphp/pest-plugin-laravel: ^5.0
- pestphp/pest-plugin-profanity: ^5.0
- pestphp/pest-plugin-type-coverage: ^5.0
- phpstan/extension-installer: ^1.4.3
Suggests
- misaf/vendra-tagger: Install this in the host application to assign typed tags to affiliates.
README
A full affiliate program for Vendra: referral codes and links, click tracking,
signup attribution, a per-conversion commission ledger, and payout settlement
into the misaf/vendra-transaction wallet — with a Filament admin cluster and
stats widgets.
Features
- Each affiliate gets a unique referral code and a
/r/{code}redirect link. - Visiting the link records an
AffiliateClickand drops an attribution cookie (code|clickId). - When a visitor registers, the referral cookie binds them to the affiliate
(
AffiliateReferral) — each user is attributed at most once and self-referrals are ignored. - Conversions credit
AffiliateCommissionledger entries idempotently:- Deposit — a referred user's approved deposit credits
commission_percentof the amount; leaving the approved state reverses the unpaid commission. - Signup — a fixed bounty per attributed registration.
- Checkout — host applications call
RecordCartConversionActionfrom their checkout flow (vendra-cart has no checkout event yet).
- Deposit — a referred user's approved deposit credits
ProcessAffiliatePayoutActionsettles approved commissions atomically: it groups them into anAffiliatePayout, marks them paid, and credits the affiliate's default-currency wallet through an approved Commission transaction. If the transaction cannot be created or settled, everything rolls back and the commissions remain payable.
Each conversion type is toggled in config/vendra-affiliate.php, alongside
the attribution cookie, payout minimum, and defaults.
Requirements
- PHP 8.3+
- Laravel 13
- Filament 5
misaf/vendra-supportmisaf/vendra-transactionmisaf/vendra-user
Installation
composer require misaf/vendra-affiliate php artisan vendor:publish --tag=vendra-affiliate-migrations php artisan migrate php artisan vendra-affiliate:seed
Optionally publish the configuration and translations:
php artisan vendor:publish --tag=vendra-affiliate-config php artisan vendor:publish --tag=vendra-affiliate-translations
Optional tags
Install misaf/vendra-tagger to assign affiliate-typed tags from the affiliate form and display them in the table. Affiliate imports neither Vendra Tagger nor Spatie Tags; the optional relationship is resolved through misaf/vendra-support.
use Misaf\VendraTagger\Models\Tagger; Tagger::findOrCreate('Top performer', type: 'affiliate', locale: 'en');
Testing
Run the package checks from the package directory:
composer test
composer analyse
License
MIT. See LICENSE.