# Lấy paywall

> Nhận paywall từ placement đã cung cấp.

## OpenAPI

```yaml
/api-specs/web-api.yaml post /api/v2/web-api/paywall/
openapi: 3.1.0
info:
  title: Adapty Web API
  version: 1.0.0
  description: |
    Adapty Web API cho phép bạn tích hợp nền tảng quản lý gói đăng ký của Adapty
    vào các ứng dụng web của bạn. API này cung cấp các endpoint để lấy paywall,
    ghi lại lượt xem paywall và thêm dữ liệu attribution.
servers:
  - url: https://api.adapty.io
    description: Máy chủ production
security:
  - apikeyAuth: []
paths:
  /api/v2/web-api/paywall/:
    post:
      summary: Lấy paywall
      description: Nhận paywall từ placement đã cung cấp.
      operationId: getPaywall
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/GetPaywallRequest"
            examples:
              basic:
                summary: Yêu cầu paywall cơ bản
                value:
                  store: app_store
                  locale: en
                  placement_id: PaywallPlacementId
                  customer_user_id: user123
      responses:
        "200":
          description: Phản hồi thành công sẽ chứa đối tượng Paywall.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PaywallResponse"
              examples:
                basic:
                  summary: Phản hồi paywall cơ bản
                  value:
                    placement_id: onboarding
                    variation_id: d76feea0-c0cf-4942-bef5-84ed701fc6db
                    paywall_id: 9a93fe6f-9162-4dc0-b4b7-73079ed95c34
                    ab_test_name: 1 week + 1 month | apple picture
                    paywall_name: 1 week + 1 month | apple picture
                    products:
                      - title: 1 week
                        is_consumable: false
                        adapty_product_id: 1c3e03e1-9c43-4f94-aeb5-c7ae2f73d0c2
                        vendor_product_id: 1_week_apple
                        introductory_offer_eligibility: true
                        promotional_offer_eligibility: true
                        base_plan_id: null
                        offer: null
                      - title: 1 month
                        is_consumable: false
                        adapty_product_id: f4088450-45a8-4737-8db0-367e642d7dcb
                        vendor_product_id: 1_month_apple
                        introductory_offer_eligibility: true
                        promotional_offer_eligibility: true
                        base_plan_id: null
                        offer: null
                    remote_config:
                      lang: en
                      data: "{\"default_product_number\":1,\"features\":[\"#fresh\",\"#green\",\"#healthy1\"],\"soft_paywall\":false,\"image_url\":\"https://adapty.io/apple.png\"}"
        "400":
          description: Yêu cầu không hợp lệ
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ParseError"
        "401":
          description: Không được phép
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "404":
          description: Không tìm thấy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VariationIdNotFoundError"
components:
  schemas:
    GetPaywallRequest:
      type: object
      required:
        - store
        - placement_id
      properties:
        store:
          type: string
          description: |
            Cửa hàng nơi sản phẩm được mua. Các giá trị có thể: `app_store`, `play_store`, `stripe`, hoặc `Store ID` của cửa hàng tùy chỉnh của bạn.
          example: app_store
        locale:
          type: string
          description: Mã định danh ngôn ngữ của paywall. Tham số này được kỳ vọng là mã ngôn ngữ gồm một hoặc nhiều thẻ con được phân tách bằng ký tự "-". Thẻ con đầu tiên là ngôn ngữ, thẻ con thứ hai là khu vực.
          example: en
        placement_id:
          type: string
          description: Mã định danh của Placement. Đây là giá trị bạn đã chỉ định khi tạo placement trong Adapty Dashboard.
          example: PaywallPlacementId
        customer_user_id:
          type: string
          description: Bắt buộc có `customer_user_id` hoặc `profile_id`. ID người dùng bạn sử dụng trong ứng dụng để nhận dạng người dùng nếu có. Ví dụ, đây có thể là UUID người dùng, email hoặc bất kỳ ID nào khác.
          example: user123
        profile_id:
          type: string
          description: Bắt buộc có `customer_user_id` hoặc `profile_id`. Mã định danh của người dùng trong Adapty.
          example: 3286abd3-48b0-4e9c-a5f6-ac0a006804a6
    PaywallResponse:
      type: object
      required:
        - placement_id
        - variation_id
        - paywall_id
        - paywall_name
        - products
      properties:
        placement_id:
          type: string
          description: ID của Placement nơi paywall này được hiển thị. Giá trị này được thiết lập khi tạo placement trong Adapty Dashboard.
          example: onboarding
        variation_id:
          type: string
          format: uuid
          description: ID biến thể được dùng để theo dõi các giao dịch mua hàng liên kết với paywall cụ thể này.
          example: d76feea0-c0cf-4942-bef5-84ed701fc6db
        paywall_id:
          type: string
          format: uuid
          description: Mã định danh duy nhất của paywall.
          example: 9a93fe6f-9162-4dc0-b4b7-73079ed95c34
        ab_test_name:
          type: string
          description: Tên của A/B test cha.
          example: 1 week + 1 month | apple picture
        paywall_name:
          type: string
          description: Tên của paywall, như đã định nghĩa trong Adapty Dashboard.
          example: 1 week + 1 month | apple picture
        products:
          type: array
          items:
            $ref: "#/components/schemas/Product"
          description: Mảng các đối tượng Product chứa thông tin sản phẩm cho paywall.
        remote_config:
          $ref: "#/components/schemas/RemoteConfig"
          description: Đối tượng RemoteConfig chứa toàn bộ Remote Config của paywall.
    ParseError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    UnauthorizedError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    VariationIdNotFoundError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    Product:
      type: object
      required:
        - is_consumable
        - vendor_product_id
      properties:
        title:
          type: string
          description: Tên sản phẩm từ mục Products trong Adapty Dashboard.
        is_consumable:
          type: boolean
          description: Cho biết sản phẩm có phải là consumable hay không.
        adapty_product_id:
          type: string
          format: uuid
          description: ID sản phẩm nội bộ như được dùng trong Adapty.
        vendor_product_id:
          type: string
          description: ID sản phẩm trong các cửa hàng ứng dụng.
        introductory_offer_eligibility:
          type: boolean
          description: Xác định liệu người dùng có đủ điều kiện nhận ưu đãi giới thiệu trên iOS hay không.
        promotional_offer_eligibility:
          type: boolean
          description: Xác định liệu người dùng có đủ điều kiện nhận ưu đãi hay không.
        base_plan_id:
          type: string
          nullable: true
          description: |
            ID base plan cho Google Play hoặc ID giá cho Stripe.
            Xem [Base plan ID](https://support.google.com/googleplay/android-developer/answer/12154973) cho Google Play hoặc
            [price ID](https://docs.stripe.com/products-prices/how-products-and-prices-work#use-products-and-prices) cho Stripe.
        offer:
          allOf:
            - $ref: "#/components/schemas/Offer"
          nullable: true
          description: Đối tượng Offer dưới dạng JSON.
    RemoteConfig:
      type: object
      required:
        - lang
        - data
      properties:
        lang:
          type: string
          description: |
            Mã ngôn ngữ cho bản địa hóa paywall. Sử dụng thẻ ngôn ngữ và khu vực
            được phân tách bằng dấu gạch ngang (-). Ví dụ: `en` cho tiếng Anh, `pt-br` cho tiếng Bồ Đào Nha (Brazil).
          example: en
        data:
          type: string
          description: |
            Chuỗi JSON được tuần tự hóa đại diện cho Remote Config của paywall.
            Bạn có thể tìm thấy nó trong tab Remote Config của một paywall cụ thể trong Adapty Dashboard.
    Offer:
      type: object
      required:
        - category
        - type
      properties:
        category:
          type: string
          enum:
            - introductory
            - promotional
            - offer_code
            - win_back
          description: Danh mục của ưu đãi được áp dụng.
        type:
          type: string
          enum:
            - free_trial
            - pay_as_you_go
            - pay_up_front
            - unknown
          description: Loại ưu đãi đang hoạt động. Nếu giá trị này không null, nghĩa là ưu đãi đã được áp dụng trong kỳ gói đăng ký hiện tại.
        id:
          type: string
          nullable: true
          description: ID của ưu đãi được áp dụng.
  securitySchemes:
    apikeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        Các yêu cầu API phải được xác thực bằng public API key của bạn trong header **Authorization**
        với giá trị `Api-Key {your_public_api_key}`, ví dụ:
        `Api-Key public_live_...`. Tìm key này trong Adapty Dashboard ->
        **App Settings** -> tab **General** -> mục **API keys**.
```
