Bohudur PHP SDK Documentation
Developer-first PHP SDK for Bohudur Payment Automation Platform.
Requirements
| Requirement | Value |
|---|---|
| PHP Version | 7.4 or higher |
| Extensions | curl, json |
| Environment | Server-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 the SDK, extract the ZIP file, and save the SDK file as:
bohudur.phpStep 2: Include SDK
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)
Bohudur::init('YOUR_API_KEY');Validation Rules
| Rule | Description |
|---|---|
| Required | Yes |
| Format | Alphanumeric only |
| Scope | Global (static) |
If initialization is skipped, all requests will fail.
API Flow Overview (PHP)
- Create Payment
- Redirect user to checkout page
- Customer completes or cancels payment
- Execute payment
- Receive webhook (optional)
- 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
$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
| Method | Required | Type | Description |
|---|---|---|---|
FullName() | YES | string | Customer full name |
Email() | YES | string | Customer email |
Amount() | YES | float | Payment amount |
ReturnType() | YES | string | GET or POST |
RedirectUrl() | YES | string | Redirect URL after success |
CancelUrl() | YES | string | Redirect URL after cancellation |
Metadata() | NO | array | Custom key-value data |
Webhook() | NO | array | Webhook URLs |
Success Response
Returned when payment creation is successful.
[
"responseCode" => 200,
"message" => "Payment created successfully",
"status" => "success",
"paymentkey" => "5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt",
"payment_url" => "https://checkout.bohudur.one/payment/5RWS4w2w1R5nFAvoP5U0JS4O74UrMXGt"
]Response Fields Explained
| Field | Type | Description |
|---|---|---|
responseCode | number | HTTP-like response code. 200 indicates success. |
message | string | Human-readable message describing the result. |
status | string | Payment creation status. Always success on success. |
paymentkey | string | A unique 32-character alphanumeric key generated for each payment. |
payment_url | string | Hosted checkout URL where the customer completes the payment. |
Failed Response
[
"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.
| Code | Message | Description |
|---|---|---|
3000 | API key not found | API key header is missing from the request. |
3001 | Required parameters not found | One or more mandatory fields are missing. |
3002 | Invalid Full Name Format | full_name must be a valid string. |
3003 | Invalid Email Format | Email address format is invalid. |
3004 | Invalid Amount Format | Amount must be a valid numeric value. |
3005 | Invalid Return Type Format | Only GET or POST is allowed. |
3006 | Invalid Return URL Format | redirect_url is not a valid URL. |
3007 | Invalid JSON format in metadata | metadata must be a valid JSON object. |
3008 | Invalid JSON format in webhook | webhook must be a valid JSON object. |
3009 | Invalid Cancel URL Format | cancel_url is not a valid URL. |
3010 | Invalid JSON format in metadata | metadata must be a valid JSON object. |
3011 | Invalid JSON format in webhook | webhook must be a valid JSON object. |
3012 | Invalid webhook actions | Only success and cancel actions are allowed. |
3013 | Invalid JSON format in metadata or webhook | One or both JSON objects are malformed. |
3014 | Invalid API key | Provided API key is incorrect or inactive. |
3015 | Oops! internal error. Try again. | Temporary server-side issue. |
3016 | Unknown amount provided | Amount value is not acceptable or supported. |
3017 | You don't have access | Request blocked due to IP restriction. |
3018 | Oops! Internal error. Try again. | Unexpected internal server error. |
3019 | Unable to create payment | Payment session could not be generated. |
Redirecting Customer
if ($response['status'] === 'success') {
header('Location =>' . $response['payment_url']);
exit;
}Execute Payment API (PHP)
Finalizes a completed payment.
PHP Example
$execute = Bohudur::Execute('PAYMENT_KEY');Execution Rules
- Can be executed only once
- Payment must be COMPLETED
- Executed payments are final
Success Response
[
"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
| Field | Type | Description |
|---|---|---|
full_name | string | Customer’s full name |
email | string | Customer’s email address |
amount | number | Original payment amount in default currency |
converted_amount | number | Amount converted to the payment currency |
total_amount | number | Total amount charged (amount + fees) |
transaction_fee | number | Transaction fees applied (if any) |
default_currency | string | Your account default currency |
payment_currency | string | Currency used for the payment |
currency_value | number | Conversion rate applied (default → payment currency) |
metadata | array | Optional metadata submitted during creation |
created_time | string | Payment creation timestamp |
payment_time | string | Time when the payment was completed by the customer |
paymentkey | string | Unique key identifying this payment |
webhook | array | Webhook URLs configured for this payment |
payment_info | object | Transaction-specific info |
status | string | Payment execution status. Always EXECUTED on success |
Error Response Example
[
"responseCode" => 3108,
"message" => "Payment already executed!",
"status" => "failed"
]Common Error Codes
| Code | Message | Description |
|---|---|---|
3100 | API key not found | The request did not include an API key. Ensure the AH-BOHUDUR-API-KEY header is set. |
3101 | API key not valid | The provided API key is invalid or inactive. |
3102 | Invalid Payment Key | The paymentkey provided is malformed or does not exist. |
3103 | Invalid api key | The API key used does not match any active account. |
3104 | You don't have access! Your IP =>... | Your IP address is not authorized to perform this request. Replace ... with your server IP in the message. |
3105 | Payment Data Not Found | No payment data exists for the given paymentkey. |
3106 | Payment is pending! | The payment has not yet been completed by the customer. Execute is only allowed after completion. |
3107 | Payment is cancelled! | The payment was cancelled by the customer or system. |
3108 | Payment already executed! | This payment has already been executed. Execution can only happen once. |
3109 | Failed to execute payment | The 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
$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.
[
"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.
[
"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 completedpayment_info→ Contains transaction details (processor-specific info)status→COMPLETEDindicates payment is successful and ready for execution
3. EXECUTED Payment
Payment has been executed/confirmed via the Execute API.
[
"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.
[
"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
| Field | Type | Description |
|---|---|---|
full_name | string | Customer’s full name |
email | string | Customer’s email |
amount | number | Original payment amount |
converted_amount | number | Amount converted to payment currency |
total_amount | number | Total amount including fees |
transaction_fee | number | Transaction fee applied (if any) |
default_currency | string | Your account default currency |
payment_currency | string | Payment currency |
currency_value | number | Conversion rate applied |
metadata | array | Optional metadata sent during creation |
created_time | string | Payment creation timestamp |
payment_time | string | Time payment completed (NONE if pending) |
paymentkey | string | Unique identifier for this payment |
webhook | array | Webhook URLs (if configured) |
payment_info | array | Empty while pending |
status | string | PENDING |
Error Codes
| Code | Message | Description |
|---|---|---|
3050 | API key not found | Request missing the AH-BOHUDUR-API-KEY header |
3051 | API key not valid | API key is invalid or inactive |
3052 | Invalid Payment Key | Provided paymentkey does not exist or is malformed |
3053 | Invalid api key | API key does not match an active account |
3054 | You don't have access! Your IP: ... | Request blocked due to IP restrictions |
3055 | Payment Data Not Found | No payment found for the given paymentkey |
Webhooks (PHP)
Bohudur sends webhook notifications using POST JSON.
• Success Webhook Payload
[
"full_name" => "Jane Doe",
"email" => "[email protected]",
"amount" => 1,
"paymentkey" => "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
"status" => "COMPLETED"
]• Cancel Webhook Payload
[
"full_name" => "Jane Doe",
"email" => "[email protected]",
"amount" => 1,
"paymentkey" => "CrD85r3ibMK6ip38reUcuECvVhaF0xOT",
"status" => "CANCELLED"
]Webhook Handler Example
$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.
