Infumar
Developer page

In-app purchase guide

Creator campaigns in a mobile app on RevenueCat: a follower enters the creator's code in the app, and the creator earns commission on purchases made with it.

How it works

Two independent proofs are required together. The store's own record says the purchase came from the campaign: it was made through the campaign offer Infumar generated for your app. The infumar_code attribute your app writes to RevenueCat says which creator. The sale reaches us through RevenueCat's signed webhook; the amount is the store's record.

Setup

1. Connect the app

In the Infumar panel, under My Brands → your brand → Integrations → In-App Purchases, enter your RevenueCat project id and a read-only v2 secret key (customer_information:customers:read and project_configuration:integrations:read). The panel gives you the webhook URL, the app key and the campaign offer names.

2. Turn on the webhook

Under RevenueCat → Integrations → Webhooks add a webhook with the panel's URL: environment Production, all event types, signing on. Paste the signing secret RevenueCat shows into the panel. The webhook is checked daily; if it's turned off the campaign pauses.

3. Create the campaign offer in the stores

In App Store Connect create a custom offer code on your subscriptions (and one-time products) whose reference name and code match the panel exactly. In Google Play Console add a developer offer with the panel's id to the same products. Price and duration are yours to decide; Infumar only looks at the name.

4. Add the code screen

Your app checks the code the user typed with Infumar. The request carries only the app key (not a secret); the answer names no one. Codes match regardless of case and Turkish characters.

curl https://api.infumar.com/api/v1/iap/codes/AYSE \
  -H "X-Infumar-App-Key: infapp_..."

// Live creator of your running campaign (or the test code):
{
  "valid": true,
  "code": "AYSE",
  "apple": { "offerCode": "INF3F9A...", "redeemUrl": "https://apps.apple.com/redeem?ctx=offercodes&id=...&code=INF3F9A..." },
  "play":  { "offerId": "inf-3f9a12bc" }
}

// Anything else — unknown, removed, no campaign running:
{ "valid": false }

5. Test purchase

With a sandbox account, enter the code INFUMARTEST and buy through the campaign offer. This code is valid even with no campaign running; when the purchase arrives the panel shows the app as verified and a campaign can open.

Sample flow

If the code is valid, write the infumar_code attribute first, then apply the campaign offer. On iOS the offer is redeemed through Apple's code redemption screen, on Android bought through the offer's option. lookup in the samples is your own helper making the request above.

iOS (Swift)

// 1. Check the code the user typed.
let lookup = try await infumar.lookup(code: typed)   // GET /iap/codes/:code
guard lookup.valid else { return showInvalidCode() }

// 2. Tag the customer BEFORE the purchase — this is what pays the creator.
Purchases.shared.attribution.setAttributes(["infumar_code": lookup.code])
await Purchases.shared.syncAttributesAndOfferingsIfNeeded()

// 3. Apply the campaign offer: Apple's redeem sheet with the offer code.
if let url = URL(string: lookup.apple!.redeemUrl) {
  await UIApplication.shared.open(url)
}

Android (Kotlin)

// 1. Check the code the user typed.
val lookup = infumar.lookup(typed)                   // GET /iap/codes/:code
if (!lookup.valid) return showInvalidCode()

// 2. Tag the customer BEFORE the purchase — this is what pays the creator.
Purchases.sharedInstance.setAttributes(mapOf("infumar_code" to lookup.code))

// 3. Buy with the campaign offer (option id = "<basePlan>:<offerId>").
val option = product.subscriptionOptions
  ?.firstOrNull { it.id.endsWith(":" + lookup.play!!.offerId) }
  ?: return showOfferMissing()
Purchases.sharedInstance.purchase(
  PurchaseParams.Builder(activity, option).build(), callback
)

React Native

const res = await fetch(`https://api.infumar.com/api/v1/iap/codes/${encodeURIComponent(typed)}`, {
  headers: { "X-Infumar-App-Key": INFUMAR_APP_KEY },
});
const lookup = await res.json();
if (!lookup.valid) return showInvalidCode();

await Purchases.setAttributes({ infumar_code: lookup.code });   // before the purchase

if (Platform.OS === "ios") {
  await Linking.openURL(lookup.apple.redeemUrl);
} else {
  const option = product.subscriptionOptions?.find((o) =>
    o.id.endsWith(":" + lookup.play.offerId),
  );
  await Purchases.purchaseSubscriptionOption(option);
}

If you don't use RevenueCat

When connecting the app choose "App Store & Google Play". For the App Store, create an In-App Purchase key; we read purchases from Apple's server notification history (an App Store Server Notifications URL must be set — your own server's is fine). For Google Play, grant a service account "View financial data" and "Manage orders and subscriptions" on the app and add a subscription to your Play notifications' Pub/Sub topic that pushes to our URL; we read every purchase from the Play API. Instead of the infumar_code attribute, when the purchase completes you report the code to us: on iOS with the original transaction id, on Android with the purchase token. The report may arrive after the purchase; a purchase through the campaign offer waits a while for its code.

curl -X POST https://api.infumar.com/api/v1/iap/attributions \
  -H "X-Infumar-App-Key: infapp_..." \
  -H "Content-Type: application/json" \
  -d '{ "platform": "ios", "purchaseId": "2000000123456789", "code": "AYSE" }'
# Android: { "platform": "android", "purchaseId": "<purchaseToken>", "code": "AYSE" }

// → { "recorded": true }   (a code the check would refuse → { "recorded": false })
// After the offer-code purchase lands (Apple's redeem sheet runs outside
// your purchase call, so listen for it):
for await update in Transaction.updates {
  guard case .verified(let transaction) = update else { continue }
  if let code = pendingInfumarCode {                 // the code the user typed
    try await infumar.report(platform: "ios",
                             purchaseId: String(transaction.originalID),
                             code: code)             // POST /iap/attributions
    pendingInfumarCode = nil
  }
  await transaction.finish()
}
// Android (Play Billing): buy with the campaign offer's token, then report.
val details = productDetails.subscriptionOfferDetails
  ?.first { it.offerId == campaign.play.offerId }      // from /iap/codes
val params = BillingFlowParams.ProductDetailsParams.newBuilder()
  .setProductDetails(productDetails)
  .setOfferToken(details!!.offerToken).build()
billingClient.launchBillingFlow(activity,
  BillingFlowParams.newBuilder().setProductDetailsParamsList(listOf(params)).build())

// in onPurchasesUpdated:
infumar.report(platform = "android", purchaseId = purchase.purchaseToken, code = code)

Rules

  • The infumar_code attribute must be written BEFORE the purchase. A code written afterwards doesn't tie that purchase to the creator.
  • Only purchases through the campaign offer count. A purchase without the offer isn't the campaign's, even with a code entered.
  • A purchase through the offer with no code is credited to no one and not charged; when a few pile up the campaign pauses. Make sure you always write the code.
  • A creator's link sends the visitor to your App Store or Google Play page, by phone. On Android the code arrives in Play's install referrer (referrer = infumar_code=CODE): if your app reads it on first launch with the Play Install Referrer API and fills the code box, the user never has to type it. On iOS an App Store link carries nothing into the app; the user enters the code.
  • Subscription renewals go to the same creator for 12 months from the first purchase; this continues for subscriptions started before a campaign closes.
  • A refunded purchase's commission is reversed. Commission is computed on what the customer paid (no store fee deducted).
  • Non-TRY payments are converted at the TCMB forex buying rate in force on the purchase day.
  • On iOS the offer code is redeemed on Apple's screen outside the app. The RevenueCat SDK picks the purchase up when the app opens; make sure the SDK is configured on every launch and that you grant access from that purchase.
  • If the webhook is off, deleted or sends only sandbox events, the campaign pauses; it resumes the morning after it's fixed.
  • The app key may live inside the app; it isn't a secret. Enter your RevenueCat API key and the signing secret only in the Infumar panel.

Frequently asked

Can one iOS offer code give both a free trial and a first-month discount?
No. An App Store offer code carries one type: free, pay as you go or pay up front. For the campaign we recommend a discounted period: it is what the creator promises their followers, and the first payment arrives at once. Your free trial can stay as the regular introductory offer for users outside the campaign. A trial starts at 0 TL, and a trial that never converts is not a sale.
On Android, can we use our own offer id (e.g. p20-monthly)?
Infumar gives the campaign offer its id (on the connection screen, inf-…); create a new developer-determined offer with that id on the same base plan in Play Console — the discount can match your existing offer. Every purchase with that id counts toward the campaign, so the id must belong to the campaign alone; your existing offers keep working in your own promotions. Play has no limit on the number of offers.
Can we forward the RevenueCat webhook to you through our own server?
No. For a campaign to open and stay open, we check through RevenueCat's API that your RevenueCat project has an enabled, production webhook pointing straight at our address; a forwarded webhook cannot pass that check and the campaign pauses. Keep your own webhook as it is and add a second one pointing at our address.
If we reconnect the app, do the offer names change?
No. Reconnecting the same app (same bundle id or package name) brings back its existing record; the app key, the offer names and the Google Play notification address stay the same.

Help

If you get stuck, write to us from the panel's support section.

Go to panel
In-App Purchase Guide | Infumar