- How do I install and configure the EasyPaisa package for Laravel 9 or 10?
- Run `composer require zfhassaan/easypaisa`, then publish the config with `php artisan vendor:publish`. Update your `.env` file with sandbox/production credentials, hash keys, and callback URLs. The package supports both Direct (REST API) and Hosted Checkout flows via `sendRequest()` and `sendHostedRequest()` methods.
- Does this package support both sandbox and production environments?
- Yes, the package includes configuration for both sandbox and production modes. Use `EASYPAISA_MODE=sandbox` or `production` in your `.env` file, and provide the corresponding credentials for each environment. The package automatically routes requests based on this setting.
- What Laravel versions are officially supported by this package?
- The package is confirmed to work with Laravel 9 and 10. Ensure your project uses PHP 8.1 or higher, as the package’s new unit tests are designed for this version. Check the release notes for any version-specific dependencies.
- How do I handle webhook validation for EasyPaisa payments?
- The package includes a `VerifyEasyPaisaSignature` middleware to validate webhook signatures. Ensure your callback route uses this middleware to secure incoming payment notifications. The package also provides helper methods to process webhook payloads, but manual testing of edge cases (e.g., duplicate requests) is recommended.
- Can I use this package with Laravel Cashier for subscriptions?
- While the package itself doesn’t integrate directly with Cashier, you can use its core payment and refund methods alongside Cashier. For subscriptions, manually trigger EasyPaisa payments via the package’s API and handle webhooks to update Cashier’s billing cycles. Test thoroughly for idempotency.
- Are there any known issues with async transactions or retries?
- The package doesn’t include built-in retry logic for failed transactions, so you’ll need to implement this manually using Laravel queues or jobs. For async flows, ensure your queue workers are configured and monitor failed jobs. The package’s unit tests don’t cover retries, so additional testing is advised.
- How do I test the package locally before deploying to production?
- Run the package’s unit tests with `php artisan test` to validate core functionality like payment requests and responses. For webhooks, manually test signature validation using the `VerifyEasyPaisaSignature` middleware. Use sandbox mode and mock API responses to simulate transactions without real payments.
- What alternatives exist if I need multi-gateway support?
- For multi-gateway support, consider Laravel Cashier with Stripe or other payment packages like `spatie/laravel-payments`. This package is tightly coupled to EasyPaisa, so extending it for multiple gateways would require significant refactoring. Alternatively, use feature flags to toggle between EasyPaisa and a backup gateway.
- How do I handle refunds or failed payments with this package?
- The package provides methods to process refunds via the EasyPaisa API. For failed payments, implement a retry mechanism using Laravel queues or manually trigger refunds. Store transaction IDs in your database to reconcile payments and handle disputes. Test refund flows in sandbox mode first.
- Is there documentation for edge cases like duplicate transactions or API rate limits?
- The package lacks detailed documentation for edge cases like idempotency or rate limits. For duplicate transactions, implement server-side checks (e.g., comparing transaction IDs) or use EasyPaisa’s API idempotency keys. Monitor API responses for rate limits and add retries with exponential backoff if needed.