Skip to content

Bohudur Android SDK

Developer-friendly Android payment SDK for Bohudur Payment Gateway.
Easily create, execute, and query payments inside Android apps with minimal code.

Features

  • Simple builder-style API
  • Secure API key authentication
  • Hosted checkout flow
  • Execute & query payments
  • Query payment status anytime
  • Webhook support (server-side)
  • Volley-based networking
  • Java & Android Studio ready

Requirements

  • Minimum SDK: 21+
  • Target SDK: 28+
  • Java: 8+
  • Internet permission
xml
<uses-permission android:name="android.permission.INTERNET"/>

Installation

Step 1: Add JitPack

settings.gradle

gradle
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Step 2: Add Dependency

gradle
dependencies {
    implementation 'com.github.bohudur:bohudur-android-sdk:1.2.1'
}

Initialization

java
import bohudur.payment.sdk.Bohudur;

String API_KEY = "YOUR_API_KEY";
Bohudur bohudur = new Bohudur(this, API_KEY);
kotlin
import bohudur.payment.sdk.Bohudur

val apiKey = "YOUR_API_KEY"
val bohudur = Bohudur(this, apiKey)

Create a Payment

java
bohudur.setFullName("Jane Doe");
bohudur.setEmail("user@gmail.com");
bohudur.setAmount(10);
bohudur.setReturnType(Bohudur.Type.GET());

bohudur.request(new PaymentResponse() {
    @Override
    public void onPaymentSuccess(SuccessResponse response) {
        // Payment executed successfully
    }

    @Override
    public void onPaymentCancelled(FailureResponse response) {
        // Payment cancelled or failed
    }
});
kotlin
bohudur.setFullName("Jane Doe")
bohudur.setEmail("user@gmail.com")
bohudur.setAmount(10.0)
bohudur.setReturnType(Bohudur.Type.GET())

bohudur.request(
    onPaymentSuccess = { response ->
        println("Payment executed successfully: ${response.amount}")
    },
    onPaymentCancelled = { failure ->
        println("Payment failed: ${failure.message}")
    }
)

Lambda Expression

java
bohudur.request(response -> {
    // onPaymentSuccess
    System.out.println("Success: " + response.getAmount());
}, failure -> {
    // onPaymentCancelled
    System.out.println("Failed: " + failure.getMessage());
});
kotlin
bohudur.request(
    onPaymentSuccess = { response ->
        println("Success: ${response.amount}")
    },
    onPaymentCancelled = { failure ->
        println("Failed: ${failure.message}")
    }
)

What Happens Internally

  1. Payment session is created
  2. Hosted checkout page is opened
  3. User completes or cancels payment
  4. SDK executes payment automatically
  5. Callback returns success or failure

Webhooks (Server-Side)

java
bohudur.setWebhookSuccessUrl("https://example.com/success.php")
bohudur.setWebhookCancelUrl("https://example.com/cancel.php");
kotlin
bohudur.setWebhookSuccessUrl("https://example.com/success.php")
bohudur.setWebhookCancelUrl("https://example.com/cancel.php")

Webhook payloads are sent via POST (JSON). Always verify webhook data using the Query API.

Metadata

To attach any extra data to the payment, use metadata. You can add as many key-value pairs as needed.

java
bohudur.addMetadata("order_id", "ORD-1001");
bohudur.addMetadata("user_id", 5541);
bohudur.addMetadata("platform", "android");
kotlin
bohudur.addMetadata("order_id", "ORD-1001")
bohudur.addMetadata("user_id", 5541)
bohudur.addMetadata("platform", "android")

Success Response

java
public void onPaymentSuccess(SuccessResponse response) {
    response.getAmount();
    response.getEmail();
    response.getPaymentCurrency();
    response.getStatus(); // EXECUTED
}
kotlin
fun onPaymentSuccess(response: SuccessResponse) {
    println(response.amount)
    println(response.email)
    println(response.paymentCurrency)
    println(response.status) // EXECUTED
}

Available Getters

MethodDescription
getFullName()Customer name
getEmail()Customer email
getAmount()Original amount
getConvertedAmount()Converted amount
getTotalAmount()Total charged
getTransactionFee()Transaction fee
getDefaultCurrency()Account currency
getPaymentCurrency()Paid currency
getCurrencyValue()Conversion rate
getCreatedTime()Creation time
getPaymentTime()Payment time
getPaymentInfo()Gateway info
getMetadata()Custom metadata
getStatus()EXECUTED

Failure Response

java
public void onPaymentCancelled(FailureResponse response) {
    response.getMessage();
    response.getErrorCode();
    response.getStatus(); // failed
}
kotlin
fun onPaymentCancelled(response: FailureResponse) {
    println(response.message)
    println(response.errorCode)
    println(response.status) // failed
}

Failure Fields

MethodDescription
getMessage()Error message
getErrorCode()API error code
getStatus()failed

Query Payment Status

java
bohudur.query("PAYMENT_KEY", new QueryResponse() {
    @Override
    public void onPaymentFound(SuccessResponse response) {
        // PENDING / COMPLETED / EXECUTED
    }

    @Override
    public void onPaymentError(FailureResponse response) {
        // Invalid or not found
    }
});
kotlin
bohudur.query("PAYMENT_KEY",
    onPaymentFound = { response ->
        println("Payment status: ${response.status}")
    },
    onPaymentError = { failure ->
        println("Query failed: ${failure.message}")
    }
)

Lambda Expression

java
bohudur.query("PAYMENT_KEY",
    success -> {
        System.out.println("Payment status: " + success.getStatus());
    },
    failure -> {
        System.out.println("Query failed: " + failure.getMessage());
    }
);
kotlin
bohudur.query("PAYMENT_KEY",
    onPaymentFound = { response ->
        println("Payment status: ${response.status}")
    },
    onPaymentError = { failure ->
        println("Query failed: ${failure.message}")
    }
)

Possible Status Values

StatusMeaning
PENDINGUser hasn’t paid yet
COMPLETEDPayment done, not executed
EXECUTEDPayment finalized
CANCELLEDUser cancelled

Error Codes

The SDK follows Bohudur API v2 error codes, including:

  • 3000–3019 → Create payment errors
  • 3050–3055 → Query errors
  • 3100–3109 → Execute errors

Always handle failures gracefully.

Versioning

  • SDK Version: 1.2.1
  • API Version: v2

Support

For integration help or issues, contact Bohudur Telegram Support