Transfers.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. namespace WePay;
  16. use WeChat\Contracts\BasicWePay;
  17. /**
  18. * 微信商户打款到零钱
  19. * Class Transfers
  20. * @package WePay
  21. */
  22. class Transfers extends BasicWePay
  23. {
  24. /**
  25. * 企业付款到零钱
  26. * @param array $options
  27. * @return array
  28. * @throws \WeChat\Exceptions\InvalidResponseException
  29. * @throws \WeChat\Exceptions\LocalCacheException
  30. */
  31. public function create(array $options)
  32. {
  33. $this->params->offsetUnset('appid');
  34. $this->params->offsetUnset('mch_id');
  35. $this->params->set('mchid', $this->config->get('mch_id'));
  36. $this->params->set('mch_appid', $this->config->get('appid'));
  37. $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
  38. return $this->callPostApi($url, $options, true, 'MD5', false);
  39. }
  40. /**
  41. * 查询企业付款到零钱
  42. * @param string $partnerTradeNo 商户调用企业付款API时使用的商户订单号
  43. * @return array
  44. * @throws \WeChat\Exceptions\InvalidResponseException
  45. * @throws \WeChat\Exceptions\LocalCacheException
  46. */
  47. public function query($partnerTradeNo)
  48. {
  49. $this->params->offsetUnset('mchid');
  50. $this->params->offsetUnset('mch_appid');
  51. $this->params->set('appid', $this->config->get('appid'));
  52. $this->params->set('mch_id', $this->config->get('mch_id'));
  53. $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo';
  54. return $this->callPostApi($url, ['partner_trade_no' => $partnerTradeNo], true, 'MD5', false);
  55. }
  56. }