Skip to main content

Checkout Sheet Kit for Android

Checkout Sheet Kit is an open-source Android library that allows you to integrate Shopify's checkout in your mobile app. To get started, see our sample projects, or follow the steps below to integrate it into your own project.


  • Integrate Checkout Sheet Kit to your project
  • Present the checkout through a checkout URL or cart permalink

  • JDK 17+
  • Android SDK 23+

Anchor to Step 1: Install the Checkout Sheet Kit as a package dependencyStep 1: Install the Checkout Sheet Kit as a package dependency

Gradle

implementation "com.shopify:checkout-sheet-kit:3.3.0"

Maven

<dependency>
<groupId>com.shopify</groupId>
<artifactId>checkout-sheet-kit</artifactId>
<version>3.3.0</version>
</dependency>

Anchor to Step 2: Import the libraryStep 2: Import the library

After adding Checkout Sheet Kit as a dependency, you can import the library in your code.

Import the library

import com.shopify.checkoutsheetkit.ShopifyCheckoutSheetKit

To present a checkout to the customer, your app must specify a checkout URL. To get this URL, you can use Storefront GraphQL API to build a cart and load its checkout URL. Or, you can provide a cart permalink.

When using GraphQL to get a checkout URL, Shopify's Mobile Buy SDK for Android can simplify the development workflow:

Get a checkout URL

val client = GraphClient.build(
context = applicationContext,
shopDomain = "yourshop.myshopify.com",
accessToken = "<storefront access token>"
)

val cartQuery = Storefront.query { query ->
query.cart(ID(id)) {
it.checkoutUrl()
}
}

client.queryGraph(cartQuery).enqueue {
if (it is GraphCallResult.Success) {
val checkoutUrl = it.response.data?.cart?.checkoutUrl
}
}

checkoutUrl is a standard web checkout URL that can be opened in any browser.

To present the checkout in your mobile app, call present on ShopifyCheckoutSheetKit. Pass in the checkout URL, along with other runtime configuration settings, as shown in this code:

Present the checkout

import com.shopify.checkoutsheetkit.ShopifyCheckoutSheetKit

fun presentCheckout() {
val checkoutUrl = cart.checkoutUrl
ShopifyCheckoutSheetKit.present(checkoutUrl, context, checkoutEventProcessor)
}

Was this page helpful?