Download the PHP package aiarmada/affiliates without Composer
On this page you can find all versions of the php package aiarmada/affiliates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aiarmada/affiliates
More information about aiarmada/affiliates
Files in aiarmada/affiliates
Package affiliates
Short Description Affiliate attribution, referral tracking, and commission management for Laravel commerce stacks.
License MIT
Homepage https://github.com/aiarmada/commerce
Informations about the package affiliates
AIArmada Affiliates
Affiliate attribution, referral tracking, and commission workflows for Laravel commerce teams. The package ships with first-class hooks for aiarmada/cart and aiarmada/vouchers, but remains completely independent β you can store affiliate programs, manage payouts, and expose APIs without installing other commerce packages.
Highlights
- π§Ύ Programs & Partners β Model affiliate partners with commission policies, voucher links, metadata, and optional owner scoping for multi-tenant platforms.
- π― Attribution Graph β Persist cart-level attribution records (cart identifier + instance) with UTM context, device data, and voucher links.
- π° Commission Engine β Basis-point and fixed-fee calculations powered by configurable defaults and overridable services.
- π§© Composable Integrations β Drop-in Cart + Voucher bridges automatically attach affiliates the moment a code or voucher is applied.
- πͺ Visit Cookies β Optional middleware captures affiliate clicks before a cart exists, keeping referrals alive across sessions.
- π‘ Events Everywhere β
AffiliateAttributedandAffiliateConversionRecordedevents make automation straightforward.
Installation
Optional integrations
| Package | Outcome |
|---|---|
aiarmada/cart |
Adds fluent helpers such as Cart::attachAffiliate('CODE'), automatic metadata persistence, and conversion recording utilities. |
aiarmada/vouchers |
Reads voucher metadata to auto-attach affiliates, enabling voucher-driven referral programs. |
aiarmada/filament-affiliates |
Filament plugin for operating affiliate programs, approvals, and analytics. |
Both integrations are lazy β the service provider detects presence via class_exists ensuring you can run affiliates inside bespoke apps or headless APIs.
Core Concepts
| Model | Purpose |
|---|---|
Affiliate |
Canonical partner/program definition with status, commission policy, voucher hints, and optional owner scoping. |
AffiliateAttribution |
Represents a cart-level session that originated from an affiliate. Stores cart identifier, instance, UTM context, voucher code, agent data, and timestamps. |
AffiliateConversion |
A recorded commercial event linked to an affiliate (order, subscription, invoice, etc.) complete with commission totals and payout status. |
Cart helpers
When aiarmada/cart is present the package registers a manager proxy so you can call these fluent methods via the Cart facade:
Attribution is stored in normalized affiliate tables keyed by the cart identifier and instance; cart metadata is not used as an attribution store.
Voucher bridge
Attach metadata to vouchers and the package will automatically hydrate the cart the moment a voucher is applied:
The AttachAffiliateFromVoucher listener handles validation, owner scoping, and persistence so staff can run co-branded campaigns without touching application code.
Set default_voucher_code on an affiliate and the listener will fall back to it when no explicit metadata is present (configurable via affiliates.integrations.vouchers.match_default_voucher_code).
Cookie tracking middleware
Activate the TrackAffiliateCookie middleware (auto-registered in the web group by default) to capture affiliate visits before a cart exists. The middleware:
- Looks for query parameters such as
aff,affiliate,ref, orreferral. - Drops a configurable cookie (defaults to
affiliate_session). - Persists an
AffiliateAttributionrow with UTM metadata, referrer, and device data. - Automatically hydrates the cart once the customer starts shopping, ensuring conversions are linked even if the voucher field was never touched.
Tweak behaviour via config/affiliates.php:
Disable auto-registration or alias the middleware manually using the affiliates.cookie key if you need to scope tracking to custom route groups or consent flows.
Rate limiting and consent
- IP rate limits for attribution capture (
tracking.ip_rate_limit.*). - Self-referral blocking when the current owner matches the affiliate owner.
- Consent gate via
cookies.require_consentwith a configurable consent cookie name.
Payout batches
Use Actions/Payouts/CreatePayout and Actions/Payouts/UpdatePayoutStatus to manage payout batches for exports or provider handoff. Conversions are linked via affiliate_payout_id, and payout records store aggregate totals and schedule/paid timestamps.
Multi-level uplines are supported via parent_affiliate_id on affiliates and payouts.multi_level.* config to define commission shares per level.
Webhook + link utilities
- Optional webhooks for attribution/conversion payloads (
events.dispatch_webhooks+webhooks.*endpoints/headers). - Signed referral links via
AffiliateLinkGeneratorusing configurable parameter name, TTL, and signing key.
Configuration
Key options exposed via config/affiliates.php:
table_namesβ override table names per tenant or schema layout.ownerβ plug in a resolver to scope queries per marketplace merchant.integrations.vouchersβ attach affiliates from the voucher's nativeaffiliate_idor its configured default voucher code.tracking.block_self_referralβ prevent owners/tenants from crediting their own affiliate code when they are the active owner.cookies.require_consent/cookies.consent_cookieβ gate tracking behind explicit consent.commissionsβ default currency, rounding, and approval behaviour.
Events
AffiliateAttributedβ fired after a cart is successfully attributed. Includes affiliate + attribution DTOs.AffiliateConversionRecordedβ emitted whenever a conversion row is created. Perfect for payouts or Slack alerts.
Both events are broadcast through Laravelβs dispatcher and can be toggled via config.
Testing
The package ships with unit coverage for the commission calculator and attribution manager. Extend the Pest suite inside
packages/affiliates/testsfor your application specifics.
License
Released under the MIT license.