- How do I install and configure the Dinas Shipping SDK in Laravel?
- Run `composer require dinas/shipping-sdk-laravel`, then add `DINAS_SHIPPING_TOKEN` and `DINAS_SHIPPING_SECRET` to your `.env`. The service provider auto-registers, and you’ll need to add the webhook route via `Route::dinasShippingWebhooks('path')`. Ensure the route is CSRF-exempt in `AppServiceProvider`.
- What Laravel versions does this package support?
- The package targets Laravel 9.x and 10.x. Check the [GitHub repository](https://github.com/DinasJp/shipping-sdk-laravel) for the latest compatibility notes, as minor updates may require adjustments for newer Laravel features like dependency injection or middleware.
- How are webhook events processed asynchronously?
- Incoming webhooks are logged, verified, and dispatched as `WebhookJob` instances via Laravel’s queue system. Configure your queue connection (e.g., `QUEUE_CONNECTION=redis`) in `.env` to handle high-volume events. Failed jobs trigger retries with exponential backoff by default.
- Can I customize the webhook endpoint path?
- Yes, use `Route::dinasShippingWebhooks('custom/path')` in your routes file. The package auto-discovers the route during setup, so no additional configuration is needed beyond defining the path. Ensure the route is CSRF-exempt for security.
- What happens if the Dinas API changes or breaks?
- The package relies on the Dinas Shipping API, which lacks a public changelog. Monitor the [Dinas API docs](https://shipping.dinas.jp/api/documentation) for updates. For critical applications, implement a fallback mechanism or wrap API calls in try-catch blocks to handle errors gracefully.
- How do I handle large batches of shipments or documents?
- Batch operations (e.g., `storeCarPhotos`) use chunking with a default size of 50 items. Adjust this via the `chunkSize` parameter in the method call. For very large datasets, consider processing in smaller chunks or using Laravel’s queue workers to avoid timeouts.
- Does this package support real-time updates via Pusher?
- Yes, enable broadcasting by configuring `BROADCAST_DRIVER=pusher` in `.env` and installing `laravel-echo`. The package broadcasts webhook events to channels like `App.Models.User.${userId}`. Ensure your auth system validates these channels before integrating.
- How do I test webhook functionality locally?
- Use the `spatie/webhook-client` package’s testing utilities to simulate webhooks. Mock the Dinas API responses in your tests and verify job dispatching. For end-to-end testing, use a staging environment with the real Dinas API, as local testing may not cover all edge cases like signed payloads.
- What are the risks of using spatie/webhook-client for high-volume webhooks?
- `spatie/webhook-client` is robust but may need tuning for high-volume events (e.g., 10,000/day). Monitor queue backlogs and adjust retry delays or worker count. For critical workflows, consider adding custom middleware to validate payloads or rate-limit requests.
- How do I scope API credentials for multi-tenant applications?
- Store tenant-specific credentials (e.g., `DINAS_SHIPPING_TOKEN_${tenant_id}`) in a database or cache. Override the default `DINAS_SHIPPING_TOKEN` dynamically in your application logic, such as middleware or service providers, based on the current tenant context.