Skip to content

下载对账单

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

请求参数类型描述
base_uristring声明接入点https://api.mch.weixin.qq.com/hk/(国内接入)
queryobject声明请求的查询参数
datestring账单日期
mchidstring商户号
headersobject声明请求的头参数
Accept-Encodingstring账单压缩:如需对账单进行压缩,设置HTTP请求头值为gzip
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->v3->statements->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
])
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance->chain('v3/statements')->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
])
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$instance['v3/statements']->getAsync([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
])
->wait();
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance->v3->statements->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
]);
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance->chain('v3/statements')->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
]);
php
$savedTo = \GuzzleHttp\Psr7\Utils::tryFopen('./somehowfile.csv.gz', 'w+');
$stream  = \GuzzleHttp\Psr7\Utils::streamFor($savedTo);

$response = $instance['v3/statements']->get([
  'base_uri' => 'https://api.mch.weixin.qq.com/hk/', // 接入点(国内接入)
  'sink' => $stream,
  'query' => [
    'date' => '20180130',
    'mchid' => '1900000109',
  ],
  'headers' => [
    'Accept-Encoding' => 'gzip',
  ],
]);
返回字典类型描述
文件流(需解析为对应数据)

参阅 官方文档

Published on the GitHub by TheNorthMemory