微信小程序支付(主要注意商户key(商户key必须用网上密码生成工具生成)、api安全证书 、关联小程序id、sign签名生成必须拼接商户key,并且md5加密 全部转为大写)
<?php
class WxPay{
protected $appid;
protected $mch_id;
protected $key;
protected $openid;
protected $out_trade_no;
protected $body;
protected $total_fee;
protected $notifyURL;
protected $unfiedorderURL;
protected $trade_type;
public function __construct($appid, $openid, $mch_id, $key,$out_trade_no,$body,$total_fee,$notifyURL,$unifiedorderURL,$trade_type){
$this->appid=$appid;
$this->mch_id=$mch_id;
$this->openid = $openid;
$this->key = $key;
$this->out_trade_no = $out_trade_no;
$this->body = $body;
$this->total_fee = $total_fee;
$this->notifyURL=$notifyURL;
$this->unfiedorderURL=$unifiedorderURL;
$this->trade_type=$trade_type;
}
public function pay(){
return $this->weixinapp();
}
private function weixinapp(){
<