微信支付統一下單post數據后,沒有返回值


這兩天閑着沒事謝了一個微信支付的類,在統一下單卡住了,向統一下單提交的xml格式如下,(xml中的敏感內容已經替換掉了)

<xml>
<appid>appid</appid>              
<mch_id>mch_id</mch_id>
<device_info>WEB</device_info>
<nonce_str>SDMMXJ4XG1KCPKT1AAYIOFPTWE5YCJJL</nonce_str>
<sign>ACDEB73B471195D9D0B9DDE5FD70ABDF</sign>
<sign_type>MD5</sign_type>
<body>JSAPI支付</body>
<detail><![CDATA[{"goods_detail":[{"goods_id": "12502", "wxpay_goods_id": "1001", "goods_name": "", "quantity": 1, "price": 528800}]}]]></detail>
<attach>商城</attach>
<out_trade_no>20200115110000000001</out_trade_no>
<fee_type>CNY</fee_type>
<total_fee>1</total_fee>
<spbill_create_ip>119.176.171.224</spbill_create_ip>
<time_start>1579074263</time_start>
<time_expire>1579074263</time_expire>
<notify_url>https://www.golaobao.com/wxpay/result.php</notify_url>
<trade_type>JSAPI</trade_type>
<openid>openid</openid>
</xml>

 

以上的xml數據使用curl向微信支付統一下單接口   https://api.mch.weixin.qq.com/pay/unifiedorder  提交數據后,接口沒有返回數據。

以下是提交代碼:

function postorder($orderXml){

$url="https://api.mch.weixin.qq.com/pay/unifiedorder";
$second=60;
$ch = curl_init();
$curlVersion = curl_version();
$ua = "WXPaySDK/3.0.9(".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." ".MCHID;
//設置超時 ".self::$VERSION."
//die("出錯");
curl_setopt($ch, CURLOPT_TIMEOUT, $second);

curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);//嚴格校驗
curl_setopt($ch,CURLOPT_USERAGENT, $ua);
//設置header
curl_setopt($ch, CURLOPT_HEADER, FALSE);
//要求結果為字符串且輸出到屏幕上
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$useCert=false;
if($useCert == true){
//設置證書
//使用證書:cert 與 key 分別屬於兩個.pem文件
//證書文件請放入服務器的非web目錄下
$sslCertPath = "";
$sslKeyPath = "";
curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM');
curl_setopt($ch,CURLOPT_SSLCERT, $sslCertPath);
curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM');
curl_setopt($ch,CURLOPT_SSLKEY, $sslKeyPath);
}
//post提交方式
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $orderXml);
//運行curl
$data = curl_exec($ch);
curl_close($ch);
return $data;
//返回結果

 

}

但是執行之后,沒有返回值,在網上查閱了很多的資料,都沒有解決問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM