首先在 /addons/epay/library/Service.php 里添加个方法
//退款
public static function refunds($order)
{
$config = Service::getConfig('wechat');
$result= Pay::wechat($config)->refund($order);
return $result;
}
之后在/application/api/controller 下定一个方法
例如我写的新建的Take.php 下的方法
use addons\epay\library\Service;
use Yansongda\Supports\Str;
use Yansongda\Pay\Pay;
use think\Config;
//退款
public function orderRefunds(){
$order=input();
$order=[
'out_trade_no' => $order['order_number'],
'out_refund_no' => time(),
'total_fee' => $order['price'],
'refund_fee' => $order['price'],
'refund_desc' => '退款',
'type' => 'miniapp',
];
$reslut=Service::refunds($order);
return json($reslut);
}