Skip to content

SDKs

Android SDK (Kotlin)

Take crypto payments in a native Android app written in Kotlin or Java. The checkout opens as a full-screen activity in your app, with no browser bar, and returns a typed result through the Activity Result API.

  • Artifact: com.razcryptogateway:android-sdk:1.0.0 (Maven Central release coming soon; use the download today)
  • Requires: minSdk 24, compileSdk 34+, JDK 17
  • Key in the app: none (opens the checkout_url from your server), or the publishable key pk_…
  • Download: razcrypto-android-sdk.zip · MIT

Using Flutter? See the Flutter SDK. React Native? See the React Native SDK.

How it works

  1. The app asks your server to start a payment.
  2. Your server creates it with the secret key and returns the checkout_url (PHP / Laravel, Node.js, Python).
  3. The app launches the checkout. The customer pays.
  4. The app gets Success, Pending, Cancelled or Failed and tells your server.
  5. Your server verifies the signature, asks RazCrypto for the status and waits for the payment.paid webhook. Only the server marks the order paid.

1. Install

Shell
curl -L -o razcrypto-android-sdk.zip https://razcryptogateway.com/downloads/razcrypto-android-sdk.zip
unzip razcrypto-android-sdk.zip
# copy the library module into your project
cp -r razcrypto-android-sdk/razcrypto-checkout  <your-project>/razcrypto-checkout
Kotlin
// settings.gradle.kts
include(":app", ":razcrypto-checkout")
Kotlin
// app/build.gradle.kts
dependencies {
    implementation(project(":razcrypto-checkout"))
}

Option B: build once and use Maven Local

Shell
cd razcrypto-android-sdk
./gradlew :razcrypto-checkout:publishToMavenLocal     # Windows: gradlew.bat …
Kotlin
// settings.gradle.kts → dependencyResolutionManagement { repositories { … } }
mavenLocal()

// app/build.gradle.kts
dependencies { implementation("com.razcryptogateway:android-sdk:1.0.0") }

Option C: Maven Central (after release)

Kotlin
dependencies { implementation("com.razcryptogateway:android-sdk:1.0.0") }

Manifest

Nothing to add. The SDK's own manifest already brings the checkout activity, the internet permission and the <queries> entries that let Android 11+ open MetaMask, Trust and other wallet apps. They merge into your app automatically.

2. Open the checkout

Kotlin
import com.razcryptogateway.checkout.CheckoutOptions
import com.razcryptogateway.checkout.CheckoutResult
import com.razcryptogateway.checkout.RazCryptoCheckout

class CartActivity : ComponentActivity() {

    // Register once, as a field
    private val checkout = registerForActivityResult(RazCryptoCheckout()) { result ->
        when (result) {
            is CheckoutResult.Success -> lifecycleScope.launch {
                // send to your server; it checks the signature and the real status
                val status = api.verifyRazCrypto(result.paymentId, result.referenceId, result.status, result.signature.orEmpty())
                if (status == "completed") showPaid() else waitForPaid(result.paymentId)
            }
            is CheckoutResult.Pending -> waitForPaid(result.paymentId)   // on-chain, confirming
            CheckoutResult.Cancelled -> Unit                             // closed; order stays pending
            is CheckoutResult.Failed -> showError(result.message)
        }
    }

    fun pay(amount: Int) = lifecycleScope.launch {
        val order = api.createRazCryptoPayment(amount)                   // your server → { payment_id, checkout_url }
        checkout.launch(
            CheckoutOptions.Builder()
                .checkoutUrl(order.checkoutUrl)
                .locale("en")                                            // or "hi"
                .build(),
        )
    }
}

With the publishable key instead of the URL:

Kotlin
CheckoutOptions.Builder().key("pk_live_…").paymentId("pay_…").build()  // a secret key is refused

waitForPaid polls your server for about 30 seconds (GET /payments/razcrypto/status/{id}), then tells the customer the order will update shortly. See the Flutter page for the same logic in Dart.

3. Server side

Your server needs four endpoints: create, verify, status and the webhook. A complete Laravel version (migration, admin settings, controller) is on the PHP SDK page.

  • Success.signature = hex HMAC-SHA256(webhook signing secret, payment_id|reference_id|status).
  • Check it with CheckoutSignature::isValid (PHP), isValidCheckoutSignature (Node) or is_valid_checkout_signature (Python), then call payments.retrieve(id).
  • Fulfil only on status == "paid" or the verified payment.paid webhook.

Reference

CheckoutOptions.Builder()Use
.checkoutUrl(url)Recommended. The checkout_url from your server.
.key(pk).paymentId(id)Publishable key + payment id.
.locale("en" | "hi")Checkout language.
.payHost(url)Only for staging or a self-hosted gateway.
CheckoutResultFields
SuccesspaymentId, referenceId, status, signature
PendingpaymentId
Cancelled—
Failedcode, message

What the customer sees: network → coin → QR or "Open in MetaMask / Trust" (wallet links open the wallet app) → green success screen that closes by itself. Back asks "Leave this payment?".

Test and go live

  1. Server on sk_test_…, open a payment from the app, then simulate(paymentId, "paid") on the server.
  2. Check Dashboard → API apps → Webhooks for the delivery and your 200.
  3. Live: sk_live_… + live signing secret + live webhook URL, then one small real payment.

Build the SDK yourself

Shell
./gradlew :razcrypto-checkout:testDebugUnitTest :razcrypto-checkout:assembleRelease

Android Studio's bundled JDK (JBR 17+) works.