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_urlfrom your server), or the publishable keypk_… - Download: razcrypto-android-sdk.zip · MIT
Using Flutter? See the Flutter SDK. React Native? See the React Native SDK.
How it works
- The app asks your server to start a payment.
- Your server creates it with the secret key and returns the
checkout_url(PHP / Laravel, Node.js, Python). - The app launches the checkout. The customer pays.
- The app gets
Success,Pending,CancelledorFailedand tells your server. - Your server verifies the signature, asks RazCrypto for the status and waits for the
payment.paidwebhook. Only the server marks the order paid.
1. Install
Option A: add the module from the download (recommended today)
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// settings.gradle.kts
include(":app", ":razcrypto-checkout")// app/build.gradle.kts
dependencies {
implementation(project(":razcrypto-checkout"))
}Option B: build once and use Maven Local
cd razcrypto-android-sdk
./gradlew :razcrypto-checkout:publishToMavenLocal # Windows: gradlew.bat …// 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)
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
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:
CheckoutOptions.Builder().key("pk_live_…").paymentId("pay_…").build() // a secret key is refusedwaitForPaid 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) oris_valid_checkout_signature(Python), then callpayments.retrieve(id). - Fulfil only on
status == "paid"or the verifiedpayment.paidwebhook.
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. |
CheckoutResult | Fields |
|---|---|
Success | paymentId, referenceId, status, signature |
Pending | paymentId |
Cancelled | — |
Failed | code, 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
- Server on
sk_test_…, open a payment from the app, thensimulate(paymentId, "paid")on the server. - Check Dashboard → API apps → Webhooks for the delivery and your
200. - Live:
sk_live_…+ live signing secret + live webhook URL, then one small real payment.
Build the SDK yourself
./gradlew :razcrypto-checkout:testDebugUnitTest :razcrypto-checkout:assembleReleaseAndroid Studio's bundled JDK (JBR 17+) works.