droplopay / droplopay-laravel
Official Laravel package for DroploPay payment gateway (bKash, Nagad, Rocket, bank).
v1.0.0
2026-11-28 06:06 UTC
Requires
- php: >=7.4
- droplopay/droplopay-php: ^1.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Accept bKash, Nagad, Rocket, Upay, bank transfer and more in your Laravel app with DroploPay. Payments are verified automatically by SMS.
Supports Laravel 8 – 12.
Installation
composer require droplopay/droplopay-laravel
Add your keys to .env:
DROPLOPAY_BASE_URL=https://yourname.droplo.online DROPLOPAY_API_KEY=your-api-key
(Optional) publish the config file:
php artisan vendor:publish --tag=droplopay-config
1. Create a payment
use DroploPay\Laravel\Facades\DroploPay; Route::post('/pay/{order}', function (App\Models\Order $order) { $res = DroploPay::createCharge([ 'full_name' => $order->customer_name, 'email' => $order->customer_email, 'amount' => $order->total, 'metadata' => ['order_id' => $order->id], 'redirect_url' => route('droplopay.return'), 'cancel_url' => route('checkout'), 'webhook_url' => route('droplopay.webhook'), 'return_type' => 'GET', ]); return redirect()->away($res['payment_url']); });
2. Verify the payment
use DroploPay\DroploPay as Client; use DroploPay\Laravel\Facades\DroploPay; use Illuminate\Http\Request; function droplopay_confirm(?string $invoiceId): bool { if (!$invoiceId) return false; $p = DroploPay::verifyPayment($invoiceId); if (($p['status'] ?? '') !== 'COMPLETED') return false; $order = App\Models\Order::find($p['metadata']['order_id'] ?? 0); if (!$order || $order->is_paid) return (bool) $order; if ((float) $p['amount'] + 0.01 < (float) $order->total) return false; $order->update(['is_paid' => true, 'transaction_id' => $p['transaction_id'] ?? null]); return true; } // Customer returns to your site Route::get('/droplopay/return', function (Request $r) { return droplopay_confirm($r->query('invoice_id')) ? redirect('/thank-you') : redirect('/checkout')->with('error', 'Payment not completed'); })->name('droplopay.return'); // Server-to-server notification Route::post('/droplopay/webhook', function () { return droplopay_confirm(Client::invoiceIdFromRequest()) ? response('OK') : response('Invalid', 400); })->name('droplopay.webhook');
⚠️ Always call
verifyPayment(). Never mark an order as paid just because someone opened your return URL.
Exclude the webhook from CSRF
Laravel 11 / 12 — bootstrap/app.php:
->withMiddleware(function (Middleware $middleware) { $middleware->validateCsrfTokens(except: ['droplopay/webhook']); })
Laravel 8 – 10 — app/Http/Middleware/VerifyCsrfToken.php:
protected $except = ['droplopay/webhook'];
Methods
| Method | Description |
|---|---|
DroploPay::createCharge(array $data) |
Creates a payment, returns payment_url |
DroploPay::verifyPayment(string $invoiceId) |
Returns status, amount, method, transaction ID, metadata |
DroploPay::isPaid(string $invoiceId) |
true only if COMPLETED |
You can also inject DroploPay\DroploPay in any controller.
Related
Support
- 💬 Discord: https://discord.gg/kB5eECvszk
- 🌐 Website: https://droplopay.com
License
MIT