Skip to content

Bohudur Laravel SDK Documentation

Developer-first Laravel SDK for the Bohudur Payment Automation Platform.

This package is a Laravel wrapper around the Bohudur Payment API, providing a clean service-based architecture, Facade access, and fluent request builders.

Requirements

RequirementValue
PHP^8.0
Laravel^10.x
Extensionscurl, json

Installation

Step 1: Install Package

bash
composer require bohudur/laravel-sdk:^1.1.0

Step 2: Configure Environment

Add your credentials to .env:

env
BOHUDUR_API_KEY=YOUR_API_KEY

Important

Never expose your Bohudur API Key in frontend JavaScript, mobile apps, or public repositories. Always use the Laravel SDK on a secure server.

API Flow Overview (Laravel)

  1. Create payment
  2. Redirect customer to hosted checkout
  3. Customer completes or cancels payment
  4. Execute payment
  5. Receive webhook (optional)
  6. Query payment anytime

This flow is identical to the PHP SDK and cURL API.

Create Payment (Laravel)

Creates a new payment session and returns a hosted checkout URL.

Example

php
use App\Modules\Bohudur\Facades\Bohudur;
use App\Modules\Bohudur\Exceptions\BohudurException;

try {
    $response = Bohudur::request()
        ->fullName('Jane Doe')
        ->email('janedoe@gmail.com')
        ->amount(10)
        ->returnType('GET')
        ->redirectUrl('https://example.com/redirect')
        ->cancelUrl('https://example.com/cancel')
        ->metadata([
            'order_id' => 'ORD-1001',
            'user_id'  => 55
        ])
        ->webhook([
            'success' => 'https://example.com/success',
            'cancel'  => 'https://example.com/cancel'
        ])
        ->send();
}catch (BohudurException $e) {
    echo $e->getMessage(); 
}

Create Payment Parameters

MethodRequiredTypeDescription
fullName()YESstringCustomer full name
email()YESstringCustomer email
amount()YESfloatPayment amount
returnType()YESstringGET or POST
redirectUrl()YESstringRedirect URL after success
cancelUrl()YESstringRedirect URL after cancellation
metadata()NOarrayCustom key-value data
webhook()NOarrayWebhook URLs

Create Payment Response

Success

json
{
  "responseCode": 200,
  "message": "Payment created successfully",
  "status": "success",
  "paymentkey": "5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt",
  "payment_url": "https://checkout.bohudur.one/payment/5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt"
}

Failed

json
{
  "responseCode": 3018,
  "message": "Oops! Internal error. Try again",
  "status": "failed"
}

Response objects are returned as stdClass, allowing direct access like:

php
$response->responseCode;
$response->payment_url;

Redirecting Customer

php
if ($response->status === 'success') {
    return redirect()->away($response->payment_url);
}

Execute Payment (Laravel)

Finalizes a completed payment.

Example

php
$execute = Bohudur::execute('PAYMENT_KEY');

Rules

  • Can be executed only once
  • Payment must be COMPLETED
  • Executed payments are final

Execute Response (Success)

json
{
  "full_name": "Gabriel Adams",
  "email": "jsondoe@gmail.com",
  "amount": 40,
  "converted_amount": 4878,
  "total_amount": 40,
  "transaction_fee": 0,
  "default_currency": "USD",
  "payment_currency": "BDT",
  "currency_value": 121.951,
  "metadata": [],
  "created_time": "2026-01-04 16:04:35",
  "payment_time": "2026-01-04 16:12:37",
  "paymentkey": "fnPwIkdIsMjN4FJxYxw6DF75GuW9qStn",
  "webhook": [],
  "payment_info": {
    "m0": "SSLCommerz",
    "status": "VALID",
    "tran_date": "2026-01-04 16:05:04",
    "tran_id": "IGQM_695a3b59h6a9"
  },
  "status": "EXECUTED"
}

Query Payment (Laravel)

Retrieve payment information at any time.

Example

php
$query = Bohudur::query('PAYMENT_KEY');

Query Payment Status

Success Response

json
{
  "full_name": "Gabriel Adams",
  "email": "jsondoe@gmail.com",
  "amount": 40,
  "converted_amount": 4878,
  "total_amount": 40,
  "transaction_fee": 0,
  "default_currency": "USD",
  "payment_currency": "BDT",
  "currency_value": 121.951,
  "metadata": [],
  "created_time": "2026-01-04 16:04:35",
  "payment_time": "2026-01-04 16:12:37",
  "paymentkey": "fnPwIkdIsMjN4FJxYxw6DF75GuW9qStn",
  "webhook": [],
  "payment_info": {
    "m0": "SSLCommerz",
    "status": "VALID",
    "tran_date": "2026-01-04 16:05:04",
    "tran_id": "IGQM_695a3b59h6a9"
  },
  "status": "EXECUTED" //Can be PENDING/COMPLETED/EXECUTED
}

The Query API may return one of the following statuses:

StatusDescription
PENDINGPayment created but not completed
COMPLETEDPayment completed, ready for execute
EXECUTEDPayment finalized
CANCELLEDPayment cancelled

Response objects are returned as stdClass, allowing direct access like:

php
$query->full_name;
$query->status;

Webhooks (Laravel)

Bohudur sends webhook notifications using POST JSON.

Success Payload

json
{
  "full_name": "Jane Doe",
  "email": "janedoe@gmail.com",
  "amount": 1,
  "paymentkey": "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
  "status": "COMPLETED"
}

Cancel Payload

json
{
  "full_name": "Jane Doe",
  "email": "janedoe@gmail.com",
  "amount": 1,
  "paymentkey": "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
  "status": "CANCELLED"
}

Webhook Handler Example

php
Route::post('/bohudur/webhook', function () {
    $data = request()->all();

    // Always verify
    Bohudur::query($data['paymentkey']);
});

Best Practices

  • Always verify payments using Query API
  • Never execute payments from frontend
  • Webhooks are not final truth
  • Execute payments only once

API Versioning

  • Current Version: v2
  • Base URL includes versioning for stability

Support

For technical support or integration help, contact Bohudur Telegram Support.