PayBito Payments
Android SDK Guide

Integrate seamless crypto & fiat payments into your Android app using our professional-grade SDK.

v1.1.2 — Stable Release

Quick Start

The PayBito Android SDK is a professional-grade fintech solution for seamless crypto and fiat payment integration. Built on a reactive architecture, it bridges native Android environments with the PayBito payment gateway.

Key Features

Reactive Cart Engine

Real-time state synchronization using Kotlin StateFlow for live cart updates across your UI.

Dynamic Branding

Automatically fetches broker-specific names and configurations for white-label support.

Secure Checkout

Mobile-optimized WebView with 3D Secure authentication for bank-grade payment security.

Easy Integration

Single-line checkout initiation and automated cart lifecycle management out-of-the-box.

Installation

1
Add JitPack Repository

Add the JitPack repository to your settings.gradle:

settings.gradle
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}
2
Add SDK Dependency

Add the SDK to your app/build.gradle dependencies block:

app/build.gradle
dependencies {
    implementation 'com.github.arunava2804.PayBito-Payments-Android-SDK:library:v1.1.2'
}
You're ready! After syncing Gradle, the SDK classes will be available in your project. Proceed to the Initialization section to set up your credentials.

Initialization

The SDK is a singleton and must be initialized once at the application level. This ensures that even if the app is killed and restarted, the SDK can restore the user's cart token from SharedPreferences.

Application Class Setup

Create or modify your Application class to initialize the SDK with your merchant credentials:

MyApplication.kt
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val config = PayBitoConfig(
            merchantId     = 26660L,
            publicKey      = "pk_your_public_key",
            brokerId       = "your_broker_id",
            origin         = "https://your-domain.com/",
            enableDebugLogs = true
        )

        PayBitoSdk.init(this, config)
    }
}

Configuration Parameters

Parameter Type Required Description
merchantId Long Yes Your PayBito merchant account ID
publicKey String Yes Your public API key from the merchant portal
brokerId String Yes Broker identifier for white-label branding
origin String Yes Whitelisted origin URL in the merchant portal
enableDebugLogs Boolean No Enable verbose SDK logging (disable in production)
Security Notice: Never hardcode production credentials in your source code. Use environment variables or a secure config file excluded from version control.

Core API

The SDK provides a clean reactive API for managing the shopping cart and triggering checkout. All network calls and local persistence are handled automatically.

A. Add to Cart

Use PayBitoSdk.addToCart() to add products. The SDK handles all network calls and local persistence automatically.

Kotlin
val product = PayBitoProduct(
    productId = "P001",
    name      = "Studio Headphones",
    price     = 89.99,
    imageUrl  = "https://example.com/image.jpg"
)

lifecycleScope.launch {
    PayBitoSdk.addToCart(product)
}

B. Observe Cart State (Reactive)

Collect the cartState Flow to automatically update your UI whenever the cart changes. This is the recommended pattern for keeping badges and totals in sync.

MainActivity.kt
lifecycleScope.launch {
    PayBitoSdk.cartState.collect { state ->
        // Runs automatically whenever the cart changes
        binding.tvCartCount.text  = state.count.toString()
        binding.tvTotalAmount.text = "$" + state.total
        adapter.updateItems(state.items)
    }
}

C. Update Item Quantity

For existing cart items, use updateQuantity() rather than re-adding the product:

Kotlin
// Increment or decrement quantity for an existing item
lifecycleScope.launch {
    PayBitoSdk.updateQuantity(productId = "P001", newQty = 3)
}

D. Open Cart UI

The SDK provides a built-in BottomSheet cart drawer that can be launched from any FragmentActivity:

Kotlin
PayBitoSdk.openCart(this) // Requires FragmentActivity

E. Clear Cart

Call clearCart() after a successful payment to reset the user's cart for the next session:

Kotlin
PayBitoSdk.clearCart()
Best Practice: Always call clearCart() inside your PaymentResultActivity after a confirmed successful checkout to guarantee a clean state for the next purchase.

Checkout Flow

The checkout process is initiated with a single method call. The SDK handles the complete secure payment flow, including 3D Secure verification and post-payment deep linking.

Launching Checkout

Kotlin
PayBitoSdk.checkout(this)

Checkout Activity Internals

Mobile-Optimized WebView

The SDK opens a custom PayBitoCheckoutActivity that forces a mobile-optimized viewport for all payment pages, ensuring a native-feeling user experience.

3D Secure Support

The WebView is pre-configured to handle 3D Secure popups required by modern banks. No additional configuration is needed on your end.

Success Deep Linking

When the web-based payment completes, the gateway redirects to paybito://checkout/success. Your app captures this via an <intent-filter> in the manifest.

AndroidManifest.xml
<activity android:name=".payment.PaymentResultActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:scheme="paybito"
            android:host="checkout"
            android:pathPrefix="/success" />
    </intent-filter>
</activity>

Demo App Guide

The TechStore Demo App demonstrates best practices for building a premium e-commerce experience with the PayBito SDK using MVVM-lite architecture and reactive programming.

App Architecture

ViewBinding

Type-Safe UI

StateFlow

Reactive

Material 3

Dark Theme

Glide

Images

Core Implementation Steps

1
Global Configuration — MyApplication.kt

Initialize the SDK once at the application level using real credentials. The SDK restores cart state automatically from SharedPreferences on app restart.

2
Reactive UI Sync — MainActivity.kt

Instead of manually updating the UI on every button click, observe PayBitoSdk.cartState. This pattern keeps badges and totals synchronized across all screens automatically.

3
Product Grid — ProductAdapter.kt

Uses a GridLayoutManager (2 columns). The adapter distinguishes two actions: addToCart() for new items and updateQuantity() for the +/- stepper on existing items. Images are loaded via Glide with placeholders.

4
Success Handling — PaymentResultActivity.kt

A deep-link activity that catches paybito://checkout/success, renders the success confirmation card, and calls PayBitoSdk.clearCart() to reset state.

Key Files to Study

  • com.example.paybitodemo.MainActivity — Central hub for UI logic and cart observation
  • com.example.paybitodemo.ProductAdapter — Complex RecyclerView with add/update logic
  • com.example.paybitodemo.payment.PaymentResultActivity — Post-checkout deep link handler

UI Design Principles

Adaptive Dimensions

Uses sdp for dimensions and ssp for text scaling, ensuring consistent layouts across all Android screen densities.

Dark Mode First

Premium dark palette reduces eye strain and makes product visuals pop — ideal for a fintech or e-commerce context.

ProGuard & Security

If your app uses code obfuscation (recommended for production releases), add the following rules to your proguard-rules.pro to prevent the SDK models from being stripped or renamed.

proguard-rules.pro
# Keep PayBito SDK models intact
-keep class com.paybito.sdk.models.** { *; }
-dontwarn com.paybito.sdk.**
Important: Forgetting these ProGuard rules is a common cause of ClassNotFoundException crashes in production. Always test a release build before submitting to the Play Store.

Security Best Practices

Credential Management
1
Store Keys Securely

Use Android Keystore, encrypted SharedPreferences, or a remote config service — never commit raw keys to Git.

2
Disable Debug Logs in Production

Set enableDebugLogs = false (or omit it) in your production PayBitoConfig to prevent sensitive data exposure in Logcat.

3
Whitelist Your Origin

Ensure your origin URL is correctly registered in the PayBito Merchant Portal to avoid 500 errors at checkout.

Distribution & JitPack

The SDK is distributed via JitPack.io. This section explains how the library is configured for publication and how to create new versioned releases.

Library build.gradle Configuration

For JitPack to correctly build the library, the library/build.gradle must include the maven-publish plugin:

library/build.gradle
plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'maven-publish'
}

android {
    publishing {
        singleVariant('release') {
            withSourcesJar()
        }
    }
}

afterEvaluate {
    publishing {
        publications {
            release(MavenPublication) {
                from components.release
                groupId    = 'com.github.arunava2804.PayBito-Payments-Android-SDK'
                artifactId = 'library'
                version    = project.findProperty('version') ?: '1.1.2'
            }
        }
    }
}

Creating a New Release

1
Push to Main

Commit all changes and push to the main branch. Ensure android.useAndroidX=true is set in gradle.properties.

2
Create a GitHub Release

Go to Releases on your GitHub repo and create a new tag (e.g., v1.1.3).

3
Trigger JitPack Build

Visit JitPack.io and look up arunava2804/PayBito-Payments-Android-SDK. Click the new tag version to trigger the build.

FAQ & Troubleshooting

Common integration issues and their solutions.

Why am I getting 500 errors during checkout?

The origin URL in your PayBitoConfig must be whitelisted in the PayBito Merchant Portal. Ensure the URL matches exactly (including trailing slash) what is registered under your merchant account.

The deep link after payment isn't working.

Verify that the scheme and host in your AndroidManifest.xml <intent-filter> match the redirect URL configured on your server. The scheme must be paybito and the host must be checkout.

Product images are not loading in the demo app.

Unsplash image URLs require an active internet connection. Verify your device or emulator has network access. Also confirm your app declares the INTERNET permission in the manifest and is not blocked by a network security config.

The app crashes in production after enabling ProGuard.

Add the required ProGuard rules to your proguard-rules.pro: -keep class com.paybito.sdk.models.** { *; } and -dontwarn com.paybito.sdk.**. This prevents the SDK model classes from being stripped during obfuscation.

How do I get my merchantId, publicKey, and brokerId?

These credentials are available in your PayBito Merchant Portal under the API / SDK settings section. Visit paybito.com/gateway-integration for the full onboarding guide.

Can I use this SDK with Java instead of Kotlin?

The SDK is written in Kotlin and uses Coroutines and StateFlow. While interoperability with Java is technically possible, you will need the Kotlin coroutine interop adapters (kotlinx-coroutines-jdk8). A pure Kotlin implementation is strongly recommended.

Need more help? Visit the official SDK documentation or open an issue on the GitHub repository.

Contents

paybito logo

Download the Mobile Apps

Contact Us

  (Max 120 Character)
  (Max 500 Character)
By checking this box, you agree to receive SMS messages from PayBitoPro. Reply STOP to opt out at any time. Reply HELP for customer care contact information. Message and data rates may apply. Message frequency may vary. Phone numbers collected for SMS consent will not be shared with third parties or affiliates for marketing purposes under any circumstance. Check out our Privacy Policy to learn more.

BitcoinBTC/USD

Ether CoinETH/USD

HCX CoinHCX/USD

BCH CoinBCH/USD

LitecoinLTC/USD

EOS CoinEOS/USD

ADA CoinADA/USD

Link CoinLINK/USD

BAT CoinBAT/USD

HBAR CoinHBAR/USD

+
Chat Now
Welcome to Paybito Support