thinkphp5.0 中简单处理微信支付异步通知

原文链接: https://my.oschina.net/mofire/blog/802846
	public function wx_notify(){
		$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
		libxml_disable_entity_loader(true);
        $xml = json_decode(json_encode(simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA)), true);        
		if($xml['out_trade_no']){
			$rs = Db::name('order_jiaoche')->where(array('order_sn'=>$xml['out_trade_no']))->find();
			if($rs){
				Db::name('order_jiaoche')->where(array('order_sn'=>$xml['out_trade_no']))->update(array('ispay'=>1));
				echo 'success';
			}
		}		
		 /*
		 调试所用 
		 $fp = fopen('notify.txt','a+'); 
		 fwrite($fp,"\n _______GET________");   
		 fwrite($fp,var_export($xml,true));     
		 fwrite($fp,"\n ________postObj________");
		 fwrite($fp,var_export($xml,true));
		 fwrite($fp,'【 Now 】:  '. date("Y-m-d H:i:s") ."\n");
		 fclose($fp); 
		 print_r($xml);
		 */
	}

 

转载于:https://my.oschina.net/mofire/blog/802846

你可能感兴趣的:(thinkphp5.0 中简单处理微信支付异步通知)