> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 创建税费报价

> 在支付前，根据客户的地址和税号为 Stripe Billing 订阅计算税费报价

根据客户的账单地址（如为企业，还包括其税号），为 Stripe Billing 订阅的首次支付计算税费报价。该报价使用 Stripe Tax 以及您 Stripe 账户中的税务登记。请参阅 [本地价格和税费](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/local-price-and-taxes.md)。

> [!NOTE]
>
> **按组织启用**
>
> 税费征收按组织启用，并且需要您已完成 Stripe Billing onboarding 且 Stripe Tax 处于启用状态。请联系您的大客户经理（KAM）启用。

* 每当国家、邮政编码或税号发生变化时，请重新报价。报价的有效期为 30 分钟。
* 美国和加拿大需要提供邮政编码。其他国家只需提供国家。
* 收取 `total`，并将报价的每一行放在支付的 `additional_data.order.taxes` 中发送，同时附带 `source: YUNO_TAX_QUOTE` 和 `tax_quote_id`（`tax_base` 为该行的 `taxable_amount`）。支付已批准后，Yuno 会在 Stripe 中创建订阅，其首张发票包含相同的税费。
* 不适用任何税费时，`status` 为 `NO_TAX`（`no_tax_reason` 说明原因，例如对于拥有有效税号的企业为 `REVERSE_CHARGE`，或者在您的 Stripe 账户没有税务登记时为 `NOT_SUBJECT_TO_TAX`）。


## OpenAPI

````yaml openapi/zh-hans/taxes/create-tax-quote.json POST /taxes/quote
openapi: 3.0.1
info:
  title: Yuno Taxes API
  version: '1.0'
servers:
  - url: https://api-sandbox.y.uno/v1
  - url: https://api.y.uno/v1
security: []
paths:
  /taxes/quote:
    post:
      summary: 创建税费报价
      description: >-
        使用 Stripe Tax，根据客户的地址和可选的税号，为 Stripe Billing 订阅生成税费报价。在支付的税费行中使用返回的
        `tax_quote_id`，并按 `total` 扣款。报价有效期为 30 分钟。
      operationId: create-tax-quote
      parameters:
        - in: header
          name: PUBLIC-API-KEY
          required: true
          schema:
            type: string
          description: 您的公钥 API 密钥。
        - in: header
          name: PRIVATE-SECRET-KEY
          required: false
          schema:
            type: string
          description: 当您从 backend 报价时使用的私有密钥。切勿在客户端暴露。
        - in: header
          name: X-Account-Code
          required: false
          schema:
            type: string
          description: 该报价所针对的账户。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - address
              properties:
                account_id:
                  type: string
                  description: 使用私有密钥时必填，且必须是已通过身份验证的账户。使用公钥时可选，此时必须与 checkout 会话一致。
                checkout_session:
                  type: string
                  description: >-
                    使用公钥时必填：带有 `tax_collection` 的 checkout 会话，其
                    `external_subscription` 会被报价。不允许与私有密钥一起使用。
                country:
                  type: string
                  description: 可选。使用公钥时，必须与 checkout 会话一致。
                external_subscription:
                  type: object
                  description: 使用私有密钥时必填，不允许与公钥一起使用。要报价的订阅。
                  properties:
                    customer_id:
                      type: string
                      description: Stripe 中的客户（`cus_...`）。
                    currency:
                      type: string
                      description: 价格的币种。
                    items:
                      type: array
                      description: 至少一项。
                      items:
                        type: object
                        properties:
                          price:
                            type: string
                            description: Stripe 中的价格（`price_...`）。
                          quantity:
                            type: integer
                            description: 默认为 `1`。
                address:
                  type: object
                  required:
                    - country
                  description: 订阅的使用地点。
                  properties:
                    country:
                      type: string
                      description: 两位 ISO 国家/地区代码。
                    postal_code:
                      type: string
                      description: 美国和加拿大必填。
                    state:
                      type: string
                    city:
                      type: string
                    line1:
                      type: string
                tax_information:
                  type: object
                  description: 可选。买家的税号，用于企业适用的税务处理（例如反向征税），并随订阅一起保存到 Stripe 客户上。
                  properties:
                    business:
                      type: boolean
                      description: 买家是否为企业。
                    type:
                      type: string
                      description: >-
                        税号类型，小写，来自 Stripe
                        的列表：`eu_vat`、`gb_vat`、`us_ein`、`mx_rfc`、`br_cnpj`... 与
                        `id` 一起使用时必填。
                    id:
                      type: string
                      description: 税号，最多 64 个字符。与 `type` 一起使用时必填。
            example:
              account_id: <your_account_id>
              external_subscription:
                customer_id: cus_RplXYZ
                items:
                  - price: price_1QwAbc
                    quantity: 1
              address:
                country: US
                postal_code: '10001'
              tax_information:
                business: false
      responses:
        '200':
          description: 税费报价
          content:
            application/json:
              schema:
                type: object
                properties:
                  tax_quote_id:
                    type: string
                  status:
                    type: string
                    enum:
                      - TAX_APPLIED
                      - NO_TAX
                      - NOT_CALCULATED
                  no_tax_reason:
                    type: string
                    enum:
                      - REVERSE_CHARGE
                      - NOT_COLLECTING
                      - EXEMPT
                      - ZERO_RATED
                      - NOT_SUBJECT_TO_TAX
                      - OTHER
                  currency:
                    type: string
                  subtotal:
                    type: number
                  tax:
                    type: number
                  total:
                    type: number
                  lines:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                        jurisdiction:
                          type: string
                        percentage:
                          type: number
                        taxable_amount:
                          type: number
                        value:
                          type: number
              example:
                tax_quote_id: txq_2a8a493dcc5c4230b4cf8d9359fd200a
                status: TAX_APPLIED
                currency: USD
                subtotal: 29
                tax: 2.57
                total: 31.57
                lines:
                  - type: sales_tax
                    jurisdiction: NY
                    percentage: 8.875
                    taxable_amount: 29
                    value: 2.57
        '400':
          description: 错误
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  messages:
                    type: array
                    items:
                      type: string
              example:
                code: INVALID_REQUEST
                messages:
                  - address.postal_code is required for US.
        '403':
          description: 您的组织未启用该产品
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                  messages:
                    type: array
                    items:
                      type: string
              example:
                code: PRODUCT_NOT_ENABLED
                messages:
                  - ...

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.