Installation
composer require anripuankare/atol-client
Add the package to your config/app.php providers (if not auto-discovered):
'providers' => [
// ...
Anripuankare\AtolClient\AtolServiceProvider::class,
],
Configuration Publish the config file:
php artisan vendor:publish --provider="Anripuankare\AtolClient\AtolServiceProvider" --tag="config"
Update .env with your ATOL credentials:
ATOL_CLIENT_ID=your_client_id
ATOL_CLIENT_SECRET=your_client_secret
ATOL_SANDBOX=false
First Use Case: Authentication
use Anripuankare\AtolClient\Facades\Atol;
$token = Atol::auth()->getAccessToken();
API Requests Use the fluent interface for API calls:
$response = Atol::api('v3')->get('/orders', [
'filter' => ['status' => 'pending']
]);
Webhooks Handle ATOL webhook payloads:
use Anripuankare\AtolClient\Events\WebhookReceived;
Event::listen(WebhookReceived::class, function ($event) {
$payload = $event->payload;
// Process webhook (e.g., order updates)
});
Order Management Create/update orders via the SDK:
$order = Atol::api('v4')->post('/orders', [
'order_number' => 'ORD-123',
'items' => [
['sku' => 'SKU-001', 'quantity' => 2]
]
]);
dispatch(new ProcessAtolOrder($orderData));
Atol::extend(function ($client) {
$client->after(function ($response) {
if ($response->failed()) {
Log::error('ATOL API Error', ['response' => $response->json()]);
}
});
});
Sandbox vs. Production
ATOL_SANDBOX can cause unexpected API calls.Rate Limiting
Atol::retry(3, function () {
return Atol::api()->get('/orders');
});
Webhook Verification
$isValid = Atol::webhook()->verify($request->getContent(), $request->header('X-Atol-Signature'));
Atol::setLogLevel(\Monolog\Logger::DEBUG);
$rawResponse = Atol::api()->get('/orders', [], [], ['debug' => true]);
Custom API Clients Extend the base client for domain-specific logic:
Atol::extend('custom', function () {
return new CustomAtolClient(Atol::getClient());
});
Mocking for Tests
Use the AtolMock facade in tests:
AtolMock::shouldReceive('getAccessToken')->andReturn('mock_token');
Event Hooks
Listen for ATOL events (e.g., OrderCreated):
Event::listen(AtolEvents::ORDER_CREATED, function ($order) {
// Sync with your ERP
});
How can I help you explore Laravel packages today?