本文整理匯總了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';
//商戶自行增加處理流程
//......
}
}