# 查询付款凭证

> 查询成功付款的凭证下载链接。请在获取链接后 30 分钟内下载，超时后链接可能过期而无法使用。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-transactions/voucher-query
info:
  title: 查询付款凭证
  version: original
  description: 查询成功付款的凭证下载链接。请在获取链接后 30 分钟内下载，超时后链接可能过期而无法使用。
servers:
  - url: https://sandbox-transfer-api.onerway.com
    description: sandbox
  - url: https://transfer-api.onerway.com
    description: production
paths:
  /api/v3/txn/voucherQuery:
    post:
      summary: 查询付款凭证
      description: 查询成功付款的凭证下载链接。请在获取链接后 30 分钟内下载，超时后链接可能过期而无法使用。
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
          schema:
            type: string
            description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                transferId:
                  type: integer
                  description: Onerway 付款编号。
                  x-onerway-constraints:
                    - kind: rule
                      text: transferId 和 requestId 至少填写一个；同时填写时须对应同一笔付款。
                    - kind: rule
                      text: 仅原始付款状态为 S 的订单可查询凭证；未成功付款不能生成成功凭证。凭证服务未返回成功结果时，本接口返回失败。
                requestId:
                  type: string
                  description: 商户生成的付款业务流水号。
                onBehalfOf:
                  type: string
                  description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
            examples:
              default:
                summary: 请求结构示例（替换为当前商户数据）
                value:
                  requestId: demo_transfer_001
      responses:
        "200":
          description: 成功示例
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      respCode:
                        type: string
                        description: 响应码；`20000` 表示请求处理成功，其余为错误码。
                      respMsg:
                        type: string
                        description: 响应码对应的可读说明。
                      data:
                        type: object
                        properties:
                          merchantNo:
                            type: string
                            description: 请求发起方的商户号。
                          onBehalfOf:
                            type: string
                            description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
                          requestId:
                            type: string
                            description: 商户生成的付款业务流水号。
                          transferId:
                            type: integer
                            description: Onerway 付款编号。
                          downloadUrl:
                            type: string
                            description: 电子付款回单的下载地址。请在获取后 30 分钟内下载，超时后链接可能过期而无法使用。
                        description: 成功业务数据；失败不作为有效业务数据读取
                        x-onerway-constraints:
                          - kind: rule
                            text: 使用响应 downloadUrl 获取凭证。
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                            description: 错误类型。
                          code:
                            type: string
                            description: 本接口错误标识。
                          declineCode:
                            type: string
                            description: 拒绝原因码，可能为空。
                          message:
                            type: string
                            description: 错误详细说明
                          param:
                            type: string
                            description: 失败字段或条件；无法定位时可能为空
                          docUrl:
                            type: string
                            description: 错误文档链接，可能为空。
                          requestId:
                            type: string
                            description: 服务端错误跟踪标识，req_ + 32 位十六进制字符；不是商户请求编号
                          errorDetails:
                            type: array
                            description: 具体错误明细；见下列分支
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                  description: 业务或校验明细码。
                                message:
                                  type: string
                                  description: 明细说明
                        description: 结构化失败信息；并非每个失败分支都有该字段
                  - type: object
                    properties:
                      respCode:
                        type: string
                      respMsg:
                        type: string
                      error:
                        type: object
                        properties:
                          type:
                            type: string
                          code:
                            type: string
                          message:
                            type: string
                          requestId:
                            type: string
                          errorDetails:
                            type: array
                            items:
                              type: object
                              properties:
                                errorCode:
                                  type: string
                                message:
                                  type: string
                              required:
                                - errorCode
                                - message
                          param:
                            type: string
                        required:
                          - type
                          - code
                          - message
                          - requestId
                          - errorDetails
                          - param
                    required:
                      - respCode
                      - respMsg
                      - error
              examples:
                "50120":
                  summary: 请求中未提供 transferId 或 requestId。
                  description: 请求中未提供 transferId 或 requestId。
                  value:
                    respCode: "50120"
                    respMsg: requestId or transferId is invalid
                    error:
                      type: business_error
                      code: "50120"
                      message: requestId or transferId is invalid
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "50120"
                          message: requestId or transferId is invalid
                      param: transferId
                success:
                  summary: 成功示例
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      merchantNo: "10000"
                      requestId: demo_transfer_001
                      transferId: 1000001
                      downloadUrl: https://developers.onerway.com/example-voucher.pdf
                failure:
                  summary: 请求中未提供 transferId 或 requestId。
                  value:
                    respCode: "50120"
                    respMsg: requestId or transferId is invalid
                    error:
                      type: business_error
                      code: "50120"
                      message: requestId or transferId is invalid
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "50120"
                          message: requestId or transferId is invalid
                      param: transferId
```
