php做乙個微信退款,PHP實現微信申請退款功能

2021-10-25 21:09:25 字數 841 閱讀 5232

前期準備:<

(2)安全考慮,涉及到支付涉及到金錢,必須要非常安全。官方sdk雖然我也吐槽,但至少會相對比較安全,再次重寫,雖然暫時沒看出問題,但是萬一有漏洞就不好了。

本篇還是使用到官方提供的sdk中的最重要的乙個類檔案wxpay.api.php中提供的refund()方法來實現,此方法在wxpay.api.php檔案的第141行,**如下:

* 申請退款,wxpayrefund中out_trade_no、transaction_id至少填乙個且

* out_refund_no、total_fee、refund_fee、op_user_id為必填引數

* @param wxpayrefund $inputobj

* @param int $timeout

* @throws wxpayexception

* @return 成功時返回,其他拋異常

public static function refund($inputobj, $timeout = 6)else if(!$inputobj->isout_refund_noset())else if(!$inputobj->istotal_feeset())else if(!$inputobj->isrefund_feeset())else if(!$inputobj->isop_user_idset())else if(($result['return_code']=='fail') || ($result['result_code']=='fail'))else{

//失敗

退款成功返回如下:

php做乙個微信退款,php實現微信支付之退款功能

需要注意的事項 如下 2.錯誤碼參照 header content type text html charset utf 8 apikey xx 帳戶設定 安全設定 api安全 api金鑰 設定api金鑰 totalfee 0.01 訂單金額,單位 元 refundfee 0.01 退款金額,單位 ...

php 實現微信退款

要是在測試的時候,網頁提示 curl 58 說明 證書的路徑出現問題 這裡要填物理路徑,也就是絕對路徑 網頁提示curl 52 說明你的證書引入少了,在官方的demo上只有兩個證書 apiclient cert.pem和 apiclient key.pem 你還需要引入乙個證書 rootca.pem...

PHP實現微信申請退款

申請退款,wxpayrefund中out trade no transaction id至少填乙個且 out refund no total fee refund fee op user id為必填引數 param wxpayrefund inputobj param int timeout thr...