Skip to main content
Version: 3.0

Step 4. Enable purchase

Congratulations! You've successfully set up your paywall to display product data from Adapty, including the product title and price.

Now, let's move on to the final step – letting users make a purchase through the paywall.

Step 4.1. Enable users make your purchase

  1. Double-click the buy button on your paywall page.
  1. In the right panel, open the Actions section if it's not already open.
  1. Open the Action Flow Editor.
  1. In the Select Action Trigger window, choose On Tap.
  2. In the No Actions Created window, click the Add Action button.
  3. In the Actions Flow Editor window, search for makePurchase custom action and choose it.
  1. In the Set Actions Arguments section, choose getPaywallProductsResult variable created earlier.

  2. Fill in the fields as follows:

    ParameterValue
    Available OptionsData Structure Field
    Select Fieldvalue
    Available OptionsItem is Index
    List Index OptionsFirst
  3. Click the Confirm button.

  4. In the Action Output Variable Name, create a new variable and name it makePurchaseResult - this will be used later to confirm the purchase was successful.

Step 4.2. Check if the purchase was successful

Now, let's set up a check to see if the purchase went through.

  1. Click the plus (+) button and click Add Conditional.

  2. In the Set Condition for Action section, select the makePurchaseResult variable.

  3. In the Set Variable window, fill in the fields as follows:

    ParameterValue
    Available OptionsHas Field
    Select Fieldprofile
  1. Click the Confirm button.

Step 4.3. Open paid content

If the purchase is successful, you can unlock the paid content. Here’s how to set that up:

  1. Click the plus (+) button under the TRUE label and click Add Action.
  2. In the Select Action field, search for and select the page you want to open from the Navigate To list. In this example, the page is YogaClessSession.

Step 4.4 Show error message if purchase failed

If the purchase fails, let's display an alert to the user.

  1. Add an Informational Dialog action to the FALSE label.
  2. In the Title field, enter the text you want for the dialog title, such as Purchase Failed.
  1. Click at the Value button of the Message box.
  1. Fill in the fields as follows:

    ParameterValue
    Set VariablemakePurchaseResult variable we've created
    Available OptionsData Structure Field
    Select Fielderror
    Available OptionsData Structure Field
    Select FielderrorMessage
  2. Click the Confirm button.

  3. Add a Terminate action to the FALSE flow.

  1. Finally, click the Close button in the top-right corner.

Congratulations! Your users can now purchase your products. As an extra step, let's set up a check for user access to paid content elsewhere to decide whether to display paid content or the paywall to them.