PHP实现微信根据订单退款
$_config = require('config.php');
$mchid = $_config['mchid']; //微信支付商户号 PartnerID 通过微信支付商户资料审核后邮件发送
$appid = $_config['appid']; //微信支付申请对应的公众号或小程序APPID
$apiKey = $_config['apikey']; //https://pay.weixin.qq.com 帐户设置-安全设置-API安全-API密钥-设置API密钥
$orderNo = $order['order_no']; //商户订单号(商户订单号与微信订单号二选一,至少填一个)
$wxOrderNo = ''; //微信订单号(商户订单号与微信订单号二选一,至少填一个)
$totalFee = number_format($order['total_price']/100,2); //订单金额,单位:元
$refundFee = number_format($order['total_price']/100,2); //退款金额,单位:元
$refundNo = date("YmdHis").rand(100000,999999); //退款订单号(可随机生成)
$wxPay = new WxpayService($mchid,$appid,$apiKey);
$result = $wxPay->doRefund($totalFee, $refundFee, $refundNo, $wxOrderNo,$orderNo);