Laravel Rewardful
#Laravel Rewardful
A Laravel client for the Rewardful affiliate and referral tracking API. A fluent Rewardful facade covers affiliates, referrals, commissions and affiliate links, authenticates every request with your API key as the HTTP Basic Auth username (empty password), and throws a RewardfulException on a non-2xx response instead of returning a silent error array.
#Features
- Affiliates —
listAffiliates(),getAffiliate(),searchAffiliateByEmail(),updateAffiliate() - Referrals —
listReferrals(),getReferral() - Commissions —
listCommissions(),getCommission() - Affiliate Links —
createAffiliateLink() - Thin by design — every method returns the raw decoded JSON response as an array, no DTOs
- Fails loud — a non-2xx API response throws
RewardfulExceptioncarrying the API's error message and HTTP status code
#Installation
You can install the package via composer:
composer require jeffersongoncalves/laravel-rewardful
Optionally publish the config file:
php artisan vendor:publish --tag="rewardful-config"
#Configuration
Add to your .env:
REWARDFUL_API_KEY=your-api-key
Find your API key in your Rewardful dashboard under Settings > API.
#Config Options
// config/rewardful.php return [ 'api_key' => env('REWARDFUL_API_KEY'), 'base_url' => env('REWARDFUL_BASE_URL', 'https://api.getrewardful.com/v1'), ];
#Usage
use JeffersonGoncalves\Rewardful\Exceptions\RewardfulException; use JeffersonGoncalves\Rewardful\Facades\Rewardful;
#Affiliates
Rewardful::listAffiliates(); // page 1 Rewardful::listAffiliates(2); // page 2 Rewardful::getAffiliate('affiliate-id'); Rewardful::searchAffiliateByEmail('jane@example.com'); Rewardful::updateAffiliate('affiliate-id', [ 'first_name' => 'Jane', 'last_name' => 'Doe', 'paypal_email' => 'jane@example.com', ]);
#Referrals
Rewardful::listReferrals(); // all referrals Rewardful::listReferrals('affiliate-id'); // filtered by affiliate Rewardful::getReferral('stripe-customer-id');
#Commissions
Rewardful::listCommissions(); // all commissions Rewardful::listCommissions('affiliate-id'); // filtered by affiliate Rewardful::getCommission('commission-id');
#Affiliate Links
Rewardful::createAffiliateLink('affiliate-id'); Rewardful::createAffiliateLink('affiliate-id', token: 'my-token', url: 'https://example.com');
#Handling errors
try { $affiliate = Rewardful::getAffiliate('affiliate-id'); } catch (RewardfulException $e) { // $e->getMessage() — the API's error message, or the raw response body // $e->statusCode — the HTTP status code returned by Rewardful }
#Testing
composer test
#Static Analysis
composer analyse
#Code Formatting
composer format
#Changelog
Please see CHANGELOG for more information on what has changed recently.
#Contributing
Please see CONTRIBUTING for details.
#Security
Please review our security policy on how to report security vulnerabilities.
#Credits
#License
The MIT License (MIT). Please see License File for more information.