recurly/recurly-client
Official PHP client for Recurly’s V3 API. Install via Composer, create a Client with your API key (US or EU region), and access all API operations in one place. Supports optional PSR-3 logging.
Pros:
Pager class simplifies handling large datasets, which is critical for Laravel applications managing subscriptions at scale.RecurlyError, Validation, NotFound) allow for granular error handling in Laravel’s exception middleware or controllers.Cons:
stdout at WARNING level may expose PII in production. Requires customization (e.g., Laravel’s Log facade).High: The package is battle-tested (last release in 2026) and aligns with Laravel’s PHP ecosystem. Key integration points:
AppServiceProvider:
$this->app->singleton(\Recurly\Client::class, function ($app) {
return new \Recurly\Client(config('services.recurly.key'), [
'region' => config('services.recurly.region', 'us'),
'logger' => $app->make(\Psr\Log\LoggerInterface::class),
]);
});
.env and bind to config/services.php.VerifyRecurlyWebhookSignature).Challenges:
/recurly/webhook) to controllers handling Recurly\Webhook events.accounts, subscriptions) may not map 1:1 to Laravel’s Eloquent models. Consider using local caching (e.g., Redis) or database sync jobs to reconcile state.Pager) are efficient, but bulk operations (e.g., listAccounts with large limit) may hit rate limits. Implement exponential backoff in retries..env + Vault if needed).Hash::check or a dedicated library like spatie/webhook-client.Data Model Alignment:
accounts, subscriptions, and invoices map to Laravel’s Eloquent models or local databases?User model have a recurly_account_id field, or will you sync data via a separate RecurlyAccount model?Webhook Strategy:
Error Recovery:
Validation errors for failed payments)?App\Exceptions\Handler to convert Recurly\Errors\Validation into user-friendly messages.Testing:
VoryxTHOR/Voryx or Laravel’s HTTP tests)?Multi-Region Support:
Rate Limiting:
Laravel Ecosystem:
Recurly\Logger with Laravel’s Log facade (PSR-3 compliant).guzzlehttp/guzzle). Laravel’s HTTP client can be swapped in if needed (though not required).SubscriptionCreated) when Recurly webhooks are received.Database:
User has recurly_subscription_id).recurly database table for syncing critical data (e.g., subscription status).predis/predis) for low-latency access.Webhooks:
RecurlyWebhookController) with middleware for signature validation.Route::post('/recurly/webhook', [RecurlyWebhookController::class, 'handle'])
->middleware('signed:recurly');
Phase 1: Core Integration
composer require recurly/recurly-client..env and bind the client to Laravel’s service container.Phase 2: Webhook Handling
public function handle(Request $request, RecurlyClient $client) {
$event = $client->parseWebhook($request->getContent());
// Dispatch event or job
event(new RecurlyWebhookReceived($event));
}
Phase 3: Data Sync
SyncRecurlySubscriptionsJob) on a schedule or via webhooks.Phase 4: Error Handling & Monitoring
openssl, json).Prerequisites:
Order of Implementation:
How can I help you explore Laravel packages today?