Refund.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 WePayV3;
  16. use WePayV3\Contracts\BasicWePay;
  17. /**
  18. * 订单退款接口
  19. * 注意:直连商户退款接口集成在 Order 中
  20. * @deprecated
  21. * @class Refund
  22. * @package WePayV3
  23. */
  24. class Refund extends BasicWePay
  25. {
  26. /**
  27. * 创建退款订单
  28. * @param array $data 退款参数
  29. * @return array
  30. * @throws \WeChat\Exceptions\InvalidResponseException
  31. * @throws \WeChat\Exceptions\LocalCacheException
  32. */
  33. public function create($data)
  34. {
  35. return Order::instance($this->config)->createRefund($data);
  36. // return $this->doRequest('POST', '/v3/ecommerce/refunds/apply', json_encode($data, JSON_UNESCAPED_UNICODE), true);
  37. }
  38. /**
  39. * 退款订单查询
  40. * @param string $refundNo 退款单号
  41. * @return array
  42. * @throws \WeChat\Exceptions\InvalidResponseException
  43. * @throws \WeChat\Exceptions\LocalCacheException
  44. */
  45. public function query($refundNo)
  46. {
  47. return Order::instance($this->config)->queryRefund($refundNo);
  48. // $pathinfo = "/v3/ecommerce/refunds/out-refund-no/{$refundNo}";
  49. // return $this->doRequest('GET', "{$pathinfo}?sub_mchid={$this->config['mch_id']}", '', true);
  50. }
  51. /**
  52. * 获取退款通知
  53. * @param mixed $xml
  54. * @return array
  55. * @throws \WeChat\Exceptions\InvalidDecryptException
  56. * @throws \WeChat\Exceptions\InvalidResponseException
  57. * @throws \WeChat\Exceptions\LocalCacheException
  58. */
  59. public function notify($xml = [])
  60. {
  61. return Order::instance($this->config)->notify($xml);
  62. // $data = Tools::xml2arr(empty($xml) ? Tools::getRawInput() : $xml);
  63. // if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') {
  64. // throw new InvalidResponseException('获取退款通知XML失败!');
  65. // }
  66. // try {
  67. // $key = md5($this->config['mch_v3_key']);
  68. // $decrypt = base64_decode($data['req_info']);
  69. // $response = openssl_decrypt($decrypt, 'aes-256-ecb', $key, OPENSSL_RAW_DATA);
  70. // $data['result'] = Tools::xml2arr($response);
  71. // return $data;
  72. // } catch (\Exception $exception) {
  73. // throw new InvalidDecryptException($exception->getMessage(), $exception->getCode());
  74. // }
  75. }
  76. }