//构造一个远程请求https的函数
function https_post($post_url,$data){
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $post_url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data );
$return = curl_exec ( $ch );
curl_close ( $ch );
return $return;
}
function array_xml($data, $root = true){
$str="";
if($root)$str .= "<xml>";
foreach($data as $key => $val){
if(is_array($val)){
$child = array_xml($val, false);
$str .= "<$key>$child</$key>";
}else{
$str.= "<$key><![CDATA[".$val."]]></$key>";
}
}
if($root)$str .= "</xml>";
return $str;
}
//xml转数组
function xml_array($xml){
//禁止引用外部xml实体
libxml_disable_entity_loader(true);
$str = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
return $str;
}
function wechat_payment($appid,$body,$mch_id,$nonce_str,$notify_url,$out_trade_no,$sign_type,$spbill_create_ip,$total_fee,$trade_type,$key,$openid=''){
if($trade_type=='JSAPI'){
//生成支付--统一下单
//支付请求接口
$payment_wechat='https://api.mch.weixin.qq.com/pay/unifiedorder';
//参数签名--ASCII排序--手动排序
$sign=strtoupper(md5(
'appid='.$appid.
php超详细的微信支付方法--包含JSAPI支付、H5支付、扫码支付
最新推荐文章于 2022-06-21 13:28:43 发布