Pay.php 6.5 KB

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