$xmlResult = file_get_contents("php://input");//获取微信的数据
$result = $this->xmlToArray($xmlResult);//将xml转成数组
// 将加密的数据解密,方法在下面
$reqInfo = $this->refund_decrypt($result[‘req_info‘]);
/* * 退款通知解密 * @Author WangZhaoBo * @param $str 微信同步的加密串req_info * @param $key 商户key */ public function refund_decrypt($str) { $key = md5($this->appSecret); $str = base64_decode($str); $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB); $block = mcrypt_get_block_size(‘rijndael_128‘, ‘ecb‘); $pad = ord($str[($len = strlen($str)) - 1]); $len = strlen($str); $pad = ord($str[$len - 1]); return substr($str, 0, strlen($str) - $pad); }