---
title: "Шаг 3. Включение покупки"
description: "Узнайте, как совершать покупки с помощью системы Feature Flags."
---

Поздравляем! Вы успешно [настроили пейвол для отображения данных о продуктах из Adapty](ff-add-variables-to-paywalls), включая название и цену продукта.

Теперь перейдём к финальному шагу — дадим пользователям возможность совершить покупку через пейвол.

## Шаг 3.1. Включите возможность покупки для пользователей \{#step-31-enable-users-to-make-purchases\}

1. Дважды кликните кнопку покупки на странице пейвола. В правой панели откройте раздел **Actions**, если он ещё не открыт.

2. Откройте **Action Flow Editor**.

  <img src="/assets/shared/img/ff-action-flow-editor.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

3. В окне **Select Action Trigger** выберите **On Tap**.
4. В окне **No Actions Created** нажмите **Add Action**. Найдите действие `makePurchase` и выберите его.

  <img src="/assets/shared/img/ff-makepurchase.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

5. В разделе **Set Actions Arguments** выберите переменную `getPaywallProductsResult`, созданную ранее.
6. Заполните поля следующим образом:
	- **Available Options**: Data Structure Field
    - **Select Field**: value
    - **Available Options**: Item at Index
    - **List Index Options**: First

  <img src="/assets/shared/img/ff-makepurchase-value.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

7. Нажмите `subscriptionUpdateParameters`, найдите `AdaptySubscriptionUpdateParameters` и выберите его. Нажмите **Confirm**.
    :::info
    По умолчанию все поля объекта можно оставить пустыми. Их нужно заполнять только при замене одной подписки другой в Android-приложениях. Подробнее читайте [здесь](https://android.adapty.io/adapty/com.adapty.models/-adapty-subscription-update-parameters/).
    :::
   
   <img src="/assets/shared/img/ff-subupdate.webp"
   style={{
   border: '1px solid #727272', /* border width and color */
   width: '700px', /* image width */
   display: 'block', /* for alignment */
   margin: '0 auto' /* center alignment */
   }}
   />
   
8. Нажмите **Confirm**.
9. В поле **Action Output Variable Name** создайте новую переменную и назовите её `makePurchaseResult` — она понадобится позже для подтверждения успешной покупки.

  <img src="/assets/shared/img/ff-makepurchaseresult.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

## Шаг 3.2. Проверьте, прошла ли покупка успешно \{#step-32-check-if-the-purchase-was-successful\}

Теперь настроим проверку того, что покупка была выполнена.

1. Нажмите **+** и выберите **Add Conditional**.
2. В разделе **Set Condition for Action** выберите переменную `makePurchaseResult`.
3. В окне **Set Variable** заполните поля следующим образом:
    - **Available Options**: Has Field
    - **Select Field**: profile

  <img src="/assets/shared/img/ff-makepurchaseresult-conditional.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

4. Нажмите **Confirm**.

## Шаг 3.3. Откройте платный контент \{#step-33-open-paid-content\}

Если покупка прошла успешно, можно открыть доступ к платному контенту. Вот как это настроить:

1. Нажмите **+** под меткой **TRUE** и выберите **Add Action**.
2. В поле **Define Action** найдите и выберите страницу, которую хотите открыть, из списка **Navigate To**. В данном примере это страница **Questions**.

  <img src="/assets/shared/img/ff-questions.webp"
  style={{
    border: '1px solid #727272', /* border width and color */
    width: '700px', /* image width */
    display: 'block', /* for alignment */
    margin: '0 auto' /* center alignment */
  }}
/>

## Шаг 3.4. Показ сообщения об ошибке при неудачной покупке \{#step-34-show-error-message-if-purchase-failed\}

Если покупка не прошла, покажем пользователю соответствующее уведомление.

1. Добавьте действие **Informational Dialog** к метке **FALSE**.
2. В поле **Title** введите текст заголовка диалога, например **Purchase Failed**.
 
    <img src="/assets/shared/img/ff-purchase-fail.webp"
    style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
    }}
  />
  

3. Нажмите **Value** в поле **Message**. В окне **Set from Variable** найдите `makePurchaseResult` и выберите его. Заполните поля следующим образом:
    
   - **Available Options**: Data Structure Field
   - **Select Field**: error
   - **Available Options**: Data Structure Field
   - **Select Field**: errorMessage
      
   
      <img src="/assets/shared/img/ff-fail-message.webp"
      style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
      }}
      />
      

4. Нажмите **Confirm**.
5. Добавьте действие **Terminate** в ветку **FALSE**.

  
    <img src="/assets/shared/img/ff-terminate-purchase.webp"
    style={{
      border: '1px solid #727272', /* border width and color */
      width: '700px', /* image width */
      display: 'block', /* for alignment */
      margin: '0 auto' /* center alignment */
    }}
  />
  

6. Наконец, нажмите **Close** в правом верхнем углу.

Поздравляем! Теперь пользователи могут приобретать ваши продукты. В качестве дополнительного шага [настройте проверку доступа пользователей к платному контенту](ff-check-subscription-status) в других местах приложения, чтобы решить — показывать им платный контент или пейвол.