# 分账结果通知

> 接收包含整体状态和各接收方明细的分账或分账回退结果回调报文。

```yaml
openapi: 3.1.0
info:
  title: 分账结果通知
  version: 1.0.0
  description: 接收包含整体状态和各接收方明细的分账或分账回退结果回调报文。
webhooks:
  profit.share.result:
    post:
      summary: 分账结果通知
      description: 接收包含整体状态和各接收方明细的分账或分账回退结果回调报文。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                profitType:
                  type: string
                  description: 本次通知对应的是分账还是分账回退。
                  enum:
                    - share
                    - return
                  x-enum-descriptions:
                    share: 本次通知对应分账。
                    return: 本次通知对应分账回退。
                  x-onerway-signature-participation: included
                profitReference:
                  type: string
                  description: 分账或分账回退请求号。通过 API 发起时，由商户提供；自动分账或自动分账回退时，由 Onerway 生成。可使用
                    `relatedTxnId` 与 `relatedMerchantTxnId` 将处理结果关联到原支付交易。
                  x-onerway-signature-participation: included
                profitGatewayReference:
                  type: string
                  description: 分账或分账回退的 Onerway 单号。
                  x-onerway-signature-participation: included
                state:
                  type: string
                  description: 分账单整体处理状态。`completed` 不代表每条明细都成功，需逐条检查 `receivers[].result`。
                  enum:
                    - processing
                    - completed
                  x-enum-descriptions:
                    processing: 分账单处理中。
                    completed: 分账单处理结束；单条明细结果需逐条检查。
                  x-onerway-signature-participation: included
                currency:
                  type: string
                  description: 分账或分账回退结算币种。
                  x-onerway-signature-participation: included
                relatedTxnId:
                  type:
                    - string
                    - "null"
                  description: 原支付交易流水号。分账回退仍关联原支付，而非分账单。
                  x-onerway-value:
                    nullable: true
                  x-onerway-signature-participation: included
                relatedMerchantTxnId:
                  type:
                    - string
                    - "null"
                  description: 原支付的商户订单号。
                  x-onerway-value:
                    nullable: true
                  x-onerway-signature-participation: included
                receivers:
                  type: string
                  description: 各接收方的处理结果列表。
                  contentMediaType: application/json
                  contentSchema:
                    type: array
                    items:
                      type: object
                      properties:
                        profitDetailReference:
                          type: string
                          description: 商户侧提交的明细请求号。
                        profitDetailGatewayReference:
                          type: string
                          description: Onerway 返回的明细单号。
                        type:
                          type:
                            - string
                            - "null"
                          description: 该明细对应的资金用途。
                          enum:
                            - "1"
                            - "2"
                            - "3"
                            - "4"
                            - "5"
                            - "6"
                            - "7"
                            - "99"
                            - null
                          x-enum-descriptions:
                            "1": 商户结算款：分给实际卖家、子商户或服务提供方的订单结算金额。
                            "2": 平台服务费：归属平台的佣金、技术服务费与软件服务费。
                            "3": 合作方佣金：支付给渠道、代理或分销合作方的佣金。
                            "4": 支付处理费：收单处理费、交易处理费与支付通道相关费用。
                            "5": 税费：VAT、GST 或其他需要单独归集的税项。
                            "6": 物流履约费：物流、配送、仓储与履约相关费用。
                            "7": 营销补贴：优惠、补贴、活动成本或由某一方承担的营销费用。
                            "99": 其他：由 Onerway 与商户约定的其他分账用途。
                          x-onerway-value:
                            nullable: true
                            when:
                              en: Returns `null` when the fund purpose is not recorded.
                              zh: 未记录资金用途时返回 `null`。
                        amount:
                          type: string
                          description: 实际分账或分账回退金额。
                          x-onerway-constraints:
                            - kind: rule
                              text: 金额使用 decimal string；商户系统应避免用二进制浮点数直接计算金额。
                        result:
                          type: string
                          description: 该明细的处理结果。
                          enum:
                            - pending
                            - success
                            - failed
                          x-enum-descriptions:
                            pending: 该明细处理中。
                            success: 该明细处理成功。
                            failed: 该明细处理失败；失败原因见 `failReason`。
                        failReason:
                          type:
                            - string
                            - "null"
                          description: 该明细的失败原因。
                          x-onerway-constraints:
                            - kind: rule
                              text: 面向排查的可读文本，取值不固定；程序分支应依据 `result`，不要匹配该字符串。
                          x-onerway-value:
                            nullable: true
                            when:
                              en: Returned only when `result` is `failed`; otherwise `null`.
                              zh: 仅当 `result` 为 `failed` 时返回；其余情况为 `null`。
                        createdAt:
                          type: string
                          description: 明细创建时间。
                          x-onerway-constraints:
                            - kind: rule
                              text: 格式为 `yyyy-MM-dd HH:mm:ss`；不要按 Unix 时间戳解析。
                        finishedAt:
                          type:
                            - string
                            - "null"
                          description: 明细完成时间。
                          x-onerway-constraints:
                            - kind: rule
                              text: 格式为 `yyyy-MM-dd HH:mm:ss`；不要按 Unix 时间戳解析。
                          x-onerway-value:
                            nullable: true
                            when:
                              en: Returns `null` while `result` is `pending`.
                              zh: "`result` 为 `pending` 时返回 `null`。"
                  x-onerway-format: json_string
                  x-onerway-signature-participation: included
                sign:
                  type: string
                  description: 使用商户 `SECRET` 计算签名，并与本字段比较，验证分账或分账回退通知。详见 [Webhook
                    验签](/zh/payments/get-started/request-signing#webhook-验签)。
                  x-onerway-constraints:
                    - kind: rule
                      text: 验签时不要把 `sign` 自身作为待签名字段。
                  x-onerway-signature-participation: signature-field
            examples:
              profit_share_completed:
                summary: 分账已完成
                value:
                  profitType: share
                  profitReference: example_profit_share_reference
                  profitGatewayReference: replace_with_profit_gateway_reference
                  state: completed
                  currency: USD
                  relatedTxnId: "9007199254740993"
                  relatedMerchantTxnId: example_payment_order
                  receivers: '[{"profitDetailReference":"example_profit_share_detail_reference","profitDetailGatewayReference":"replace_with_profit_detail_gateway_reference","type":"1","amount":"80.00","result":"success","failReason":null,"createdAt":"2026-06-22
                    10:00:00","finishedAt":"2026-06-22 10:00:08"}]'
                  sign: replace_with_sha256_signature
              profit_share_reversal_completed:
                summary: 分账回退已完成
                value:
                  profitType: return
                  profitReference: example_profit_reversal_reference
                  profitGatewayReference: replace_with_profit_reversal_gateway_reference
                  state: completed
                  currency: USD
                  relatedTxnId: "9007199254740993"
                  relatedMerchantTxnId: example_payment_order
                  receivers: '[{"profitDetailReference":"example_profit_reversal_detail_reference","profitDetailGatewayReference":"replace_with_profit_reversal_detail_gateway_reference","type":"1","amount":"80.00","result":"success","failReason":null,"createdAt":"2026-06-22
                    11:00:00","finishedAt":"2026-06-22 11:00:08"}]'
                  sign: replace_with_sha256_signature
      responses:
        "200":
          description: 成功接收并受理分账 webhook 后返回 HTTP 200；不需要在响应体中返回固定内容。
```
