Ejemplo n.º 1
0
 public function cPayQrcode()
 {
     //设置静态链接
     $nativeLink = new \NativeLink_pub();
     $product_id = WxPayConf_pub::APPID . "static";
     //自定义商品id
     $nativeLink->setParameter("product_id", "{$product_id}");
     //商品id
     //获取链接
     $product_url = $nativeLink->getUrl();
     return $product_url;
 }
Ejemplo n.º 2
0
 /**
  * 生成支付代码
  * 
  * @param array $order
  *        	订单信息
  * @param array $payment
  *        	支付方式信息
  */
 function get_code($order, $payment)
 {
     $conf = new WxPayConf_pub($payment);
     //微信浏览器的JSAPI支付\
     if (strpos($_SERVER['HTTP_USER_AGENT'], "MicroMessenger")) {
         $tools = new JsApi_pub($payment);
         $openid = $tools->GetOpenid();
         $unifiedOrder = new UnifiedOrder_pub();
         $returnrul = $conf->successurl;
         $unifiedOrder->setParameter("appid", $conf->wxpay_app_id);
         // appid
         $unifiedOrder->setParameter("openid", "{$openid}");
         // openid
         $unifiedOrder->setParameter("body", $order['order_sn']);
         // 商品描述
         $timeStamp = time();
         // $out_trade_no = WxPayConf_pub::APPID."$timeStamp";
         $unifiedOrder->setParameter("out_trade_no", $order['order_sn']);
         // 商户订单号
         $unifiedOrder->setParameter("total_fee", intval($order['order_amount'] * 100));
         // 总金额
         $unifiedOrder->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
         $unifiedOrder->setParameter("notify_url", 'http://' . $_SERVER["HTTP_HOST"] . '/respond.php');
         // 通知地址
         $unifiedOrder->setParameter("trade_type", "JSAPI");
         // 交易类型
         // 非必填参数,商户可根据实际情况选填
         // $unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号
         // $unifiedOrder->setParameter("device_info","XXXX");//设备号
         // $unifiedOrder->setParameter("attach","XXXX");//附加数据
         // $unifiedOrder->setParameter("time_start","XXXX");//交易起始时间
         // $unifiedOrder->setParameter("time_expire","XXXX");//交易结束时间
         // $unifiedOrder->setParameter("goods_tag","XXXX");//商品标记
         // $unifiedOrder->setParameter("openid","XXXX");//用户标识
         // $unifiedOrder->setParameter("product_id","XXXX");//商品ID
         $prepay_id = $unifiedOrder->getPrepayId();
         //var_dump($prepay_id);
         $jsApi = new JsApi_pub();
         $jsApi->setPrepayId($prepay_id);
         $jsApiParameters = $jsApi->getParameters();
         $pay_online = $jsApi->getbutton($jsApiParameters, $returnrul);
         return $pay_online;
     } else {
         $native = new NativeLink_pub($payment);
         //var_dump($order);die();
         $native->setParameter("body", $order['order_sn']);
         // 商品描述
         $timeStamp = time();
         // $out_trade_no = WxPayConf_pub::APPID."$timeStamp";
         $native->setParameter("appid", $conf->wxpay_app_id);
         // openid
         $native->setParameter("out_trade_no", $order['order_sn']);
         // 商户订单号
         $native->setParameter("total_fee", intval($order['order_amount'] * 100));
         // 总金额
         $native->setParameter("notify_url", $conf->notifyurl);
         // 通知地址
         $native->setParameter("trade_type", "NATIVE");
         // 交易类型
         $native->setParameter("product_id", $order['order_id']);
         $url = $native->getUrl();
         return $url;
         // 			// 非必填参数,商户可根据实际情况选填
         // 			// $unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号
         // 			// $unifiedOrder->setParameter("device_info","XXXX");//设备号
         // 			// $unifiedOrder->setParameter("attach","XXXX");//附加数据
         // 			 $unifiedOrder->setParameter("time_start",date ( "YmdHis" ));//交易起始时间
         // 			 $unifiedOrder->setParameter("time_expire",date ( "YmdHis", time () + 600 ));//交易结束时间
         // 			// $unifiedOrder->setParameter("goods_tag","XXXX");//商品标记
         // 			// $unifiedOrder->setParameter("openid","XXXX");//用户标识
         // 			// $unifiedOrder->setParameter("product_id","XXXX");//商品ID
     }
 }
Ejemplo n.º 3
0
 /**
  * 静态支付
  * return  $product_url  二维码链接
  */
 function NativeStaticInterface()
 {
     $nativeLink = new NativeLink_pub();
     $nativeLink->setParameter("product_id", WxPayConf_pub::APPID . "static");
     //商品id
     //获取链接
     $product_url = $nativeLink->getUrl();
     $shortUrl = new ShortUrl_pub();
     $shortUrl->setParameter("long_url", "{$product_url}");
     //URL链接
     $codeUrl = $shortUrl->getShortUrl();
     return $product_url;
 }
Ejemplo n.º 4
0
include_once "../WxPayPubHelper/WxPayPubHelper.php";
//设置静态链接
$nativeLink = new NativeLink_pub();
//设置静态链接参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//time_stamp已填,商户无需重复填写
//sign已填,商户无需重复填写
$product_id = WxPayConf_pub::APPID . "static";
//自定义商品id
$nativeLink->setParameter("product_id", "{$product_id}");
//商品id
//获取链接
$product_url = $nativeLink->getUrl();
//使用短链接转换接口
$shortUrl = new ShortUrl_pub();
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//sign已填,商户无需重复填写
$shortUrl->setParameter("long_url", "{$product_url}");
//URL链接
//获取短链接
$codeUrl = $shortUrl->getShortUrl();
?>

<!DOCTYPE HTML>
<html>
Ejemplo n.º 5
0
 public function native_pay()
 {
     //全局引入微信支付类
     Vendor('Wxpay.WxPayPubHelper.WxPayPubHelper');
     //设置静态链接
     $nativeLink = new \NativeLink_pub();
     //设置静态链接参数
     //设置必填参数
     //appid已填,商户无需重复填写
     //mch_id已填,商户无需重复填写
     //noncestr已填,商户无需重复填写
     //time_stamp已填,商户无需重复填写
     //sign已填,商户无需重复填写
     $product_id = \WxPayConf_pub::APPID . "static";
     //自定义商品id
     $nativeLink->setParameter("product_id", $product_id);
     //商品id
     //获取链接
     $product_url = $nativeLink->getUrl();
     //使用短链接转换接口
     $shortUrl = new \ShortUrl_pub();
     //设置必填参数
     //appid已填,商户无需重复填写
     //mch_id已填,商户无需重复填写
     //noncestr已填,商户无需重复填写
     //sign已填,商户无需重复填写
     $shortUrl->setParameter("long_url", $product_url);
     //URL链接
     //获取短链接
     $codeUrl = $shortUrl->getShortUrl();
     $this->assign('product_url', $product_url);
     $this->assign('codeUrl', $codeUrl);
     $this->display();
 }