Skip to content

请求分账

微信订单支付成功后,由服务商发起分账请求,将结算后的资金分给分账接收方。

请求参数类型描述
jsonobject声明请求的JSON数据结构
brand_mchidstring品牌主商户号
sub_mchidstring子商户号
appidstring公众账号ID
sub_appidstring子商户公众账号ID
transaction_idstring微信订单号
out_order_nostring商户分账单号
receiversobject[]分账接收方列表
typestring分账接收方类型
accountstring分账接收方账号
amountinteger分账金额
descriptionstring分账描述
namestring分账个人接收方姓名
finishboolean是否分账完成
headersobject声明请求的头参数
Wechatpay-Serialstring平台公钥ID/平台公钥证书序列号
php
$instance->v3->brand->profitsharing->orders->postAsync([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/brand/profitsharing/orders')->postAsync([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/brand/profitsharing/orders']->postAsync([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->brand->profitsharing->orders->post([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/brand/profitsharing/orders')->post([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/brand/profitsharing/orders']->post([
  'json' => [
    'brand_mchid' => '1900000108',
    'sub_mchid' => '1900000109',
    'appid' => 'wx8888888888888888',
    'sub_appid' => 'wx8888888888888889',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
    'receivers' => [[
      'type' => 'MERCHANT_ID',
      'account' => '1900000109',
      'amount' => 190,
      'description' => '1900000109分给商户1900000110',
      'name' => 'hu89ohu89ohu89o',
    ],],
    'finish' => true,
  ],
  'headers' => [
    'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
brand_mchidstring品牌主商户号
sub_mchidstring子商户号
transaction_idstring微信订单号
out_order_nostring商户分账单号
order_idstring微信分账单号
receiversobject[]分账接收方列表
typestring接收方类型
accountstring接收方账号
amountnumber分账金额
descriptionstring分账描述
resultstring分账结果
finish_timestring分账完成时间
fail_reasonstring分账失败原因
detail_idstring分账明细单号
statusstring分账单状态

参阅 官方文档

查询分账结果

发起分账请求后,可调用此接口查询分账结果。发起分账完结请求后,可调用此接口查询分账完结的结果。

请求参数类型描述
queryobject声明请求的查询参数
sub_mchidstring子商户号
transaction_idstring微信订单号
out_order_nostring商户分账单号
php
$instance->v3->brand->profitsharing->orders->getAsync([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/brand/profitsharing/orders')->getAsync([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/brand/profitsharing/orders']->getAsync([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->brand->profitsharing->orders->get([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/brand/profitsharing/orders')->get([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/brand/profitsharing/orders']->get([
  'query' => [
    'sub_mchid' => '1900000109',
    'transaction_id' => '4208450740201411110007820472',
    'out_order_no' => 'P20150806125346',
  ],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典类型描述
sub_mchidstring子商户号
transaction_idstring微信订单号
out_order_nostring商户分账单号
order_idstring微信分账单号
statusstring分账单状态
PROCESSING | FINISHED 枚举值之一
receiversobject[]分账接收方列表
typestring分账接收方类型
MERCHANT_ID | PERSONAL_OPENID | PERSONAL_SUB_OPENID 枚举值之一
accountstring分账接收方账号
amountinteger分账金额
descriptionstring分账描述
resultstring分账结果
PENDING | SUCEESS | CLOSED 枚举值之一
finish_timestring完成时间
fail_reasonstring分账失败原因
ACCOUNT_ABNORMAL | NO_RELATION | RECEIVER_HIGH_RISK 枚举值之一
detail_idstring分账明细单号
finish_amountinteger分账完结金额
finish_descriptionstring分账完结描述

参阅 官方文档

Published on the GitHub by TheNorthMemory