Pay.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 WeChat;
  16. use WeChat\Contracts\BasicWePay;
  17. use WePay\Bill;
  18. use WePay\Order;
  19. use WePay\Refund;
  20. use WePay\Transfers;
  21. use WePay\TransfersBank;
  22. /**
  23. * 微信支付商户
  24. * Class Pay
  25. * @package WeChat\Contracts
  26. */
  27. class Pay extends BasicWePay
  28. {
  29. /**
  30. * 统一下单
  31. * @param array $options
  32. * @return array
  33. * @throws \WeChat\Exceptions\InvalidResponseException
  34. * @throws \WeChat\Exceptions\LocalCacheException
  35. */
  36. public function createOrder(array $options)
  37. {
  38. return Order::instance($this->config->get())->create($options);
  39. }
  40. /**
  41. * 刷卡支付
  42. * @param array $options
  43. * @return array
  44. * @throws \WeChat\Exceptions\InvalidResponseException
  45. * @throws \WeChat\Exceptions\LocalCacheException
  46. */
  47. public function createMicropay($options)
  48. {
  49. return Order::instance($this->config->get())->micropay($options);
  50. }
  51. /**
  52. * 创建JsApi及H5支付参数
  53. * @param string $prepay_id 统一下单预支付码
  54. * @return array
  55. */
  56. public function createParamsForJsApi($prepay_id)
  57. {
  58. return Order::instance($this->config->get())->jsapiParams($prepay_id);
  59. }
  60. /**
  61. * 获取APP支付参数
  62. * @param string $prepay_id 统一下单预支付码
  63. * @return array
  64. */
  65. public function createParamsForApp($prepay_id)
  66. {
  67. return Order::instance($this->config->get())->appParams($prepay_id);
  68. }
  69. /**
  70. * 获取支付规则二维码
  71. * @param string $product_id 商户定义的商品id 或者订单号
  72. * @return string
  73. */
  74. public function createParamsForRuleQrc($product_id)
  75. {
  76. return Order::instance($this->config->get())->qrcParams($product_id);
  77. }
  78. /**
  79. * 查询订单
  80. * @param array $options
  81. * @return array
  82. * @throws \WeChat\Exceptions\InvalidResponseException
  83. * @throws \WeChat\Exceptions\LocalCacheException
  84. */
  85. public function queryOrder(array $options)
  86. {
  87. return Order::instance($this->config->get())->query($options);
  88. }
  89. /**
  90. * 关闭订单
  91. * @param string $out_trade_no 商户订单号
  92. * @return array
  93. * @throws \WeChat\Exceptions\InvalidResponseException
  94. * @throws \WeChat\Exceptions\LocalCacheException
  95. */
  96. public function closeOrder($out_trade_no)
  97. {
  98. return Order::instance($this->config->get())->close($out_trade_no);
  99. }
  100. /**
  101. * 申请退款
  102. * @param array $options
  103. * @return array
  104. * @throws \WeChat\Exceptions\InvalidResponseException
  105. * @throws \WeChat\Exceptions\LocalCacheException
  106. */
  107. public function createRefund(array $options)
  108. {
  109. return Refund::instance($this->config->get())->create($options);
  110. }
  111. /**
  112. * 查询退款
  113. * @param array $options
  114. * @return array
  115. * @throws \WeChat\Exceptions\InvalidResponseException
  116. * @throws \WeChat\Exceptions\LocalCacheException
  117. */
  118. public function queryRefund(array $options)
  119. {
  120. return Refund::instance($this->config->get())->query($options);
  121. }
  122. /**
  123. * 交易保障
  124. * @param array $options
  125. * @return array
  126. * @throws \WeChat\Exceptions\InvalidResponseException
  127. * @throws \WeChat\Exceptions\LocalCacheException
  128. */
  129. public function report(array $options)
  130. {
  131. return Order::instance($this->config->get())->report($options);
  132. }
  133. /**
  134. * 授权码查询openid
  135. * @param string $authCode 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
  136. * @return array
  137. * @throws \WeChat\Exceptions\InvalidResponseException
  138. * @throws \WeChat\Exceptions\LocalCacheException
  139. */
  140. public function queryAuthCode($authCode)
  141. {
  142. return Order::instance($this->config->get())->queryAuthCode($authCode);
  143. }
  144. /**
  145. * 下载对账单
  146. * @param array $options 静音参数
  147. * @param null|string $outType 输出类型
  148. * @return bool|string
  149. * @throws \WeChat\Exceptions\InvalidResponseException
  150. * @throws \WeChat\Exceptions\LocalCacheException
  151. */
  152. public function billDownload(array $options, $outType = null)
  153. {
  154. return Bill::instance($this->config->get())->download($options, $outType);
  155. }
  156. /**
  157. * 拉取订单评价数据
  158. * @param array $options
  159. * @return array
  160. * @throws \WeChat\Exceptions\InvalidResponseException
  161. * @throws \WeChat\Exceptions\LocalCacheException
  162. */
  163. public function billCommtent(array $options)
  164. {
  165. return Bill::instance($this->config->get())->comment($options);
  166. }
  167. /**
  168. * 企业付款到零钱
  169. * @param array $options
  170. * @return array
  171. * @throws \WeChat\Exceptions\InvalidResponseException
  172. * @throws \WeChat\Exceptions\LocalCacheException
  173. */
  174. public function createTransfers(array $options)
  175. {
  176. return Transfers::instance($this->config->get())->create($options);
  177. }
  178. /**
  179. * 查询企业付款到零钱
  180. * @param string $partner_trade_no 商户调用企业付款API时使用的商户订单号
  181. * @return array
  182. * @throws \WeChat\Exceptions\InvalidResponseException
  183. * @throws \WeChat\Exceptions\LocalCacheException
  184. */
  185. public function queryTransfers($partner_trade_no)
  186. {
  187. return Transfers::instance($this->config->get())->query($partner_trade_no);
  188. }
  189. /**
  190. * 企业付款到银行卡
  191. * @param array $options
  192. * @return array
  193. * @throws \WeChat\Exceptions\InvalidDecryptException
  194. * @throws \WeChat\Exceptions\InvalidResponseException
  195. * @throws \WeChat\Exceptions\LocalCacheException
  196. */
  197. public function createTransfersBank(array $options)
  198. {
  199. return TransfersBank::instance($this->config->get())->create($options);
  200. }
  201. /**
  202. * 商户企业付款到银行卡操作进行结果查询
  203. * @param string $partner_trade_no 商户订单号,需保持唯一
  204. * @return array
  205. * @throws \WeChat\Exceptions\InvalidResponseException
  206. * @throws \WeChat\Exceptions\LocalCacheException
  207. */
  208. public function queryTransFresBank($partner_trade_no)
  209. {
  210. return TransfersBank::instance($this->config->get())->query($partner_trade_no);
  211. }
  212. }