Files
liche/api/third_party/WXpay/WxRefundNotify.php
T
2021-07-05 09:56:27 +08:00

33 lines
998 B
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: lcc
* Date: 2020/1/19
* Time: 19:51
*/
class WxRefundNotify
{
public $return_info;
public function __construct($str, $key) {
$str=$this->xmltoArray($str);
if($str['return_code']=='SUCCESS'){
$decrypt = base64_decode($str['req_info'], true);
$this->return_info=$this->xmlToArray(openssl_decrypt($decrypt , 'aes-256-ecb', MD5($key), OPENSSL_RAW_DATA));
$this->return_info['return_code']='SUCCESS';
}else{
$this->return_info=['return_code'=>'FAIL','return_msg'=>$str['return_msg']];
}
}
public function decryptData(){
return $this->return_info;
}
public function xmlToArray($xml)
{
libxml_disable_entity_loader(true); // 禁止引用外部xml实体
$jsonxml = json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA));
$result = json_decode($jsonxml, true);
return $result;
}
}