pay-transfers-create.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. try {
  14. // 1. 手动加载入口文件
  15. include "../include.php";
  16. // 2. 准备公众号配置参数
  17. $config = include "./config.php";
  18. // 3. 创建接口实例
  19. // $wechat = new \WeChat\Pay($config);
  20. // $wechat = \We::WeChatPay($config);
  21. $wechat = \WeChat\Pay::instance($config);
  22. // 4. 组装参数,可以参考官方商户文档
  23. $options = [
  24. 'partner_trade_no' => time(),
  25. 'openid' => 'o38gps3vNdCqaggFfrBRCRikwlWY',
  26. 'check_name' => 'NO_CHECK',
  27. 'amount' => '100',
  28. 'desc' => '企业付款操作说明信息',
  29. 'spbill_create_ip' => '127.0.0.1',
  30. ];
  31. $result = $wechat->createTransfers($options);
  32. echo '<pre>';
  33. var_export($result);
  34. $result = $wechat->queryTransfers($options['partner_trade_no']);
  35. var_export($result);
  36. } catch (Exception $e) {
  37. // 出错啦,处理下吧
  38. echo $e->getMessage() . PHP_EOL;
  39. }