Skip to main content
7 min read

How to Track Affiliate-Driven Stripe Payments in Your Mobile App

Connect Stripe to Appfiliate for automatic affiliate attribution on mobile app payments. Track which creators drive paying customers with webhook integration.

A
Appfiliate
How to Track Affiliate-Driven Stripe Payments in Your Mobile App

Stripe processes your payments. But Stripe has no idea which creator referred the customer. If you're running an affiliate or creator program for your mobile app, that's a problem.

Here's the typical flow: a user watches a video, clicks a creator's link, installs your app, and subscribes via Stripe. Stripe sees a new customer and a successful payment. What it doesn't see is the creator who started the whole chain. Without Stripe affiliate tracking for your mobile app, you can't tell which creators to pay and which ones aren't delivering results.

How Appfiliate solves this

Appfiliate links the creator's affiliate link to the customer's Stripe account. When a payment comes in, you know exactly which creator generated it. No manual matching, no spreadsheets, no screenshot-based reporting.

This guide walks through the full setup: integrating the Appfiliate SDK, connecting the Stripe customer ID, and configuring the Stripe webhook for automatic tracking of payments, renewals, and cancellations.

How Stripe affiliate tracking works

The integration has three layers:

Install attribution. The Appfiliate SDK ties the creator's affiliate link to the app install. This happens the first time the user opens the app. It uses device fingerprinting, so it doesn't require IDFA, ATT prompts, or any special permissions. User ID linking. Once the customer gets a Stripe customer ID (either client-side or server-side), you pass that ID to the Appfiliate SDK. This connects the attributed install to the Stripe customer. Webhook-based tracking. Stripe sends payment events to the Appfiliate webhook endpoint. On successful payments or cancellations, Appfiliate matches the Stripe customer ID back to the original creator. Revenue is attributed automatically.

The result: your Appfiliate dashboard shows which creators generated paying customers, how much revenue each creator drove, and whether those customers renewed or canceled.

Step 1: Add the Appfiliate SDK

Pick your platform and add the SDK to your app.

iOS (Swift)

Add the Swift Package in Xcode: File > Add Package Dependencies, enter https://github.com/Appfiliate-sdk/appfiliate-ios-sdk, and select version 1.0.0 or later.

Then configure the SDK in your app's init() or didFinishLaunchingWithOptions:

import Appfiliate

Appfiliate.configure(appId: "APP_ID_HERE", apiKey: "API_KEY_HERE")
Appfiliate.trackInstall()

Android (Kotlin)

Add JitPack to settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

Add the dependency to your app's build.gradle.kts:

dependencies {
    implementation("com.github.Appfiliate-sdk:appfiliate-android-sdk:1.0.0")
}

Then initialize the SDK in your Application.onCreate() or main Activity.onCreate():

import com.appfiliate.sdk.Appfiliate

Appfiliate.configure(this, appId = "APP_ID_HERE", apiKey = "API_KEY_HERE")
Appfiliate.trackInstall(this)

Flutter (Dart)

Add to pubspec.yaml:

dependencies:
  appfiliate: ^1.0.0

Run flutter pub get, then initialize in main() or initState:

import 'package:appfiliate/appfiliate.dart';

Appfiliate.configure(appId: 'APP_ID_HERE', apiKey: 'API_KEY_HERE');
await Appfiliate.trackInstall();

React Native

Install the package:

npm install appfiliate-react-native

Add to your root component or entry point:

import { appfiliate } from 'appfiliate-react-native';

appfiliate.configure({ appId: 'APP_ID_HERE', apiKey: 'API_KEY_HERE' });
await appfiliate.trackInstall();

Your appId and apiKey come from your Appfiliate dashboard. If you don't have an account yet, sign up at appfiliate.io.

Step 2: Link the Stripe customer ID

After the user creates a Stripe customer (either when they sign up or when they start a subscription), pass the Stripe customer ID to the SDK. This is the bridge between install attribution and payment tracking.

Call setUserId with the Stripe customer ID (the cus_ prefixed string):

iOS (Swift):

Appfiliate.configure(appId: "APP_ID", apiKey: "API_KEY")
Appfiliate.trackInstall()
Appfiliate.setUserId(stripeCustomerId) // e.g. "cus_R4x9bKmVf1Hq7Z"

Android (Kotlin):

Appfiliate.configure(this, appId = "APP_ID", apiKey = "API_KEY")
Appfiliate.trackInstall(this)
Appfiliate.setUserId(this, stripeCustomerId) // e.g. "cus_R4x9bKmVf1Hq7Z"

Flutter (Dart):

Appfiliate.configure(appId: 'APP_ID', apiKey: 'API_KEY');
await Appfiliate.trackInstall();
await Appfiliate.setUserId(stripeCustomerId); // e.g. "cus_R4x9bKmVf1Hq7Z"

React Native:

appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
await appfiliate.trackInstall();
await appfiliate.setUserId(stripeCustomerId); // e.g. "cus_R4x9bKmVf1Hq7Z"

The timing depends on your app's flow. If the Stripe customer is created during onboarding, call setUserId right after you receive the customer ID from your backend. If it's created later at the point of purchase, call it then. The SDK will queue the attribution data until the user ID is set.

Step 3: Add the webhook in Stripe

This is where the automation happens. Instead of calling trackPurchase() in your app code every time a payment succeeds, you configure Stripe to send payment events directly to Appfiliate.

https://us-central1-appfiliate-5a18b.cloudfunctions.net/api/v1/webhooks/stripe?secret=YOUR_WEBHOOK_SECRET
    • Under Select events to listen to, choose:
- invoice.paid: triggers on successful payments and subscription renewals - customer.subscription.deleted: triggers on cancellations
    • Click Add endpoint
Replace YOUR_WEBHOOK_SECRET with the webhook secret from your Appfiliate dashboard under the Stripe integration settings.

That's it. Three steps. No manual trackPurchase() calls needed.

What gets tracked automatically

Once the webhook is connected, Appfiliate captures the following events without any additional code:

  • Initial purchases. The first payment a customer makes is attributed to the creator who drove the install.
  • Subscription renewals. Every renewal is logged and attributed. If a creator sent you a customer who renewed for 12 months, you see all 12 payments.
  • Cancellations. When a subscription is cancelled, the event is recorded against the original creator attribution. You can track revenue per creator, average revenue per user, renewal rate, and churn rate -- all broken down by creator.
All of this shows up in the Appfiliate dashboard.

Why use webhooks instead of client-side tracking

You could call trackPurchase() directly in your app after each successful Stripe payment. But the webhook approach is better for three reasons.

First, webhooks capture renewals. The user might not have your app open when their subscription renews. The Stripe webhook fires regardless.

Second, webhooks capture cancellations. There's no client-side callback when a user cancels a subscription from the Stripe dashboard or through the customer portal.

Third, webhooks require less code. One URL handles purchase tracking across all platforms your app runs on.

If you're already using RevenueCat, Superwall, Adapty, or Qonversion to manage subscriptions, Appfiliate supports those as webhook integrations too. See the integrations page for details.

FAQ

Do I still need to call trackInstall() if I'm using the Stripe webhook?

Yes. trackInstall() handles the initial attribution -- linking the app install to the creator. The webhook handles payment tracking. You need both.

What if the Stripe customer ID isn't available on app launch?

Call setUserId whenever the customer ID becomes available. The SDK stores the attribution data until then. The link between the creator and the Stripe customer is made at the moment you call setUserId.

Does this work with Stripe's test mode?

Yes. During development, use your test mode webhook URL. The attribution flow works identically in test and live modes.

What if I use Stripe for web payments too?

The webhook captures all Stripe events for the given endpoint. If a user was attributed through a mobile install but later pays on the web, the attribution still works as long as the Stripe customer ID is the same.

How much does this cost?

See the pricing page for current rates. The Stripe webhook integration is included on all plans.

Does the SDK require IDFA or App Tracking Transparency?

No. The Appfiliate SDK uses device fingerprinting (device model, OS version, locale, timezone) for attribution. No IDFA, no ATT prompt, no tracking dialogs.

Get started

The full integration takes three things: add the SDK, link the Stripe customer ID, and paste in a webhook URL. Under 15 minutes total.

Sign up at appfiliate.io, grab your app ID and API key, and start tracking which creators actually drive revenue through your Stripe account.