For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Dashboard
DocsAPI Reference
DocsAPI Reference
    • What is Transak
  • Features
    • Auth Reliance
    • KYC Reliance using Sumsub
    • Webhooks
    • WebSockets
  • Products Overview
    • On Ramp
    • Off Ramp
    • NFT Checkout
  • Integration Options
    • API
      • Android
      • iOS
      • React Native
      • Flutter (Deprecated)
  • Customization Options
    • Query Parameters
    • Customizing theme using query parameters
  • Guides
    • How To Create a Partner Dashboard Account
    • How to Add Partner Fees and Set Up Partner Payouts
    • How to Test using Sandbox Credentials
    • How to Test ACH Pull Transaction in Sandbox
    • How to Test Apple Pay in Sandbox
    • How to Track Order Status
    • Transak Different KYC Levels
    • How to Submit FCA Requirements
    • How to Use Advanced Query Params
    • How to Create a Widget URL with Parameters and Test Different Scenarios
    • How to Generate Calldata for NFT Checkout
    • How to Add NFT Smart Contract in the Dashboard and Create a contractId
    • Get Price based on User Region
    • How to Create Partner Access Token
    • How to Decrypt the Webhook Payload
    • How to add MCP Server for Transak Documentation
    • Widget with API Customization
    • Integration Update - Mandatory Migration to API based Transak Widget URL
    • Biconomy: Simplified Onboarding Using MEE-Compatible Smart Accounts
    • Partner FAQs
    • Need Help?
Dashboard
LogoLogo
On this page
  • Use cases
  • Deeplink
  • Events
  • Supported Events
Integration OptionsMobile WebView

Android

Seamless Transak integration for Android applications
||View as Markdown|
Was this page helpful?
Edit this page
Previous

JavaScript SDK

Next

iOS

Built with

The Transak Android integration allows you to embed a fully functional interface directly into your native Android application using Webview.

Google Pay is not supported with Android webview integration.

1

Add Permissions in Manifest File

Update your AndroidManifest.xml to include required permissions for internet access and camera (for KYC verification):

1<uses-permission android:name="android.permission.INTERNET"/>
2<uses-permission android:name="android.permission.CAMERA"/>
2

Implement WebView in Activity

Configure your MainActivity to load the Transak widget URL using your preferred implementation:

1import android.webkit.PermissionRequest
2import android.webkit.WebChromeClient
3import android.webkit.WebView
4...
5
6AndroidView(
7 factory = {
8 WebView(it).apply {
9
10 this.layoutParams =
11 ViewGroup.LayoutParams(
12 ViewGroup.LayoutParams.MATCH_PARENT,
13 ViewGroup.LayoutParams.MATCH_PARENT
14 )
15
16 this.settings.javaScriptEnabled = true
17 this.settings.domStorageEnabled = true
18
19 this.webChromeClient = object : WebChromeClient() {
20 override fun onPermissionRequest(request: PermissionRequest) {
21 request.grant(request.resources)
22 }
23 }
24 }
25 },
26 update = {
27 it.loadUrl(
28 "https://global-stg.transak.com?apiKey=<YOUR_API_KEY>&sessionId=<YOUR_SESSION_ID>"
29 )
30 }
31)
3

Configure XML Layout (Skip if using Compose)

Add the WebView to your activity_main.xml layout file:

1<WebView xmlns:android="http://schemas.android.com/apk/res/android"
2 android:id="@+id/transakWidgetView"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"/>
4

Create Widget URL (using Backend Only)

Call the Create Widget URL API from your backend to generate a secure widget url using Query parameters

The response returns a widgetUrl that should be used to load Transak in Android Webview.

A widgetUrl is valid for 5 minutes and can only be used once. A new widgetUrl must be generated for every user flow.

Example Request:

$curl --request POST \
> --url https://api-gateway-stg.transak.com/api/v2/auth/session \
> --header 'access-token: YOUR_ACCESS_TOKEN' \
> --header 'content-type: application/json' \
> --data '{
> "widgetParams": {
> "apiKey": "YOUR_API_KEY",
> "referrerDomain": "yourdomain.com"
> }
>}'

Use cases

Use the table below to choose the right approach for redirects, order data, and WebView events.

FeatureApproach

How to redirect users back to your app after a transaction

Deeplink

How to get order data (e.g. status, order ID, amount)

Deeplink, Events

Listen to WebView events (order created, widget close, etc.)

Events

Deeplink

Transak supports deeplinking through the use of the redirectURL query parameter to enable seamless navigation after the purchase/sell process is completed.

1

Register Deeplink in AndroidManifest File

Add an intent filter to your AndroidManifest.xml to handle the deeplink:

1<activity android:name=".MainActivity">
2 <intent-filter>
3 <action android:name="android.intent.action.VIEW"/>
4 <category android:name="android.intent.category.DEFAULT"/>
5 <category android:name="android.intent.category.BROWSABLE"/>
6 <data android:scheme="myapp"
7 android:host="transak-redirect" />
8 </intent-filter>
9</activity>
2

Handle Deeplink and Parse Parameters

Listen for the deeplink and parse the returned parameters in your Activity.

When Transak redirects back, it includes additional query parameters appended to deeplink URL mentioned here.

1override fun onNewIntent(intent: Intent?) {
2 super.onNewIntent(intent)
3 intent?.data?.let { uri ->
4 val status = uri.getQueryParameter("status")
5 val orderId = uri.getQueryParameter("order_id")
6 val cryptoAmount = uri.getQueryParameter("cryptoAmount")
7 // Handle more parameters
8 }
9}
3

Pass redirectURL in Create Widget URL API

Call the Create Widget URL API from your backend to generate a secure widget url using Query parameters along with redirectURL parameter.

The response returns a widgetUrl that should be used to load Transak in Android Webview.

A widgetUrl is valid for 5 minutes and can only be used once. A new widgetUrl must be generated for every user flow.

Example Request:

$curl --request POST \
> --url https://api-gateway-stg.transak.com/api/v2/auth/session \
> --header 'access-token: YOUR_ACCESS_TOKEN' \
> --header 'content-type: application/json' \
> --data '{
> "widgetParams": {
> "apiKey": "YOUR_API_KEY",
> "referrerDomain": "yourdomain.com",
> "redirectURL": "myapp://transak-redirect"
> }
>}'

Events

Transak allows listening of in-widget events (like order creation, completion, and widget close) through native event handlers in Android WebViews.

Add a JavaScript interface to your WebView using the handler name Android to listen for all frontend events.

1import android.webkit.PermissionRequest
2import android.webkit.WebChromeClient
3...
4
5transakWidgetView.run {
6 this.settings.javaScriptEnabled = true
7 this.settings.domStorageEnabled = true
8 this.addJavascriptInterface(WebAppInterface(this@MainActivity), "Android")
9
10 this.webChromeClient = object : WebChromeClient() {
11 override fun onPermissionRequest(request: PermissionRequest) {
12 request.grant(request.resources)
13 }
14 }
15
16 loadUrl("https://global-stg.transak.com?apiKey=<YOUR_API_KEY>&sessionId=<YOUR_SESSION_ID>")
17}
18
19class WebAppInterface(private val context: Context) {
20 @JavascriptInterface
21 fun postMessage(eventData: String) {
22 Log.d("WebViewEvent", "postMessage: $eventData")
23 }
24}

Supported Events

Event NameDescription
TRANSAK_WIDGET_INITIALISED

Widget initialised with query params

TRANSAK_WIDGET_OPEN

Widget fully loaded

TRANSAK_ORDER_CREATED

Order created by user

TRANSAK_ORDER_SUCCESSFUL

Order is successful

TRANSAK_ORDER_CANCELLED

Order is cancelled

TRANSAK_ORDER_FAILED

Order is failed

TRANSAK_WIDGET_CLOSE

Widget is about to close