Skip to content

下载对账单

商户可以通过该接口下载历史交易清单。比如掉单、系统错误等导致商户侧和微信侧数据不一致,通过对账单核对后可校正支付状态。

请求参数类型描述
xmlobject声明请求的XML数据结构
appidstring公众账号ID
mch_idstring商户号
bill_datestring对账单日期
bill_typestring账单类型
tar_typestring压缩账单
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->v2->pay->downloadbill->postAsync([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  $tmp = $response->getBody();
  $tmp->tell() && $tmp->rewind();
  $firstFiveBytes = $tmp->read(5);
  if ('<xml>' === $firstFiveBytes) {
    print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
  }
})
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->chain('v2/pay/downloadbill')->postAsync([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  $tmp = $response->getBody();
  $tmp->tell() && $tmp->rewind();
  $firstFiveBytes = $tmp->read(5);
  if ('<xml>' === $firstFiveBytes) {
    print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
  }
})
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance['v2/pay/downloadbill']->postAsync([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  $tmp = $response->getBody();
  $tmp->tell() && $tmp->rewind();
  $firstFiveBytes = $tmp->read(5);
  if ('<xml>' === $firstFiveBytes) {
    print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
  }
})
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance->v2->pay->downloadbill->post([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
]);

$tmp = $response->getBody();
$tmp->tell() && $tmp->rewind();
$firstFiveBytes = $tmp->read(5);
if ('<xml>' === $firstFiveBytes) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
}
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance->chain('v2/pay/downloadbill')->post([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
]);

$tmp = $response->getBody();
$tmp->tell() && $tmp->rewind();
$firstFiveBytes = $tmp->read(5);
if ('<xml>' === $firstFiveBytes) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
}
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance['v2/pay/downloadbill']->post([
  'sink' => $stream,
  'xml' => [
    'appid' => 'wx8888888888888888',
    'mch_id' => '1900000109',
    'bill_date' => '20140603',
    'bill_type' => 'ALL',
    'tar_type' => 'GZIP',
  ],
]);

$tmp = $response->getBody();
$tmp->tell() && $tmp->rewind();
$firstFiveBytes = $tmp->read(5);
if ('<xml>' === $firstFiveBytes) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
}
异常字典类型描述
return_codestring返回状态码
return_msgstring错误码描述
error_codestring错误码

参阅 官方付款码文档 官方JSAPI文档 官方NATIVE文档 官方APP文档 官方H5文档 官方小程序支付文档 官方人脸支付文档

Published on the GitHub by TheNorthMemory