小程序訪問(wèn)地址:
payfee.PHP:
-
[php] view plain copy
-
include 'WeixinPay.php';
-
$appid='';
-
$openid= $_GET['id'];
-
$mch_id='';
-
$key='';
-
$out_trade_no = $mch_id. time();
-
$total_fee = $_GET['fee'];
-
if(empty($total_fee)) //押金
-
{
-
$body = "充值押金";
-
$total_fee = floatval(99*100);
-
}
-
else {
-
$body = "充值余額";
-
$total_fee = floatval($total_fee*100);
-
}
-
$weixinpay = new WeixinPay($appid,$openid,$mch_id,$key,$out_trade_no,$body,$total_fee);
-
$return=$weixinpay->pay();
-
-
echo json_encode($return);
WeixinPay.php:
-
[php] view plain copy
-
<?php
-
-
-
/*
-
* 小程序微信支付
-
*/
-
-
-
class WeixinPay {
-
-
-
protected $appid;
-
protected $mch_id;
-
protected $key;
-
protected $openid;
-
protected $out_trade_no;
-
protected $body;
-
protected $total_fee;
-
function __construct($appid, $openid, $mch_id, $key,$out_trade_no,$body,$total_fee) {
-
$this->appid = $appid;
-
$this->openid = $openid;
-
$this->mch_id = $mch_id;
-
$this->key = $key;
-
$this->out_trade_no = $out_trade_no;
-
$this->body = $body;
-
$this->total_fee = $total_fee;
-
}
-
-
-
public function pay() {
-
//統(tǒng)一下單接口
-
$return = $this->weixinapp();
-
return $return;
-
}
|