# 校验付款请求

> 校验付款请求的字段和当前业务条件，返回校验结果。不会执行发起付款流程。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-transactions/validate
info:
  title: 校验付款请求
  version: original
  description: 校验付款请求的字段和当前业务条件，返回校验结果。不会执行发起付款流程。
servers:
  - url: https://sandbox-transfer-api.onerway.com
    description: sandbox
  - url: https://transfer-api.onerway.com
    description: production
paths:
  /api/v3/txn/validate:
    post:
      summary: 校验付款请求
      description: 校验付款请求的字段和当前业务条件，返回校验结果。不会执行发起付款流程。
      parameters:
        - name: ApiKey
          in: header
          required: true
          description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
          schema:
            type: string
            description: Onerway 分配的账户服务 API key 请求 Header；必须使用与请求域名相同环境的值。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                requestId:
                  type: string
                  description: 商户生成的付款业务流水号。
                  x-onerway-constraints:
                    - kind: rule
                      text: 最大长度：64。
                transactionInfo:
                  type: object
                  properties:
                    sourceAmount:
                      type: number
                      description: 以 `sourceCurrency` 计价的源金额。
                      x-onerway-required: conditional
                      x-onerway-condition:
                        - chargeBearer=CRED 时必填
                      x-onerway-constraints:
                        - kind: rule
                          text: chargeBearer=CRED 时须大于 0，目标金额由服务换算；不能通过同时指定两个金额约定固定汇率。
                    sourceCurrency:
                      type: string
                      description: 源币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                    targetAmount:
                      type: number
                      description: 以 `targetCurrency` 计价的目标金额。
                      x-onerway-required: conditional
                      x-onerway-condition:
                        - chargeBearer=DEBT 时必填
                      x-onerway-constraints:
                        - kind: rule
                          text: chargeBearer=DEBT 时须大于 0，源金额由服务换算；不能通过同时指定两个金额约定固定汇率。
                    targetCurrency:
                      type: string
                      description: 目标币种，参见[币种枚举](/zh/transfer/api-reference/v3-enums#币种枚举)。
                    destinationCountry:
                      type: string
                      description: 收款账户所在国家或地区，参见[国家/地区枚举](/zh/transfer/api-reference/v3-enums#国家地区枚举)。
                    paymentMethod:
                      type: string
                      description: 付款方式，参见[枚举说明](/zh/transfer/api-reference/v3-enums#paymentmethod-付款方式)。
                      enum:
                        - BANK_TRANSFER
                        - SWIFT
                        - E_WALLET
                        - CASH_PICKUP
                      x-enum-descriptions:
                        BANK_TRANSFER: 银行转账
                        SWIFT: SWIFT 汇款
                        E_WALLET: 电子钱包
                        CASH_PICKUP: 现金支取
                    transactionPurpose:
                      type: string
                      description: 交易用途，参见[枚举说明](/zh/transfer/api-reference/v3-enums#transactionpurpose-交易用途)。
                      enum:
                        - TRANSFER_TO_OWN_ACCOUNT
                        - LOAN_OR_CREDIT_REPAYMENT
                        - FREIGHT_CHARGES
                        - PROFESSIONAL_OR_BUSINESS_SERVICES
                        - OTHER
                      x-enum-descriptions:
                        TRANSFER_TO_OWN_ACCOUNT: 转至本人账户
                        LOAN_OR_CREDIT_REPAYMENT: 贷款或信贷偿还
                        FREIGHT_CHARGES: 运费
                        PROFESSIONAL_OR_BUSINESS_SERVICES: 专业服务或商业服务
                        OTHER: 其他
                    reference:
                      type: string
                      description: 付款交易附言或备注。
                      x-onerway-constraints:
                        - kind: rule
                          text: 最大长度按收款人地址国家确定：CA 为 19；VN 为 25；MX 为 30；SG、AU、IN 为 32；ID 为 35；NG 为 64；BR 为
                            106；PH、MY、US、GB、JP、SA、KR、CN、EG 为 200；其他国家为 140 个字符。
                    chargeBearer:
                      type: string
                      description: 平台手续费承担方，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#chargebearer-平台手续费承担方)。
                      enum:
                        - DEBT
                        - CRED
                      x-enum-descriptions:
                        DEBT: 付款人承担平台手续费
                        CRED: 收款人承担平台手续费
                    swiftFeeType:
                      type: string
                      description: SWIFT
                        费用承担方式，与平台手续费承担方分别设置，取值见[枚举说明](/zh/transfer/api-reference/v3-enums#swiftfeetype-swift-费用承担方式)。
                      enum:
                        - OUR
                        - SHA
                      x-enum-descriptions:
                        OUR: 付款人承担 SWIFT 费用
                        SHA: 双方分担 SWIFT 费用
                      x-onerway-required: conditional
                      x-onerway-condition:
                        - paymentMethod 为 SWIFT 时必填；其他付款方式不传。
                      x-onerway-constraints:
                        - kind: rule
                          text: 付款方式为 SWIFT 时，填写 OUR 或 SHA；其他付款方式不传。
                  required:
                    - sourceCurrency
                    - targetCurrency
                    - destinationCountry
                    - paymentMethod
                    - transactionPurpose
                    - reference
                    - chargeBearer
                  description: 本次付款的金额、币种及方式
                beneficiary:
                  type: object
                  properties:
                    beneficiaryId:
                      type: integer
                      description: Onerway 收款人 ID（64 位整数）。
                  required:
                    - beneficiaryId
                  description: 本次付款的收款人。
                onBehalfOf:
                  type: string
                  description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
              required:
                - requestId
                - transactionInfo
                - beneficiary
            examples:
              default:
                summary: 请求结构示例（替换为当前商户数据）
                value:
                  requestId: demo_transfer_001
                  transactionInfo:
                    sourceAmount: 100
                    sourceCurrency: USD
                    targetCurrency: USD
                    destinationCountry: US
                    paymentMethod: BANK_TRANSFER
                    transactionPurpose: TRANSFER_TO_OWN_ACCOUNT
                    chargeBearer: CRED
                  beneficiary:
                    beneficiaryId: 10001
      responses:
        "200":
          description: 成功示例
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      respCode:
                        type: string
                        description: 响应码；`20000` 表示请求处理成功，其余为错误码。
                      respMsg:
                        type: string
                        description: 响应码对应的可读说明。
                      data:
                        type: object
                        properties:
                          success:
                            type: boolean
                            description: 校验通过时为 true
                          errors:
                            type: array
                            description: 校验成功时为空数组；失败使用顶层 error
                            items:
                              type: object
                              properties:
                                {}
                        description: 成功业务数据；失败不作为有效业务数据读取
                        x-onerway-constraints:
                          - kind: rule
                            text: 成功时 data.success=true、data.errors=[]；预校验失败放在顶层 error，error.errorDetails
                              为消息字符串数组。通过校验不预留资金、锁定汇率或保证之后付款成功。
                      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: string
                        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: string
                        required:
                          - type
                          - code
                          - message
                          - requestId
                          - errorDetails
                    required:
                      - respCode
                      - respMsg
                      - error
              examples:
                "90001":
                  summary: CRED 模式下将 sourceAmount 改为 0。
                  description: CRED 模式下将 sourceAmount 改为 0。
                  value:
                    respCode: "90001"
                    respMsg: Source amount needs to be greater than zero
                    error:
                      type: validation_error
                      code: payout_validate_failed
                      message: One or more request fields failed payout validation rules
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - Source amount needs to be greater than zero
                success:
                  summary: 成功示例
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      success: true
                      errors:
                        []
                failure:
                  summary: CRED 模式下将 sourceAmount 改为 0。
                  value:
                    respCode: "90001"
                    respMsg: Source amount needs to be greater than zero
                    error:
                      type: validation_error
                      code: payout_validate_failed
                      message: One or more request fields failed payout validation rules
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - Source amount needs to be greater than zero
```
