> For the complete documentation index, see [llms.txt](https://help.twinr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.twinr.dev/extensions/in-app-purchase-iap/revenuecat/paywall-integration.md).

# Paywall Integration

### Overview

Twinr allows you to integrate RevenueCat’s Paywall system directly into your app.

Using Twinr’s JavaScript bridge functions, you can:

* Present a RevenueCat paywall
* Show paywall only if entitlement is missing
* Restore previous purchases
* Trigger paywall from custom HTML buttons

This integration works only when:

* RevenueCat is selected as Purchase Provider
* RevenueCat API keys are configured
* The app is published

## Part 1: Configure Paywall Setup

Before using Twinr bridge functions, you must configure RevenueCat properly.

If using RevenueCat’s Hosted Paywall:

1. Go to **Paywalls**
2. Create a new Paywall
3. Attach it to your Offering
4. Customize:
   * Layout
   * Branding
   * Pricing display
5. Publish Paywall

Now the paywall is ready to be triggered via Twinr.

## Part 2: Paywall Trigger Functions (Twinr Bridge)

All calls must use:

```
window.flutter_inappwebview.callHandler(...)
```

***

## Available Paywall Functions

***

### 1️⃣ Present Paywall

Displays the offering paywall.

```
window.flutter_inappwebview.callHandler(
  'iapPresentPaywall',
  'default'
);
```

`default` = Offering Identifier

***

### 2️⃣ Present Paywall If Needed

Shows paywall only if entitlement is not active.

```
window.flutter_inappwebview.callHandler(
  'iapPresentPaywallIfNeeded',
  'premium_access',
  'default'
);
```

Parameters:

* `premium_access` → Entitlement Identifier
* `default` → Offering Identifier

***

### 3️⃣ Restore Purchase

Required especially for iOS compliance.

```
window.flutter_inappwebview.callHandler(
  'iapRestorePurchase'
);
```

No parameters required.
