微信支付回調處理分爲
1.同步
2.異步
這裏微信官方推薦使用 第二種php
php對微信回調異步處理json
//獲取返回的xml $testxml = file_get_contents("php://input"); //將xml轉化爲json格式 $jsonxml = json_encode(simplexml_load_string($testxml, 'SimpleXMLElement', LIBXML_NOCDATA)); //轉成數組 $result = json_decode($jsonxml, true); if($result){ //若是成功返回了 if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){ //進行改變訂單狀態等操做。。。。 } }
本次微信支付返回的xml轉化爲json格式以下:數組
{ "appid": "12345", "attach": "pay", "bank_type": "CFT", "cash_fee": "1", "fee_type": "CNY", "is_subscribe": "Y", "mch_id": "12345", "nonce_str": "dZYFpaDYRpF5rwhv", "openid": "onhwF1hiutUySKCsrV21A6MCtT5Q", "out_trade_no": "SH201808222055598628", "result_code": "SUCCESS", "return_code": "SUCCESS", "sign": "5A019F52BEF1C3A98AE0F1FF29D01574", "time_end": "20180822205606", "total_fee": "1", "trade_type": "MWEB", "transaction_id": "4200000171201808221550954201" }
其中微信
"result_code": "SUCCESS", "return_code": "SUCCESS",
是判斷用戶是否已經支付的依據app
若是這篇文章對你有用,能夠點個贊或者是收藏,算是對做者的鼓勵~異步
另附上小弟網站。。。www.entercode.cn 推廣一波...微信支付