alipay-bill.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2023 ThinkAdmin [ thinkadmin.top ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免责声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/WeChatDeveloper
  13. // | github 代码仓库:https://github.com/zoujingli/WeChatDeveloper
  14. // +----------------------------------------------------------------------
  15. // 1. 手动加载入口文件
  16. include "../include.php";
  17. // 2. 准备公众号配置参数
  18. $config = include "./alipay.php";
  19. try {
  20. // 实例支付对象
  21. // $pay = new \AliPay\Bill($config);
  22. // $pay = \We::AliPayBill($config);
  23. $pay = \AliPay\Bill::instance($config);
  24. /**
  25. * 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型,支持:
  26. * trade:商户基于支付宝交易收单的业务账单;
  27. * signcustomer:基于商户支付宝余额收入及支出等资金变动的账务账单;
  28. * merchant_act:营销活动账单,包含营销活动的发放,核销记录
  29. * trade_zft_merchant:直付通二级商户查询交易的业务账单;
  30. * zft_acc:直付通平台商查询二级商户流水使用,返回所有二级商户流水。
  31. */
  32. // 请参考(请求参数):https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query
  33. $result = $pay->apply([
  34. 'bill_date' => date('Y-m-d', strtotime('-1 month')), // 账单时间(日账单yyyy-MM-dd,月账单 yyyy-MM)
  35. 'bill_type' => 'trade',
  36. ]);
  37. echo '<pre>';
  38. var_export($result);
  39. } catch (Exception $e) {
  40. echo $e->getMessage();
  41. }