Refund.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. */
  32. public function create($data)
  33. {
  34. return Order::instance($this->config)->createRefund($data);
  35. // return $this->doRequest('POST', '/v3/ecommerce/refunds/apply', json_encode($data, JSON_UNESCAPED_UNICODE), true);
  36. }
  37. /**
  38. * 退款订单查询
  39. * @param string $refundNo 退款单号
  40. * @return array
  41. * @throws \WeChat\Exceptions\InvalidResponseException
  42. */
  43. public function query($refundNo)
  44. {
  45. return Order::instance($this->config)->queryRefund($refundNo);
  46. // $pathinfo = "/v3/ecommerce/refunds/out-refund-no/{$refundNo}";
  47. // return $this->doRequest('GET', "{$pathinfo}?sub_mchid={$this->config['mch_id']}", '', true);
  48. }
  49. /**
  50. * 获取退款通知
  51. * @param string $xml
  52. * @return array
  53. * @return array
  54. * @throws \WeChat\Exceptions\InvalidDecryptException
  55. * @throws \WeChat\Exceptions\InvalidResponseException
  56. */
  57. public function notify($xml = '')
  58. {
  59. return Order::instance($this->config)->notifyRefund($xml);
  60. // $data = Tools::xml2arr(empty($xml) ? Tools::getRawInput() : $xml);
  61. // if (!isset($data['return_code']) || $data['return_code'] !== 'SUCCESS') {
  62. // throw new InvalidResponseException('获取退款通知XML失败!');
  63. // }
  64. // try {
  65. // $key = md5($this->config['mch_v3_key']);
  66. // $decrypt = base64_decode($data['req_info']);
  67. // $response = openssl_decrypt($decrypt, 'aes-256-ecb', $key, OPENSSL_RAW_DATA);
  68. // $data['result'] = Tools::xml2arr($response);
  69. // return $data;
  70. // } catch (\Exception $exception) {
  71. // throw new InvalidDecryptException($exception->getMessage(), $exception->getCode());
  72. // }
  73. }
  74. }