Skip to content

Bohudur PHP SDK

Developer-first PHP SDK for Bohudur Payment Automation Platform.

Requirements

RequirementValue
PHP Version7.4 or higher
Extensionscurl, json
EnvironmentServer-side only

Installation

Step 1: Download SDK

Download Bohudur WHMCS Module

Download the SDK, extract the ZIP file, and save the SDK file as:

text
bohudur.php

Step 2: Include SDK

php
define('BOHUDUR', true);
require 'bohudur.php';

Important

Direct access is blocked unless the BOHUDUR constant is defined.

Authentication

All API requests are authenticated using an API Key.

Initialization (Required)

php
Bohudur::init('YOUR_API_KEY');

Important

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

Validation Rules

RuleDescription
RequiredYes
FormatAlphanumeric only
ScopeGlobal (static)

If initialization is skipped, all requests will fail.

API Flow

1. Bohudur::Request()->Send()   → Get payment_url + paymentkey

2. Redirect user to payment_url

3. User pays or cancels on hosted checkout

4. Bohudur::Execute('key')      → Confirm and finalize the payment

5. Webhook sent to your server (if configured)

6. Bohudur::Query('key')        → Check status anytime

Create Payment API (PHP)

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

PHP Example

php
$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.php',
        'cancel'  => 'https://example.com/cancel.php'
    ])
    ->Send();

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

Success Response

Returned when payment creation is successful.

php
[
  "responseCode" => 200,
  "message" => "Payment created successfully",
  "status" => "success",
  "paymentkey" => "5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt",
  "payment_url" => "https://checkout.bohudur.one/payment/5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt"
]

Response Fields Explained

FieldTypeDescription
responseCodenumberHTTP-like response code. 200 indicates success.
messagestringHuman-readable message describing the result.
statusstringPayment creation status. Always success on success.
paymentkeystringA unique 32-character alphanumeric key generated for each payment.
payment_urlstringHosted checkout URL where the customer completes the payment.

Failed Response

php
[
  "responseCode" => 3018,
  "message" => "Oops! Internal error. Try again",
  "status" => "failed"
]

Create Payment Error Codes (PHP)

The following table lists all possible error codes returned by the Create Payment API.

CodeMessageDescription
3000API key not foundAH-BOHUDUR-API-KEY header is missing
3001Required parameters not foundOne or more required fields are missing
3002--- parameter is emptySpecific field value is empty
3003Invalid Full Name Formatfull_name must be a valid non-empty string
3004Invalid Email FormatEmail address is not valid
3005Invalid Amount FormatAmount must be a positive numeric value
3006Invalid Return Type FormatOnly GET or POST allowed
3007Invalid Return URL Formatredirect_url is not a valid URL
3008Invalid Cancel URL Formatcancel_url is not a valid URL
3009Invalid JSON format in metadatametadata must be a valid JSON object
3010Invalid JSON format in webhookwebhook must be a valid JSON object
3011Invalid webhook actionsOnly success and cancel keys allowed in webhook
3012Invalid JSON format in metadata or webhookOne or both JSON objects are malformed
3013Invalid API keyAPI key is incorrect or inactive
3014Oops! internal error. Try again.Temporary server-side issue — retry
3015Unknown amount providedAmount value is not acceptable
3016You don't have accessRequest blocked due to IP restriction
3017Oops! Internal error. Try again.Unexpected internal server error
3018Unable to create paymentPayment session could not be created

Redirecting Customer

php
if ($response['status'] === 'success') {
    header('Location =>' . $response['payment_url']);
    exit;
}

Execute Payment API (PHP)

Finalizes a completed payment.

PHP Example

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

Execution Rules

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

Success Response

php
[
  "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",
  "receipt" => "https://pay.bohudur.one/receipt/download/102f89389f9e",
  "webhook" =>[],
  "payment_info" => [
    "m0" => "Stripe",
    more....
  ],
  "status" => "EXECUTED"
]

Response Parameters

FieldTypeDescription
full_namestringCustomer’s full name
emailstringCustomer’s email address
amountnumberOriginal payment amount in default currency
converted_amountnumberAmount converted to the payment currency
total_amountnumberTotal amount charged (amount + fees)
transaction_feenumberTransaction fees applied (if any)
default_currencystringYour account default currency
payment_currencystringCurrency used for the payment
currency_valuenumberConversion rate applied (default → payment currency)
metadataarrayOptional metadata submitted during creation
created_timestringPayment creation timestamp
payment_timestringTime when the payment was completed by the customer
paymentkeystringUnique key identifying this payment
webhookarrayWebhook URLs configured for this payment
receiptstringURL to download the PDF receipt for this payment
payment_infoobjectTransaction-specific info
statusstringPayment execution status. Always EXECUTED on success

Error Response Example

php
[
  "responseCode" => 3108,
  "message" => "Payment already executed!",
  "status" => "failed"
]

Common Error Codes

CodeMessageDescription
3100API key not foundThe request did not include an API key. Ensure the AH-BOHUDUR-API-KEY header is set.
3101API key not validThe provided API key is invalid or inactive.
3102Invalid Payment KeyThe paymentkey provided is malformed or does not exist.
3103Invalid api keyThe API key used does not match any active account.
3104You don't have access! Your IP =>...Your IP address is not authorized to perform this request. Replace...with your server IP in the message.
3105Payment Data Not FoundNo payment data exists for the given paymentkey.
3106Payment is pending!The payment has not yet been completed by the customer. Execute is only allowed after completion.
3107Payment is cancelled!The payment was cancelled by the customer or system.
3108Payment already executed!This payment has already been executed. Execution can only happen once.
3109Failed to execute paymentThe payment could not be executed due to a server or processing error.

Important

The Execute API is idempotent by design.
A payment can only be executed once. Any attempt to execute the same payment again will return Payment already executed!.
This prevents duplicate payments.

Query Payment API (PHP)

Retrieve payment data at any time.

PHP Example

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

Response Types

The Query API can return four types of responses, depending on the payment status.

1. PENDING Payment

Payment created but not yet completed by the user.

php
[
  "full_name" => "Chloe Morales",
  "email" => "demo@gmail.com",
  "amount" => 1,
  "converted_amount" => 1,
  "total_amount" => 1,
  "transaction_fee" => 0,
  "default_currency" => "USD",
  "payment_currency" => "USD",
  "currency_value" => 1,
  "metadata" => [],
  "created_time" => "2026-01-07 10:02:20",
  "payment_time" => "NONE",
  "paymentkey" => "7QWQsOhg9X7dgQlfRO4EPxWKK9qaCWka",
  "receipt" => "NONE",
  "webhook" => [],
  "payment_info" => [],
  "status" => "PENDING"
]

2. COMPLETED Payment

Payment successfully completed by the user.

php
[
  "full_name" => "Jane Doe",
  "email" => "demo@gmail.com",
  "amount" => 150,
  "converted_amount" => 150,
  "total_amount" => 150,
  "transaction_fee" => 0,
  "default_currency" => "USD",
  "payment_currency" => "USD",
  "currency_value" => 1,
  "metadata" => [],
  "created_time" => "2025-12-11 21:47:11",
  "payment_time" => "2025-12-11 23:11:25",
  "paymentkey" => "TYtsYll15iqsDqsR4h8EJrMfou9NavE2",
  "receipt" => "https://pay.bohudur.one/receipt/download/102f89389f9e",
  "webhook" => [],
  "payment_info" => [
    "m0" => "Stripe",
    more....
  ],
  "status" => "COMPLETED"
]

Explanation

  • payment_time → Timestamp when payment was completed
  • payment_info → Contains transaction details (processor-specific info)
  • statusCOMPLETED indicates payment is successful and ready for execution

3. EXECUTED Payment

Payment has been executed/confirmed via the Execute API.

php
[
  "full_name" => "Gabriel Adams",
  "email" => "demo@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" => "fnPwIkdIsMjN4FJxYxw6DF0I92W9qStn",
  "webhook" => [],
  "payment_info" => [
    "m0" => "Stripe",
    more....
  ],
  "status" => "EXECUTED"
]

Important

An executed payment is final and cannot be executed again. This protects your system from duplicate payments and ensures each payment key is one-time use only.

4. CANCELLED Payment

Payment that was cancelled by the user or system.

php
[
  "full_name" => "Jane Doe",
  "email" => "demo@gmail.com",
  "amount" => 1,
  "converted_amount" => 1,
  "total_amount" => 1,
  "transaction_fee" => 0,
  "default_currency" => "USD",
  "payment_currency" => "USD",
  "currency_value" => 1,
  "metadata" => [
    "data1" => "value1",
    "data2" => "value2"
  ],
  "created_time" => "2026-01-18 19:30:56",
  "payment_time" => "NONE",
  "paymentkey" => "P4m1OEiopqPy4cFx9QO0mARuzqxx7bsf",
  "receipt" => "NONE",
  "webhook" => [
    "success" => "https://example.com/success.php",
    "cancel" => "https://example.com/cancel.php"
  ],
  "payment_info" => [],
  "status" => "CANCELLED"
]

Notice

A cancelled payment cannot be executed. If a user cancels a payment, the payment link becomes inactive and the status is set to CANCELLED.

Explanation

FieldTypeDescription
full_namestringCustomer’s full name
emailstringCustomer’s email
amountnumberOriginal payment amount
converted_amountnumberAmount converted to payment currency
total_amountnumberTotal amount including fees
transaction_feenumberTransaction fee applied (if any)
default_currencystringYour account default currency
payment_currencystringPayment currency
currency_valuenumberConversion rate applied
metadataarrayOptional metadata sent during creation
created_timestringPayment creation timestamp
payment_timestringTime payment completed (NONE if pending)
paymentkeystringUnique identifier for this payment
webhookarrayWebhook URLs (if configured)
payment_infoarrayEmpty while pending
statusstringPENDING

Payment Info By Gateways

json
{
    "payment_info": {
        "id": 1,
        "gateway": "bkash",
        "method": "Send Money",
        "number": "01XXXXXXXXX",
        "amount": 100,
        "trx": "TRX123ABC456",
        "time": "01/01/2026 12:00",
        "m0": "Bkash Send Money"
    }
}
json
{
    "payment_info": {
        "id": 1,
        "gateway": "nagad",
        "method": "Send Money",
        "number": "01XXXXXXXXX",
        "amount": 100,
        "trx": "TRX123ABC456",
        "time": "01/01/2026 12:00",
        "m0": "Nagad Send Money"
    }
}
json
{
    "payment_info": {
        "id": 1,
        "gateway": "rocket",
        "method": "Send Money",
        "number": "01XXXXXXXXX",
        "amount": 100,
        "trx": "TRX123ABC456",
        "time": "01/01/2026 12:00",
        "m0": "Rocket Send Money"
    }
}
json
{
    "payment_info": {
        "id": 1,
        "gateway": "upay",
        "method": "Send Money",
        "number": "01XXXXXXXXX",
        "amount": 100,
        "trx": "TRX123ABC456",
        "time": "01/01/2026 12:00",
        "m0": "Upay Send Money"
    }
}
json
{
    "payment_info": {
        "id": 1,
        "gateway": "mcash",
        "method": "Send Money",
        "number": "01XXXXXXXXX",
        "amount": 100,
        "trx": "TRX123ABC456",
        "time": "01/01/2026 12:00",
        "m0": "mCash Send Money"
    }
}
json
{
    "paymentID": "TRX_PAYMENT_ID_EXAMPLE",
    "trxID": "TRX123ABC456",
    "transactionStatus": "Completed",
    "amount": "100",
    "currency": "BDT",
    "intent": "sale",
    "paymentExecuteTime": "2026-01-01T12:00:00 GMT+0600",
    "merchantInvoiceNumber": "invoice_demo_12345",
    "payerType": "Customer",
    "payerReference": "CUSTOMER_REF",
    "customerMsisdn": "01XXXXXXXXX",
    "payerAccount": "01XXXXXXXXX",
    "maxRefundableAmount": "100",
    "statusCode": "0000",
    "statusMessage": "Successful",
    "m0": "Bkash Merchant"
}
json
{
    "status": "VALID",
    "tran_date": "2026-01-01 12:00:00",
    "tran_id": "SSLCZ_DEMO_TRANSACTION",
    "val_id": "VALIDATION_ID_EXAMPLE",
    "amount": "100.00",
    "store_amount": "97.50",
    "currency": "BDT",
    "bank_tran_id": "BANK_TRANSACTION_ID",
    "card_type": "NAGAD-Nagad",
    "card_no": "",
    "card_issuer": "Nagad",
    "card_brand": "MOBILEBANKING",
    "card_category": "MOBILE",
    "card_sub_brand": "",
    "card_issuer_country": "Bangladesh",
    "card_issuer_country_code": "BD",
    "currency_type": "BDT",
    "currency_amount": "100.00",
    "currency_rate": "1.0000",
    "base_fair": "0.00",
    "value_a": "",
    "value_b": "",
    "value_c": "",
    "value_d": "",
    "emi_instalment": "0",
    "emi_amount": "0.00",
    "emi_description": "",
    "emi_issuer": "Nagad",
    "account_details": "",
    "risk_title": "Safe",
    "risk_level": "0",
    "discount_percentage": "0",
    "discount_amount": "0.00",
    "discount_remarks": "",
    "APIConnect": "DONE",
    "validated_on": "2026-01-01 12:00:10",
    "gw_version": "",
    "offer_avail": 1,
    "card_ref_id": "CARD_REFERENCE_ID_EXAMPLE",
    "isTokeizeSuccess": 0,
    "campaign_code": "",
    "m0": "SSLCommerz"
}
json
{
    "id": "pi_demo_payment_intent",
    "object": "payment_intent",
    "amount": 10000,
    "amount_capturable": 0,
    "amount_details": {
        "tip": []
    },
    "amount_received": 10000,
    "application": null,
    "application_fee_amount": null,
    "automatic_payment_methods": null,
    "canceled_at": null,
    "cancellation_reason": null,
    "capture_method": "automatic_async",
    "client_secret": "pi_demo_payment_intent_secret_example",
    "confirmation_method": "automatic",
    "created": 1767225600,
    "currency": "usd",
    "customer": null,
    "customer_account": null,
    "description": "Demo Payment",
    "excluded_payment_method_types": null,
    "last_payment_error": null,
    "latest_charge": "ch_demo_charge_id",
    "livemode": false,
    "managed_payments": {
        "enabled": false
    },
    "metadata": [],
    "next_action": null,
    "on_behalf_of": null,
    "payment_details": {
        "customer_reference": null,
        "order_reference": "ORDER_REFERENCE_EXAMPLE"
    },
    "payment_method": "pm_demo_payment_method",
    "payment_method_configuration_details": null,
    "payment_method_options": {
        "card": {
            "installments": null,
            "mandate_options": null,
            "network": null,
            "request_three_d_secure": "automatic"
        }
    },
    "payment_method_types": [
        "card"
    ],
    "presentment_details": {
        "presentment_amount": 12000,
        "presentment_currency": "bdt"
    },
    "processing": null,
    "receipt_email": "customer@example.com",
    "review": null,
    "setup_future_usage": null,
    "shared_payment_granted_token": null,
    "shipping": null,
    "source": null,
    "statement_descriptor": null,
    "statement_descriptor_suffix": null,
    "status": "succeeded",
    "transfer_data": null,
    "transfer_group": null,
    "m0": "Stripe"
}
json
{
    "uid": 123456789,
    "counterpartyId": 987654321,
    "orderId": "ORDER_ID_EXAMPLE",
    "orderType": "CRYPTO_BOX",
    "transactionId": "TRANSACTION_ID_EXAMPLE",
    "transactionTime": 1767225600000,
    "amount": "10.00",
    "currency": "USDT",
    "walletType": 1,
    "walletTypes": [
        "1"
    ],
    "fundsDetail": [
        {
            "currency": "USDT",
            "amount": "10.00"
            "walletAssetCost": {
                "1": "10.00"
            }
        }
    ],
    "payerInfo": {
        "name": "John Doe",
        "type": "USER",
        "email": "customer@example.com",
        "countryCode": 880,
        "phoneNumber": "01XXXXXXXXX",
        "mobileCode": "BD",
        "unmaskData": false
    },
    "receiverInfo": {
        "binanceId": 123456789,
        "accountId": 987654321,
        "unmaskData": false
    },
    "totalPaymentFee": "0",
    "m0": "Binance Personal"
}

Error Codes

CodeMessageDescription
3050API key not foundRequest missing the AH-BOHUDUR-API-KEY header
3051API key not validAPI key is invalid or inactive
3052Invalid Payment KeyProvided paymentkey does not exist or is malformed
3053Invalid api keyAPI key does not match an active account
3054You don't have access! Your IP: ...Request blocked due to IP restrictions
3055Payment Data Not FoundNo payment data exists for the given paymentkey

Webhooks (PHP)

Bohudur sends webhook notifications using POST JSON.

Success Webhook Payload

php
[
  "full_name" => "Jane Doe",
  "email" => "janedoe@gmail.com",
  "amount" => 1,
  "paymentkey" => "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
  "status" => "COMPLETED"
]

Cancel Webhook Payload

php
[
  "full_name" => "Jane Doe",
  "email" => "janedoe@gmail.com",
  "amount" => 1,
  "paymentkey" => "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
  "status" => "CANCELLED"
]

Webhook Handler Example

php
$data = json_decode(file_get_contents('php://input'), true);

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

Best Practices (Critical)

PracticeDescription
Always verify using Query APIAlways verify webhook data by calling Bohudur::Query()
Never execute from frontendAll payment execution must happen server-side
Webhooks ≠ final truthWebhooks can be delayed; use Query API as source of truth
Execute only onceImplement idempotency checks to prevent duplicate execution

Support

Bohudur is free and open to everyone. No trade license required.