$params = [
'appid'=> self::APPID,
'mch_id'=> self::MCHID,
'nonce_str'=>md5(time()),
'body'=>'公众号支付测试',
'out_trade_no'=>$oid,
'total_fee'=> 2,
'spbill_create_ip'=>$_SERVER['REMOTE_ADDR'],
'notify_url'=> 'https://www.liminghulian.com/test/notify.php',
'trade_type'=>'JSAPI',
'product_id'=>$oid,
'openid' => $this->getOpenId()
];
//数组转xml
public function ArrToXml($arr)
{
if(!is_array($arr) || count($arr) == 0) return '';
$xml = "<xml>";
foreach ($arr as $key=>$val)
{
if (is_numeric($val)){
$xml.="<".$key.">".$val."</".$key.">";
}else{
$xml.="<".$key."><![CDATA[".$val."]]></".$key.">";
}
}
$xml.="</xml>";
return $xml;
}