RevenueCat

Integrate with RevenueCat for managing in-app purchases and subscriptions using a simple ready-to-use platform.

How It Works

To trigger RevenueCat actions, set window.despia to a specific URL:

window.despia = "[url_scheme]://[parameters]"

Available URL Schemes

Purchase

To start a purchase, use the RevenueCat URL with the user's ID and product:

window.despia = "revenuecat://purchase?external_id=user_777&product=monthly_premium"

The URL needs two parameters:

  • external_id - Your user's unique identifier

  • product - The product ID from RevenueCat

Restore Purchases

To restore a user's previous purchases, use:

window.despia = "restoreinapppurchases://"

Cancel Purchase

To cancel an ongoing purchase, use:

window.despia = "cancelinapppurchase://"

Usage

When a user taps your purchase button, run:

window.despia = "revenuecat://purchase?external_id=user_777&product=monthly_premium"

When a user taps your restore button, run:

window.despia = "restoreinapppurchases://"

When a user wants to cancel a purchase in progress, run:

window.despia = "cancelinapppurchase://"

Quick Reference

Action

Code to Run

Purchase

window.despia = "revenuecat://purchase?external_id=USER_ID&product=PRODUCT_ID"

Restore

window.despia = "restoreinapppurchases://"

Cancel

window.despia = "cancelinapppurchase://"

Important Notes

  • Replace USER_ID with your actual user's ID

  • Replace PRODUCT_ID with your RevenueCat product ID

  • These URLs communicate with the native RevenueCat SDK in your app

Server-Side Integration

Listening for RevenueCat Webhooks

To properly handle purchases and keep your app in sync with subscription status, you need to set up server-side webhook processing:

  1. Configure webhooks in RevenueCat - Go to your RevenueCat dashboard and set up webhooks to point to your server endpoint. RevenueCat will send events like purchase completions, cancellations, and renewals to this endpoint.

  2. Process webhook events on your server - When your server receives a webhook from RevenueCat, validate it and update your database with the user's current subscription status, purchase history, and entitlements.

  3. Implement real-time updates in your Despia app - Set up WebSocket connections between your Despia app and your server. You can use various tools and libraries for this:

    • WeWeb - If you're using WeWeb, use their WebSocket plugin

    • Nordcraft - Nordcraft has WebSocket packages you can install

    • Wized - Wized supports WebSocket connections through their JS API

    • JavaScript libraries - Use any WebSocket library or plugin that works with your setup

    When your server processes a RevenueCat webhook, it should immediately notify the connected Despia app through the WebSocket.

  4. Update UI based on server events - When your Despia app receives a WebSocket message about a purchase completion or subscription change, update the UI to reflect the new status without requiring a page refresh.

Why This Matters

  • Security - Never trust client-side purchase validation alone. Always verify purchases server-side.

  • Real-time sync - Users expect immediate updates when they complete a purchase, especially if they're using multiple devices.

  • Reliability - Webhook processing ensures you don't miss important events like subscription renewals or cancellations.

Flow Summary

  1. User initiates purchase in Despia app using window.despia

  2. Native app processes purchase through RevenueCat

  3. RevenueCat sends webhook to your server

  4. Your server validates and stores the purchase data

  5. Server sends update to Despia app via WebSocket

  6. Despia app updates UI to reflect new purchase status

This approach ensures your app always shows accurate subscription information and provides a seamless user experience across all devices.

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on