Callback navigation

Learn about the merchant deeplink you can add to your requests.

Overview

You can add a merchantDeeplink to your initiate transaction or modify transaction requests to take the customer back to your application after the transaction is completed. Note that transaction details are returned directly through the SDK's response, not via the deep link.

Deep link configuration

To use deeplinks in your project, add your URL scheme to your Android Manifest file:

<activity android:name=".MainActivity">
  <intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.DEFAULT" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data android:scheme="app" android:host="merchantapp" />
  </intent-filter>
</activity>

Example

// In your transaction request
val transactionRequest = TransactionRequest(
  // ... other parameters ...
  merchantDeeplink = "app://merchantapp/return"
)

// In your Activity
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  handleDeepLink(intent)
}

override fun onNewIntent(intent: Intent?) {
  super.onNewIntent(intent)
  handleDeepLink(intent)
}

private fun handleDeepLink(intent: Intent?) {
  intent?.data?.let { uri ->
    if (uri.host == "merchantapp") {
      // Handle return to app
      // Transaction response is already available through the SDK
    }
  }
}

Best practices

  • Simple formatting: We recommend using a simple format for your link. For example, merchantDeeplink = "app://merchantapp/return".
  • Unique scheme: Use a unique scheme to avoid conflicts with other apps. Consider including your company or app name in the scheme.
  • Error handling: Handle cases where the app might be in different states and implement proper deep link validation.
  • Testing: Test the navigation in various states: app in foreground, app in background, and app closed.
ℹ️

Set merchantDeeplink to String.Empty if no callback navigation is needed.