- Can I use baks-dev/four-tochki directly in Laravel, or is it only for Symfony?
- The package is built as a Symfony bundle but can be adapted to Laravel. You’ll need to replace Symfony dependencies (like Console or HttpClient) with Laravel equivalents (Artisan, Guzzle, or Laravel HTTP Client) and register services in Laravel’s container. The core API functionality remains usable with minimal refactoring.
- What Laravel versions does baks-dev/four-tochki support?
- The package requires PHP 8.4+ and is designed for Laravel 10+ or 11. While it’s Symfony-based, its modular structure allows integration with Laravel’s ecosystem. Test thoroughly with your Laravel version, as some Symfony components may need bridging.
- How do I authenticate with 4Tochki’s API using this package?
- Authentication typically relies on OAuth2 or API keys. The package likely handles this via configuration (check the `fourtochki-config` publishable file). If undocumented, reverse-engineer the API using 4Tochki’s B2B portal or contact their support for OAuth2 flow details.
- Does this package support webhooks for real-time order updates?
- Webhook support isn’t explicitly documented, but you can map 4Tochki’s webhooks to Laravel Events or Queued Jobs. Implement signature validation (e.g., HMAC) and use Laravel’s `queue:work` to process events asynchronously. Check 4Tochki’s API docs for event payload structures.
- How do I handle API rate limits or failed requests?
- The package may not include retry logic by default. Use Laravel’s HTTP client with exponential backoff (e.g., `retry_after` headers) or a library like `spatie/retries`. Configure rate limits in your `.env` and log failed requests for debugging.
- Can I use Eloquent models instead of Doctrine migrations?
- Yes, replace Doctrine migrations with Eloquent models or DBAL queries. The package’s schema may need adjustments (e.g., snake_case conventions). Publish the config (`php artisan vendor:publish --tag=fourtochki-config`) to customize database interactions.
- Are there alternatives to baks-dev/four-tochki for 4Tochki integration?
- For Laravel, consider building a custom API wrapper using Guzzle or Laravel HTTP Client for direct 4Tochki API calls. Alternatively, check for unofficial PHP SDKs or Symfony bundles that might be easier to adapt. This package is ideal if you need pre-built migrations and CLI tools.
- How do I test the package in a Laravel environment?
- Run the package’s test suite with `php bin/phpunit --group=four-tochki`, but augment it with Laravel-specific tests (e.g., Pest). Mock API responses and test edge cases like failed requests, rate limits, and webhook validation. Use Laravel’s `Http::fake()` for API testing.
- What’s the best way to integrate this into a microservice architecture?
- Scope the package to a feature module or microservice by extracting its dependencies (e.g., API client, migrations) into standalone classes. Use Laravel’s service container to bind FourTochki services and expose them via API endpoints or queues for async processing.
- How do I handle Russian address formats or tax rules in Laravel?
- The package may include Russian-specific validations, but you’ll need to extend Laravel’s validation rules (e.g., `Illuminate/Validation`) for address formats. For tax rules, use Laravel’s `taxable` trait or custom logic tied to 4Tochki’s API responses. Check the published config for locale-specific settings.