Links

RevenueCat

Actions listed under this help you purchase the paid items or subscriptions using RevenueCat. This includes displaying a paywall, purchasing items, and restoring subscriptions.
RevenueCat actions

Prerequisites

Before you add any of these actions, you'll need to complete the RevenueCat Integration setup.

Types of RevenueCat action

Below are the types of RevenueCat action:
  1. 1.
    Paywall: This checks whether a user has purchased an item.
  2. 2.
    Purchase: This allows you to purchase the item.
  3. 3.
    Restore Purchases: Using this action, you can re-activate the in-app purchase that had previously been purchased.

Building subscription flow

Let's try building the subscription flow for an app that only allows users to watch premium movies if they are subscribed. Here is how it looks:
Subscription flow
As the figure above shows, you must create two pages (MovieDetails and WatchMovie) with one Bottom Sheet to display the Paywall.
To build a subscription flow, you must use PayWall, Purchase, and Restore Purchases actions.
Here are the step-by-step instructions:
  1. 1.
    ​Building UI​
  2. 2.
    ​Displaying paywall​
  3. 5.

1. Building UI

Let's build a UI for the subscription flow.
You can skip this step if you already have a UI ready.

1.1 MovieDetails page

Add the Movie_Details page from the template and modify the Add to Favorites button as per your need. Here's how it looks:
MovieDetails page

1.2 Paywall bottom sheet

Create the Paywall UI in a Bottom Sheet widget to display the subscription options (e.g., monthly, yearly) by following the instructions here.
Here's how it looks:
Paywall bottom sheet

1.3 WatchMovie page

On this page, add the VideoPlayer widget to play premium movies.
WatchMovie page

2. Displaying paywall

Once you have designed the subscription flow, you can add an action to see if the user is subscribed or not. If not, you can open the Paywall (asking to buy a subscription).
The Paywall is typically a page or component displaying the list of suggested purchases.
To see if a user is subscribed.
  • Select the Widget (e.g., Button) on which you want to define the action.
  • Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
  • Click on the + Add Action.
  • On the right side, search and select the Paywall (under RevenueCat) action.
  • Under the Entitlement ID section, set the Value Source and Value of the entitlement. (e.g., Value Source -> Specific Value and Value -> [name_of_entitlement]).
  • Click on the plus button and select Add Conditional. On the right side (Set Condition for Action), select the User Has RevenueCat Entitlement. This condition checks if a user is subscribed.
    • Under the TRUE section, add an action to navigate to the MovieDetails page.
    • Under the False section, add action to open the bottom sheet that hosts the Paywall UI.
Displaying paywall

3. Retrieving subscription details

To display the subscription details, such as price, description, etc., inside the Paywall, you need to retrieve this information from RevenueCat.
To retrieve details of the subscription option:
  • Select the Text widget from the widget tree or the canvas area.
  • Move to the property panel and click on the Set from Variable text. (This will open a new panel)
  • Set the Source to RevenueCat.
  • Set the Available Options to Current Offerings.
  • Set the Options to the appropriate value from the list. For example, select Monthly Package if you want to retrieve the price for the monthly package.
  • Set the Available Options (second) to Price String. This will display the price of the monthly package.
  • Click Confirm.
Other attributes of a package include an Identifier, Description, Product Price, and Price String.
Retrieving subscription details

4. Purchasing subscription

To allow users to purchase a subscription:
  • Select the Widget (e.g., Button) on which you want to define the action.
  • Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.
  • Click on the + Add Action.
  • On the right side, search and select the Purchase (under RevenueCat) action.
  • Under the Package ID section, set the Value Source to From Variable.
  • Set the Source to Revenue Cat and choose the Current Offerings.
  • Set the Options to the appropriate value from the list. For example, select Monthly Package if you want users to buy a monthly plan.
  • Set the Available Options (second) to Package Identifier.
  • Finally, set the Action Output Variable Name (e.g., didPurchase). This will be used to check if the purchase was successful.
  • Click on the plus button and select Add Conditional.
  • On the right side (Set Condition for Action), select the Action Output > [action_output_variable_name] (e.g, didPurchase).
    • Under the TRUE section, add an action to navigate back, followed by an action to navigate to the MovieDetails page.
    • Under the False section, add an action to show the snackbar with a failure message.
Purchasing subscription

5. Restoring purchases

Restoring a purchase helps the user re-activate the subscription he has already paid for. This is helpful when a user has reinstalled the app or logged in to a new device.
To allow a user to restore purchase:
  • Select the Widget (e.g., Text or Button) on which you want to define the action.
  • Select Actions from the Properties panel (the right menu), and click + Add Action.
  • Search and select the Restore Purchases (under RevenueCat) action.
Restoring purchases