bolt.com is getting a new home → boltapp.com. Click here to transition smoothly to boltapp.com.

Skip to content

Android checkout

Open Bolt Checkout from an Android app with an order token from your backend.

View As MarkdownMCP

Before you begin

Complete steps 1 through 5 of the Custom Cart integration. Your app also needs:

  • The Android SDK installed and initialized with the publishable key and environment for this integration.
  • An application backend endpoint that returns a fresh order token for the current cart.

Never call POST /v1/merchant/orders or put a Bolt API key in the app. Follow Create an order token for the server implementation.

1. Get an order token

When the shopper selects checkout, send the current cart identifier to your backend. Wait for your backend to return the token from Bolt before opening checkout.

Create a new order token when the cart changes or the shopper starts another checkout attempt.

2. Register the result launcher

Register an ActivityResultLauncher while the activity is being created. The delegate handles the three terminal results:

Kotlin
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResultLauncher
import com.bolt.checkout.BoltCheckout
import com.bolt.checkout.intl.BoltCheckoutDelegate
import com.bolt.checkout.intl.BoltCheckoutResult

class MainActivity : ComponentActivity() {
    private lateinit var checkoutLauncher: ActivityResultLauncher<Intent>

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        checkoutLauncher = BoltCheckout.get().getBoltCheckoutActivityResultLauncher(
            activity = this,
            boltCheckoutDelegate = object : BoltCheckoutDelegate {
                override fun onCheckoutSuccess(result: BoltCheckoutResult) {
                    println("Bolt transaction: ${result.transactionReference}")
                }

                override fun onCheckoutError(errorReason: String) {
                    println("Bolt Checkout failed: $errorReason")
                }

                override fun onCheckoutCancel() {
                    // Return the shopper to the cart.
                }
            },
        )
    }
}

The app callback controls client-side state only. Use verified Merchant Callbacks and transaction webhooks as the source of truth for order and payment state.

Register from a fragment

Use the fragment overload when a Fragment owns the checkout result:

Kotlin
checkoutLauncher = BoltCheckout.get().getBoltCheckoutActivityResultLauncher(
    fragment = this,
    boltCheckoutDelegate = checkoutDelegate,
)

3. Open checkout

After your backend returns the order token, configure checkout and pass the registered launcher:

Kotlin
import com.bolt.checkout.model.BoltCheckoutConfig

fun openBoltCheckout(orderToken: String) {
    val config = BoltCheckoutConfig(orderToken = orderToken)

    BoltCheckout.get().startCheckout(
        checkoutConfig = config,
        context = this,
        checkoutActivityResultLauncher = checkoutLauncher,
    )
}

Prefill shopper details

Pass optional hints when your app already has shopper information:

Kotlin
import com.bolt.checkout.model.BoltCheckoutConfig
import com.bolt.checkout.model.BoltMerchantHints

val hints = BoltMerchantHints(
    firstName = "Ada",
    lastName = "Lovelace",
    email = "ada@example.com",
    country = "US",
)

val config = BoltCheckoutConfig(orderToken = orderToken, hints = hints)

Do not send placeholder or stale values. The shopper can review the information in checkout.

4. Verify the Android client

In sandbox:

  1. Start checkout from a cart and confirm your backend returns a new order token.
  2. Confirm Bolt Checkout opens and shows the same items and total as the cart.
  3. Complete a purchase with a sandbox test card.
  4. Confirm the app receives a success result and your backend receives the expected callback and webhook events.
  5. Cancel another attempt and confirm the app returns the shopper to the cart without treating it as a completed order.

If checkout does not open or the cart does not match, continue to Custom Cart troubleshooting.

On this page