Skip to main content

Documentation Index

Fetch the complete documentation index at: https://setup.despia.com/llms.txt

Use this file to discover all available pages before exploring further.

Native iOS and Android billing fully bridged to your web layer. Trigger purchases, display native paywalls, and check entitlements from your web app using despia(), with no native code and no native billing SDK to configure.

Installation

npm install despia-native
import despia from 'despia-native';

RevenueCat and Despia setup

Configure RevenueCat, then connect it to Despia. The steps go in order, each one feeds the next.
1

Create a RevenueCat account

Go to app.revenuecat.com and sign up, or sign in with an existing account. RevenueCat is free up to a monthly tracked revenue threshold, after which a percentage fee applies, so account creation does not block early development.
2

Create an iOS app in RevenueCat

In RevenueCat, go to Project settings > Apps > + New and choose App Store. Enter your iOS bundle ID (e.g. com.despia.myapp), upload a new App Store Connect API key (App Manager), and an in-app purchase key. RevenueCat needs both to validate iOS receipts on your behalf.
3

Create an Android app in RevenueCat

Repeat Project settings > Apps > + New and choose Play Store. Enter your Android package name (the same value as your iOS bundle ID for Despia apps) and upload your Google Play Service Account credentials JSON. This lets RevenueCat verify Play Store purchases.
4

Configure entitlements and offerings

In RevenueCat, go to Entitlements > + New and create entitlements that represent the things users unlock, like premium or no_ads. Then go to Products and import your App Store Connect and Play Console products, attaching each to the matching entitlement. Finally, go to Offerings and group products into offerings that drive your paywalls (e.g. a default offering with monthly and annual packages).
5

Get your RevenueCat API keys

Go to Project settings > API keys. Copy the iOS Public SDK Key and the Android Public SDK Key. You will paste both into Despia in the next step.
6

Enable RevenueCat in the Despia Editor

Open the Despia Editor and go to App > Settings > Integrations > RevenueCat. Toggle the integration on, then paste in:
  • iOS Public SDK Key
  • Android Public SDK Key
Both values must match exactly what RevenueCat issued.
7

Rebuild your app

Trigger a fresh build from the Despia Editor. The RevenueCat SDK has to be compiled into the app binary, so this cannot be applied over-the-air. After the build finishes, calls to revenuecat://, getpurchasehistory://, and the rest of the schemes will function in production.
Skipping the rebuild leaves RevenueCat inactive even if the toggle reads enabled. Purchases will fail silently and entitlement checks will return empty arrays. If purchases stop working after editing settings, rebuild before opening a support ticket.

How it works

Despia bridges your web layer to the native RevenueCat SDK. Purchases go through the App Store or Google Play billing system. When a transaction completes, the runtime fires window.onRevenueCatPurchase() in your web layer. You can then check entitlements instantly using getpurchasehistory://, which queries the native store directly with no backend needed.
// Check entitlements on load and after every purchase
const data   = await despia('getpurchasehistory://', ['restoredData'])
const active = (data.restoredData ?? []).filter(p => p.isActive)

if (active.some(p => p.entitlementId === 'premium')) unlockPremium()
For users on the web app who are not in the Despia WebView, fall back to a RevenueCat Web Purchase Link with the user’s ID appended.
const isDespia = navigator.userAgent.toLowerCase().includes('despia')

if (isDespia) {
    despia(`revenuecat://launchPaywall?external_id=${userId}&offering=default`)
} else {
    window.location.href = `https://pay.rev.cat/<your_token>/${encodeURIComponent(userId)}`
}

Reference

All schemes, parameters, response fields, callback behaviour, and webhook setup.

Webhooks

Full backend webhook handler covering all RevenueCat event types.

Entitlement check

Set up entitlements in your RevenueCat dashboard first. Create an entitlement (e.g. premium), then attach both your iOS and Android products to it. Both platforms will return the same entitlementId in the response.
// Reuse this function on app load, page navigation, and in onRevenueCatPurchase
async function checkEntitlements() {
    const data   = await despia('getpurchasehistory://', ['restoredData'])
    const active = (data.restoredData ?? []).filter(p => p.isActive)

    if (active.some(p => p.entitlementId === 'premium')) unlockPremium()
    if (active.some(p => p.entitlementId === 'no_ads'))  removeAds()
}

checkEntitlements()
window.onRevenueCatPurchase = checkEntitlements

Customer Center

The RevenueCat Customer Center is a native UI where users can restore purchases, manage their subscription, request refunds (iOS only), and submit feedback surveys without leaving your app. Trigger it from your web layer with a single scheme.
despia(`revenuecat://center?external_id=${userId}`)
When the user runs Restore Purchases from inside the sheet, the recommended fully-safe pattern is to also fire your existing Despia restore flow on restoreCompleted. The Customer Center’s restore and the Despia getpurchasehistory:// query both hit the native store, but running both back-to-back guarantees your web layer reflects whatever the device thinks is true, regardless of timing or edge cases.
window.onRevenueCatCenter = (event) => {
    if (event.event === 'restoreCompleted') {
        // Fully safe: run the Despia restore + entitlement check ourselves
        checkEntitlements()
    }
    if (event.event === 'dismissed') {
        // Catch-all on close, in case any other state changed inside the sheet
        checkEntitlements()
    }
}
Google Play does not allow in-app refund requests, so the Customer Center on Android has no refund button and the refundRequested / refundCompleted events never fire on Android. Configure a custom URL management option in your RevenueCat dashboard to route Android users to your support email or Google Play subscriptions page. See the Reference for the full Android refund fallback pattern.
See the Reference for the full event list and payload fields.

Resources

NPM Package

despia-native

RevenueCat Dashboard

Configure entitlements, offerings, and paywalls

RevenueCat Webhooks

Event types, fields, and sample payloads