---
title: "ステップ 3. 購入を有効にする"
description: "Adaptyの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. **FALSE** ラベルに **Informational Dialog** アクションを追加します。
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. **Message** ボックスの **Value** をクリックします。**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. **FALSE** フローに **Terminate** アクションを追加します。

  
    <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)を行い、有料コンテンツまたはペイウォールのどちらを表示するかを判断できるようにしましょう。