EPS Payment Gateway for Laravel - Easy Payment System (eps.com.bd). Simple integration with token, payment initialization, verification, and optional currency conversion to BDT.

Maintainers

Package info

github.com/sixersoft/eps

pkg:composer/sixersoft/eps

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-04 01:36 UTC

This package is auto-updated.

Last update: 2026-06-04 02:02:46 UTC


README

sixersoft/eps — Simple, clean, and production-ready integration for EPS (Easy Payment System) Bangladesh (eps.com.bd).

  • Official API support (Get Token → Initialize Payment → Verify Transaction)
  • Optional automatic currency conversion (USD / EUR / any → BDT)
  • Clean Facade + Service injection
  • Sandbox + Production ready
  • Full hash generation exactly as per EPS official guide (HMAC-SHA512 + Base64)
  • Detailed logging

Installation

1. Install via Composer

composer require sixersoft/eps

2. Publish the configuration file

php artisan vendor:publish --provider="Sixersoft\Eps\EpsServiceProvider" --tag="eps-config"

This will create config/eps.php.

3. Add credentials to .env

# EPS Credentials (get from https://www.eps.com.bd merchant portal)
EPS_IS_SANDBOX=true

EPS_MERCHANT_ID=your-merchant-id
EPS_STORE_ID=your-store-id
EPS_USERNAME=your-username
EPS_PASSWORD=your-password
EPS_HASH_KEY=your-hash-key

# Optional: Currency conversion (see below)
EPS_CURRENCY_CONVERSION=false
EPS_RATE_USD=117.50
EPS_RATE_EUR=127.00

4. (Optional) Clear cache

php artisan config:clear

Basic Usage

Using Facade (Recommended - Easiest)

use Sixersoft\Eps\Facades\EPS;

// 1. Initialize Payment
$result = EPS::initializePayment([
    'amount' => 150,                    // Can be in USD if conversion enabled
    'currency' => 'USD',                // Optional - triggers conversion if enabled
    'customer_name' => 'John Doe',
    'customer_email' => 'john@example.com',
    'customer_phone' => '01911223344',
    'customer_address' => '123 Main St, Dhaka',
    'customer_city' => 'Dhaka',
    'customer_state' => 'Dhaka',
    'customer_postcode' => '1200',
    'success_url' => 'https://yoursite.com/payment/success',
    'fail_url' => 'https://yoursite.com/payment/fail',
    'cancel_url' => 'https://yoursite.com/payment/cancel',
    'product_name' => 'Premium T-Shirt',
    // 'products' => [...]              // Optional: full ProductList array
]);

if ($result['success']) {
    // Redirect user to EPS gateway
    return redirect()->away($result['redirect_url']);
}

return back()->with('error', $result['message']);

Using Dependency Injection

use Sixersoft\Eps\EPS;

public function pay(EPS $eps)
{
    $result = $eps->initializePayment([...]);
}

Verify Payment (in success/fail/cancel routes)

use Sixersoft\Eps\Facades\EPS;

public function success(Request $request)
{
    $merchantTxnId = $request->get('merchantTransactionId') 
        ?? session('eps_merchant_txn_id');

    $verification = EPS::verifyTransaction($merchantTxnId);

    if ($verification['success']) {
        // Update your order as PAID
        // Order::where('merchant_transaction_id', $merchantTxnId)->update(['status' => 'paid']);
        
        return view('payment.success', compact('verification'));
    }

    return view('payment.failed', compact('verification'));
}

Important: Always call verifyTransaction() on callback pages for security.

Currency Conversion to BDT (The Special Feature)

EPS only accepts amounts in BDT. This package makes it dead simple to accept payments in other currencies.

Enable in config/eps.php or .env

EPS_CURRENCY_CONVERSION=true
EPS_RATE_USD=118.00          # Update regularly
EPS_RATE_EUR=128.50

Usage

$result = EPS::initializePayment([
    'amount' => 10,           // 10 USD
    'currency' => 'USD',
    // ... other fields
]);

// In response you will get:
// 'converted_amount_bdt' => 1180.00
// 'original_amount' => 10
// 'currency' => 'USD'

Manual Conversion (anywhere in your app)

use Sixersoft\Eps\Facades\EPS;

$bdtAmount = EPS::convertToBDT(25, 'USD');   // 25 USD → BDT using current rate

// Or get the converter for advanced use
$converter = EPS::currency();
$converter->setRate('USD', 119.75);           // Update rate at runtime
$converter->setEnabled(true);

echo EPS::convertToBDT(5, 'EUR');

How to keep rates updated?

Recommended (simple & free):

  • Update rates manually in config/eps.php or .env every few days.
  • Or create a daily command that fetches from a free API (exchangerate.host, etc.) and calls EPS::currency()->setRate().

You can completely disable the feature (EPS_CURRENCY_CONVERSION=false) — the package will then expect you to always pass BDT amount.

Full Configuration Reference

See the published config/eps.php. Most important keys are in .env.

You can also override at runtime:

EPS::setConfig([
    'is_sandbox' => false,
    'merchant_id' => 'live-xxx',
]);

Required Fields for initializePayment()

Field Required Notes
success_url Yes Your success callback
fail_url Yes Your fail callback
cancel_url Yes Your cancel callback
customer_name Yes
customer_email Yes
customer_phone Yes
customer_address Yes
customer_city Yes
customer_state Yes
customer_postcode Yes
amount + currency Yes* Or use total_amount (in BDT)

Optional but recommended:

  • product_name
  • products (array for ProductList)
  • customer_order_id
  • merchant_transaction_id (auto-generated if not provided — must be unique)

Callback URLs Best Practice

Create three routes in your app:

// routes/web.php
Route::get('/payment/success', [PaymentController::class, 'success']);
Route::get('/payment/fail', [PaymentController::class, 'fail']);
Route::get('/payment/cancel', [PaymentController::class, 'cancel']);

Pass these exact URLs when calling initializePayment().

In the callback controllers, always verify using EPS::verifyTransaction().

Logging

All requests/responses are logged to your default log channel (or EPS_LOG_CHANNEL).

Check storage/logs/laravel.log for [EPS Package].

Testing / Sandbox

Use the sandbox credentials provided by EPS.

Example sandbox credentials (for testing only — replace with yours):

EPS_IS_SANDBOX=true
EPS_MERCHANT_ID=29e86e70-0ac6-45eb-ba04-9fcb0aaed12a
EPS_STORE_ID=d44e705f-9e3a-41de-98b1-1674631637da
EPS_USERNAME=Epsdemo@gmail.com
EPS_PASSWORD=Epsdemo258@
EPS_HASH_KEY=FHZxyzeps56789gfhg678ygu876o=

After going live, set EPS_IS_SANDBOX=false and use production credentials.

Example Full Flow (Controller)

Ready-to-use example files are included in the examples/ folder of this package:

  • examples/PaymentController.php — Complete controller with checkout, pay, success, fail, cancel
  • examples/routes.php — Sample routes to add in your web.php

Copy them into your project and customize as needed.

A beautiful demo product page (from the original integration) is also available in the GitHub repository.

Security Notes

  • Never expose your hash_key, password etc.
  • Always verify transactions server-side using verifyTransaction().
  • Use HTTPS for all callback URLs in production.
  • Store merchant_transaction_id in your database for reconciliation.

Contributing

Pull requests are welcome! Please open an issue first for major changes.

License

MIT License. See LICENSE file.

Support

Developed by SixerSoft — Making Bangladesh payment integration easy.

Repository: https://github.com/sixersoft/eps

Packagist: https://packagist.org/packages/sixersoft/eps

Happy integrating! 🇧🇩