pay-transfers-create.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. try {
  16. // 1. 手动加载入口文件
  17. include "../include.php";
  18. // 2. 准备公众号配置参数
  19. $config = include "./config.php";
  20. // 3. 创建接口实例
  21. // $wechat = new \WeChat\Pay($config);
  22. // $wechat = \We::WeChatPay($config);
  23. $wechat = \WeChat\Pay::instance($config);
  24. // 4. 组装参数,可以参考官方商户文档
  25. $options = [
  26. 'partner_trade_no' => time(),
  27. 'openid' => 'o38gps3vNdCqaggFfrBRCRikwlWY',
  28. 'check_name' => 'NO_CHECK',
  29. 'amount' => '100',
  30. 'desc' => '企业付款操作说明信息',
  31. 'spbill_create_ip' => '127.0.0.1',
  32. ];
  33. $result = $wechat->createTransfers($options);
  34. echo '<pre>';
  35. var_export($result);
  36. $result = $wechat->queryTransfers($options['partner_trade_no']);
  37. var_export($result);
  38. } catch (Exception $e) {
  39. // 出错啦,处理下吧
  40. echo $e->getMessage() . PHP_EOL;
  41. }