Skip to main content

Here’s how I combined RevenueCat subscriptions with usage-based credits without overcomplicating things (perfect for AI tools, AI wrappers API calls, or limiting features):

  1. Subscriptions via RevenueCat: Users pick weekly/monthly/yearly plans. RevenueCat handles Apple/Google payments.

  2. Credit Tracking in Firestore: We store credits in Firebase. Example: "Monthly plan = 1000 credits."

  3. Auto-Sync with Webhooks: When someone subscribes/cancels, Custom Written Revenuecat Webhook Handler in nextjs deployed on vercel extension updates Firestore. Credits auto-add/reset.

  4. Deduct Credits via Backend: Every API call from ios app hits our backend → checks Firestore → subtracts credits.

    IOS App: Firebase Auth and Reveneucat login with firebase userID
    Backend 1: Communicatig with 3rd party services, spends credits from user’s firestore record.
    Backend 2: Webhook handler for revenuecat, add credits to user accounts on new subscriptions, resets and adds new credits on renewal etc. I wrote all handlers for all events. 
    I dont know if there was an easier solution. If you are trying to do the same, feel free to contact me. I am planning to publish free opensource customizable Revenuecat Webhook handler server that can be easily deployable on vercel(free) for subscription and usage-based credit systems.