下载对账单的接口如下。
https:// api.mch.weixin.qq.com/pay/downloadbill
下载对账单时,POST数据示例如下。
<xml> <appid>wx2421b1c4370ec43b</appid> <bill_date>20141110</bill_date> <bill_type>ALL</bill_type> <mch_id>10000100</mch_id> <nonce_str>21df7dc9cd8616b56919f20d9f679233</nonce_str> <sign>332F17B766FC787203EBE9D6E40457A1</sign> </xml>
上述数据的参数说明如表17-22所示。
表17-22 下载对账单接口的参数说明


成功时,数据以文本表格的方式返回,第一行为表头,后面各行为对应的字段内容,字段内容与查询订单或退款结果一致。具体字段说明可查阅相应接口。
下载对账单接口类的实现如下。
1 /** 2 * 下载对账单接口 3 */ 4 class DownloadBill_pub extends Wxpay_client_pub 5 { 6 7 function __construct 8 { 9 // 设置接口链接 10 $this->url = "https:// api.mch.weixin.qq.com/pay/downloadbill"; 11 // 设置curl超时时间 12 $this->curl_timeout = WxPayConf_pub::CURL_TIMEOUT; 13 } 14 15 /** 16 * 生成接口参数XML 17 */ 18 function createXml 19 { 20 try 21 { 22 if($this->parameters["bill_date"] == null ) 23 { 24 throw new SDKRuntimeException("对账单接口中,缺少必填参数bill_date!". "<br>"); 25 } 26 $this->parameters["appid"] = WxPayConf_pub::APPID; // 公众账号ID 27 $this->parameters["mch_id"] = WxPayConf_pub::MCHID; // 商户号 28 $this->parameters["nonce_str"] = $this->createNoncestr;// 随机字符串 29 $this->parameters["sign"] = $this->getSign($this->parameters);// 签名 30 return $this->arrayToXml($this->parameters); 31 }catch (SDKRuntimeException $e) 32 { 33 die($e->errorMessage); 34 } 35 } 36 37 /** 38 * 作用:获取结果,默认不使用证书 39 */ 40 function getResult 41 { 42 $this->postXml; 43 $this->result = $this->xmlToArray($this->result_xml); 44 return $this->result; 45 } 46 47 }