dinas/shipping-sdk-laravel
Laravel SDK for the Dinas Shipping API. Send requests to REST endpoints and receive/verify incoming webhooks. Webhook events are logged and dispatched as Laravel jobs for async updates like shipment status changes and document availability.
Shipping) and domain-specific methods (e.g., syncCars, storeCarPhotos), reducing boilerplate for common operations.spatie/webhook-client, a mature package for handling signed payloads, retries, and logging.| Risk Area | Assessment |
|---|---|
| API Stability | Dinas API is undocumented in the package (links to external docs). Risk of breaking changes if API evolves without backward compatibility. |
| Webhook Reliability | Depends on spatie/webhook-client (tested but not battle-proven for high-volume shipping events). Retry logic must be validated for critical workflows. |
| Async Job Handling | Callback serialization/deserialization could fail if custom objects are passed. Mitigation: Use simple callables or DTOs. |
| Performance | Batch operations (e.g., storeCarPhotos) use chunking (default: 50 items), which may need tuning for large datasets. |
| Security | Webhook endpoint must be CSRF-exempt (as configured). Ensure DINAS_SHIPPING_SECRET is securely stored (not hardcoded). |
| Migration Complexity | Requires publishing two migrations (spatie/webhook-client + package-specific). Test in staging first. |
| Dependency Bloat | Adds spatie/webhook-client (~10MB) and guzzlehttp/psr7 (~1MB). Justify for projects with shipping needs. |
spatie/webhook-client need tuning (e.g., queue workers, retry delays)?WebhookJob records be retained? The default 30-day pruning may need adjustment for compliance or debugging.DINAS_SHIPPING_TOKEN/SECRET be scoped per tenant?App.Models.User.${userId}) compatible with the app’s auth system?| Laravel Component | Package Integration |
|---|---|
| Routing | Adds a CSRF-exempt POST route (dinas-shipping/webhook) via Artisan command. Customizable path. |
| Middleware | Requires CSRF exemption for the webhook route (configured in app/Providers/AppServiceProvider). |
| Service Providers | Auto-registers on install. No manual binding needed. |
| Queues | Async operations (e.g., storeCarPhotos) dispatch Laravel jobs for webhook resolution. Configure queue connection in .env (e.g., QUEUE_CONNECTION=redis). |
| Broadcasting | Optional Pusher integration for real-time updates. Requires laravel-echo and Pusher credentials. |
| Migrations | Publishes two migrations: |
spatie/webhook-client (for webhook calls).webhook_jobs table).
Run with php artisan vendor:publish --tag=shipping-sdk-laravel-migrations and php artisan migrate. |
| Artisan Commands | Provides CLI tools for:php artisan webhook:dinas-shipping -i).php artisan webhook:dinas-shipping).php artisan webhook:dinas-shipping -r). |
| Configuration | Publishes config/dinas-shipping-sdk.php for:delete_after_days). |
| Facades/Dependency Injection | Exposes Shipping facade or injectable class for direct API access. |Pre-Installation:
php artisan queue:work --queue=high).Installation:
composer require dinas/shipping-sdk-laravel
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
php artisan vendor:publish --tag="shipping-sdk-laravel-migrations"
php artisan vendor:publish --tag="shipping-sdk-laravel-config"
php artisan migrate
Configuration:
.env:
DINAS_SHIPPING_TOKEN=your_api_token
DINAS_SHIPPING_SECRET=your_webhook_secret
app/Providers/AppServiceProvider.php.config/dinas-shipping-sdk.php (e.g., chunk size, pruning).Webhook Setup:
Route::dinasShippingWebhooks('dinas-shipping/webhook');
php artisan webhook:dinas-shipping -i
Testing:
Shipping::getCars).spatie/webhook-client test helpers.Go-Live:
WebhookCall failures (via spatie/webhook-client events).strict_types compatibility.guzzlehttp/guzzle (for API calls).spatie/webhook-client (for webhooks).spatie/laravel-webhook-server (optional, for local testing).Phase 1: Core Integration (2–4 weeks):
getCars, getVoyages).syncCars, storeCarPhotos) in a non-critical workflow.Phase 2: Async Workflows (1–2 weeks):
How can I help you explore Laravel packages today?