Search by

abdur-rahaman / laravel-bd-payment

abdurrahamanbabu

Universal Laravel Payment Gateway Package for Bangladesh - bKash, Nagad, SSLCommerz, ShurjoPay, AamarPay, PayStation, EPS, PortPos

Package info

github.com/abdurrahamanbabu/laravel-bd-payment

pkg:composer/abdur-rahaman/laravel-bd-payment

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-11-29 18:36 UTC

This package is auto-updated.

Last update: 2026-11-29 18:37:36 UTC


README

Universal Laravel package for integrating major Bangladeshi payment gateways through one consistent API.

Package: abdur-rahaman/laravel-bd-payment
Namespace: Abdurrahaman\PaymentGateway
License: MIT
PHP: 8.2+
Laravel: 10 / 11 / 12 / 13

Supported Gateways

Gateway Pay Verify Refund Status
bKash ✅ ✅ ✅ Production
Nagad ✅ ✅ ⚠️ Production*
SSLCommerz ✅ ✅ ⚠️ Production
ShurjoPay ✅ ✅ ⚠️ Production
AamarPay ✅ ✅ ⚠️ Production
PayStation ✅ ✅ ⚠️ Production*
EPS ✅ ✅ ⚠️ Production*
PortPos ✅ ✅ ⚠️ Production*

* Implement against official docs; endpoint paths may need adjustment after merchant onboarding. Always verify with sandbox credentials.

Features

  • Unified pay() / verify() / refund() API across gateways
  • Object-oriented classes and Laravel Facades
  • Dynamic gateway selection via Payment::gateway('bkash')
  • Normalized PaymentResponse with original provider payload preserved
  • Secure server-side verification (never trust redirects alone)
  • Callback / IPN routes with idempotency protection
  • Laravel events: PaymentInitiated, PaymentSuccessful, PaymentFailed, PaymentCancelled, PaymentVerified, PaymentRefunded
  • Publishable config + .env example
  • Strict typing, PSR-12, SOLID-friendly design

Installation

composer require abdur-rahaman/laravel-bd-payment

Publish config:

php artisan vendor:publish --tag=payment-gateway-config

Copy variables from .env.example into your .env and fill credentials from each provider.

Quick Start

Facade (static) API

use Abdurrahaman\PaymentGateway\Facades\Bkash;
use Abdurrahaman\PaymentGateway\Facades\Nagad;
use Abdurrahaman\PaymentGateway\Facades\SSLCommerz;
use Abdurrahaman\PaymentGateway\Facades\ShurjoPay;
use Abdurrahaman\PaymentGateway\Facades\AamarPay;
use Abdurrahaman\PaymentGateway\Facades\PayStation;
use Abdurrahaman\PaymentGateway\Facades\EPS;
use Abdurrahaman\PaymentGateway\Facades\PortPos;

$response = Bkash::pay([
    'amount' => 1500,
    'currency' => 'BDT',
    'order_id' => 'ORDER-1001',
    'customer_name' => 'John Doe',
    'customer_phone' => '017XXXXXXXX',
    'return_url' => route('payment.callback', ['gateway' => 'bkash']),
]);

if ($response->isSuccessful() && $response->getPaymentUrl()) {
    return redirect()->away($response->getPaymentUrl());
}

Object-oriented API

use Abdurrahaman\PaymentGateway\Gateways\ShurjoPay\ShurjoPayGateway;

$gateway = new ShurjoPayGateway(config('payment-gateway.gateways.shurjopay'));
$response = $gateway->pay([...]);

Dynamic gateway selection

use Abdurrahaman\PaymentGateway\Facades\Payment;

$response = Payment::gateway('sslcommerz')->pay([
    'amount' => 500,
    'order_id' => 'ORDER-1003',
    'customer_name' => 'Jane Doe',
    'customer_email' => 'jane@example.com',
    'customer_phone' => '018XXXXXXXX',
    'return_url' => route('payment.callback', ['gateway' => 'sslcommerz']),
]);

Verification (always required)

$verified = Bkash::verify([
    'payment_id' => $paymentId,
]);

if ($verified->getStatus() === 'successful') {
    // Update order — payment is confirmed by provider
}

Never mark an order paid based only on a browser redirect.

Normalized Response

[
    'success' => true,
    'status' => 'pending',          // pending|processing|successful|failed|cancelled|refunded|expired
    'gateway' => 'bkash',
    'transaction_id' => 'TR0011...',
    'order_id' => 'ORDER-1001',
    'amount' => 1500.0,
    'currency' => 'BDT',
    'payment_url' => 'https://...',
    'message' => 'Payment initiated successfully',
    'data' => [ /* original provider response */ ],
]

Callbacks & Events

Routes registered automatically:

  • GET|POST /payment/callback/{gateway}
  • GET|POST /payment/ipn/{gateway}

Listen for events:

use Abdurrahaman\PaymentGateway\Events\PaymentSuccessful;

Event::listen(PaymentSuccessful::class, function ($event) {
    // $event->response, $event->gateway
});

Configuration

See config/payment-gateway.php. Each gateway has its own credential keys matching the official provider requirements. Do not invent shared credential shapes.

Security

  • Credentials only via environment / config
  • HTTPS enforced in production contexts
  • Sensitive values redacted from logs
  • Server-side amount/status verification
  • Callback idempotency (24h cache key)
  • Token caching with safe expiry for bKash / ShurjoPay / EPS

Testing

composer test

Use HTTP fakes; never commit real credentials.

Documentation

Per-gateway notes:

Contributing

See CONTRIBUTING.md.

Changelog

See CHANGELOG.md.

Security Vulnerabilities

See SECURITY.md.

License

MIT — see LICENSE.