RevenueCat Integration

Configure RevenueCat webhooks for automatic commission tracking

Why RevenueCat?

RevenueCat handles subscription complexity (trials, renewals, refunds, platform differences). InfluTo integrates via webhooks to automatically track which subscriptions came from which influencers.

Benefits

  • ✓ Automatic attribution via subscriber attributes
  • ✓ Handles iOS and Android subscriptions
  • ✓ Tracks trials, renewals, cancellations, refunds
  • ✓ No manual webhook code needed

Step 1: Create RevenueCat Account

  1. Go to app.revenuecat.com/signup
  2. Create account (free tier available)
  3. Create a new project
  4. Add your app (iOS and/or Android)

Step 2: Install RevenueCat SDK

React Native

npm install react-native-purchases
# or
yarn add react-native-purchases

# iOS
cd ios && pod install && cd ..

Initialize RevenueCat

import Purchases from 'react-native-purchases';

Purchases.configure({
  apiKey: Platform.OS === 'ios'
    ? 'rcpk_ios_abc123...'      // From RevenueCat dashboard
    : 'rcpk_android_xyz789...'
});

// IMPORTANT: Do this BEFORE InfluTo.initialize()

Step 3: Configure Webhook in RevenueCat

Get Your Webhook URL

  1. Go to InfluTo Dashboard → Your App → Settings
  2. Copy webhook URL: https://influ.to/api/webhooks/revenuecat
  3. Copy webhook secret (shown once)

Add Webhook in RevenueCat

  1. RevenueCat Dashboard → Integrations → Webhooks
  2. Click "+ New"
  3. Enter webhook URL: https://influ.to/api/webhooks/revenuecat
  4. Enter authorization: Bearer rc_webhook_... (your webhook secret)

Enable Events

Check these event types:

  • INITIAL_PURCHASE - First subscription
  • RENEWAL - Recurring payments
  • CANCELLATION - User cancels
  • PRODUCT_CHANGE - Plan changes
  • BILLING_ISSUE - Payment failures
  • EXPIRATION - Subscription expires

💡 Pro Tip

Enable all event types. InfluTo automatically handles each type correctly and calculates recurring commissions on renewals.

Step 4: Test Webhook

Send Test Event

  1. RevenueCat Dashboard → Integrations → Webhooks
  2. Click your webhook
  3. Click "Send Test Event"
  4. Select INITIAL_PURCHASE
  5. Click Send

Verify in InfluTo

  1. InfluTo Dashboard → Analytics → Recent Events
  2. Should see test event logged
  3. Status: Processed or Error (with message)

How Attribution Works

The Flow

1. User clicks influencer link
   → InfluTo stores click with device fingerprint

2. User installs app and opens it
   → SDK.checkAttribution() matches device to click
   → SDK gets referral code: "FITGURU30"

3. SDK automatically calls RevenueCat:
   → Purchases.setAttributes({ referral_code: "FITGURU30" })

4. User purchases subscription
   → RevenueCat transaction completes

5. RevenueCat webhook fires to InfluTo:
   POST https://influ.to/api/webhooks/revenuecat
   {
     "event": {
       "app_user_id": "user_123",
       "product_id": "premium_monthly",
       "price": 9.99,
       "subscriber_attributes": {
         "referral_code": {
           "value": "FITGURU30"  ← SDK set this!
         }
       }
     }
   }

6. InfluTo receives webhook:
   → Finds campaign for "FITGURU30"
   → Calculates commission: $9.99 × 30% = $2.997
   → Credits influencer's balance
   → Updates analytics

7. Month-end: Automatic payout
   → Influencer receives $2.997 in their bank account

Subscriber Attributes

What They Are

RevenueCat subscriber attributes are key-value pairs attached to each user. They're included in every webhook, allowing attribution.

Setting Attributes

// InfluTo SDK does this automatically:
await Purchases.setAttributes({
  referral_code: 'FITGURU30'
});

// But you can also set manually:
await Purchases.setAttributes({
  referral_code: userEnteredCode,
  source: 'influencer',
  campaign: 'launch'
});

Viewing Attributes

const customerInfo = await Purchases.getCustomerInfo();
console.log(customerInfo.entitlements.all);

// You'll see:
// {
//   referral_code: "FITGURU30",
//   source: "influencer"
// }

Webhook Payload Structure

INITIAL_PURCHASE

{
  "event": {
    "event_timestamp_ms": 1658726378679,
    "product_id": "premium_monthly",
    "period_type": "NORMAL",
    "purchased_at_ms": 1658726374000,
    "expiration_at_ms": 1659331174000,
    "environment": "PRODUCTION",
    "app_user_id": "user_123",
    "price": 9.99,
    "price_in_purchased_currency": 9.99,
    "currency": "USD",
    "subscriber_attributes": {
      "referral_code": {
        "value": "FITGURU30",
        "updated_at_ms": 1658726370000
      }
    },
    "store": "APP_STORE"
  },
  "type": "INITIAL_PURCHASE",
  "api_version": "1.0"
}

RENEWAL

{
  "event": {
    "event_timestamp_ms": 1661404778679,
    "product_id": "premium_monthly",
    "period_type": "NORMAL",
    "app_user_id": "user_123",
    "price": 9.99,
    "original_transaction_id": "original_txn_123"
  },
  "type": "RENEWAL"
}

✓ Recurring Commissions

RENEWAL events automatically credit recurring commission to the influencer. No additional code needed - InfluTo handles it automatically.

Testing Webhooks

Sandbox Mode

  1. Use RevenueCat sandbox environment
  2. Make test purchase with sandbox account
  3. Webhook fires with "environment": "SANDBOX"
  4. InfluTo logs but doesn't create production commission

Test Purchase Flow

// 1. Set test code
await Purchases.setAttributes({ referral_code: 'TESTCODE' });

// 2. Make sandbox purchase
const offering = await Purchases.getOfferings();
await Purchases.purchasePackage(offering.current.availablePackages[0]);

// 3. Check InfluTo dashboard
// Should see: SANDBOX event logged with TESTCODE

Troubleshooting

Webhook Not Firing

  • Check webhook is enabled in RevenueCat
  • Verify URL is correct
  • Check authorization header matches secret
  • Look at RevenueCat webhook logs

Attribution Not Working

  • Verify referral_code is in subscriber attributes
  • Check code exists in InfluTo dashboard
  • Verify campaign is active
  • Check InfluTo webhook logs for errors

Commission Not Calculated

  • Check webhook secret is correct
  • Verify environment (PRODUCTION vs SANDBOX)
  • Check wallet has sufficient balance
  • Look for processing errors in dashboard

Advanced Configuration

Multiple Apps

Each app needs its own webhook configuration:

App 1: https://influ.to/api/webhooks/revenuecat/app_id_1
App 2: https://influ.to/api/webhooks/revenuecat/app_id_2

Webhook Retries

  • RevenueCat retries failed webhooks automatically
  • Exponential backoff: 1min, 5min, 30min, 2hr, 8hr
  • InfluTo handles duplicates via idempotency

Next Steps

  1. Learn about webhook security
  2. Test your integration