예제 #1
0
  public function wx_notify(){
	require_once getcwd()."/Wxpay/lib/WxPay.Api.php";
	$rrmodel = M('record_remark');
	$rrdata['type'] = 2;
	$rrdata['rid'] = 0;
	if($_POST){
	  $rrdata['info'] = serialize($_POST);
	}else{
	  $rrdata['info'] = file_get_contents('php://input');
	}
	$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
	$xml = '<xml><appid><![CDATA[wx2be892adc35c8c7d]]></appid>
<attach><![CDATA[test]]></attach>
<bank_type><![CDATA[CFT]]></bank_type>
<cash_fee><![CDATA[1]]></cash_fee>
<fee_type><![CDATA[CNY]]></fee_type>
<is_subscribe><![CDATA[N]]></is_subscribe>
<mch_id><![CDATA[1241883502]]></mch_id>
<nonce_str><![CDATA[wtk0c2zlxxx9yk10poxa4zpcrhr2prql]]></nonce_str>
<openid><![CDATA[oNjyPs7mmMVX7xf0qsScaRq4RRpY]]></openid>
<out_trade_no><![CDATA[124188350220150604143444]]></out_trade_no>
<result_code><![CDATA[SUCCESS]]></result_code>
<return_code><![CDATA[SUCCESS]]></return_code>
<sign><![CDATA[D07549833387139CF68B97D6A50B4E6B]]></sign>
<time_end><![CDATA[20150604143150]]></time_end>
<total_fee>1</total_fee>
<trade_type><![CDATA[JSAPI]]></trade_type>
<transaction_id><![CDATA[1009530519201506040206996268]]></transaction_id>
</xml>';
    $array_data = WxPayResults::FromXml($xml);
	dump(unserialize('a:17:{s:5:"appid";s:18:"wx2be892adc35c8c7d";s:6:"attach";s:4:"test";s:9:"bank_type";s:3:"CFT";s:8:"cash_fee";s:1:"1";s:8:"fee_type";s:3:"CNY";s:12:"is_subscribe";s:1:"Y";s:6:"mch_id";s:10:"1241883502";s:9:"nonce_str";s:32:"ciqfhznmzsxcxwl6j9olwio9y3jeumkz";s:6:"openid";s:28:"oNjyPs7mmMVX7xf0qsScaRq4RRpY";s:12:"out_trade_no";s:24:"124188350220150604170134";s:11:"result_code";s:7:"SUCCESS";s:11:"return_code";s:7:"SUCCESS";s:4:"sign";s:32:"F35BD87FAC7D03C4B53AD0A4539A06C7";s:8:"time_end";s:14:"20150604165822";s:9:"total_fee";s:1:"1";s:10:"trade_type";s:5:"JSAPI";s:14:"transaction_id";s:28:"1009530519201506040207633897";}'));exit;
	dump($array_data);exit;
	//微信签名认证
	$result = WxPayResults::Init2($xml);
	if($result){
	  $rrdata['error_msg'] = '签名通过';
	}else{
	  $rrdata['error_msg'] = '签名错误';
	  return false;
	}
	$transaction_id = $array_data['transaction_id'];
		$input = new WxPayOrderQuery();
		$input->SetTransaction_id($transaction_id);
		$result = WxPayApi::orderQuery($input);

	dump(serialize($result));exit;	
	$rrdata['rstatus'] = 0;
	$rrdata['order_id'] = 0;//微信订单
	$rrdata['oid'] = $array_data['out_trade_no'];//我方订单
	$rrdata['create_time'] = time();
	$remark_id = $rrmodel->add($rrdata);
    //echo "SUCCESS";EXIT;
  }
예제 #2
0
  public function _initialize(){
	require_once C('INTERFACE_PATH')."Wxpay/lib/WxPay.Api.php";
	require_once C('INTERFACE_PATH')."Wxpay/unit/WxPay.JsApiPay.php";
	$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
	$xml = '<xml>
	<return_code><![CDATA[SUCCESS]]></return_code>
	<return_msg><![CDATA[OK]]></return_msg>
	<appid><![CDATA[wx2421b1c4370ec43b]]></appid> <mch_id><![CDATA[10000100]]></mch_id> <device_info><![CDATA[1000]]></device_info> <nonce_str><![CDATA[FvYSnPuFFPkAr77M]]></nonce_str> <sign><![CDATA[63238039D6E43634297CF2A6EB5F3B72]]></sign>
	<result_code><![CDATA[SUCCESS]]></result_code> <openid><![CDATA[oUpF8uN95-Ptaags6E_roPHg7AG0]]></openid>
	<is_subscribe><![CDATA[Y]]></is_subscribe> <trade_type><![CDATA[JSAPI]]></trade_type> <bank_type><![CDATA[CCB_CREDIT]]></bank_type>
	<total_fee>100</total_fee>
	<coupon_fee>0</coupon_fee>
	<fee_type><![CDATA[CNY]]></fee_type> <transaction_id><![CDATA[1008450740201407220000058756]]></transaction_id>
	<out_trade_no><![CDATA[20150519975154104261,20150529101555658541]]></out_trade_no>
	<attach><![CDATA[pay_type|2]]></attach> <time_end><![CDATA[20140722160655]]></time_end>
	</xml>';
	/*
	$xml = '<xml>
	<return_code><![CDATA[SUCCESS]]></return_code>
	<return_msg><![CDATA[OK]]></return_msg>
	<appid><![CDATA[wx2421b1c4370ec43b]]></appid>
	<mch_id><![CDATA[10000100]]></mch_id>
	<device_info><![CDATA[1000]]></device_info>
	<nonce_str><![CDATA[sthBJ9QyUG6vkrjJ]]></nonce_str>
	<sign><![CDATA[6277A96D7875D4FF23AA7B6A4C3046AB]]></sign>
	<result_code><![CDATA[FAIL]]></result_code>
	<err_code><![CDATA[PAYERROR]]></err_code>
	<err_code_des><![CDATA[支付错误]]></err_code_des>
	</xml> ';
	*/
	$this->data = WxPayResults::FromXml($xml);
	//dump($this->data);exit;
	$checkSign = WxPayResults::Init2($xml);
	if($checkSign){
	    $transaction_id = $this->data['transaction_id'];
		$input = new WxPayOrderQuery();
		$input->SetTransaction_id($transaction_id);
		$order = WxPayApi::orderQuery($input);
		if($order['result_code']=='SUCCESS'){
		   $order_status = 1;
		   $error_msg = '订单验证成功';
		}else{
		   $order_status = 0;
		   $error_msg = serialize($order);
		}
	}else{
	  $error_msg = '签名错误';
	}
	//配置
	if($checkSign !== FALSE){
	  //记录传值信息
	  $rrmodel = M('pay_notify');
	  $rrdata['type'] = 2;
	  $rrdata['rid'] = 0;
	  $rrdata['info'] = $xml;
	  $rrdata['error_msg'] = $error_msg;
	  $rrdata['rstatus'] = 0;
	  $rrdata['order_id'] = $this->data['transaction_id'];//微信订单
	  $rrdata['oid'] = $this->data['out_trade_no'];//我方订单
	  $rrdata['create_time'] = time();
	  $remark_id = $rrmodel->add($rrdata);
	  $this->remark_id = $remark_id;
	  if($order_status==0){
	    //订单支付失败
		//exit;
	  }
	  //echo $rrmodel->getlastsql();exit;
	}else{
		$returnXml = $notify->returnXml();
	    //Common_util_pub::postXmlSSLCurl($returnXml,'localhost');
		//dump($returnXml);
		$rrmodel = M('pay_notify');
		$rrdata['type'] = 2;
		$rrdata['rid'] = 0;
		$rrdata['info'] = $xml;
		$rrdata['error_msg'] = $error_msg;
		$rrdata['rstatus'] = 0;
		$rrdata['order_id'] = $this->data['transaction_id'];//微信订单
		$rrdata['oid'] = $this->data['out_trade_no'];//我方订单
		$rrdata['create_time'] = time();
		$rrmodel->add($rrdata);
		//exit;
	}
	$this->ReplyNotify();
  }