thinkPHP和微支付实现的微信支付插件,在微信中调用微信jssdk实现支付,这里有详细的代码和教程,具体看这里:
//=========步骤1:网页授权获取用户openid============
if (!isset($_GET['code']))
{
//触发微信返回code码
$url = $jsApi->createOauthUrlForCode(\WxPayConf_pub::JS_API_CALL_URL.'/order_id/'.$param['order_id']);
Header("Location: $url");
}else
{
$order_id = $param['order_id'];
$info = M('Order')->where('id='.$order_id)->find();
if(empty($info) || $info['is_pay'] == 1){
dump('该订单不存在或已支付'.$order_id);
exit();
}
$this->assign('info',$info);
$a = $info['money'];
$b = 100;
$c = $a * $b;
//<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>code码,以<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>openid
$code = $_GET['code'];
$jsApi->setCode($code);
$openid = $jsApi->getOpenId();
}
//=========步骤2:使用统一支付接口,<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>prepay_id============
//使用统一支付接口
$unifiedOrder = new \UnifiedOrder_pub();
$unifiedOrder->setParameter("openid","$openid");//商品描述
$unifiedOrder->setParameter("body","在线预订");//商品描述
//<a href="https://www.jb51.cc/tag/zidingyi/" target="_blank" class="keywords">自定义</a>订单号,此处仅作举例
$timeStamp = time();
// $out_trade_no = \WxPayConf_pub::APPID."$timeStamp";
$out_trade_no = $info['ordersn'];
$unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号
$unifiedOrder->setParameter("total_fee","$c");//总金额
$unifiedOrder->setParameter("notify_url",\WxPayConf_pub::NOTIFY_URL.'/order_id/'.$param['order_id']);//通知地址
$unifiedOrder->setParameter("trade_type","JSAPI");//交易类型
$prepay_id = $unifiedOrder->getPrepayId();
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
$this->assign('jsApiParameters',$jsApiParameters);
$this->display('pay');
}</pre>