---
title: "Bước 3. Kích hoạt tính năng mua hàng"
description: "Tìm hiểu cách thực hiện mua hàng bằng hệ thống Feature Flags của Adapty."
---

Chúc mừng! Bạn đã [thiết lập thành công paywall để hiển thị dữ liệu sản phẩm từ Adapty](ff-add-variables-to-paywalls), bao gồm tên và giá sản phẩm.

Bây giờ, hãy chuyển sang bước cuối cùng – cho phép người dùng thực hiện mua hàng qua paywall.

## Bước 3.1. Cho phép người dùng mua hàng \{#step-31-enable-users-to-make-purchases\}

1. Nhấp đúp vào nút mua trên trang paywall của bạn. Trong bảng bên phải, mở phần **Actions** nếu chưa mở.

2. Mở **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. Trong cửa sổ **Select Action Trigger**, chọn **On Tap**.
4. Trong cửa sổ **No Actions Created**, nhấp **Add Action**. Tìm kiếm action `makePurchase` và chọn nó.

  <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. Trong phần **Set Actions Arguments**, chọn biến `getPaywallProductsResult` đã tạo trước đó.
6. Điền vào các trường như sau:
	- **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. Nhấp vào `subscriptionUpdateParameters`, tìm kiếm `AdaptySubscriptionUpdateParameters` và chọn nó. Nhấp **Confirm**.
    :::info
    Theo mặc định, bạn có thể để trống tất cả các trường của object. Bạn chỉ cần điền vào khi muốn thay thế một gói đăng ký bằng gói khác trong ứng dụng Android. Đọc thêm [tại đây](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. Nhấp **Confirm**. 
9. Trong **Action Output Variable Name**, tạo một biến mới và đặt tên là `makePurchaseResult` – biến này sẽ được dùng sau để xác nhận mua hàng thành công.

  <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 */
  }}
/>

## Bước 3.2. Kiểm tra xem mua hàng có thành công không \{#step-32-check-if-the-purchase-was-successful\}

Bây giờ, hãy thiết lập kiểm tra xem giao dịch mua có được thực hiện thành công không.

1. Nhấp **+** và nhấp **Add Conditional**.
2. Trong **Set Condition for Action**, chọn biến `makePurchaseResult`.
3. Trong cửa sổ **Set Variable**, điền vào các trường như sau:
    - **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. Nhấp **Confirm**.

## Bước 3.3. Mở nội dung trả phí \{#step-33-open-paid-content\}

Nếu mua hàng thành công, bạn có thể mở khóa nội dung trả phí. Cách thiết lập như sau:

1. Nhấp **+** dưới nhãn **TRUE** và nhấp **Add Action**.
2. Trong trường **Define Action**, tìm kiếm và chọn trang bạn muốn mở từ danh sách **Navigate To**. Trong ví dụ này, trang đó là **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 */
  }}
/>

## Bước 3.4. Hiển thị thông báo lỗi nếu mua hàng thất bại \{#step-34-show-error-message-if-purchase-failed\}

Nếu mua hàng thất bại, hãy hiển thị thông báo cho người dùng.

1. Thêm action **Informational Dialog** vào nhãn **FALSE**.
2. Trong trường **Title**, nhập văn bản bạn muốn dùng làm tiêu đề hộp thoại, chẳng hạn **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. Nhấp **Value** trong hộp **Message**. Trong cửa sổ **Set from Variable**, tìm kiếm `makePurchaseResult` và chọn nó. Điền vào các trường như sau:
    
   - **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. Nhấp **Confirm**.
5. Thêm action **Terminate** vào flow **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. Cuối cùng, nhấp **Close** ở góc trên bên phải.

Chúc mừng! Người dùng của bạn giờ đây có thể mua sản phẩm. Để hoàn thiện hơn, hãy [thiết lập kiểm tra quyền truy cập nội dung trả phí](ff-check-subscription-status) ở các nơi khác để quyết định hiển thị nội dung trả phí hay paywall cho họ.