mdiqbal / laravel-payments
A unified payment gateway package for Laravel supporting 21+ payment providers
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:laravel-package
pkg:composer/mdiqbal/laravel-payments
Requires
- php: ^8.2
- abraham-flutterwave/laravel-payment: ^1.0
- guzzlehttp/guzzle: ^7.0
- illuminate/http: ^10|^11|^12
- illuminate/support: ^10|^11|^12
- loveycom/cashfree: ^2.0
- midtrans/midtrans-php: ^2.5
- mollie/laravel-mollie: ^3.0
- myfatoorah/laravel-package: ^2.0
- njoguamos/laravel-pesapal: ^2.0
- raziul/sslcommerz-laravel: ^1.0
- sabitahmad/laravel-bkash: ^2.0
- srmklive/paypal: ^3.0
- stripe/stripe-php: ^15.0
- yogeshgupta/phonepe-laravel: ^1.0
- zfhassaan/easypaisa: ^1.0
Requires (Dev)
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^10
Suggests
- iamolayemi/laravel-paystack: Paystack (Laravel 9/10)
- squareboat/razorpay-cashier: Required for Razorpay support (Laravel 12 only)
- techtailor/laravel-paytm: Paytm (Laravel 9 only)
README
A comprehensive Laravel package for integrating multiple payment gateways into your application. This package provides a unified interface for processing payments through various payment providers including Stripe, PayPal, Razorpay, Paystack, and many more.
Table of Contents
- Features
- Supported Gateways
- Installation
- Configuration
- Basic Usage
- Gateway Documentation
- Testing
- Contributing
- License
Features
- Unified Interface: Single API for all payment gateways
- Multiple Gateways: Support for 20+ payment gateways
- Secure: Built with security best practices
- Flexible: Easy to extend with new gateways
- Laravel Ready: Built specifically for Laravel
- Webhook Support: Built-in webhook handling
- Error Handling: Comprehensive error management
- Test Friendly: Full testing support
Supported Gateways
| Gateway | Regions | Supported Methods | Documentation |
|---|---|---|---|
| Stripe | Global | Cards, Apple Pay, Google Pay, ACH | Guide |
| PayPal | Global | PayPal, Cards, Venmo | Guide |
| Paystack | Africa | Cards, Bank Transfer, USSD | Guide |
| Razorpay | India | Cards, UPI, NetBanking, Wallets | Guide |
| PayTM | India | Wallet, Cards, NetBanking, UPI | Guide |
| Flutterwave | Africa | Cards, Mobile Money, Bank Transfer | Guide |
| SSLCommerz | Bangladesh | Cards, Mobile Banking, Bank Transfer | Guide |
| Mollie | Europe | Cards, iDEAL, Bank Transfer, Klarna | Guide |
| SenangPay | Malaysia | Cards, FPX, Online Banking | Guide |
| bKash | Bangladesh | Mobile Wallet | Guide |
| Mercado Pago | Latin America | Cards, Bank Transfer, Wallets | Guide |
| Cashfree | India | Cards, UPI, NetBanking, Wallets | Guide |
| PayFast | South Africa | Cards, EFT, Zapper, Masterpass | Guide |
| Skrill | Global | Wallet, Cards, Bank Transfer | Guide |
| PhonePe | India | UPI, Cards, Wallets | Guide |
| Telr | Middle East | Cards, Knet, Sadad, Fawry | Guide |
| iyzico | Turkey | Cards, Bank Transfer, Wallets | Guide |
| Pesapal | Africa | Cards, Mobile Money, Bank Transfer | Guide |
| Midtrans | Indonesia | Cards, Bank Transfer, E-Wallets | Guide |
| MyFatoorah | Middle East | Cards, Knet, Benefit, Sadad | Guide |
| EasyPaisa | Pakistan | Mobile Wallet, Bank Transfer | Guide |
Installation
- Install the package via Composer:
composer require mdiqbal/laravel-payments
- Publish the configuration file:
php artisan vendor:publish --provider="Mdiqbal\LaravelPayments\PaymentsServiceProvider"
- Add your payment gateway credentials to your
.envfile:
# Example for Stripe STRIPE_MODE=test STRIPE_SANDBOX_SECRET=your_sandbox_secret_key STRIPE_SANDBOX_KEY=your_sandbox_publishable_key STRIPE_LIVE_SECRET=your_live_secret_key STRIPE_LIVE_KEY=your_live_publishable_key STRIPE_WEBHOOK_SECRET=your_webhook_secret # Example for PayPal PAYPAL_MODE=sandbox PAYPAL_SANDBOX_CLIENT_ID=your_sandbox_client_id PAYPAL_SANDBOX_CLIENT_SECRET=your_sandbox_client_secret PAYPAL_LIVE_CLIENT_ID=your_live_client_id PAYPAL_LIVE_CLIENT_SECRET=your_live_client_secret # Example for Mercado Pago MERCADOPAGO_MODE=sandbox MERCADOPAGO_SANDBOX_ACCESS_TOKEN=your_sandbox_access_token MERCADOPAGO_LIVE_ACCESS_TOKEN=your_live_access_token MERCADOPAGO_COUNTRY=MX MERCADOPAGO_WEBHOOK_SECRET=your_webhook_secret
Configuration
The package configuration file is located at config/payments.php. Here you can configure all supported gateways:
return [ 'default' => env('PAYMENT_DEFAULT_GATEWAY', 'stripe'), 'gateways' => [ 'stripe' => [ 'mode' => env('STRIPE_MODE', 'sandbox'), 'sandbox' => [ 'secret_key' => env('STRIPE_SANDBOX_SECRET'), 'api_key' => env('STRIPE_SANDBOX_KEY'), ], 'live' => [ 'secret_key' => env('STRIPE_LIVE_SECRET'), 'api_key' => env('STRIPE_LIVE_KEY'), ], 'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'), ], 'paypal' => [ 'mode' => env('PAYPAL_MODE', 'sandbox'), 'sandbox' => [ 'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID'), 'client_secret' => env('PAYPAL_SANDBOX_CLIENT_SECRET'), ], 'live' => [ 'client_id' => env('PAYPAL_LIVE_CLIENT_ID'), 'client_secret' => env('PAYPAL_LIVE_CLIENT_SECRET'), ], 'webhook_id' => env('PAYPAL_WEBHOOK_ID'), ], // ... other gateways ], ];
Basic Usage
Making a Payment
use Mdiqbal\LaravelPayments\Facades\Payment; use Mdiqbal\LaravelPayments\DTO\PaymentRequest; // Create a payment request $paymentRequest = new PaymentRequest( amount: 100.00, currency: 'USD', description: 'Payment for Order #12345' ); // Set optional parameters $paymentRequest->setTransactionId('order_' . uniqid()); $paymentRequest->setReturnUrl(route('payment.success')); $paymentRequest->setCancelUrl(route('payment.cancel')); // Process payment with default gateway $response = Payment::pay($paymentRequest); // Or process with a specific gateway $response = Payment::gateway('stripe')->pay($paymentRequest); // Handle response if ($response->isSuccess()) { if ($response->isRedirect()) { return redirect($response->getRedirectUrl()); } $transactionId = $response->getTransactionId(); // Save transaction ID to database } else { $errorMessage = $response->getMessage(); // Handle error }
Retrieving Payment Status
use Mdiqbal\LaravelPayments\Facades\Payment; $transactionId = 'txn_1234567890'; $response = Payment::gateway('stripe')->retrievePayment($transactionId); if ($response->isSuccess()) { $status = $response->getData()['status']; $amount = $response->getData()['amount']; // Update order status }
Processing Refunds
use Mdiqbal\LaravelPayments\Facades\Payment; $transactionId = 'txn_1234567890'; $refundAmount = 50.00; $reason = 'Customer requested refund'; try { $success = Payment::gateway('stripe')->refund($transactionId, $refundAmount, $reason); if ($success) { // Refund processed successfully } } catch (\Exception $e) { // Handle refund failure }
Gateway Documentation
Stripe
Stripe is a global payment gateway accepting cards, digital wallets, and local payment methods. Ideal for international businesses.
Quick Start:
$response = Payment::gateway('stripe')->pay($paymentRequest); $clientSecret = $response->getData()['client_secret'];
PayPal
PayPal provides a trusted payment solution with support for PayPal accounts, cards, and alternative payment methods.
Quick Start:
$response = Payment::gateway('paypal')->pay($paymentRequest); $approvalUrl = $response->getRedirectUrl();
Paystack
Paystack is the leading payment gateway in Africa, supporting cards, bank transfers, and mobile money.
Quick Start:
$response = Payment::gateway('paystack')->pay($paymentRequest); $authorizationUrl = $response->getRedirectUrl();
Razorpay
Razorpay is India's payment solution supporting UPI, cards, net banking, and popular wallets.
Quick Start:
$response = Payment::gateway('razorpay')->pay($paymentRequest); $orderId = $response->getData()['id'];
PayTM
PayTM is one of India's largest digital payment platforms supporting wallet, cards, and UPI payments.
Quick Start:
$response = Payment::gateway('paytm')->pay($paymentRequest); $txnToken = $response->getData()['txnToken'];
Flutterwave
Flutterwave powers payments across Africa with support for cards, mobile money, and bank transfers.
Quick Start:
$response = Payment::gateway('flutterwave')->pay($paymentRequest); $paymentLink = $response->getRedirectUrl();
SSLCommerz
SSLCommerz is Bangladesh's leading payment gateway with support for cards, mobile banking, and bank transfers.
Quick Start:
$response = Payment::gateway('sslcommerz')->pay($paymentRequest); $gatewayUrl = $response->getRedirectUrl();
Mollie
Mollie is a European payment gateway supporting iDEAL, credit cards, Bancontact, and other local payment methods.
Quick Start:
$response = Payment::gateway('mollie')->pay($paymentRequest); $checkoutUrl = $response->getRedirectUrl();
SenangPay
SenangPay is Malaysia's payment gateway supporting FPX, online banking, and credit cards.
Quick Start:
$response = Payment::gateway('senangpay')->pay($paymentRequest); $paymentUrl = $response->getRedirectUrl();
bKash
bKash is Bangladesh's largest mobile financial service providing mobile wallet payments.
Quick Start:
$response = Payment::gateway('bkash')->pay($paymentRequest); $paymentID = $response->getData()['paymentID'];
Mercado Pago
Mercado Pago is Latin America's leading payment platform supporting various local payment methods.
Quick Start:
$response = Payment::gateway('mercadopago')->pay($paymentRequest); $initPoint = $response->getData()['init_point'];
Cashfree
Cashfree is an Indian payment gateway supporting UPI, cards, net banking, and wallets.
Quick Start:
$response = Payment::gateway('cashfree')->pay($paymentRequest); $paymentLink = $response->getRedirectUrl();
PayFast
PayFast is South Africa's payment gateway supporting cards, EFT, and various payment methods.
Quick Start:
$response = Payment::gateway('payfast')->pay($paymentRequest); $redirectUrl = $response->getRedirectUrl();
Skrill
Skrill is a global payment solution supporting wallet transfers, cards, and bank transfers.
Quick Start:
$response = Payment::gateway('skrill')->pay($paymentRequest); $sessionId = $response->getData()['sessionid'];
PhonePe
PhonePe is India's UPI-based payment platform supporting UPI, cards, and wallets.
Quick Start:
$response = Payment::gateway('phonepe')->pay($paymentRequest); $paymentUrl = $response->getRedirectUrl();
Telr
Telr is a Middle East payment gateway supporting cards, Knet, Sadad, and other local methods.
Quick Start:
$response = Payment::gateway('telr')->pay($paymentRequest); $orderUrl = $response->getRedirectUrl();
iyzico
iyzico is Turkey's payment platform supporting cards, bank transfers, and digital wallets.
Quick Start:
$response = Payment::gateway('iyzico')->pay($paymentRequest); $paymentPageUrl = $response->getData()['paymentPageUrl'];
Pesapal
Pesapal provides payment solutions across Africa with support for cards and mobile money.
Quick Start:
$response = Payment::gateway('pesapal')->pay($paymentRequest); $redirectUrl = $response->getRedirectUrl();
Midtrans
Midtrans is Indonesia's payment gateway supporting cards, bank transfers, and e-wallets.
Quick Start:
$response = Payment::gateway('midtrans')->pay($paymentRequest); $redirectUrl = $response->getRedirectUrl();
MyFatoorah
MyFatoorah is a Middle East payment platform supporting Knet, Benefit, and other local methods.
Quick Start:
$response = Payment::gateway('myfatoorah')->pay($paymentRequest); $invoiceURL = $response->getData()['InvoiceURL'];
EasyPaisa
EasyPaisa is Pakistan's mobile banking platform supporting wallet payments and bank transfers.
Quick Start:
$response = Payment::gateway('easypaisa')->pay($paymentRequest); $transactionUrl = $response->getRedirectUrl();
Testing
Running Tests
# Run all tests composer test # Run specific test composer test -- --filter StripePaymentTest # Generate coverage report composer test -- --coverage
Test Configuration
Set test mode in your .env.testing file:
PAYMENT_DEFAULT_GATEWAY=stripe STRIPE_MODE=test STRIPE_SANDBOX_SECRET=sk_test_xxxxxxxxxxxxxx STRIPE_SANDBOX_KEY=pk_test_xxxxxxxxxxxxxx
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Development Setup
- Clone the repository
- Install dependencies:
composer install - Run tests:
composer test
License
This package is open-sourced software licensed under the MIT license.
Support
- 📧 Email: support@laravel-payments.com
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Full Documentation
- 💬 Discord: Join our Discord
Security
If you discover any security related issues, please email security@laravel-payments.com instead of using the issue tracker.