Agent instructions

Tap App Link + Stripe

You are a coding assistant helping a developer integrate Tap App Link (creator dashboards, tracked install links, and discount codes for apps) with Stripe. Tap App Link matches installs client-side via an SDK and attributes purchase revenue server-side via a Stripe webhook. Promo codes are a second attribution path when the viewer types a code at checkout.

1. Install and configure the Tap App Link SDK

If the project is missing the SDK, add it for the target platform, then call configure once on launch. Use the sandbox key and environment on test builds, production on store builds.

Use SDK 0.3.3 or later on every platform.

yarn add @tapapplink/react-native@^0.3.3 @react-native-async-storage/async-storage
# or: npm install @tapapplink/react-native@^0.3.3 @react-native-async-storage/async-storage
# or: npx expo install @tapapplink/react-native@^0.3.3 @react-native-async-storage/async-storage
import { TapAppLink } from "@tapapplink/react-native";

TapAppLink.configure({
  publicKey: "YOUR_TAPAPPLINK_KEY",
  environment: __DEV__ ? "sandbox" : "production",
});

await TapAppLink.trackInstall();
// Same id you put on Stripe subscription_data.metadata.app_user_id
await TapAppLink.setAppUserId(currentUser.id);

const offer = TapAppLink.getOffer();
// Present your Stripe Checkout / paywall. Creator codes sync as promotion codes.

2. Track the install, then bridge the Stripe user id

trackInstall() is safe to call on every launch from SDK 0.3.0 or later (React Native also needs @react-native-async-storage/async-storage installed). Immediately after, call setAppUserId() with the id on the webhook. That bridge attaches webhook events to the creator who drove the install.

subscription_data.metadata.app_user_id / setAppUserId

  1. Set metadata.app_user_id on the subscription (for example subscription_data.metadata in Checkout) so it reaches the invoice. Pass that same id to setAppUserId() in the app so web and app purchases join up.
  2. Tap App Link also reads app_user_id / appUserId / tal_app_user_id from invoice metadata, subscription metadata, and the first line item. If those are missing, it uses the Stripe customer id (cus_…). Email is used only when there is no customer id.
  3. Creator attribution on web does not require an app open when a promotion code or tap_creator_code metadata is present.
// Checkout Session (subscription)
const session = await stripe.checkout.sessions.create({
  mode: "subscription",
  // Optional: keep for your own records. Invoice webhooks do not receive this field.
  // client_reference_id: buyerId,
  subscription_data: {
    metadata: {
      app_user_id: buyerId, // same id you pass to TapAppLink.setAppUserId()
      tap_creator_code: creatorCode, // optional when a promotion code is applied
    },
  },
  // ...
});

3. Wire discount codes

After a match, getOffer() returns the creator's discount. If the user types a code in-app, call applyCode() so they still attribute to that creator.

await TapAppLink.applyCode("SARAH10");
const offer = TapAppLink.getOffer();

Creator discount codes sync as Stripe promotion codes when Stripe is connected. Buyers can redeem them at Checkout. Metadata keys tal_code and tap_creator_code also credit the creator.

Full product guide: https://tapapplink.com/docs/concepts/promo-codes/

4. Configure the Stripe webhook

Human click path: https://tapapplink.com/docs/integrations/stripe/. Follow those dashboard steps. Summary:

  1. In Tap App Link, open Apps → Revenue, select Stripe. A restricted key (rk_…) works with any Stripe account. If Connect with Stripe is set up for your workspace, you can use it instead.
  2. If you used a restricted key: copy the webhook URL, add the endpoint in Stripe → Developers → Webhooks, subscribe to invoice.paid, charge.refunded and credit_note.created, then paste Stripe's signing secret (whsec_…) into Tap App Link before saving the key.
  3. If you used Connect with Stripe: the endpoint and events are set up for you. Skip to a test purchase. Do not create a second endpoint in Stripe.
  4. Creator codes sync as Stripe promotion codes after connect. New codes sync when you create a discount.

A restricted key works with any Stripe account: add the endpoint in Stripe, then paste the signing secret Stripe shows (whsec_…) into Tap App Link. If you use Connect with Stripe instead, Tap App Link creates the webhook endpoint for you.

Enable events: invoice.paid, charge.refunded, credit_note.created. Extra events are ignored. Sandbox Stripe events must hit the Tap App Link sandbox environment URL. Production events must hit production. Mixing them puts test purchases on your live commission statements.

5. Verify

  1. In Tap App Link, switch to Sandbox and open the Live Attribution Debugger.
  2. In Tap App Link, switch to Sandbox and open the Live Attribution Debugger.
  3. Confirm the timeline reaches install matched and billing customer linked. If you retry, call resetForTesting() in debug builds first.
  4. Trigger a sandbox purchase and confirm the webhook returns 2xx.
  5. Optionally start a promo-code watch and redeem a creator code with applyCode().

Hard constraints

Human quick start: https://tapapplink.com/docs/quick-start/. Questions: support@tapapplink.com.