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

# 准备兑换结账

> 按报价为选定的卡牌、收件人、地址和快递服务生成 Permit2 授权。

1. 请钱包持有人核对所选卡牌、收件人、地址、快递和总价。
2. 使用服务端报价中的费用。准备结账时，这些信息会与当前开发者绑定。
3. 提交前，请核对钱包授予 Permit2（`permitTypedData.domain.verifyingContract`）的 USDT 额度，确保足以支付 `permitTypedData.message.permitted.amount`。额度不足时，请授权所需金额并等待确认。仅签署 witness 不会增加这项额度。
4. 保存准备 ID，并让钱包签署一份 Permit2 witness 授权。

## 请求

需要开发者密钥和钱包访问令牌

## 响应

## 错误码

在下表中查找接口返回的 HTTP 状态码和响应原文。有关各接口通用的处理建议，请参阅[错误码含义与处理方式](https://docs.renaiss.xyz/cn/api-reference/errors.md)。

| HTTP | 错误码 | 文本字段 | 响应文本与处理方式 |
| :- | :- | :- | :- |
| `400` | `WRONG_REQUEST_PARAMS` | `error` | `Invalid redemption input` `Request body is too large` 字段或购物车无效、藏品尚不可兑换、来自多个金库地区、缺少申报价值，或目的地不可用或缺少州或省。请修正后重发。报价过期或所选承运商不在报价内时，需重新获取报价。 |
| `401` | `API_AUTH_INVALID_CREDENTIAL` | `error` | `Invalid authentication credential` 密钥或钱包令牌格式错误、未知、已过期或被撤销。核对密钥，刷新钱包令牌或让钱包重新登录。 |
| `401` | `API_AUTH_MISSING_CREDENTIAL` | `error` | `Required authentication credential is missing` 缺少开发者密钥或钱包访问令牌。请在 `x-builder-api-key` 中发送密钥，并同时发送 Bearer 令牌。 |
| `403` | `API_AUTH_CREDENTIAL_NOT_ALLOWED` | `error` | `Credential is not allowed by this policy` 路由不接受所提供的某些凭据。仅发送开发者密钥和钱包访问令牌。 |
| `403` | `API_AUTH_INSUFFICIENT_SCOPE` | `error` | `Required authentication scope is missing` 令牌缺少所需权限，读取需 `redeem:read`，修改需 `redeem:write`。请钱包重新登录并申请相应权限。 |
| `403` | `API_AUTH_INTEGRATION_MISMATCH` | `error` | `Authentication integrations do not match` 令牌和密钥属于不同开发者。请使用签发令牌的开发者对应的密钥。 |
| `403` | `API_AUTH_SUBJECT_MISMATCH` | `error` | `Authentication subjects do not match` 令牌所属链与 API 不符。请针对正确的链重新验证钱包。 |
| `403` | `GACHA_V3_BUILDER_NOT_ACCEPTED_ON_PUBLIC_API` | `error` | `This builder checks out on its own surface, not on the public API` 此密钥无法用于当前 API。请联系 Renaiss，无需重试。 |
| `403` | `WRONG_REQUEST_PARAMS` | `error` | `Every collectible must be owned by the authenticated EOA` 购物车包含钱包令牌所属钱包未持有的藏品。仅提交该钱包持有的藏品。 |
| `404` | `REDEMPTION_ORDER_NOT_FOUND` | `error` | `Not found or expired` `Not found` 当前钱包及开发者名下没有对应报价或准备记录，或记录已过期。请重新获取报价。 |
| `429` | `API_AUTH_RATE_LIMITED` | `error` | `Authentication rate limit exceeded` 已达到密钥的请求频率上限。稍候再以较低频率重试。 |
| `500` | `API_AUTH_INVALID_CONFIGURATION` | `error` | `Internal server error` 若钱包认证持续失败，请将 `x-request-id` 提供给 Renaiss。 |
| `500` | `API_AUTH_ERROR` | `error` | `Internal server error` |
| `500` | `FUNCTION_ERROR` | `error` | `Internal server error` |
| `503` | `FUNCTION_ERROR` | `error` | `Internal server error` |


## OpenAPI

````yaml cn/api-reference/openapi.json POST /v2/redeem/checkout/prepare
openapi: 3.1.1
info:
  version: 1.0.0
  title: Renaiss 开发者 API v2
  description: >-
    在 BNB 智能链（链 ID 56）上使用外部钱包接入抽卡、交易市场和实物兑换。所有已批准且有效的开发者密钥均可准备购买。


    藏品包括钱包可抽取、交易、回售或兑换的物品，例如卡牌。接口路径、字段和描述统一使用 collectible 表示藏品。


    可以匿名浏览目录。准备购买后，请由买家钱包签名。抽卡记录和回购报价需要开发者密钥，购买和回购还需操作签名。私有配送信息及兑换需要钱包访问令牌，由钱包在已注册的合作方来源签署登录消息后签发。抽卡和市场不使用钱包访问令牌。请在后端保管开发者密钥。


    操作钱包可以是 EOA 或已部署的 ERC-1271 合约账户。不支持 EIP-7702 委托账户、ERC-6492 或 ERC-8010 封装签名及
    Renaiss 托管的 Safe（签名验证后才会识别并拒绝该类 Safe）。无法接收 ERC-721 的合约钱包抽卡会返回
    `CONTRACT_WALLET_CANNOT_RECEIVE_NFT`。链上读取失败返回
    `API_AUTH_ERROR`（500）。钱包访问令牌及实物兑换仅支持 EOA。
servers:
  - url: https://api.renaiss.xyz
    description: BNB 智能链主网
  - url: https://dev-api.renaiss.xyz
    description: BNB 测试网
security: []
tags:
  - name: Gacha v2
    description: 使用 EOA 浏览和购买卡包、揭晓藏品、读取购买记录及回购。无需钱包访问令牌。
  - name: Marketplace
    description: 公开浏览藏品，通过外部钱包挂牌、出价、购买或撤单。交易需要开发者授权及钱包操作签名。
  - name: Users
    description: 查询特定钱包的藏品、市场总估值和链上活动。仅需开发者密钥，各接口按相应的可见范围返回记录。
  - name: Redemption
    description: 查询兑换资格、运费报价，准备并提交兑换及跟踪物流。需要开发者密钥及同一钱包的访问令牌。
  - name: Wallet access tokens
    description: >-
      获取、刷新或撤销实物兑换使用的钱包访问令牌。钱包签署一次性登录消息（5 分钟有效）后，API 返回访问令牌（15 分钟）和一次性刷新令牌（7
      天）。先注册精确的合作方前端来源。抽卡和市场无需钱包访问令牌。
paths:
  /v2/redeem/checkout/prepare:
    post:
      tags:
        - Redemption
      summary: 根据已保存的报价准备 EOA 的 Permit2 兑换
      description: 按报价为选定的卡牌、收件人、地址和快递服务生成 Permit2 授权。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                quoteId:
                  type: string
                  format: uuid
                courierId:
                  type: string
                recipient:
                  type: object
                  properties:
                    name:
                      type: string
                      minLength: 1
                      maxLength: 22
                    phone:
                      type: string
                      pattern: ^\+[1-9]\d{6,14}$
                    email:
                      type: string
                      maxLength: 50
                      format: email
                    taxId:
                      type: string
                      maxLength: 100
                    chineseName:
                      type: string
                      maxLength: 100
                  required:
                    - name
                    - phone
                    - email
                  additionalProperties: false
                insurance:
                  type: boolean
              required:
                - quoteId
                - courierId
                - recipient
                - insurance
              additionalProperties: false
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                properties:
                  preparationId:
                    type: string
                    format: uuid
                  requestId:
                    type: string
                    description: 32 字节，以 0x 开头，后接 64 个十六进制数字。
                  walletAddress:
                    type: string
                    description: 带 0x 前缀的 20 字节钱包或合约地址。请使用全小写或有效的校验和格式。
                  tokenIds:
                    type: array
                    items:
                      type: string
                      pattern: ^\d{1,78}$
                      description: 小于 2^256 的无符号十进制整数，以字符串表示。
                    minItems: 1
                    maxItems: 50
                    description: 每个数值代币 ID 只能出现一次，例如 "1" 与 "01" 表示同一代币。
                  expiresAt:
                    type: string
                    format: date-time
                  address:
                    type: object
                    properties:
                      countryCode:
                        type: string
                        pattern: ^[A-Z]{2}$
                      addressLine1:
                        type: string
                        minLength: 1
                        maxLength: 35
                      addressLine2:
                        type: string
                        maxLength: 35
                      city:
                        type: string
                        minLength: 1
                        maxLength: 200
                      state:
                        type: string
                        maxLength: 200
                      postalCode:
                        type: string
                        minLength: 1
                        maxLength: 20
                    required:
                      - countryCode
                      - addressLine1
                      - city
                      - postalCode
                    additionalProperties: false
                  recipient:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 22
                      phone:
                        type: string
                        pattern: ^\+[1-9]\d{6,14}$
                      email:
                        type: string
                        maxLength: 50
                        format: email
                      taxId:
                        type: string
                        maxLength: 100
                      chineseName:
                        type: string
                        maxLength: 100
                    required:
                      - name
                      - phone
                      - email
                    additionalProperties: false
                  courierName:
                    type: string
                  fees:
                    type: object
                    properties:
                      handlingFeeInUsd:
                        type: string
                        pattern: ^\d{1,78}$
                        description: 小于 2^256 的无符号十进制整数，以字符串表示。
                      shippingFeeInUsd:
                        type: string
                        pattern: ^\d{1,78}$
                        description: 小于 2^256 的无符号十进制整数，以字符串表示。
                      insuranceFeeInUsd:
                        type: string
                        pattern: ^\d{1,78}$
                        description: 小于 2^256 的无符号十进制整数，以字符串表示。
                      dutyAndTaxesInUsd:
                        type: string
                        pattern: ^\d{1,78}$
                        description: 小于 2^256 的无符号十进制整数，以字符串表示。
                      totalFeeInUsdt:
                        type: string
                        pattern: ^\d{1,78}$
                        description: 小于 2^256 的无符号十进制整数，以字符串表示。
                    required:
                      - handlingFeeInUsd
                      - shippingFeeInUsd
                      - insuranceFeeInUsd
                      - dutyAndTaxesInUsd
                      - totalFeeInUsdt
                  redemptionTypedData:
                    type: object
                    properties:
                      domain:
                        type: object
                        properties:
                          name:
                            type: string
                          version:
                            type: string
                          chainId:
                            type: integer
                          verifyingContract:
                            type: string
                            description: 带 0x 前缀的 20 字节钱包或合约地址。请使用全小写或有效的校验和格式。
                        required:
                          - name
                          - chainId
                          - verifyingContract
                      types:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: object
                            properties:
                              name:
                                type: string
                              type:
                                type: string
                            required:
                              - name
                              - type
                      primaryType:
                        type: string
                      message:
                        type: object
                        additionalProperties: {}
                    required:
                      - domain
                      - types
                      - primaryType
                      - message
                  permitTypedData:
                    type: object
                    properties:
                      domain:
                        type: object
                        properties:
                          name:
                            type: string
                          version:
                            type: string
                          chainId:
                            type: integer
                          verifyingContract:
                            type: string
                            description: 带 0x 前缀的 20 字节钱包或合约地址。请使用全小写或有效的校验和格式。
                        required:
                          - name
                          - chainId
                          - verifyingContract
                      types:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: object
                            properties:
                              name:
                                type: string
                              type:
                                type: string
                            required:
                              - name
                              - type
                      primaryType:
                        type: string
                      message:
                        type: object
                        additionalProperties: {}
                    required:
                      - domain
                      - types
                      - primaryType
                      - message
                required:
                  - preparationId
                  - requestId
                  - walletAddress
                  - tokenIds
                  - expiresAt
                  - address
                  - recipient
                  - courierName
                  - fees
                  - redemptionTypedData
                  - permitTypedData
        '400':
          description: |-
            请求在执行前被拒绝。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                    enum:
                      - WRONG_REQUEST_PARAMS
                required:
                  - error
                  - code
              example:
                error: Invalid redemption input
                code: WRONG_REQUEST_PARAMS
        '401':
          description: |-
            开发者密钥或钱包访问令牌无效。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                    enum:
                      - API_AUTH_MISSING_CREDENTIAL
                      - API_AUTH_INVALID_CREDENTIAL
                required:
                  - error
                  - code
              example:
                error: Required authentication credential is missing
                code: API_AUTH_MISSING_CREDENTIAL
        '403':
          description: |-
            钱包不持有其中一件藏品。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                    enum:
                      - WRONG_REQUEST_PARAMS
                      - API_AUTH_INSUFFICIENT_SCOPE
                      - API_AUTH_INTEGRATION_MISMATCH
                      - API_AUTH_SUBJECT_MISMATCH
                      - API_AUTH_CREDENTIAL_NOT_ALLOWED
                      - GACHA_V3_BUILDER_NOT_ACCEPTED_ON_PUBLIC_API
                required:
                  - error
                  - code
              example:
                error: Every collectible must be owned by the authenticated EOA
                code: WRONG_REQUEST_PARAMS
        '404':
          description: |-
            找不到报价或结账准备记录。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                    enum:
                      - REDEMPTION_ORDER_NOT_FOUND
                required:
                  - error
                  - code
              example:
                error: Not found or expired
                code: REDEMPTION_ORDER_NOT_FOUND
        '429':
          description: |-
            该开发者密钥的请求过于频繁。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                    enum:
                      - API_AUTH_RATE_LIMITED
                required:
                  - error
                  - code
              example:
                error: Authentication rate limit exceeded
                code: API_AUTH_RATE_LIMITED
        '500':
          description: |-
            服务端暂时失败，请稍后重试。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                required:
                  - error
                  - code
              example:
                error: Internal server error
                code: FUNCTION_ERROR
        '503':
          description: |-
            结账服务暂时不可用，请几秒后重试。

            见[错误码与处理方式](/cn/api-reference/redeem/prepare-checkout#http-errors)。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: 简短的错误说明。
                  code:
                    type: string
                required:
                  - error
                  - code
              example:
                error: Internal server error
                code: FUNCTION_ERROR
      security:
        - builderAuth: []
          walletSession: []
components:
  securitySchemes:
    builderAuth:
      type: apiKey
      in: header
      name: x-builder-api-key
      description: >-
        已获准使用的开发者 API 密钥，仅在后端保存。抽卡和市场的写入操作还需钱包签名，实物兑换还需钱包签署登录消息后由 API 签发的 Bearer
        令牌。
    walletSession:
      type: http
      scheme: bearer
      description: 钱包访问令牌，用于实物兑换的 Bearer 身份验证。

````

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