微信app支付

2021-09-19 17:27:50 字數 1846 閱讀 4702

文件

$arr = [

'mchid'=>$mchid,

'nonce_str'=>str_random(32),//隨機數

'partner_trade_no'=>$order_id,//自己定義乙個不重複訂單號

'check_name'=>'no_check',

'desc'=>$desc,

'spbill_create_ip'=>\request::getclientip(),

'sign'=>'',

];ksort($arr);

$sign="";

foreach ($arr as $key => $value)

}$arr['sign'] = strtoupper(md5($sign));

$xml = "";

foreach ($arr as $key=>$val)

else

$xml.="<".$key.">";

}$xml.="";

$ch = curl_init();

//超時時間

curl_setopt($ch,curlopt_timeout,60);

curl_setopt($ch,curlopt_url,'');

curl_setopt($ch,curlopt_ssl_verifypeer,false);

curl_setopt($ch,curlopt_ssl_verifyhost,false);

//預設格式為pem

return $data;//$data['return_code'] == 'success' && $data['result_code'] == 'success' 支付成功}}

//3.採集

$output = curl_exec($curl);

//4.關閉

curl_close($curl);

if ($res == 'json')

}

function getwxaccesstoken()else

}//上傳素材(該方法只能獲取到的url)

function addmaterialurl()

php5.6加上curl_setopt ($curl, curlopt_safe_upload, false);或者直接"media" => new curlfile(realpath($real_path)),附:

微信app支付

商戶id public static final string partner id 14698sdfs402dsfdew402 常量固定值 public static final string grant type client credential 獲取預支付id的介面url public st...

微信APP支付

final string mchid,final string notifyurl,final string outtradeno,final string noncestr,final string body,final string productid,final string totalfee...

微信APP支付demo

use think controller class wxpaycontroller extends homecontroller public function wxpay outtradeno order info tag time totalfee order info total money...