Skip to content

Crossmint/crossmint-kotlin-checkout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crossmint Kotlin Checkout Example

Example Android app demonstrating the CrossmintEmbeddedCheckout component from the Crossmint Kotlin SDK.

Installation

This example uses the Crossmint SDK from Maven Central:

dependencies {
    implementation("com.crossmint:crossmint-sdk-android:0.0.9")
}

Integration Flow

1. Create Order (Server-side)

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 order
  • clientSecret - Token scoped to this order for client-side operations

2. Use the Component (Client-side)

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()
)

3. Track Order Status (Server-side)

Monitor the order as it progresses through payment and delivery. Use webhooks for real-time updates or polling as a fallback.

Option A: Webhooks (Recommended)

Set up webhooks to receive real-time updates as the order progresses through payment and delivery.

Setup:

  1. Create a POST endpoint on your server (e.g., /webhooks/crossmint)
  2. Configure webhook in Crossmint Console
  3. Save the signing secret for verification

Key Events:

  • orders.quote.created - Order created
  • orders.payment.succeeded - Payment confirmed
  • orders.delivery.completed - Tokens delivered (includes txId)
  • orders.payment.failed - Payment failed

See full documentation: Webhooks Guide

Option B: Polling (Fallback)

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

Available Properties

Currently Supported

  • orderId - Order identifier from create order API
  • clientSecret - Client secret from create order API
  • payment - Payment method configuration
  • appearance - UI customization options
  • environment - CheckoutEnvironment.STAGING or CheckoutEnvironment.PRODUCTION

Work in Progress

The following properties are defined but not yet implemented:

  • lineItems - Line items configuration
  • recipient - Recipient information
  • apiKey - Crossmint Client API Key

Example

See MainActivity.kt for a complete working example.

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages