php 微信下订单/退款类源码(含调用示例)
//使用方法一: * 配置好自己的参数,注意这里的两个证书路径得根据你自己的项目证书路径来写,同时存放证书的目录要开放可读权限 * 单纯的支付不需要证书 , 退款的时候需要证书 $config = array( 'appid' => 'wx123456789876', 'mch_id' => '123456789', 'pay_apikey' => '123456789876123456789876123456789876', 'api_cert' => getcwd().'/cert/apiclient_cert.pem', 'api_key' => getcwd().'/cert/apiclient_key.pem' ); $wxpay = new WxPay($config); //初始化类(同时传递参数) $data = $wxpay->wxpay($openid,$total_fee,$body,$order_sn); //微信支付,将返回值$data(json格式)返回给页面,进行JSAPI支付 $wxpay->refund($transaction_id,$out_refund_no,$total_fee,$refund_fee); //微信退款 //使用方法二: $wxpay = new WxPay(); //初始化类 $wxpay->appid = 'wx123456789876'; //配置参数 $wxpay->mch_id = '123456789'; $wxpay->pay_apikey = '123456789876123456789876123456789876'; $wxpay->api_cert = getcwd().'/cert/apiclient_cert.pem'; $wxpay->api_key = getcwd().'/cert/apiclient_key.pem'; $data = $wxpay->wxpay($openid,$total_fee,$body,$order_sn); //微信支付,将返回值$data(json格式)返回给页面,进行JSAPI支付 $wxpay->refund($transaction_id,$out_refund_no,$total_fee,$refund_fee); //微信退款