Skip to content

Bohudur PHP SDK Documentation

Developer-first PHP SDK for Bohudur Payment Automation Platform.

Requirements

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

Security Notice

Important

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

Installation

Step 1: Download SDK

Download PHP SDK

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');

Validation Rules

RuleDescription
RequiredYes
FormatAlphanumeric only
ScopeGlobal (static)

If initialization is skipped, all requests will fail.

API Flow Overview (PHP)

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

This flow is identical to the cURL API.

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('[email protected]')
    ->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 foundAPI key header is missing from the request.
3001Required parameters not foundOne or more mandatory fields are missing.
3002Invalid Full Name Formatfull_name must be a valid string.
3003Invalid Email FormatEmail address format is invalid.
3004Invalid Amount FormatAmount must be a valid numeric value.
3005Invalid Return Type FormatOnly GET or POST is allowed.
3006Invalid Return URL Formatredirect_url is not a valid URL.
3007Invalid JSON format in metadatametadata must be a valid JSON object.
3008Invalid JSON format in webhookwebhook must be a valid JSON object.
3009Invalid Cancel URL Formatcancel_url is not a valid URL.
3010Invalid JSON format in metadatametadata must be a valid JSON object.
3011Invalid JSON format in webhookwebhook must be a valid JSON object.
3012Invalid webhook actionsOnly success and cancel actions are allowed.
3013Invalid JSON format in metadata or webhookOne or both JSON objects are malformed.
3014Invalid API keyProvided API key is incorrect or inactive.
3015Oops! internal error. Try again.Temporary server-side issue.
3016Unknown amount providedAmount value is not acceptable or supported.
3017You don't have accessRequest blocked due to IP restriction.
3018Oops! Internal error. Try again.Unexpected internal server error.
3019Unable to create paymentPayment session could not be generated.

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

json
[
  "full_name" => "Gabriel Adams",
  "email" => "[email protected]",
  "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" => "Stripe",
    "status" => "VALID",
    "tran_date" => "2026-01-04 16:05:04",
    "tran_id" => "IGQM_695a3b59h6a9"
  ],
  "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
payment_infoobjectTransaction-specific info
statusstringPayment execution status. Always EXECUTED on success

Error Response Example

json
[
  "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.

json
[
  "full_name" => "Chloe Morales",
  "email" => "[email protected]",
  "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",
  "webhook" => [],
  "payment_info" => [],
  "status" => "PENDING"
]

2. COMPLETED Payment

Payment successfully completed by the user.

json
[
  "full_name" => "Jane Doe",
  "email" => "[email protected]",
  "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",
  "webhook" => [],
  "payment_info" => [
    "m0" => "Stripe",
    "status" => "succeeded",
    "tran_id" => "IGQM_695a3b59h6a9"
  ],
  "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.

json
[
  "full_name" => "Gabriel Adams",
  "email" => "[email protected]",
  "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",
    "status" => "VALID",
    "tran_date" => "2026-01-04 16:05:04",
  ],
  "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.

json
[
  "full_name" => "Jane Doe",
  "email" => "[email protected]",
  "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",
  "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

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 found for the given paymentkey

Webhooks (PHP)

Bohudur sends webhook notifications using POST JSON.

• Success Webhook Payload

php
[
  "full_name" => "Jane Doe",
  "email" => "[email protected]",
  "amount" => 1,
  "paymentkey" => "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
  "status" => "COMPLETED"
]

• Cancel Webhook Payload

php
[
  "full_name" => "Jane Doe",
  "email" => "[email protected]",
  "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)

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

API Versioning

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

Changelog

  • v2: Improved response structure, webhook support, metadata support

Support

For technical support or integration issues, contact in Bohudur Telegram Support.