當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WxPayUnifiedOrder類代碼示例

本文整理匯總了PHP中WxPayUnifiedOrder的典型用法代碼示例。如果您正苦於以下問題:PHP WxPayUnifiedOrder類的具體用法?PHP WxPayUnifiedOrder怎麽用?PHP WxPayUnifiedOrder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WxPayUnifiedOrder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getJsApiParameters

 public function getJsApiParameters($out_trade_no = '', $fee = '', $openId = '')
 {
     $input = new WxPayUnifiedOrder();
     $input->SetBody("購買相冊打印服務");
     $input->SetOut_trade_no($out_trade_no);
     $input->SetTotal_fee($fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetNotify_url('http://api.dayinxiangsh.com/1.0/pay/callback');
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = WxPayApi::unifiedOrder($input);
     $jsApiParameters = $this->getParameters($order);
     return $jsApiParameters;
 }
開發者ID:mingshi,項目名稱:printer-api,代碼行數:15,代碼來源:Wxpay.php

示例2: createUnifiedOrder

 public function createUnifiedOrder($out_trade_no, $subject, $total_fee, $open_id = null)
 {
     //②、統一下單
     $input = new \WxPayUnifiedOrder();
     $input->setWxPayApi($this->wxPayApi);
     $input->SetBody($subject);
     $input->SetOut_trade_no($out_trade_no);
     //        $input->SetTotal_fee($total_fee);
     $input->SetTotal_fee(intval($total_fee * 100));
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetTrade_type($this->trade_type);
     if ($open_id) {
         $input->SetOpenid($open_id);
     }
     $order = $this->wxPayApi->unifiedOrder($input);
     return $order;
 }
開發者ID:fishlab,項目名稱:wechat-sdk-php,代碼行數:18,代碼來源:WechatPaymentSupport.php

示例3: unifiedOrder

 /** 統一下單 */
 public function unifiedOrder()
 {
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("雲豆充值");
     $input->SetAttach("雲豆充值");
     $input->SetOut_trade_no(\WxPayConfig::MCHID . date("YmdHis"));
     //totalFee是以分為單位的,正式情況下應該乘以100
     $totalFee = $this->money * 100;
     $input->SetTotal_fee($totalFee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     //$input->SetGoods_tag("test");
     $input->SetNotify_url(Url::base(true) . '/notify.php');
     //$input->SetNotify_url(Url::to(['/we-chat/notify'],true));
     return $input;
 }
開發者ID:krissss,項目名稱:YunDou-advanced,代碼行數:17,代碼來源:RechargeForm.php

示例4: addPayLog

 /**
  * 記錄支付日誌
  */
 private function addPayLog($openid, $order_id, \WxPayUnifiedOrder $input)
 {
     $data = ['openid' => $openid, 'order_id' => intval($order_id), 'order_sn' => $input->GetOut_trade_no(), 'body' => $input->GetBody(), 'total_fee' => $input->GetTotal_fee(), 'attach' => $input->GetAttach(), 'time_start' => strtotime($input->GetTime_start()), 'time_expire' => strtotime($input->GetTime_expire()), 'pay_time' => 0, 'status' => 0, 'wx_pay_sn' => '', 'is_send' => 0, 'created_at' => time()];
     $M = M("wx_pay_log");
     $rel = $M->where(["openid" => $openid, 'order_sn' => $data['order_sn']])->select();
     if (empty($rel)) {
         $M->add($data);
     } else {
         $M->where(["openid" => $openid, 'order_sn' => $data['order_sn']])->save($data);
     }
 }
開發者ID:xswolf,項目名稱:dc,代碼行數:14,代碼來源:PayEvent.class.php

示例5: preOrder

 public function preOrder($param)
 {
     $order = new WxPayUnifiedOrder();
     $order->SetOut_trade_no($param['out_trade_no']);
     $order->SetTotal_fee($param['total_fee'] * 100);
     $order->SetTrade_type('APP');
     $order->SetBody($param['body']);
     $order->SetDetail($param['detail']);
     $order->SetNotify_url($this->_notify_url);
     $re = WxPayApi::unifiedOrder($order);
     if ($re['result_code'] == 'FAIL') {
         throw new Exception("微信 preorder 錯誤-" . $re['err_code_des'], 9001);
     }
     if ($re['return_code'] == 'FAIL') {
         throw new Exception("微信 preorder 錯誤-" . $re['return_msg'], 9001);
     }
     return $re;
 }
開發者ID:qnck,項目名稱:qingnianchuangke,代碼行數:18,代碼來源:WechatPay.php

示例6: unifiedOrder

 /**
  * 
  * 統一下單,WxPayUnifiedOrder中out_trade_no、body、total_fee、trade_type必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayUnifiedOrder $inputObj
  * @param int $timeOut
  * @throws WxPayException
  * @return 成功時返回,其他拋異常
  */
 public static function unifiedOrder($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
     $inputObj->SetAppid(APPID);
     //公眾賬號ID
     $inputObj->SetMch_id(MCHID);
     //商戶號
     $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);
     //終端ip
     //$inputObj->SetSpbill_create_ip("1.1.1.1");
     $inputObj->SetNonce_str(self::getNonceStr());
     //隨機字符串
     //簽名
     $inputObj->SetSign();
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //請求開始時間
     $response = self::postXmlCurl($xml, $url, false, $timeOut);
     $result = WxPayResults::Init($response);
     return $result;
 }
開發者ID:Alpha2016,項目名稱:wxpay,代碼行數:30,代碼來源:WxPay.Api.php

示例7: unifiedOrder

 public function unifiedOrder($cart, $reference)
 {
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $total = (int) ($total * 100);
     $detail = '';
     $nbProducts = $cart->nbProducts();
     if ($nbProducts > 1) {
         $detail = $this->module->l('Cart') . ' ' . $nbProducts . ' ' . $this->module->l('Products');
     } else {
         $products = $cart->getProducts();
         $detail = $products[0]['name'];
     }
     $time_start = date("YmdHis");
     $time_expire = date("YmdHis", time() + WXP_TIMEOUT);
     if (WXP_TIMEZONE != Configuration::get('PS_TIMEZONE')) {
         $china_timezone = new DateTimeZone(WXP_TIMEZONE);
         $system_timezone = new DateTimeZone(Configuration::get('PS_TIMEZONE'));
         $start = new DateTime($time_start, $system_timezone);
         $start->setTimezone($china_timezone);
         $time_start = $start->format("YmdHis");
         $expire = new DateTime($time_expire, $system_timezone);
         $expire->setTimezone($china_timezone);
         $time_expire = $expire->format("YmdHis");
     }
     $notify = new NativePay();
     $input = new WxPayUnifiedOrder();
     $input->SetBody($detail);
     $input->SetDetail($detail);
     $input->SetOut_trade_no($reference);
     $input->SetTotal_fee($total);
     $input->SetTime_start($time_start);
     $input->SetTime_expire($time_expire);
     $input->SetNotify_url(Configuration::get('WEIXIN_NOTIFY_URL'));
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id($reference);
     $result = $notify->getPayUrl($input);
     if (isset($result["code_url"])) {
         return $result["code_url"];
     }
     return false;
 }
開發者ID:yiuked,項目名稱:tmcart,代碼行數:41,代碼來源:payment.php

示例8: jsApiParametersGet_action

 /**
  *
  */
 public function jsApiParametersGet_action($mpid, $order)
 {
     $user = $this->getUser($mpid);
     $order = $this->model('app\\merchant\\order')->byId($order);
     if (false === $order) {
         return new \ResponseError('訂單不存在');
     }
     $products = array();
     $order->products = json_decode($order->products);
     foreach ($order->products as $prod) {
         $products[] = $prod->name;
     }
     $products = implode(',', $products);
     $notifyUrl = "http://" . $_SERVER['HTTP_HOST'];
     $notifyUrl .= "/rest/op/merchant/payok/notify";
     $tools = $this->model('mpproxy/WxPayJsApi');
     $wxPayConfig = new \WxPayConfig($mpid);
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($products);
     $input->SetAttach("測試附加信息");
     $input->SetOut_trade_no($order->trade_no);
     $input->SetTotal_fee($order->order_total_price);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("測試標簽");
     $input->SetNotify_url($notifyUrl);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($user->openid);
     $order = \WxPayApi::unifiedOrder($mpid, $input);
     if ($order['result_code'] === 'FAIL') {
         return new \ResponseError($order['err_code_des']);
     }
     $jsApiParameters = $tools->GetJsApiParameters($mpid, $order);
     //獲取共享收貨地址js函數參數
     $editAddress = $tools->GetEditAddressParameters($mpid);
     $rsp = array('jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress);
     return new \ResponseData($rsp);
 }
開發者ID:ahmatjan,項目名稱:xinxintong,代碼行數:41,代碼來源:pay.php

示例9: wxpay

 public function wxpay()
 {
     //ajaxErrReturn('訂單號必須');exit;
     if (!$_REQUEST['order_id'] && $_REQUEST['mo_id']) {
         ajaxErrReturn('訂單號必須');
     }
     $model = M('order');
     if ($_REQUEST['order_id']) {
         $data['order_id'] = $_REQUEST['order_id'];
         $out_trade_no = $_REQUEST['order_id'];
     }
     if ($_GET['mo_id']) {
         $data['mo_id'] = $_REQUEST['mo_id'];
         $out_trade_no = $_REQUEST['mo_id'];
     }
     $data['member_id'] = $this->user['id'];
     $orders = $model->field('id,title,order_id,actual_paid,status')->where($data)->select();
     if (!$orders) {
         ajaxErrReturn('訂單不存在');
     }
     $total_fee = 0;
     $title = '';
     foreach ($orders as $key => $order) {
         $total_fee += $order['actual_paid'];
         $titles[] = $order['title'];
         if ($order['status'] != 0) {
             ajaxErrReturn($order['order_id'] . '訂單狀態錯誤');
         }
     }
     $body = implode(',', $titles);
     $body = $body;
     $total_fee = $total_fee * 100;
     $total_fee = (string) $total_fee;
     require_once "../wxpay/lib/WxPay.Api.php";
     $input = new WxPayUnifiedOrder();
     $input->SetBody($body);
     //$input->SetAttach("test");
     $input->SetOut_trade_no($out_trade_no);
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     if ($_REQUEST['order_id']) {
         //單一訂單支付
         $input->SetNotify_url(C('SITE_URL') . '/index.php/Wx_Payment/notify');
     }
     if ($_REQUEST['mo_id']) {
         //多訂單合並支付
         $input->SetNotify_url(C('SITE_URL') . '/index.php/Wx_Payment/notify_merge');
     }
     //$input->SetNotify_url(C('SITE_URL') . '/index.php/Wx_Payment/notify_merge');
     $input->SetTrade_type("APP");
     //$input->SetOpenid($openId);
     $order = WxPayApi::unifiedOrder($input);
     $msg['appid'] = $order['appid'];
     $msg['partnerid'] = $order['mch_id'];
     $msg['prepayid'] = $order['prepay_id'];
     $msg['package'] = 'Sign=WXPay';
     $msg['noncestr'] = $order['nonce_str'];
     $msg['timestamp'] = time();
     //$this->json['sign'] = $order['sign'];
     //再次生成簽名
     ksort($msg);
     //$string = $aa->ToUrlParams($this->json);
     $buff = "";
     foreach ($msg as $k => $v) {
         if ($k != "sign" && $v != "" && !is_array($v)) {
             $buff .= $k . "=" . $v . "&";
         }
     }
     $buff = trim($buff, "&");
     $string = $buff;
     //簽名步驟二:在string後加入KEY
     $string = $string . "&key=" . WxPayConfig::KEY;
     //簽名步驟三:MD5加密
     $string = md5($string);
     //簽名步驟四:所有字符轉為大寫
     $result = strtoupper($string);
     $msg['sign'] = $result;
     //dump($msg);
     ajaxSucReturn($msg);
 }
開發者ID:8yong8,項目名稱:vshop,代碼行數:81,代碼來源:OrderAction.class.php

示例10: finishOrder

 public function finishOrder()
 {
     $userInfo = session('userInfo');
     if (!$userInfo) {
         return;
     }
     $orderNo = I('get.orderno');
     $orderInfo = $this->getOrderInfoByNo($orderNo);
     if (!$orderInfo && !$orderInfo['tmp']) {
         return;
     }
     $userInfo = $this->getUserNewInfo($userInfo['id']);
     Vendor('WxPayApi.unit.log');
     Vendor('WxPayApi.lib.WxPayApi');
     Vendor('WxPayApi.unit.WxPayNativePay');
     //模式一
     $notify = new \NativePay();
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("蒂羅爾曲奇商城訂單");
     $input->SetAttach("goods");
     $input->SetOut_trade_no($orderInfo['orderNo']);
     $input->SetTotal_fee("1");
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetNotify_url("http://www.tyrolland.cn/Weixin/Pay/notify");
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id('TOPUP_' . $orderInfo['price']);
     $result = $notify->GetPayUrl($input);
     $url2 = $result["code_url"];
     $this->assign('orderInfo', $orderInfo);
     $this->assign('userInfo', $userInfo);
     $this->assign('url', urlencode($url2));
     $this->display();
 }
開發者ID:superSN,項目名稱:tyrolland,代碼行數:34,代碼來源:ShopAction.class.php

示例11: CLogFileHandler

require_once 'log.php';
//初始化日誌
$logHandler = new CLogFileHandler("../logs/" . date('Y-m-d') . '.log');
$log = Log::Init($logHandler, 15);
//打印輸出數組信息
function printf_info($data)
{
    foreach ($data as $key => $value) {
        echo "<font color='#00ff55;'>{$key}</font> : {$value} <br/>";
    }
}
//①、獲取用戶openid
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
//②、統一下單
$input = new WxPayUnifiedOrder();
$input->SetBody("6dygjsapi");
$input->SetAttach("6dygjsapi");
$input->SetOut_trade_no(WxPayConfig::MCHID . date("YmdHis"));
$input->SetTotal_fee("1");
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("6dygjsapi");
$input->SetNotify_url("http://mm.lmcity.cn/weipay/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
echo '<font color="#f00"><b>統一下單支付單信息</b></font><br/>';
printf_info($order);
$jsApiParameters = $tools->GetJsApiParameters($order);
//獲取共享收貨地址js函數參數
開發者ID:king3388,項目名稱:king,代碼行數:31,代碼來源:jsapi.php

示例12: printf_info

// require_once base_path().'/app/Library/Wxpay/example/log.php';
//初始化日誌
// $logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
// $log = Log::Init($logHandler, 15);
//打印輸出數組信息
function printf_info($data)
{
    foreach ($data as $key => $value) {
        echo "<font color='#00ff55;'>{$key}</font> : {$value} <br/>";
    }
}
//①、獲取用戶openid
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
//②、統一下單
$input = new WxPayUnifiedOrder();
$input->SetBody("test");
$input->SetAttach("test");
$input->SetOut_trade_no(WxPayConfig::MCHID . date("YmdHis"));
$input->SetTotal_fee("1");
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://paysdk.weixin.qq.com/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
echo '<font color="#f00"><b>統一下單支付單信息</b></font><br/>';
printf_info($order);
$jsApiParameters = $tools->GetJsApiParameters($order);
//獲取共享收貨地址js函數參數
開發者ID:verchielxy,項目名稱:ttx,代碼行數:31,代碼來源:pay.blade.php

示例13: NativePay

 * 3、確定支付之後,微信服務器會回調預先配置的回調地址,在【微信開放平台-微信支付-支付配置】中進行配置
 * 4、在接到回調通知之後,用戶進行統一下單支付,並返回支付信息以完成支付(見:native_notify.php)
 * 5、支付完成之後,微信服務器會通知支付成功
 * 6、在支付成功通知中需要查單確認是否真正支付成功(見:notify.php)
 */
$notify = new NativePay();
$url1 = $notify->GetPrePayUrl("123456789");
//模式二
/**
 * 流程:
 * 1、調用統一下單,取得code_url,生成二維碼
 * 2、用戶掃描二維碼,進行支付
 * 3、支付完成之後,微信服務器會通知支付成功
 * 4、在支付成功通知中需要查單確認是否真正支付成功(見:notify.php)
 */
$input = new WxPayUnifiedOrder();
$input->SetBody("test");
$input->SetAttach("test");
$input->SetOut_trade_no(WxPayConfig::MCHID . date("YmdHis"));
$input->SetTotal_fee("1");
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://paysdk.weixin.qq.com/example/notify.php");
$input->SetTrade_type("NATIVE");
$input->SetProduct_id("123456789");
$result = $notify->GetPayUrl($input);
$url2 = $result["code_url"];
?>

<html>
開發者ID:1290800466,項目名稱:weixin_pay,代碼行數:31,代碼來源:native.php

示例14: header

header('Access-Control-Allow-Origin: *');
header('Content-type: text/plain');
require_once "WxPay.Api.php";
require_once "WxPay.Data.php";
// 獲取支付金額
$amount = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $amount = $_POST['total'];
} else {
    $amount = $_GET['total'];
}
$total = floatval($amount);
$total = round($total * 100);
// 將元轉成分
if (empty($total)) {
    $total = 100;
}
// 商品名稱
$subject = 'DCloud項目捐贈';
// 訂單號,示例代碼使用時間值作為唯一的訂單ID號
$out_trade_no = date('YmdHis', time());
$unifiedOrder = new WxPayUnifiedOrder();
$unifiedOrder->SetBody($subject);
//商品或支付單簡要描述
$unifiedOrder->SetOut_trade_no($out_trade_no);
$unifiedOrder->SetTotal_fee($total);
$unifiedOrder->SetTrade_type("APP");
$result = WxPayApi::unifiedOrder($unifiedOrder);
if (is_array($result)) {
    echo json_encode($result);
}
開發者ID:peaceleo,項目名稱:H5P.Server,代碼行數:31,代碼來源:index.php

示例15: get_pay_url

function get_pay_url($charge_type, $pay_amount, $payment_config, $subject, $order_id, $model_id = null, $obj_id = null, $service = null, $sign_type = 'MD5', $show_url = 'index.php?do=user&view=finance&op=details')
{
    global $_K, $uid, $username;
    $charge_type == 'order_charge' and $t = "訂單充值" or $t = "餘額充值";
    $body = $t . "(from:" . $username . ")";
    $notify = new NativePay();
    $WxPayCfg = new WxPayCfg();
    $Out_trade_no = $WxPayCfg->_mchid . date("YmdHis");
    $attach = "charge-{$charge_type}-{$uid}-{$obj_id}-{$order_id}-{$model_id}-" . time();
    $input = new WxPayUnifiedOrder();
    $input->SetBody($body);
    $input->SetDetail($body);
    $input->SetAttach($attach);
    $input->SetOut_trade_no($Out_trade_no);
    $input->SetFee_type("CNY");
    $input->SetTotal_fee($pay_amount * 100);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetNotify_url(BASE_WXPAY_URL . "notify.php");
    $input->SetTrade_type("NATIVE");
    $input->SetProduct_id($obj_id);
    $result = $notify->GetPayUrl($input);
    $url2 = $result["code_url"];
    keke_order_class::create_order_charge('online_charge', 'wxpay', null, $obj_id, $uid, $username, $pay_amount, 'wait', '用戶充值', $Out_trade_no, null, $attach);
    $baseUrl = urlencode($url2);
    $data = array();
    $data['url'] = BASE_WXPAY_URL . "qrcode.php?data=" . $baseUrl;
    $data['out_trade_no'] = $Out_trade_no;
    return $data;
}
開發者ID:huangbinzd,項目名稱:kppwGit,代碼行數:30,代碼來源:order.php


注:本文中的WxPayUnifiedOrder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。