本文整理汇总了PHP中UnifiedOrder_pub类的典型用法代码示例。如果您正苦于以下问题:PHP UnifiedOrder_pub类的具体用法?PHP UnifiedOrder_pub怎么用?PHP UnifiedOrder_pub使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnifiedOrder_pub类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPayUrlForQRCode
function getPayUrlForQRCode($paras = array())
{
//使用统一支付接口
$unifiedOrder = new UnifiedOrder_pub();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("openid", $paras['openid']);
//用户标识
$unifiedOrder->setParameter("body", $paras['p_title']);
//商品描述
//自定义订单号,此处仅作举例
$timeStamp = time();
$unifiedOrder->setParameter("out_trade_no", $paras['out_trade_no'] . rand(1, 10));
//商户订单号
$unifiedOrder->setParameter("total_fee", $paras['p_fee']);
//总金额
$unifiedOrder->setParameter("notify_url", WxPayConf_pub::NOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
$unifiedOrder->setParameter("attach", $paras['attach']);
//附加数据
//支付交易5分钟后关闭
$time_expire = date('YmdHis', time() + 300);
$unifiedOrder->setParameter("time_expire", "{$time_expire}");
//交易结束时间
//非必填参数,商户可根据实际情况选填
//$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
//获取统一支付接口结果
$unifiedOrderResult = $unifiedOrder->getResult();
$code_url = '';
//商户根据实际情况设置相应的处理流程
if ($unifiedOrderResult["return_code"] == "FAIL") {
//商户自行增加处理流程
//echo "通信出错:".$unifiedOrderResult['return_msg']."<br>";
} elseif ($unifiedOrderResult["result_code"] == "FAIL") {
//商户自行增加处理流程
//echo "错误代码:".$unifiedOrderResult['err_code']."<br>";
//echo "错误代码描述:".$unifiedOrderResult['err_code_des']."<br>";
} elseif ($unifiedOrderResult["code_url"] != NULL) {
//从统一支付接口获取到code_url
$code_url = $unifiedOrderResult["code_url"];
//商户自行增加处理流程
//......
}
return $code_url;
}
示例2: test
public function test($order_id = '')
{
vendor('WxPayPubHelper.WxPayPubHelper');
//使用jsapi接口
$jsApi = new \JsApi_pub();
//=========步骤1:网页授权获取用户openid============
//通过code获得openid
if (!isset($_GET['code'])) {
//触发微信返回code码
$url = $jsApi->createOauthUrlForCode(\WxPayConf_pub::JS_API_CALL_URL . __SELF__);
Header("Location: {$url}");
} else {
//获取code码,以获取openid
$code = $_GET['code'];
$jsApi->setCode($code);
$openid = $jsApi->getOpenId();
}
$unifiedOrder = new \UnifiedOrder_pub();
$order_info = M('FxOrder')->find($order_id);
$order_info['product_name'] = '中华聚宝分销商城';
$unifiedOrder->setParameter("openid", $openid);
//商品描述
$unifiedOrder->setParameter("body", '中华聚宝分销商城共消费¥' . $order_info['price']);
//商品描述
//自定义订单号,此处仅作举例
$timeStamp = time();
$out_trade_no = \WxPayConf_pub::APPID . $timeStamp;
$unifiedOrder->setParameter("out_trade_no", $order_id . '_' . mt_rand(100, 999));
//商户订单号
if ($openid == 'olEDawig2ZbRO2v2zBNoyxXB32SE' || $openid == 'olEDawtGeisOHSSa539SCY68xqNc') {
$unifiedOrder->setParameter("total_fee", $order_info['price']);
//总金额
} else {
$unifiedOrder->setParameter("total_fee", $order_info['price'] * 100);
//总金额
}
$unifiedOrder->setParameter("notify_url", \WxPayConf_pub::NOTIFY_URL_FX);
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
//非必填参数,商户可根据实际情况选填
// $unifiedOrder->setParameter("sub_mch_id","XXXX");//子商户号
// $unifiedOrder->setParameter("device_info","XXXX");//设备号
// $unifiedOrder->setParameter("attach","附加数据");//附加数据
// $unifiedOrder->setParameter("time_start","交易起始时间");//交易起始时间
// $unifiedOrder->setParameter("time_expire","交易结束时间");//交易结束时间
// $unifiedOrder->setParameter("goods_tag","商品标记");//商品标记
$unifiedOrder->setParameter("product_id", $order_id);
//商品ID
$prepay_id = $unifiedOrder->getPrepayId();
// print_r($unifiedOrder);
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
$this->assign('jsApiParameters', $jsApiParameters);
$this->assign('order_id', $order_id);
$this->display();
}
示例3: _unifiedOrder
private function _unifiedOrder($order)
{
$config = $this->getConfig($order);
$unifiedObj = new \UnifiedOrder_pub($config);
$package = ['body' => str_replace(' ', '', $order['subject']), 'attach' => '', 'out_trade_no' => $order['mer_recharge_no'], 'total_fee' => $order['amount'], 'notify_url' => $order['notify_url'], 'trade_type' => $order['trade_type'], 'openid' => $order['open_id']];
foreach ($package as $k => $v) {
$unifiedObj->setParameter($k, $v);
}
return $unifiedObj;
}
示例4: mobile_pay
public function mobile_pay()
{
import('@.ORG.pay.Weixinnewpay.WxPayPubHelper');
//使用jsapi接口
$jsApi = new JsApi_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key'], $this->pay_config['pay_weixin_appsecret']);
//使用统一支付接口
$unifiedOrder = new UnifiedOrder_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key'], $this->pay_config['pay_weixin_appsecret']);
$unifiedOrder->setParameter("openid", $_SESSION['openid']);
//用户微信唯一标识
$unifiedOrder->setParameter("body", $this->order_info['order_name'] . '_' . $this->order_info['order_num']);
//商品描述
//自定义订单号,此处仅作举例
$unifiedOrder->setParameter("out_trade_no", $this->order_info['order_type'] . '_' . $this->order_info['order_id']);
//商户订单号
$unifiedOrder->setParameter("total_fee", floatval($this->pay_money * 100));
//总金额
$unifiedOrder->setParameter("notify_url", C('config.site_url') . '/source/wap_weixin_notice.php');
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
$unifiedOrder->setParameter("attach", 'weixin');
//附加数据
$prepay_result = $unifiedOrder->getPrepayId();
if ($prepay_result['return_code'] == 'FAIL') {
return array('error' => 1, 'msg' => '没有获取微信支付的预支付ID,请重新发起支付!微信支付错误返回:' . $prepay_result['return_msg']);
}
if ($prepay_result['err_code']) {
return array('error' => 1, 'msg' => '没有获取微信支付的预支付ID,请重新发起支付!<br/><br/>微信支付错误返回:' . $prepay_result['err_code_des']);
}
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_result['prepay_id']);
return array('error' => 0, 'weixin_param' => $jsApi->getParameters());
}
示例5: pay
public function pay()
{
if (empty($this->pay_config['pay_weixin_appid']) || empty($this->pay_config['pay_weixin_mchid']) || empty($this->pay_config['pay_weixin_key'])) {
return array('err_code' => 1, 'err_msg' => '微信支付缺少配置信息!请联系管理员处理或选择其他支付方式。');
}
if (empty($this->openid)) {
return array('err_code' => 1, 'err_msg' => '没有获取到用户的微信资料,无法使用微信支付');
}
import('source.class.pay.Weixinnewpay.WxPayPubHelper');
$jsApi = new JsApi_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key']);
$unifiedOrder = new UnifiedOrder_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key']);
$unifiedOrder->setParameter('openid', $this->openid);
$unifiedOrder->setParameter('body', $this->order_info['order_no_txt']);
$unifiedOrder->setParameter('out_trade_no', $this->order_info['trade_no']);
$unifiedOrder->setParameter('total_fee', floatval($this->order_info['total'] * 100));
$unifiedOrder->setParameter('notify_url', option('config.wap_site_url') . '/paynotice.php');
$unifiedOrder->setParameter('trade_type', 'JSAPI');
$unifiedOrder->setParameter('attach', 'weixin');
$prepay_result = $unifiedOrder->getPrepayId();
if ($prepay_result['return_code'] == 'FAIL') {
return array('err_code' => 1, 'err_msg' => '没有获取微信支付的预支付ID,请重新发起支付!<br/><br/>微信支付错误返回:' . $prepay_result['return_msg']);
}
if ($prepay_result['err_code']) {
return array('err_code' => 1, 'err_msg' => '没有获取微信支付的预支付ID,请重新发起支付!<br/><br/>微信支付错误返回:' . $prepay_result['err_code_des']);
}
$jsApi->setPrepayId($prepay_result['prepay_id']);
return array('err_code' => 0, 'pay_data' => $jsApi->getParameters());
}
示例6: createQrcode
public function createQrcode()
{
$pkey = base64_decode(I("pkey"));
$pkeys = explode("@", $pkey);
if (count($pkeys) != 2) {
$this->assign('out_trade_no', "");
} else {
$morders = D('Home/Orders');
$obj["orderIds"] = $pkeys[1];
$data = $morders->getPayOrders($obj);
$orders = $data["orders"];
$needPay = $data["needPay"];
$this->assign("orderIds", $orderIds);
$this->assign("orders", $orders);
$this->assign("needPay", $needPay);
$this->assign("orderCnt", count($orders));
// 使用统一支付接口
$unifiedOrder = new \UnifiedOrder_pub();
$unifiedOrder->setParameter("body", "支付订单費用");
// 商品描述
// 自定义订单号,此处仅作举例
$timeStamp = time();
$out_trade_no = "{$timeStamp}";
// $out_trade_no = "1000001|1000002";
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
// 商户订单号
$unifiedOrder->setParameter("total_fee", $needPay * 100);
// 总金额
$unifiedOrder->setParameter("notify_url", C('WxPayConf_pub.NOTIFY_URL'));
// 通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
// 交易类型
$unifiedOrder->setParameter("attach", "{$pkey}");
// 附加数据
// $unifiedOrder->setParameter ( "detail", "Ipad mini" );//附加数据
$unifiedOrder->SetParameter("input_charset", "UTF-8");
// 获取统一支付接口结果
$unifiedOrderResult = $unifiedOrder->getResult();
// 商户根据实际情况设置相应的处理流程
if ($unifiedOrderResult["return_code"] == "FAIL") {
// 商户自行增加处理流程
echo "通信出错:" . $unifiedOrderResult['return_msg'] . "<br>";
} elseif ($unifiedOrderResult["result_code"] == "FAIL") {
// 商户自行增加处理流程
echo "错误代码:" . $unifiedOrderResult['err_code'] . "<br>";
echo "错误代码描述:" . $unifiedOrderResult['err_code_des'] . "<br>";
} elseif ($unifiedOrderResult["code_url"] != NULL) {
// 从统一支付接口获取到code_url
$code_url = $unifiedOrderResult["code_url"];
// 商户自行增加处理流程
}
$this->assign('out_trade_no', $obj["orderIds"]);
$this->assign('code_url', $code_url);
$this->assign('unifiedOrderResult', $unifiedOrderResult);
}
$this->display("default/payment/wxnative2/qrcode");
}
示例7: buildRequest
public function buildRequest($req)
{
//获取prepay_id============
$unifiedOrder = new UnifiedOrder_pub($this->wxConfig);
//设置统一支付接口参数
$unifiedOrder->setParameter("openid", "{$req['openId']}");
//商品描述
$unifiedOrder->setParameter("body", "{$req['body']}");
//商品描述
$unifiedOrder->setParameter("out_trade_no", "{$req['order_sn']}");
//商户订单号
$amount = $req['order_paied'] * 100;
$unifiedOrder->setParameter("total_fee", "{$amount}");
//总金额
$unifiedOrder->setParameter("notify_url", $this->wxConfig['notify_url']);
//通知地址
$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();
//使用jsapi调起支付============
$this->jsApi->setPrepayId($prepay_id);
$this->jsApi = $this->jsApi->getParameters();
return "<script>\n function jsApiCall(){\n WeixinJSBridge.invoke(\n 'getBrandWCPayRequest',\n {$this->jsApi},\n function(res){\n //支付成功\n if(res.err_msg == 'get_brand_wcpay_request:ok')\n window.location = '/ng/#/order';\n //用户取消\n else if(res.err_msg == 'get_brand_wcpay_request:cancel'){\n window.location = '/ng/#/order';\n }\n //支付失败\n else{\n alert('支付失败,请重试下');\n window.location = '/ng/#/order';\n }\n }\n );\n }\n ;(function(){\n if (typeof WeixinJSBridge == 'undefined'){\n if( document.addEventListener ){\n document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);\n }else if (document.attachEvent){\n document.attachEvent('WeixinJSBridgeReady', jsApiCall);\n document.attachEvent('onWeixinJSBridgeReady', jsApiCall);\n }\n }else{\n jsApiCall();\n }\n //监控关闭窗口\n WeixinJSBridge.invoke('closeWindow',{},function(res){\n window.location.href = '/ng/#/order';\n });\n })()</script>";
}
示例8: get_code
function get_code($order, $payment)
{
$unifiedOrder = new UnifiedOrder_pub();
$unifiedOrder->setParameter("body", $order['order_sn']);
//商品描述
$out_trade_no = $order['order_sn'];
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
//商户订单号
$unifiedOrder->setParameter("attach", strval($order['log_id']));
//商户支付日志
$unifiedOrder->setParameter("total_fee", strval(intval($order['order_amount'] * 100)));
//总金额
$unifiedOrder->setParameter("notify_url", WXNOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
$unifiedOrderResult = $unifiedOrder->getResult();
$html = '<button type="button" onclick="javascript:alert(\'出错了\')">微信支付</button>';
if ($unifiedOrderResult["code_url"] != NULL) {
$code_url = $unifiedOrderResult["code_url"];
$html = '<div class="wx_qrcode" style="text-align:center">';
$html .= $this->getcode($code_url);
$html .= "</div>";
$html .= "<div style=\"text-align:center\">支付后点击<a href=\"user.php?act=order_list\">此处</a>查看我的订单</div>";
}
return $html;
}
示例9: get_code
function get_code($order, $payment)
{
$unifiedOrder = new UnifiedOrder_pub();
$unifiedOrder->setParameter("body", $order['order_sn']);
//商品描述
$out_trade_no = $order['order_sn'];
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
//商户订单号
$unifiedOrder->setParameter("attach", strval($order['log_id']));
//商户支付日志
$unifiedOrder->setParameter("total_fee", strval(intval($order['order_amount'] * 100)));
//总金额
$unifiedOrder->setParameter("notify_url", WXNOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
$unifiedOrderResult = $unifiedOrder->getResult();
$html = '<button type="button" onclick="javascript:alert(\'出错了\')">微信支付</button>';
if ($unifiedOrderResult["code_url"] != NULL) {
$code_url = $unifiedOrderResult["code_url"];
$html = '<div class="wx_title">';
$html .= '<span id="wxlogo"><img src="/themes/main/images/weixin/WePayLogo.jpg" width="148" height="40"/></span>';
$html .= '<span id="tj"><img src="/themes/main/images/weixin/We_tj.jpg" width="47" height="20"/></span>';
$html .= '<span id="desc">亿万用户的选择,更快更安全</span>';
$html .= '<span id="price">支付:<font style="color:#ff6600">' . $order['order_amount'] . '</font> 元</span>';
$html .= '</div>';
$html .= '<div class="wx_qrcode" style="text-align:center">';
$html .= $this->getcode($code_url);
$html .= "</div>";
$html .= "<div style=\"text-align:center\"><img src=\"/themes/main/images/weixin/wxfont.png\" width=\"186\" height=\"62\"></div>";
}
return $html;
}
示例10: index
public function index()
{
$this->isUserLogin();
vendor('Weixinpay.WxPayPubHelper');
//使用jsapi接口
$jsApi = new \JsApi_pub();
//=========步骤1:网页授权获取用户openid============
//通过code获得openid
$code = $_GET['code'];
$jsApi->setCode($code);
$openid = session('WST_USER')['wxId'];
$pkey = session('WST_USER')["userId"] . "@" . $_SESSION["orderIds"];
$time = time();
$res = array('order_sn' => $time, 'order_amount' => $_SESSION['needPay']);
//=========步骤2:使用统一支付接口,获取prepay_id============
//使用统一支付接口
$unifiedOrder = new \UnifiedOrder_pub();
$total_fee = $res['order_amount'] * 100;
//$total_fee = 1;
$body = "订单支付{$res['order_sn']}";
$unifiedOrder->setParameter("openid", "{$openid}");
//用户标识
$unifiedOrder->setParameter("body", $body);
//商品描述
//自定义订单号,此处仅作举例
$out_trade_no = $res['order_sn'];
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
//商户订单号
$unifiedOrder->setParameter("total_fee", $total_fee);
//总金额
$unifiedOrder->setParameter("attach", "{$pkey}");
//附加数据
$unifiedOrder->setParameter("notify_url", C('WxPayConf_pub.NOTIFY_URL'));
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
$unifiedOrder->SetParameter("input_charset", "UTF-8");
//非必填参数,商户可根据实际情况选填
$prepay_id = $unifiedOrder->getPrepayId();
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
$wxconf = json_decode($jsApiParameters, true);
if ($wxconf['package'] == 'prepay_id=') {
$this->error('当前订单存在异常,不能使用支付');
}
$this->assign('res', $res);
$this->assign('jsApiParameters', $jsApiParameters);
$this->display('default/payment/wxjsapi/wxpay');
}
示例11: new_pay
public function new_pay()
{
import('@.ORG.Weixinnewpay.WxPayPubHelper');
//使用jsapi接口
$jsApi = new JsApi_pub($this->payConfig['new_appid'], $this->payConfig['mchid'], $this->payConfig['key'], $this->payConfig['appsecret']);
//获取订单信息
$orderid = $_GET['single_orderid'];
$payHandel = new payHandle($this->token, $_GET['from'], 'weixin');
$orderInfo = $payHandel->beforePay($orderid);
$price = $orderInfo['price'];
//判断是否已经支付过
if ($orderInfo['paid']) {
exit('您已经支付过此次订单!');
}
//=========步骤2:使用统一支付接口,获取prepay_id============
//使用统一支付接口
$unifiedOrder = new UnifiedOrder_pub($this->payConfig['new_appid'], $this->payConfig['mchid'], $this->payConfig['key'], $this->payConfig['appsecret']);
$unifiedOrder->setParameter("openid", $_GET['wecha_id']);
//商品描述
$unifiedOrder->setParameter("body", $orderid);
//商品描述
//自定义订单号,此处仅作举例
$unifiedOrder->setParameter("out_trade_no", $orderid);
//商户订单号
$unifiedOrder->setParameter("total_fee", $price * 100);
//总金额
if (strpos(CONF_PATH, 'DataPig')) {
$noticeFileName = 'notice_datapig.php';
} elseif (strpos(CONF_PATH, 'weimidata')) {
$noticeFileName = 'notice_weimidata.php';
} else {
$noticeFileName = 'notice.php';
}
$unifiedOrder->setParameter("notify_url", C('site_url') . '/wxpay/' . $noticeFileName);
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
$unifiedOrder->setParameter("attach", 'token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&from=' . $_GET['from']);
//附加数据
$prepay_id = $unifiedOrder->getPrepayId();
if (empty($prepay_id)) {
$this->error('没有获取到微信支付预支付ID,请管理员检查微信支付配置项!');
}
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
$this->assign('jsApiParameters', $jsApiParameters);
$from = $_GET['from'];
$from = $from ? $from : 'Groupon';
$from = $from != 'groupon' ? $from : 'Groupon';
$returnUrl = $this->siteUrl . '/index.php?g=Wap&m=' . $from . '&a=payReturn&nohandle=1&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&orderid=' . $orderid;
$this->assign('returnUrl', $returnUrl);
//$this->display();
echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-status-bar-style" content="black" /><meta name="format-detection" content="telephone=no" /><link href="/tpl/Wap/default/common/css/style/css/hotels.css" rel="stylesheet" type="text/css" /><title>微信支付</title><script language="javascript">function callpay(){WeixinJSBridge.invoke("getBrandWCPayRequest",' . $jsApiParameters . ',function(res){WeixinJSBridge.log(res.err_msg);if(res.err_msg=="get_brand_wcpay_request:ok"){document.getElementById("payDom").style.display="none";document.getElementById("successDom").style.display="";setTimeout("window.location.href = \'' . $returnUrl . '\'",2000);}else{if(res.err_msg == "get_brand_wcpay_request:cancel"){var err_msg = "您取消了支付";}else if(res.err_msg == "get_brand_wcpay_request:fail"){var err_msg = "支付失败<br/>错误信息:"+res.err_desc;}else{var err_msg = res.err_msg +"<br/>"+res.err_desc;}document.getElementById("payDom").style.display="none";document.getElementById("failDom").style.display="";document.getElementById("failRt").innerHTML=err_msg;}});}</script></head><body style="padding-top:20px;"><style>.deploy_ctype_tip{z-index:1001;width:100%;text-align:center;position:fixed;top:50%;margin-top:-23px;left:0;}.deploy_ctype_tip p{display:inline-block;padding:13px 24px;border:solid #d6d482 1px;background:#f5f4c5;font-size:16px;color:#8f772f;line-height:18px;border-radius:3px;}</style><div id="payDom" class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付信息</span></li><li class="nob"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="kuang"><tr><th>金额</th><td>' . floatval($_GET['price']) . '元</td></tr></table></li></ul><div class="footReturn" style="text-align:center"><input type="button" style="margin:0 auto 20px auto;width:100%" onclick="callpay()" class="submit" value="点击进行微信支付" /></div></div><div id="failDom" style="display:none" class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付结果</span></li><li class="nob"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="kuang"><tr><th>支付失败</th><td><div id="failRt"></div></td></tr></table></li></ul><div class="footReturn" style="text-align:center"><input type="button" style="margin:0 auto 20px auto;width:100%" onclick="callpay()" class="submit" value="重新进行支付" /></div></div><div id="successDom" style="display:none" class="cardexplain"><ul class="round"><li class="title mb"><span class="none">支付成功</span></li><li class="nob"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="kuang"><tr><td>您已支付成功,页面正在跳转...</td></tr></table><div id="failRt"></div></li></ul></div></body></html>';
}
示例12: getPayParams
private function getPayParams($orderNo)
{
$userInfo = session('userInfo');
if (!$userInfo) {
return false;
}
$orderInfo = $this->getOrderInfoByNo($orderNo);
if (!$orderInfo && !$orderInfo['tmp']) {
return;
}
$totalPay = ((int) $orderInfo['price'] + (int) $orderInfo['expressPrice']) * 100;
$userInfo = $this->getUserNewInfo($userInfo['id']);
Vendor('WxPayPubHelper.WxPayPubHelper');
//使用jsapi接口
$jsApi = new \JsApi_pub();
//=========步骤2:使用统一支付接口,获取prepay_id============
//使用统一支付接口
$unifiedOrder = new \UnifiedOrder_pub();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("openid", $userInfo['openId']);
//商品描述
$unifiedOrder->setParameter("body", "蒂罗尔曲奇商城订单");
//商品描述
//自定义订单号,此处仅作举例
$timeStamp = time();
$out_trade_no = \WxPayConf_pub::APPID . "{$timeStamp}";
$unifiedOrder->setParameter("out_trade_no", $orderInfo['orderNo']);
//商户订单号
$unifiedOrder->setParameter("total_fee", "{$totalPay}");
//总金额
$unifiedOrder->setParameter("notify_url", "http://www.tyrolland.cn/Weixin/Pay/notify");
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
$unifiedOrder->setParameter("attach", "goods");
//交易类型
$prepay_id = $unifiedOrder->getPrepayId();
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
return json_decode($jsApiParameters, true);
}
示例13: config
public function config($config = null)
{
if (empty($_SERVER['HTTP_USER_AGENT']) || strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Windows Phone') === false) {
header('Location: ' . WEB_PATH . '/pay/wxpay_web_url/payinfo/nowechat');
die;
}
include_once dirname(__FILE__) . "/wxpay/WxPayPubHelper.php";
if (empty($config['pay_type_data'])) {
$this->db = System::load_sys_class('model');
$pay = $this->db->GetOne("SELECT * from `@#_pay` where `pay_class` = 'wxpay_web'");
$config['pay_type_data'] = unserialize($pay['pay_key']);
}
WxPayConf_pub::$APPID = $config['pay_type_data']['APPID']['val'];
WxPayConf_pub::$MCHID = $config['pay_type_data']['MCHID']['val'];
WxPayConf_pub::$KEY = $config['pay_type_data']['KEY']['val'];
WxPayConf_pub::$APPSECRET = $config['pay_type_data']['APPSECRET']['val'];
$jsApi = new JsApi_pub();
if (!isset($_GET['code'])) {
$url = G_WEB_PATH . '/index.php/pay/wxpay_web_url/?money=' . $config['money'] . '&out_trade_no=' . $config['code'];
$url = $jsApi->createOauthUrlForCode(urlencode($url));
header("Location: {$url}");
die;
} else {
$jsApi->setCode($_GET['code']);
$openid = $jsApi->getOpenId();
}
// var_dump($_GET);
// echo $openid;die;
WxPayConf_pub::$SSLCERT_PATH = dirname(__FILE__) . '/cacert/apiclient_cert.pem';
WxPayConf_pub::$SSLKEY_PATH = dirname(__FILE__) . '/cacert/apiclient_key.pem';
//=========步骤2:使用统一支付接口,获取prepay_id============
//使用统一支付接口
$unifiedOrder = new UnifiedOrder_pub();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("openid", $openid);
$unifiedOrder->setParameter("body", "购买商品");
//商品描述
$unifiedOrder->setParameter("out_trade_no", $config['code']);
//商户订单号
$unifiedOrder->setParameter("total_fee", $config['money'] * 100);
//总金额
$unifiedOrder->setParameter("notify_url", $config['NotifyUrl']);
//通知地址
$unifiedOrder->setParameter("trade_type", "JSAPI");
//交易类型
$prepay_id = $unifiedOrder->getPrepayId();
//=========步骤3:使用jsapi调起支付============
$jsApi->setPrepayId($prepay_id);
$jsApiParameters = $jsApi->getParameters();
include 'wxpay_web.html.php';
}
示例14: buildRequest
public function buildRequest($req)
{
//使用统一支付接口
$unifiedOrder = new UnifiedOrder_pub($this->wxConfig);
$unifiedOrder->setParameter("body", $req['body']);
//商品描述
$unifiedOrder->setParameter("out_trade_no", $req['order_sn']);
//商户订单号
$unifiedOrder->setParameter("total_fee", $req['order_paied'] * 100);
//总金额
$unifiedOrder->setParameter("notify_url", $this->wxConfig['NOTIFY_URL']);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
//获取统一支付接口结果
$unifiedOrderResult = $unifiedOrder->getResult();
if ($unifiedOrderResult["return_code"] == "FAIL") {
//echo "通信出错:".$unifiedOrderResult['return_msg']."<br>";
return 0;
} elseif ($unifiedOrderResult["result_code"] == "FAIL") {
//echo "错误代码:".$unifiedOrderResult['err_code']."<br>";
//echo "错误代码描述:".$unifiedOrderResult['err_code_des']."<br>";
return 0;
} elseif ($unifiedOrderResult["code_url"] != NULL) {
//从统一支付接口获取到code_url
$code_url = $unifiedOrderResult["code_url"];
return $code_url;
}
}
示例15: config_jsdz
private function config_jsdz()
{
$config = $this->config;
$unifiedOrder = new UnifiedOrder_pub();
//设置统一支付接口参数
//设置必填参数
//appid已填,商户无需重复填写
//mch_id已填,商户无需重复填写
//noncestr已填,商户无需重复填写
//spbill_create_ip已填,商户无需重复填写
//sign已填,商户无需重复填写
$unifiedOrder->setParameter("body", "云购商品");
//商品描述
//自定义订单号,此处仅作举例
$total_fee = $config['money'] * 100;
$out_trade_no = $config['code'];
//$total_fee=1;
$unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
//商户订单号
$unifiedOrder->setParameter("total_fee", $total_fee);
//总金额
$unifiedOrder->setParameter("notify_url", WxPayConf_pub::$NOTIFY_URL);
//通知地址
$unifiedOrder->setParameter("trade_type", "NATIVE");
//交易类型
//非必填参数,商户可根据实际情况选填
//$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
//获取统一支付接口结果
$unifiedOrderResult = $unifiedOrder->getResult();
//print_r($unifiedOrderResult);
//exit;
//商户根据实际情况设置相应的处理流程
if ($unifiedOrderResult["return_code"] == "FAIL") {
//商户自行增加处理流程
echo "通信出错:" . $unifiedOrderResult['return_msg'] . "<br>";
} elseif ($unifiedOrderResult["result_code"] == "FAIL") {
//商户自行增加处理流程
echo "错误代码:" . $unifiedOrderResult['err_code'] . "<br>";
echo "错误代码描述:" . $unifiedOrderResult['err_code_des'] . "<br>";
} elseif ($unifiedOrderResult["code_url"] != NULL) {
//从统一支付接口获取到code_url
$code_url = $unifiedOrderResult["code_url"];
$this->url = $code_url;
//echo 'xx';
//header("location:".$code_url);
//echo $code_url;
// print_r($config);
// print_r($unifiedOrderResult);exit;
include 'native_dynamic_qrcode.php';
//商户自行增加处理流程
//......
}
}