Weave 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 Affiliate Network Laravel Package

padosoft/laravel-affiliate-network

A Laravel package for building affiliate and referral programs out of the box. Track referrals, attribute conversions, calculate commissions, and manage payouts with Eloquent models and configurable, multi-tier-ready workflows. Integrates cleanly into existing apps.

View on GitHub
Deep Wiki
Context7

Getting Started

This package wraps several affiliate networks (Commission Junction, Zanox, Effiliation, Publicideas) behind a common NetworkManager so you can pull product feeds and build affiliate links without writing a separate client per network. Version 2.0.1 is a maintenance release — no installation changes — so treat the setup below as the baseline.

Minimal steps:

  1. Install and publish config:
    composer require <vendor>/<package>
    php artisan vendor:publish --tag=<package>-config
    
  2. Add credentials per network in config/<package>.php (or .env if the package maps them). Each network needs its own keys — Commission Junction uses a publisher PID/website ID, Zanox uses a connect ID plus secret key, Effiliation uses an API key.
  3. Resolve the manager from the container rather than instantiating adapters directly:
    use <Vendor>\<Package>\NetworkManager;
    
    $manager = app(NetworkManager::class);
    $zanox = $manager->driver('zanox');
    
  4. First use case — fetch a product list and cache it. Product feeds are large and rate-limited, so schedule a pull into your own table or cache rather than querying on request:
    $products = $manager->driver('zanox')->getProducts(['q' => 'laptop']);
    
    Note getProducts() on Zanox is new in 2.0.1 — if you're coming from 2.0.0 the method simply doesn't exist, so any code path relying on it must be gated behind a version constraint of ^2.0.1.

Where to look first: the NetworkManager class (driver resolution, shared config, default network), then the individual adapter you actually need. Each adapter exposes a different surface — do not assume parity across networks. The Publicideas and EffiliationEx adapters are the thinnest and are the most likely to lag behind their real APIs.

Implementation Patterns

Manager-as-facade, adapter-per-network. The constructor change in 2.0.1 (Commission Junction now accepts the arguments NetworkManager passes) confirms the intended pattern: always go through the manager, never new CommissionJunction(...) in your own code. Direct instantiation is what broke in the previous version and it will break again.

Wrap network calls in your own repository/service. Because each network returns differently shaped payloads, normalise early:

class ProductFeed
{
    public function __construct(private NetworkManager $manager) {}

    public function forNetwork(string $network, array $filters = []): Collection
    {
        return Cache::remember(
            "feed:{$network}:" . md5(serialize($filters)),
            now()->addHours(6),
            fn () => collect($this->manager->driver($network)->getProducts($filters))
                ->map(fn ($p) => ProductData::fromNetwork($network, $p))
        );
    }
}

This isolates your app from the fact that getProducts() exists on Zanox but may be named differently elsewhere.

Queue the pulls. Feeds are slow and networks throttle. Push each network into its own job so one failing network doesn't sink the whole refresh:

foreach (config('affiliate.networks') as $network) {
    RefreshNetworkFeed::dispatch($network);
}

Multi-network fallback for links. If you generate outbound links, keep the network name on the record and resolve the driver at render time. This lets you move a product from Zanox to CJ without a data migration.

Testing. Bind a fake into the container instead of hitting live APIs — $this->mock(NetworkManager::class) and have driver() return a stub. Given the constructor signature changed in this release, fakes are also your regression net for future adapter swaps.

Integration tip: if you expose affiliate data via an API, cache aggressively at the boundary. The package adds no caching layer of its own.

Gotchas and Tips

  • The 2.0.1 constructor change is a silent break for anyone who instantiated CommissionJunction directly. If you have new CommissionJunction($pid, $websiteId) scattered in your codebase, it now expects the NetworkManager-compatible signature. Grep for direct instantiation and migrate to $manager->driver('commissionjunction').
  • var_dump() was removed from the Publicideas adapter. If you were relying on that debug output — deliberately or not — you'll lose it. Add your own logging around the adapter call if you need visibility into its responses.
  • Effiliation is now UTF-8. If your database columns or json_encode paths assumed a different encoding, re-verify product names and descriptions after upgrading. Existing rows pulled before the upgrade may still hold mis-encoded data; re-run the feed import rather than assuming the fix is retroactive.
  • getProducts() on Zanox is additive, not universal. It's tempting to write $manager->driver($n)->getProducts() across all networks. Check each adapter first — calling a missing method is a fatal error, not a graceful null.
  • Pin your constraint. These patch releases have shipped a breaking constructor change and method additions in the same breath, so "^2.0.1" is safer than "^2.0", and definitely avoid "*".
  • Config caching catches people out. After editing credentials in config/, run php artisan config:clear in local dev. Most "invalid credentials" reports on packages like this are stale config caches.
  • Error handling is uneven across adapters. Wrap every network call in try/catch and log the network name plus the raw response; the exception types are not guaranteed to be consistent between adapters, and a network being down is a routine condition here, not an exceptional one.
  • Extension point: if you need a network the package doesn't ship, implement the adapter interface and register it with the manager rather than forking. The NetworkManager constructor injection introduced in 2.0.1 is the hook that makes third-party adapters viable — accept the manager in your constructor and you'll stay compatible.
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.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator