Download the PHP package beziworld/laravel-allegro without Composer
On this page you can find all versions of the php package beziworld/laravel-allegro. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beziworld/laravel-allegro
More information about beziworld/laravel-allegro
Files in beziworld/laravel-allegro
Package laravel-allegro
Short Description Allegro REST API client for Laravel: OAuth2 (code with PKCE, device flow, client credentials), multiple seller accounts, orders and offer event polling, fulfillment, tracking numbers, Wysylam z Allegro shipments, billing, messaging and returns.
License MIT
Homepage https://github.com/beziworld/laravel-allegro
Informations about the package laravel-allegro
Laravel Allegro
Allegro REST API client for Laravel, built for shops and SaaS platforms that serve one or many Allegro sellers:
- OAuth2: authorization code (with PKCE), device flow and client credentials; rotating refresh tokens are refreshed under a lock and kept in a pluggable token store
- many seller accounts on one application: named accounts in the config and sellers connected at runtime
- orders: event journal polling with Laravel events, checkout forms, fulfillment status, tracking numbers, invoices
- offers: listing, create and edit through
/sale/product-offers(with async operation polling), batch price and quantity changes, offer event journal - Wysyłam z Allegro: shipments, labels (PDF/ZPL, A4/A6), protocols, courier pickups
- billing entries, message center, customer returns (beta), categories, parameters and the product catalogue
- typed, immutable DTOs (
Moneykeeps amounts as strings) and a genericrequest()for every other endpoint
Polska wersja dokumentacji
Installation
Register an application at apps.developer.allegro.pl (sandbox: apps.developer.allegro.pl.allegrosandbox.pl).
Allegro requires every integration to send a User-Agent in the format AppName/Version (+https://info-page-url),
consistent with the name of the registered application; the package refuses to start without it. Requests also carry
Accept/Content-Type: application/vnd.allegro.public.v1+json (the beta media type for beta resources) and
Accept-Language (ALLEGRO_LANGUAGE, default pl-PL), which sets the language of error messages.
Connecting a seller
Authorization code with PKCE
Without PKCE call authorizationUrl($state) and exchangeCode($code). Pass scopes as the third argument (or set
allegro.scopes) to request fewer permissions, and 'confirm' as the fourth one to show the account confirmation
screen.
Device flow
For back-office tools and terminals (the application must be registered as a device application):
Or in code:
Application token
Public resources (categories, parameters, carriers, billing types) accept a client credentials token:
Tokens
Access tokens live 12 hours; refresh tokens live 3 months and are single use: every refresh returns a new pair and the previous refresh token stays valid for only 60 seconds. The client refreshes expired tokens under a cache lock, re-reads the store after acquiring the lock, and stores the new pair immediately. After HTTP 401 it refreshes once and repeats the request.
Tokens are kept in the cache by default (CacheTokenStore, 90-day TTL). To keep them in your database, implement
Beziworld\Allegro\Contracts\TokenStore (get, put, forget; the key is the account name or the forUser() key)
and set allegro.token_store to your class, or bind the interface in the container. An account can also be seeded with
a refresh token in the config (ALLEGRO_REFRESH_TOKEN).
When Allegro revokes the authorization (password change, unlinking the application, expired refresh token), calls
throw AuthenticationException with requiresReauthorization() === true: ask the seller to connect again.
Multiple seller accounts
One application serves any number of sellers, each with its own tokens:
Account entries may override any shared option, including client_id, client_secret and sandbox.
Orders
Polling new orders
Allegro has no webhooks; changes are read from event journals. allegro:poll-orders reads /order/events from the
last stored event id and dispatches OrderEventReceived for every new event. On the first run of an account it starts
at the newest event (set allegro.events.start to beginning to replay the last 60 days).
The cursor is saved after each event and a lock prevents overlapping runs. Allegro may repeat events or deliver them out
of order, so key your processing on checkoutFormId and make listeners idempotent. Address and invoice data are final
only at READY_FOR_PROCESSING. allegro:poll-offers does the same for /sale/offer-events (OfferEventReceived; the
journal keeps 24 hours).
Listing and reading orders
Fulfillment and tracking numbers
Invoices
Offers
Wysyłam z Allegro
Other resources
Errors and rate limits
| Situation | Exception | Useful methods |
|---|---|---|
| HTTP 400/422 validation | ApiException |
errors() (code, message, details, path, userMessage), userMessage(), isValidationError() |
| HTTP 401 after one refresh and retry | ApiException |
httpStatus(), OAuth error mapped to errors()[0]['code'] |
| HTTP 404 | ApiException |
isNotFound() |
| HTTP 409 (stale revision, reused commandId) | ApiException |
isConflict() |
| HTTP 429 (9000 requests/min per Client ID, per-resource limits) | ApiException |
isRateLimited(), retryAfter() |
| Connection failure | ApiException |
getPrevious() |
| Failed WzA command, operation still running | ApiException |
errors() |
| Missing token, revoked refresh token, denied device flow | AuthenticationException |
requiresReauthorization(), error() |
| Missing configuration | InvalidConfiguration |
Every exception extends AllegroException. traceId() (and lastTraceId() on the client) returns the Trace-Id
header that Allegro support asks for; set ALLEGRO_LOG_CHANNEL to log failed requests with it. The client never
repeats a request automatically, except once after HTTP 401 (a rejected request was not processed). Back off on 429:
exceeding the global limit blocks the Client ID for a minute.
Development
Author
Created and maintained by Kamil Ćwiertnia, beziworld.eu.
- E-mail: [email protected]
- Issues: GitHub issues
Need an Allegro or marketplace integration? Get in touch through beziworld.eu.
License
MIT. See LICENSE.md. This package is not affiliated with, endorsed or sponsored by Allegro.pl sp. z o.o.
All versions of laravel-allegro with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.8
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
psr/log Version ^2.0|^3.0