# 发起付款

> 发起一笔付款，返回付款编号及受理时状态。响应成功表示本次请求处理成功，不等同于资金已经到账。

```yaml
openapi: 3.1.0
x-onerway-docs-version: original
x-onerway-spec-key: transfer/v3-transactions/remittance
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/remittance:
    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。
                    - kind: rule
                      text: 同一操作商户下 requestId 必须唯一。重复提交会报错，接口不会以“重放成功响应”方式处理重复请求。
                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:
                          transferId:
                            type: integer
                            description: Onerway 付款编号。
                          status:
                            type: string
                            description: 受理时的业务状态；不使用查询接口的状态定义，不能据此认定已到账
                          requestId:
                            type: string
                            description: 商户生成的付款业务流水号。
                          onBehalfOf:
                            type: string
                            description: 请求实际对应的商户号，仅在代其他商户发起请求时填写。
                        description: 成功业务数据；失败不作为有效业务数据读取
                        x-onerway-constraints:
                          - kind: rule
                            text: 付款会创建业务记录。结果不明确时，使用原 requestId 查询付款状态，避免立即换新 requestId
                              再次付款。费用、余额、路由和收款人状态均会影响最终受理结果。
                      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
                        required:
                          - type
                          - code
                          - message
                          - requestId
                          - errorDetails
                    required:
                      - respCode
                      - respMsg
                      - error
              examples:
                "50118":
                  summary: 同一商户重复使用 requestId。
                  description: 同一商户重复使用 requestId。
                  value:
                    respCode: "50118"
                    respMsg: request id repeat
                    error:
                      type: business_error
                      code: payout_remittance_failed
                      message: request id repeat
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "50118"
                          message: request id repeat
                success:
                  summary: 成功示例
                  value:
                    respCode: "20000"
                    respMsg: Success
                    data:
                      transferId: 1000001
                      status: P
                      requestId: demo_transfer_001
                failure:
                  summary: 同一商户重复使用 requestId。
                  value:
                    respCode: "50118"
                    respMsg: request id repeat
                    error:
                      type: business_error
                      code: payout_remittance_failed
                      message: request id repeat
                      requestId: req_00000000000000000000000000000001
                      errorDetails:
                        - errorCode: "50118"
                          message: request id repeat
```
