- How do I install and set up melipayamak/php in a Laravel project?
- Run `composer require melipayamak/php` to install the package. Configure your API credentials in `config/services.php` under a `melipayamak` key, then bind the client to Laravel’s service container in `AppServiceProvider` using `singleton(Melipayamak::class, ...)`. Follow the README for exact syntax.
- Does this package support Laravel’s HTTP client (Guzzle) for API requests?
- Yes, the package is designed to work with Guzzle, which Laravel uses by default. You can leverage Laravel’s `Http::asForm()` or `Http::json()` methods for requests, and the wrapper abstracts the underlying API calls. Ensure your Laravel version aligns with Guzzle 7.x for compatibility.
- Can I use this package for asynchronous SMS delivery in Laravel?
- Absolutely. Dispatch SMS sending as a Laravel job (e.g., `MelipayamakSmsJob`) and place it on a queue. Use Laravel’s queue workers to process messages asynchronously. The package’s REST/SOAP support aligns well with Laravel’s queue system for delayed or background tasks.
- What Laravel versions does melipayamak/php officially support?
- The package is compatible with Laravel 10 and 11, assuming minor adjustments may be needed for newer features. Test thoroughly with your Laravel version, especially if using PHP 8.1+. Check the package’s GitHub issues for version-specific notes or updates.
- How does error handling work in this package? Does it integrate with Laravel’s exceptions?
- The package likely throws custom exceptions for API errors, which you can catch and convert to Laravel’s `HttpException` or `PaymentException` for consistency. Review the package’s documentation for specific error classes and extend them if needed for your application’s error-handling logic.
- Is there built-in support for webhooks or callbacks from MeliPayamak?
- The package does not explicitly mention webhook support, but you can manually handle SOAP/REST callbacks in Laravel using route middleware or a dedicated `WebhookController`. If the API supports callbacks, extend the package or use Laravel’s `Broadcasting` for real-time updates.
- How can I test SMS sending or API responses locally without hitting rate limits?
- Use Laravel’s `Http::fake()` or `PestPHP` to mock API responses. Create a test double for the `Melipayamak` client and assert interactions with the API. For SMS testing, log messages to a test database or console instead of sending real messages.
- Are there alternatives to melipayamak/php for Turkish SMS or payment APIs?
- If you need alternatives, consider official SDKs like `twilio/sdk` for global SMS or `omnipay/omnipay` for payment gateways. For Turkish-specific solutions, check if MeliPayamak offers an official PHP SDK or explore packages like `yookassa/laravel` for broader payment support.
- How do I handle rate limits or retries for failed API requests in production?
- Implement Laravel’s `retry()` helper in your jobs or use the `retry` middleware for HTTP requests. For rate limits, cache API responses with Laravel’s `cache()->remember()` or integrate with `spatie/laravel-rate-limiting` to throttle requests gracefully.
- Can I integrate this package with Laravel Cashier or a custom billing system?
- While the package isn’t Cashier-specific, you can extend it to work with Laravel Cashier by creating custom payment methods or using it alongside Cashier’s subscription logic. For a custom billing system, wrap the package in a service class (e.g., `PaymentService`) to abstract transaction flows and integrate with your existing models.