3rd-Party Payment Flow
  • 24 Jun 2025
  • 1 Minute to read
  • Contributors
  • Dark
    Light

3rd-Party Payment Flow

  • Dark
    Light

Article summary

Redirecting Back to Your App from a 3rd-Party Payment Flow

When a user chooses a 3rd-party payment method, they will be temporarily taken out of your app to complete the transaction. To handle the return (whether the payment is successful or not), you need to set up a custom scheme-based redirect.

Below are the steps to implement this mechanism:


Android

1. Define a Custom URL Scheme

Create a custom scheme (e.g., xyzpayments) that the 3rd-party payment provider will use to redirect the user back to your app after the transaction.

2. Register the Scheme in the Manifest

The scheme should be declared as part of an intent-filter in the activity responsible for hosting the EDP (Event Detail Page) — for example PurchaseActivity.

Update your AndroidManifest.xml like so:

<activity
    android:name="com.ticketmaster.mobile.android.library.retail.purchase.PurchaseActivity"
    android:exported="true"
    android:launchMode="singleTop"
    android:screenOrientation="portrait">

    <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="xyzpayments" />
    </intent-filter>

</activity>

This enables your app to respond to URLs like xyzpayments://... and bring the user back to the appropriate activity.


3. Pass the Scheme to the Payment SDK

When initializing the payment SDK (e.g., TMPurchase), provide the custom scheme so that it knows where to redirect after the payment flow:

val tmPurchase = TMPurchase(
    apiKey = apiKey,
    purchaseUrlScheme = "xyzpayments"
)

4. Handle the Redirect with TMPurchaseDeeplinkDelegate

To properly receive and handle the redirect intent, pass a TMPurchaseDeeplinkDelegate to your TMPurchaseFragmentFactory. This allows the SDK to listen for and handle deep links when onNewIntent() is triggered.

private val tmPurchaseDeeplinkDelegate = TMPurchaseDeeplinkDelegate()

val factory = TMPurchaseFragmentFactory(
    tmPurchaseNavigationListener = PurchaseNavigationListener {
        // Example: close the activity when purchase flow completes
        finish()
    },
    tmPurchaseDeeplinkDelegate = tmPurchaseDeeplinkDelegate // 👈 required to handle deep links
)

Then, inside your PurchaseActivity, forward the new intent like this:

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


Was this article helpful?