Pay.php 6.8 KB

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