Example Android app demonstrating the CrossmintEmbeddedCheckout component from the Crossmint Kotlin SDK.
This example uses the Crossmint SDK from Maven Central:
dependencies {
implementation("com.crossmint:crossmint-sdk-android:0.0.9")
}First, create an order on your server using the Crossmint API:
Important: Order creation must be done server-side to keep your API key secure.
# Production
curl --location 'https://www.crossmint.com/api/2022-06-09/orders' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"recipient": {
"walletAddress": "WALLET_ADDRESS"
},
"payment": {
"receiptEmail": "user@example.com",
"method": "card"
},
"lineItems": {
"tokenLocator": "chain:token",
"executionParameters": {
"mode": "exact-in",
"amount": "1"
}
}
}'
# Staging
curl --location 'https://staging.crossmint.com/api/2022-06-09/orders' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{...}'See full documentation: Create Order API and Payment Methods
The response will include:
orderId- Unique identifier for the orderclientSecret- Token scoped to this order for client-side operations
Pass the orderId, clientSecret, and optional configuration to the component:
import com.crossmint.kotlin.checkout.CheckoutEnvironment
import com.crossmint.kotlin.checkout.CrossmintEmbeddedCheckout
import com.crossmint.kotlin.checkout.models.*
CrossmintEmbeddedCheckout(
orderId = "your-order-id",
clientSecret = "your-client-secret",
payment = CheckoutPayment(
crypto = CheckoutCryptoPayment(enabled = false),
fiat = CheckoutFiatPayment(
enabled = true,
allowedMethods = CheckoutAllowedMethods(
googlePay = true,
applePay = false,
card = true
)
)
),
appearance = CheckoutAppearance(
rules = CheckoutAppearanceRules(
destinationInput = CheckoutDestinationInputRule(display = "hidden"),
receiptEmailInput = CheckoutReceiptEmailInputRule(display = "hidden")
)
),
environment = CheckoutEnvironment.STAGING, // or .PRODUCTION
modifier = Modifier.fillMaxSize()
)Monitor the order as it progresses through payment and delivery. Use webhooks for real-time updates or polling as a fallback.
Set up webhooks to receive real-time updates as the order progresses through payment and delivery.
Setup:
- Create a
POSTendpoint on your server (e.g.,/webhooks/crossmint) - Configure webhook in Crossmint Console
- Save the signing secret for verification
Key Events:
orders.quote.created- Order createdorders.payment.succeeded- Payment confirmedorders.delivery.completed- Tokens delivered (includestxId)orders.payment.failed- Payment failed
See full documentation: Webhooks Guide
Poll the order status if webhooks aren't feasible. Be mindful of rate limits.
curl --location 'https://www.crossmint.com/api/2022-06-09/orders/{orderId}' \
--header 'x-api-key: YOUR_API_KEY'See full documentation: Get Order API
orderId- Order identifier from create order APIclientSecret- Client secret from create order APIpayment- Payment method configurationappearance- UI customization optionsenvironment-CheckoutEnvironment.STAGINGorCheckoutEnvironment.PRODUCTION
The following properties are defined but not yet implemented:
lineItems- Line items configurationrecipient- Recipient informationapiKey- Crossmint Client API Key
See MainActivity.kt for a complete working example.