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.

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. Paywall: This checks whether a user has purchased an item.

  2. Purchase: This allows you to purchase the item.

  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:

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. 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:

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:

1.3 WatchMovie page

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

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.

  1. Select the Widget (e.g., Button) on which you want to define the action.

  2. Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.

  3. Click on the + Add Action.

  4. On the right side, search and select the Paywall (under Integrations) action.

  5. 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]).

  6. 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.

    1. Under the TRUE section, add an action to navigate to the MovieDetails page.

    2. Under the False section, add action to open the bottom sheet that hosts the Paywall UI.

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:

  1. Select the Text widget from the widget tree or the canvas area.

  2. Move to the property panel and click on the Set from Variable text. (This will open a new panel)

  3. Set the Source to RevenueCat.

  4. Set the Available Options to Current Offerings.

  5. 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.

  6. Set the Available Options (second) to Price String. This will display the price of the monthly package.

  7. Click Confirm.

Other attributes of a package include an Identifier, Description, Product Price, and Price String.

4. Purchasing subscription

To allow users to purchase a subscription:

  1. Select the Widget (e.g., Button) on which you want to define the action.

  2. Select Actions from the Properties panel (the right menu), and click Open. This will open an Action flow Editor in a new popup window.

  3. Click on the + Add Action.

  4. On the right side, search and select the Purchase (under RevenueCat) action.

  5. Under the Package ID section, set the Value Source to From Variable.

  6. Set the Source to Revenue Cat and choose the Current Offerings.

  7. Set the Options to the appropriate value from the list. For example, select Monthly Package if you want users to buy a monthly plan.

  8. Set the Available Options (second) to Package Identifier.

  9. Finally, set the Action Output Variable Name (e.g., didPurchase). This will be used to check if the purchase was successful.

  10. Click on the plus button and select Add Conditional.

  11. On the right side (Set Condition for Action), select the Action Output > [action_output_variable_name] (e.g, didPurchase).

    1. Under the TRUE section, add an action to navigate back, followed by an action to navigate to the MovieDetails page.

    2. Under the False section, add an action to show the snackbar with a failure message.

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:

  1. Select the Widget (e.g., Text or Button) on which you want to define the action.

  2. Select Actions from the Properties panel (the right menu), and click + Add Action.

  3. Search and select the Restore Purchases (under RevenueCat) action.

Last updated