Tlpay.php 716 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\payment;
  3. use Payment\Client\Refund;
  4. use Payment\Config;
  5. use Payment\Common\PayException;
  6. use support\Cache;
  7. class Tlpay
  8. {
  9. protected $config;
  10. public function __construct()
  11. {
  12. $this->config = config('payment.tl');
  13. }
  14. public function refund($data)
  15. {
  16. if (!$data){
  17. return json_fail('参数异常');
  18. }
  19. try {
  20. $ret = Refund::run(Config::TL_REFUND, $this->config, $data);
  21. file_put_contents(runtime_path('logs/tlpay.log'),json_encode($ret, JSON_UNESCAPED_UNICODE));
  22. return $ret;
  23. } catch (PayException $e) {
  24. throw new PayException("发起退款失败");
  25. }
  26. }
  27. }