1.微信支付回调
此方法从网上查找的 需要配置文件的支持
/*
*微信支付
* 回调地址 notifyurl
*
*/
public function notifyurl()
{
//使用通用通知接口
$notify = new \Notify_pub();
//存储微信的回调
$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
$notify->saveData($xml);
$re = $notify->data;
$aaaa = json_encode($re);
if($re["sign"] && $re["return_code"] == "SUCCESS" && $re["result_code"] == "SUCCESS"){
echo 'success';
$notify->setReturnParameter("return_code","SUCCESS");
} else {
echo 'error';
}
}
2.微信支付回调
此方法偏向原生解析
<?php
$log = array('get'=>$_GET,'post'=>$_POST,'row_data'=>file_get_contents("php://input"));
//开启调试
define('WXDEBUG', true);
$data = array();
$xml = simplexml_load_string(file_get_contents("php://input"), 'SimpleXMLElement', LIBXML_NOCDATA);
foreach ($xml as $k => $v) {
$data[(string) $k] = (string) $v;
}
$data['total_fee'] = $data['total_fee'] / 100;
$log['data'] = $data;
extract($data);
if($result_code=='SUCCESS'&&$return_code=='SUCCESS'){
echo 'success';
}
wlogs('wx-log', var_export($log, true) );
exit;
?>
付签名算法
//签名生成
//$data 微信回调或构造的数据
//$key 微信商户秘钥
private function signs($data,$key)
{
//签名步骤一:按字典序排序参数
ksort($data);
$string = $this->ToUrlParams($data);
//$this->common_out($string);
//签名步骤二:在string后加入KEY
$string = $string . "&key=".$key;
//签名步骤三:MD5加密
$string = md5($string);
//签名步骤四:所有字符转为大写
$result = strtoupper($string);
return $result;
//stringA="appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA";
}