Download the PHP package unipay/unipay-bd without Composer
On this page you can find all versions of the php package unipay/unipay-bd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download unipay/unipay-bd
More information about unipay/unipay-bd
Files in unipay/unipay-bd
Package unipay-bd
Short Description Unified Bangladesh Payment Gateway & SaaS Billing Package for Laravel (bKash, Nagad, Rocket, Upay, CellFin, SSLCommerz, Shurjopay & aamarPay)
License MIT
Informations about the package unipay-bd
UniPay BD โ Unified Bangladesh Payment Gateway & SaaS Billing for Laravel
The ultimate unified Laravel payment gateway & SaaS recurring billing engine for Bangladeshi MFS & Card Gateways (bKash, Nagad, Rocket, Upay, CellFin, SSLCommerz, Shurjopay & aamarPay).
๐ Table of Contents
- Overview
- Supported Payment Gateways
- What's New in v2.0
- Requirements
- Installation
- Configuration
- Quick Start & Core Usage
- 1. Fluent Payment Initiation
- 2. Callbacks & Webhooks
- 3. Listen to Payment Events
- 4. Process Refunds
- 5. Query Payment Status
- ๐ข SaaS & Multi-Tenancy Architecture
- Multi-Tenant Gateway Routing
- Runtime Gateway Config Overrides
- ๐ Subscriptions & Recurring Billing (Cashier-Style)
- Using the Billable Trait
- Automatic Billing Cron Worker
- ๐ Hosted Payment Links
- ๐ Virtual Wallets & Credits
- ๐ฑ Currency Conversion & FX Buffering
- ๐ก๏ธ Anti-Fraud & Rate-Limiting (UniPayShield)
- ๐จ Drop-in Checkout Blade Component
- ๐ฉบ System Health Doctor CLI
- ๐งช Mock Gateway for Local Testing
- Extending with Custom Drivers
- Exception & Error Handling
- Testing
- Security
- License
๐ Overview
UniPay BD (unipay/unipay-bd) provides a seamless, developer-friendly driver-based payment integration and SaaS recurring subscription engine for Laravel applications operating in Bangladesh.
Inspired by Laravel's native driver pattern (FilesystemManager, CacheManager, Laravel Cashier), UniPay standardizes bKash, Nagad, Rocket, Upay, CellFin, SSLCommerz, Shurjopay, and aamarPay into an elegant, unified API syntax with complete support for Multi-Tenancy, Subscriptions, Wallets, FX Conversion, and Fraud Prevention.
๐ณ Supported Payment Gateways
UniPay BD natively supports 8 Bangladeshi payment providers + 1 offline mock driver:
| Gateway | Driver | Provider / Channel | Protocol & Security | Supported Operations |
|---|---|---|---|---|
| bKash | bkash |
bKash PGW | Tokenized REST API v1.2 with Bearer token caching | Single Payment, Agreement Recurring, Query, Refund |
| Nagad | nagad |
Nagad MFS | RSA OpenSSL Public Key Encryption & Private Key Signing | Create, Complete, Verify, Refund |
| Rocket | rocket |
Dutch-Bangla Bank (DBBL) | Merchant API v1 with Terminal ID | Create, Verify, Refund |
| Upay | upay |
UCB Fintech | Bearer Token REST API | Create, Verify, Refund |
| CellFin | cellfin |
Islami Bank (IBBL) | Reference ID Checkout API | Create, Verify, Refund |
| SSLCommerz | sslcommerz |
SSL Wireless | GWProcess v4 API & Validation API | Create, Validate, Refund |
| Shurjopay | shurjopay |
ShurjoMukhi | Shurjopay API v2 Tokenized | Create, Verify, Refund |
| aamarPay | aamarpay |
aamarPay PGW | Signature Key Secure JSON API | Create, Query, Refund |
| Mock Driver | mock |
Local Offline Test | Zero-credential sandbox simulation | Instant Create, Query, Refund |
๐ What's New in v2.0
- ๐ข Multi-Tenant SaaS Routing: Dynamically resolve tenant-specific merchant credentials using
Payment::forTenant($tenant)or runtimewithConfig(). Platform fee calculation (platform_fee,net_amount). - ๐ Cashier-Style Subscriptions: Built-in
Billabletrait on any Eloquent model (User,Team), bKash tokenized agreement billing, intervals (monthly,yearly), trial periods, and automated recurring billing worker (php artisan unipay:billing:process). - ๐ Hosted Payment Links: Generate shareable checkout URLs (
PaymentLink::create(...)) with custom expirations, viewable directly at/unipay/pay/{code}with drop-in checkout UI or JSON API. - ๐ Virtual Wallets: Integrated credit ledger (
WalletandWalletTransaction) for customer balance top-ups, deductions, and balance verification. - ๐ฑ Currency Conversion (FX): Automatic multi-currency conversion (
USD,EUR,GBPtoBDT) with configurable safety buffer markup. - ๐ก๏ธ UniPayShield Anti-Fraud: IP/Phone blacklist, velocity limiters, and rapid payment surge detection.
- ๐ณ aamarPay Gateway Driver: First-class support for aamarPay checkout, verification, and refunds.
- ๐งช Offline Mock Gateway: Effortless local development without internet access or sandbox credentials.
- ๐ฉบ Artisan Doctor: Diagnostics command
php artisan unipay:doctorchecking environment configs, migrations, PHP extensions, and gateway endpoints. - ๐จ Drop-in Blade UI:
<x-unipay-checkout />component with sleek styling for zero-friction front-end integration.
โ๏ธ Requirements
- PHP:
^8.1 || ^8.2 || ^8.3 - Laravel:
^10.0 || ^11.0 - PHP Extensions:
ext-json,ext-openssl,ext-curl
๐ฆ Installation
Install the package via Composer:
Run the Artisan installer to publish configuration and run database migrations:
๐ง Configuration
Add your payment gateway credentials to your application's .env file:
โก Quick Start & Core Usage
1. Fluent Payment Initiation
You can construct a payment using the fluent PaymentRequest::builder():
2. Callbacks & Webhooks
UniPay automatically registers a unified callback route at /unipay/callback/{gateway}. When a customer finishes payment, the gateway redirects back to this endpoint, where UniPay verifies transaction status and dispatches events.
3. Listen to Payment Events
Decouple your order processing logic by listening to UniPay events in App\Providers\EventServiceProvider.php (or via Laravel 11 auto-discovery):
4. Process Refunds
Issue full or partial refunds directly:
5. Query Payment Status
Query any transaction status explicitly at any time:
๐ข SaaS & Multi-Tenancy Architecture
UniPay BD v2.0 is built from the ground up to support multi-tenant SaaS applications where different tenants/vendors have their own merchant accounts or where platform fees must be retained.
Multi-Tenant Gateway Routing
Define a global tenant resolver in your AppServiceProvider:
Then initiate payments scoped to the tenant:
Runtime Gateway Config Overrides
You can also override credentials on the fly without using the tenant resolver:
๐ Subscriptions & Recurring Billing (Cashier-Style)
UniPay BD provides an expressive, Cashier-inspired recurring billing engine using bKash Tokenized Agreements or automatic wallet deductions.
Using the Billable Trait
Add the Billable trait to your User or Organization model:
Create and Manage Subscriptions
Automatic Billing Cron Worker
UniPay provides a console command to automatically charge all active subscriptions that are due for renewal:
Schedule it in your routes/console.php (Laravel 11) or app/Console/Kernel.php (Laravel 10):
๐ Hosted Payment Links
Create instant, shareable payment links for invoices, donations, or custom orders:
When opened in a browser, customers see a clean checkout portal where they can pick a payment method. Alternatively, your frontend can fetch it via JSON:
๐ Virtual Wallets & Credits
Enable micro-transactions, customer top-ups, and in-app credit systems:
๐ฑ Currency Conversion & FX Buffering
If your SaaS charges in USD, EUR, or GBP, UniPay converts international currencies to BDT with an optional safety margin buffer:
๐ก๏ธ Anti-Fraud & Rate-Limiting (UniPayShield)
Protect your platform from rapid bot carding and spam payments:
Throws \Unipay\BD\Exceptions\UnipayException if suspicious velocity or blacklisted identity is detected.
๐จ Drop-in Checkout Blade Component
Render a ready-to-use payment selector widget in any Blade template:
๐ฉบ System Health Doctor CLI
Troubleshoot payment issues, verify migrations, validate SSL certificates, and check merchant credentials with a single command:
Sample output:
๐งช Mock Gateway for Local Testing
Need to test your checkout flow in development or CI without active sandbox credentials?
Use the built-in mock driver:
Or programmatically:
๐ ๏ธ Extending with Custom Drivers
You can easily register custom gateway drivers using Payment::extend():
โ ๏ธ Exception & Error Handling
UniPay provides a clean exception hierarchy:
Unipay\BD\Exceptions\UnipayException: Base package exception.Unipay\BD\Exceptions\InvalidGatewayException: Thrown when requesting an unsupported gateway.Unipay\BD\Exceptions\BkashApiException: Thrown when bKash returns API/credential errors.Unipay\BD\Exceptions\NagadEncryptionException: Thrown when OpenSSL RSA keys or signatures fail.Unipay\BD\Exceptions\PaymentVerificationFailedException: Thrown on failed checksums or invalid amounts.
๐งช Testing
UniPay BD includes a comprehensive test suite with 100% mocked HTTP and database coverage:
๐ Security
If you discover any security-related issues, please email [email protected] instead of using the public issue tracker.
๐ License
UniPay BD is open-sourced software licensed under the MIT License.
Crafted with โค๏ธ for the Bangladeshi Developer Community by Atik Hasan.
All versions of unipay-bd with dependencies
illuminate/support Version ^10.0 || ^11.0
illuminate/contracts Version ^10.0 || ^11.0
guzzlehttp/guzzle Version ^7.5
ext-json Version *
ext-openssl Version *