예제 #1
0
파일: Weixin.php 프로젝트: pancke/yyaf
 /**
  * 生成微信支付二维码
  */
 public static function qrcode($product_id, $body, $total_fee, $attach = '', $detail = '', $goods_tag = '')
 {
     // 处理金额
     if (ENV_SCENE == 'dev') {
         $total_fee = 0.01;
     }
     $total_fee *= 100;
     $notify = new NativePay();
     /**
      * 流程:
      * 1、调用统一下单,取得code_url,生成二维码
      * 2、用户扫描二维码,进行支付
      * 3、支付完成之后,微信服务器会通知支付成功
      * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
      */
     $input = new WxPayUnifiedOrder();
     $input->SetBody($body);
     $input->SetAttach($product_id);
     if (!empty($detail)) {
         $input->SetDetail($detail);
     }
     $input->SetOut_trade_no(WxPayConfig::$APPID . substr($product_id, 1));
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     if (!empty($goods_tag)) {
         $input->SetGoods_tag($goods_tag);
     }
     $input->SetNotify_url(WxPayConfig::$NOTIFY_URL);
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id($product_id);
     $result = $notify->GetPayUrl($input);
     return $result["code_url"];
 }
예제 #2
0
 /**
  * 组装包含支付信息的url(模式2)
  */
 public function get_payurl()
 {
     require_once BASE_PATH . '/api/payment/wxpay/lib/WxPay.Api.php';
     require_once BASE_PATH . '/api/payment/wxpay/WxPay.NativePay.php';
     require_once BASE_PATH . '/api/payment/wxpay/log.php';
     $logHandler = new CLogFileHandler(BASE_DATA_PATH . '/log/wxpay/' . date('Y-m-d') . '.log');
     $Logwx = Logwx::Init($logHandler, 15);
     //统一下单
     $input = new WxPayUnifiedOrder();
     $input->SetBody($this->_order_info['pay_sn'] . '订单');
     //         $input->SetBody(C('site_name').'订单');
     $input->SetAttach($this->_order_info['order_type'] == 'vr_order' ? 'v' : 'r');
     $input->SetOut_trade_no($this->_order_info['pay_sn']);
     $input->SetTotal_fee($this->_order_info['api_pay_amount'] * 100);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 3600));
     $input->SetGoods_tag('');
     $input->SetNotify_url(SHOP_SITE_URL . '/api/payment/wxpay/notify_url.php');
     $input->SetTrade_type("NATIVE");
     //$input->SetOpenid($openId);
     $input->SetProduct_id($this->_order_info['pay_sn']);
     $result = WxPayApi::unifiedOrder($input);
     //         header("Content-type:text/html;charset=utf-8");
     //         print_R($result);exit;
     Logwx::DEBUG("unifiedorder-:" . json_encode($result));
     return $result["code_url"];
 }
예제 #3
0
 public function unifiedorder($openId, $product_id)
 {
     //得到支付金额
     $order_pay_info = Model('order')->getOrderPayInfo(array('pay_sn' => $product_id));
     if (empty($order_pay_info)) {
         $condition = array();
         $condition['order_sn'] = $product_id;
         $condition['order_state'] = ORDER_STATE_NEW;
         $order_info = Model('vr_order')->getOrderInfo($condition, 'sum(order_amount-rcb_amount-pd_amount) as order_amount');
         $attach = 'v';
     } else {
         $condition = array();
         $condition['pay_sn'] = $product_id;
         $condition['order_state'] = ORDER_STATE_NEW;
         $order_info = Model('order')->getOrderInfo($condition, array(), 'sum(order_amount-rcb_amount-pd_amount) as order_amount');
         $attach = 'r';
     }
     //统一下单
     $input = new WxPayUnifiedOrder();
     $input->SetBody($product_id . '订单');
     // 		$input->SetBody(C('site_name').'订单');
     $input->SetAttach($attach);
     $input->SetOut_trade_no($product_id);
     $input->SetTotal_fee($order_info['order_amount'] * 100);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 3600));
     $input->SetGoods_tag('');
     $input->SetNotify_url(SHOP_SITE_URL . '/api/payment/wxpay/notify_url.php');
     $input->SetTrade_type("NATIVE");
     // 		$input->SetOpenid($openId);
     $input->SetProduct_id($product_id);
     $result = WxPayApi::unifiedOrder($input);
     Log::DEBUG("unifiedorder:" . json_encode($result));
     return $result;
 }
예제 #4
0
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;
}
예제 #5
0
파일: weizhao.php 프로젝트: ysc8620/zhima
/**
 * 生成支付接口内容
 * @param $data
 * @param bool $debug
 * @return json
 */
function jsapipay($data, $debug = false)
{
    // C('weixin.weixin_')
    //①、获取用户openid
    $tools = new JsApiPay();
    //    $openId = $tools->GetOpenid();
    if (!empty($data['openid'])) {
        $openId = $data['openid'];
    } else {
        echo "empty openid";
        die;
    }
    //②、统一下单
    $input = new WxPayUnifiedOrder();
    $input->SetBody($data['body']);
    $input->SetAttach($data['attach']);
    $input->SetOut_trade_no($data['order_sn']);
    $input->SetTotal_fee($data['total_fee']);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag($data['goods_tag']);
    $input->SetNotify_url("http://{$_SERVER[HTTP_HOST]}/weixin/notify.html");
    $input->SetTrade_type("JSAPI");
    $input->SetOpenid($openId);
    $order = WxPayApi::unifiedOrder($input);
    if ($debug) {
        echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
        printf_info($order);
    }
    $jsApiParameters = $tools->GetJsApiParameters($order);
    return $jsApiParameters;
}
예제 #6
0
 public function topup()
 {
     $orderInfo = session('orderInfo');
     Vendor('WxPayApi.unit.log');
     Vendor('WxPayApi.lib.WxPayApi');
     Vendor('WxPayApi.unit.WxPayNativePay');
     //模式一
     $notify = new \NativePay();
     $input = new \WxPayUnifiedOrder();
     $input->SetBody("会员充值");
     $input->SetAttach("topup");
     $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"];
     $userInfo = session('userInfo');
     $this->assign('orderInfo', $orderInfo);
     $this->assign('userInfo', $userInfo);
     $this->assign('url', urlencode($url2));
     $this->display();
 }
예제 #7
0
파일: Api.php 프로젝트: ljimmy/pay
 /**
  *
  * 统一下单,WxPayUnifiedOrder中out_trade_no、body、total_fee、trade_type必填
  * appid、mchid、spbill_create_ip、nonce_str不需要填入
  * @param WxPayUnifiedOrder $inputObj
  * @param int $timeOut
  * @throws Exception
  * @return 成功时返回,其他抛异常
  */
 public static function unifiedOrder($inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
     //检测必填参数
     if (!$inputObj->IsOut_trade_noSet()) {
         throw new Exception("缺少统一支付接口必填参数out_trade_no!");
     } else {
         if (!$inputObj->IsBodySet()) {
             throw new Exception("缺少统一支付接口必填参数body!");
         } else {
             if (!$inputObj->IsTotal_feeSet()) {
                 throw new Exception("缺少统一支付接口必填参数total_fee!");
             } else {
                 if (!$inputObj->IsTrade_typeSet()) {
                     throw new Exception("缺少统一支付接口必填参数trade_type!");
                 }
             }
         }
     }
     //关联参数
     if ($inputObj->GetTrade_type() == "JSAPI" && !$inputObj->IsOpenidSet()) {
         throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!");
     }
     if ($inputObj->GetTrade_type() == "NATIVE" && !$inputObj->IsProduct_idSet()) {
         throw new Exception("统一支付接口中,缺少必填参数product_id!trade_type为NATIVE时,product_id为必填参数!");
     }
     //异步通知url未设置,则使用配置文件中的url
     if (!$inputObj->IsNotify_urlSet()) {
         $inputObj->SetNotify_url(Config::NOTIFY_URL);
         //异步通知url
     }
     $inputObj->SetAppid(Config::APPID);
     //公众账号ID
     $inputObj->SetMch_id(Config::MCHID);
     //商户号
     if (!$inputObj->IsSpbill_create_ipSet()) {
         $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 = Results::Init($response);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     if ($result['return_code'] != 'SUCCESS') {
         throw new Exception($result['return_msg']);
     }
     if ($result['result_code'] != 'SUCCESS') {
         throw new Exception('err_code:' . $result['err_code'] . ';err_code_des:' . $result['err_code_des']);
     }
     return $result;
 }
예제 #8
0
 public function index()
 {
     require_once DIR_SYSTEM . 'library/wxpay/wxpayexception.php';
     define('WXPAY_APPID', trim($this->config->get('wxpay_appid')));
     define('WXPAY_MCHID', trim($this->config->get('wxpay_mchid')));
     define('WXPAY_KEY', trim($this->config->get('wxpay_key')));
     define('WXPAY_APPSECRET', trim($this->config->get('wxpay_appsecret')));
     define('WXPAY_SSLCERT_PATH', DIR_SYSTEM . 'helper/wxpay_key/apiclient_cert.pem');
     define('WXPAY_SSLKEY_PATH', DIR_SYSTEM . 'helper/wxpay_key/apiclient_key.pem');
     define('WXPAY_CURL_PROXY_HOST', "0.0.0.0");
     define('WXPAY_CURL_PROXY_PORT', 0);
     define('REPORT_LEVENL', 1);
     require_once DIR_SYSTEM . 'library/wxpay/wxpayconfig.php';
     require_once DIR_SYSTEM . 'library/wxpay/wxpaydata.php';
     require_once DIR_SYSTEM . 'library/wxpay/wxpayapi.php';
     require_once DIR_SYSTEM . 'library/wxpay/wxpaynativepay.php';
     $this->load->language('extension/payment/qrcode_wxpay');
     $data['button_confirm'] = $this->language->get('button_confirm');
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $item_name = $this->config->get('config_name');
     $fullname = $order_info['payment_fullname'];
     $this->load->model('account/order');
     $shipping_cost = 0;
     $totals = $this->model_account_order->getOrderTotals($order_id);
     foreach ($totals as $total) {
         if ($total['title'] == 'shipping') {
             $shipping_cost = $total['value'];
         }
     }
     $notify_url = HTTPS_SERVER . 'catalog/controller/extension/payment/qrcode_wxpay_callback.php';
     $out_trade_no = $this->session->data['order_id'];
     $subject = $item_name . ' ' . $this->language->get('text_order') . ' ' . $order_id;
     $amount = $order_info['total'];
     $currency_value = $this->currency->getValue('CNY');
     $price = $amount * $currency_value;
     $price = number_format($price, 2, '.', '');
     $total_fee = $price * 100;
     //乘100去掉小数点,以传递整数给微信支付
     $notify = new NativePay();
     $input = new WxPayUnifiedOrder();
     $input->SetBody($subject);
     $input->SetAttach("mycncart");
     $input->SetOut_trade_no($order_id);
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("mycncart");
     $input->SetNotify_url(HTTPS_SERVER . "catalog/controller/extension/payment/qrcode_wxpay_callback.php");
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id($order_id);
     $result = $notify->GetPayUrl($input);
     $this->session->data['code_url'] = $result['code_url'];
     $data['redirect'] = $this->url->link('checkout/qrcode_wxpay_success');
     return $this->load->view('extension/payment/qrcode_wxpay', $data);
 }
예제 #9
0
 public function wxJsPay()
 {
     $list = isset($_SESSION['orderinfo']) ? $_SESSION['orderinfo'] : array();
     if (!isset($_SESSION['orderinfo'])) {
         header("Location:" . appurl('getMeOrder'));
         die;
     }
     //验证是否能预定
     if (isset($_SESSION['orderList'])) {
         foreach ($_SESSION['orderList'] as $key => $value) {
             $this->checkCanSum($value['bookid'], $value);
             if (!$this->checkBook($value['bookid'])) {
                 $this->alert($value['title'] . '已经售卖结束');
                 exit;
             }
         }
     }
     //初始化日志
     $logHandler = new CLogFileHandler("../logs/" . date('Y-m-d') . '.log');
     $log = Log::Init($logHandler, 15);
     //①、获取用户openid
     $tools = new JsApiPay();
     $openId = $tools->GetOpenid();
     //②、统一下单
     //价钱转成分
     $totalFee = $list['allPrice'] * 100;
     $input = new WxPayUnifiedOrder();
     $input->SetBody("订单");
     $input->SetAttach("订单");
     $input->SetOut_trade_no($list['orderid']);
     $input->SetTotal_fee($totalFee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("订单");
     $input->SetNotify_url(appurl('callBack'));
     // "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/>';
     // $this->printf_info($order);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //获取共享收货地址js函数参数
     $editAddress = $tools->GetEditAddressParameters();
     //③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
     /**
      * 注意:
      * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
      * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
      * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
      */
     $data = array('jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress, 'orderid' => $list['orderid'], 'pageTitle' => '支付');
     unset($_SESSION['orderinfo']);
     $this->layoutRender('/wxpay', $data);
 }
예제 #10
0
 /**
  * 
  * 统一下单,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 function unifiedOrder(WxPayUnifiedOrder $inputObj, $timeOut = 6)
 {
     $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
     //检测必填参数
     if (!$inputObj->IsOut_trade_noSet()) {
         throw new WxPayException("缺少统一支付接口必填参数out_trade_no!");
     } else {
         if (!$inputObj->IsBodySet()) {
             throw new WxPayException("缺少统一支付接口必填参数body!");
         } else {
             if (!$inputObj->IsTotal_feeSet()) {
                 throw new WxPayException("缺少统一支付接口必填参数total_fee!");
             } else {
                 if (!$inputObj->IsTrade_typeSet()) {
                     throw new WxPayException("缺少统一支付接口必填参数trade_type!");
                 }
             }
         }
     }
     //关联参数
     if ($inputObj->GetTrade_type() == "JSAPI" && !$inputObj->IsOpenidSet()) {
         throw new WxPayException("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!");
     }
     if ($inputObj->GetTrade_type() == "NATIVE" && !$inputObj->IsProduct_idSet()) {
         throw new WxPayException("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!");
     }
     //异步通知url未设置,则使用配置文件中的url
     if (!$inputObj->IsNotify_urlSet()) {
         $inputObj->SetNotify_url($this->wxPayConfig['NOTIFY_URL']);
         //异步通知url
     }
     $inputObj->SetAppid($this->wxPayConfig['APPID']);
     //公众账号ID
     $inputObj->SetMch_id($this->wxPayConfig['MCHID']);
     //商户号
     try {
         $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']);
         //终端ip
     } catch (\Exception $e) {
         $inputObj->SetSpbill_create_ip("1.1.1.1");
     }
     $inputObj->SetNonce_str(self::getNonceStr());
     //随机字符串
     //签名
     $inputObj->SetSign();
     $xml = $inputObj->ToXml();
     $startTimeStamp = self::getMillisecond();
     //请求开始时间
     $response = $this->postXmlCurl($xml, $url, false, $timeOut);
     //		print_r($response);
     $result = WxPayResults::Init($response, $this->wxPayConfig);
     $this->reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
예제 #11
0
 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;
 }
예제 #12
0
function getPrepayId($total_amount, $order_number, $attach)
{
    $input = new WxPayUnifiedOrder();
    $input->SetBody("美果优鲜订单");
    $input->SetAttach("缤纷水果");
    $input->SetOut_trade_no($attach);
    $input->SetTotal_fee($total_amount * 100);
    $input->SetAttach($order_number);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag("商品标签");
    $input->SetNotify_url("https://dev1.meiguoyouxian.com/magento/custom/api/util/wx.php");
    $input->SetTrade_type("APP");
    $order = WxPayApi::unifiedOrder($input);
    return $order;
}
예제 #13
0
 /** 统一下单 */
 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;
 }
예제 #14
0
 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;
 }
예제 #15
0
 public function unifiedorder($openId, $product_id)
 {
     //统一下单
     $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->SetOpenid($openId);
     $input->SetProduct_id($product_id);
     $result = WxPayApi::unifiedOrder($input);
     Log::DEBUG("unifiedorder:" . json_encode($result));
     return $result;
 }
예제 #16
0
 public function unifiedorder($openId, $product_id)
 {
     //统一下单
     $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(Config::API_NOTIFY_URL);
     $input->SetTrade_type("NATIVE");
     $input->SetOpenid($openId);
     $input->SetProduct_id($product_id);
     $result = WxPayApi::unifiedOrder($input, Config::API_TIMEOUT);
     Log::DEBUG("unifiedorder:" . json_encode($result));
     return $result;
 }
 /**
  * [paymenttList 微信支付页面]
  * @Author   罗江涛
  * @DateTime 2016-03-07T17:01:37+0800
  */
 public function weixinPayment()
 {
     $title = I("title");
     $price = I("price");
     $reportId = I("reportId");
     $userId = I("userId");
     ini_set('date.timezone', 'Asia/Shanghai');
     require "./Application/Index/Service/weixinPayApi/WxPay.Api.php";
     require "./Application/Index/Service/weixinPayApi/WxPay.NativePay.php";
     //模式二
     $notify = new \NativePay();
     /**
      * 流程:
      * 1、调用统一下单,取得code_url,生成二维码
      * 2、用户扫描二维码,进行支付
      * 3、支付完成之后,微信服务器会通知支付成功
      * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
      */
     // $input = new \Index\Service\weixinPayApi\lib\WxPayUnifiedOrder();
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($title);
     $input->SetAttach($userId . "|" . $reportId);
     $input->SetOut_trade_no(\WxPayConfig::MCHID . date("YmdHis"));
     // $input->SetOut_trade_no($reportId);
     $input->SetTotal_fee($price);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("SetGoods_tag");
     // $input->SetNotify_url("http://qingdao.luojiangtao.com/index.php/Api/Payment/getWeixinPaymentInfo");
     // $input->SetNotify_url(U("Api/Payment/getWeixinPayPost"));
     $input->SetNotify_url("http://qingdao.luojiangtao.com/vcbeat/index.php/Api/Payment/getWeixinPayPost");
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id("123456789");
     // p($_SERVER);die;
     $result = $notify->GetPayUrl($input);
     $url2 = $result["code_url"];
     // p($result);die;
     // $this->assign("url2", $url2);
     $this->url2 = $url2;
     $this->display();
 }
예제 #18
0
파일: Api.php 프로젝트: hejxing/jt
 /**
  * 统一下单
  *
  * @param $amount
  *
  * @return string
  */
 private function getUnifiedOrder($amount)
 {
     $tools = new \JsApiPay();
     $openId = $tools->GetOpenid();
     //获取用户openID
     $outTradeNo = \tools\Tools::uuid();
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($this->data['memo']);
     $input->SetAttach($this->data['id']);
     $input->SetOut_trade_no($outTradeNo);
     $input->SetTotal_fee($this->amount);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag($this->data['memo']);
     $input->SetNotify_url($this->notify_url);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //获取共享收货地址js函数参数
     $editAddress = $tools->GetEditAddressParameters();
     return ['jsApiParameters' => $jsApiParameters, 'editAddress' => $editAddress, 'amount' => $amount, 'orderId' => $this->data['id']];
 }
예제 #19
0
 public function pay_get()
 {
     $order = I('get.order', '');
     $m = M('orders');
     // $map['from_member_id'] = $this->uid;
     $map['order_number'] = $order;
     // $map['status'] = 0;
     $info = $m->where($map)->find();
     if (empty($info)) {
         //未支付订单不存在
         $this->error(5015);
     }
     $total = $info['total'] * 100;
     $describe = 'testname';
     require_once APP_PATH . "SDK/Payment/wechat/lib/WxPay.Api.php";
     $input = new \WxPayUnifiedOrder();
     //设置公众账号ID
     $input->SetAppid(\WxPayConfig::APPID);
     //设置商户号
     $input->SetMch_id(\WxPayConfig::MCHID);
     //设置随机字符串
     $input->SetNonce_str(\WxPayApi::getNonceStr());
     //设置商品描述
     $input->SetBody($describe);
     //设置商户订单号
     $input->SetOut_trade_no($info['order_number']);
     //设置总金额
     $input->SetTotal_fee($total);
     //设置终端IP
     $input->SetSpbill_create_ip(get_client_ip());
     //设置通知地址
     $input->SetNotify_url(U('Wxpay/callback@api'));
     //设置交易类型
     $input->SetTrade_type('APP');
     $order = \WxPayApi::unifiedOrder($input);
     $this->success($order);
 }
예제 #20
0
 public function pay()
 {
     require_once 'Weixinpay/WxPayData.class.php';
     require_once 'Weixinpay/WxPayApi.class.php';
     require_once 'Weixinpay/WxPayJsApiPay.php';
     // require_once ('Weixinpay/log.php');
     $paymentId = $_GET['paymentId'];
     $token = $_GET['token'];
     $body = $_GET['orderName'];
     $orderNo = $_GET['orderNumber'];
     if ($orderNo == "") {
         $orderNo = $_GET['single_orderid'];
     }
     $totalFee = $_GET['price'] * 100;
     // 单位为分
     // $paytype=$_GET['paytype'];
     $tools = new \JsApiPay();
     // $openId = $tools->GetOpenid();
     // $openId=$_GET['wecha_id'];
     // $openId=get_openid();
     // dump($openId);
     // die();
     // // dump($openId);
     //         $openId='orgF0t-HyMrDJHFOl9GAkENyu6i0';
     // dump('45456');
     $openId = $this->getPaymentOpenid();
     //         dump(session('paymentinfo'));
     //         dump($openId);
     //         dump('1232');die;
     // 统一下单
     import('Weixinpay.WxPayData');
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($body);
     // $input->SetAttach("test");
     $input->SetOut_trade_no($orderNo);
     $input->SetTotal_fee($totalFee);
     // $input->SetTime_start(date("YmdHis"));
     // $input->SetTime_expire(date("YmdHis", time() + 600));
     // $input->SetGoods_tag("test");
     $input->SetNotify_url("Weixinpay/notify.php");
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     //         echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
     //dump($order);
     //         die;
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //  dump($jsApiParameters);
     $returnUrl = addons_url('Payment://Weixin/payOK');
     header('Location:' . SITE_URL . '/WxpayAPI/unifiedorder.php?jsApiParameters=' . $jsApiParameters . '&returnurl=' . $returnUrl . '&totalfee=' . $_GET['price'] . '&paymentId=' . $paymentId);
     // echo $jsApiParameters;
     // die;
     // session('jsaparams',$jsApiParameters);
     // $_COOKIE['jsaparams']=$jsApiParameters;
     // $from=$_GET['from'];
     // if($from!='shop'){
     // $from=$this->doFromStr($_GET['from']);
     // }
     // //$returnUrl = '/index.php?g=Wap&m=' . $from . '&a=payReturn&token=' . $_GET ['token'] . '&wecha_id=' . $_GET ['wecha_id'] . '&orderid=' . $orderNo;
     // $returnUrl=addons_url('Payment://Weixin/payOK');
     // //$this->assign ( 'returnUrl', $returnUrl );
     // $this->assign ( 'jsApiParameters', $jsApiParameters );
     // $this->assign ( 'price', $_GET['price'] );
     // die;
     // header('Location:http://'.$_SERVER['HTTP_HOST'].'/weishi/WxpayAPI/unifiedorder.php?body='.$body.'&out_trade_no='.$orderNo.'&totalfee='.$totalFee.'&openid='.$openId.'&returnurl='.$returnUrl);
 }
예제 #21
0
 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);
 }
예제 #22
0
파일: jsapi.php 프로젝트: king3388/king
        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函数参数
$editAddress = $tools->GetEditAddressParameters();
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
 * 注意:
 * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
 * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
 * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
 */
예제 #23
0
 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();
 }
예제 #24
0
/**
 * 流程:
 * 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>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" /> 
    <title>微信支付样例-退款</title>
</head>
<body>
	<div style="margin-left: 10px;color:#556B2F;font-size:30px;font-weight: bolder;">扫描支付模式一</div><br/>
	<img alt="模式一扫码支付" src="http://paysdk.weixin.qq.com/example/qrcode.php?data=<?php 
예제 #25
0
        $input->SetBody(Config::WX_ORDER_TITLE);
        // 商品或支付单简要描述
        $input->SetAttach(PAY_ENV);
        // 设置附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
        $input->SetOut_trade_no($order_info['id']);
        // 商户系统内部的订单号,32个字符内
        $input->SetTotal_fee($pay_toatal_price);
        // 订单支付总金额,整数,以分为单位
        //$input->SetTotal_fee(1);
        $input->SetTime_start(date("YmdHis"));
        // 订单生成时间,格式为yyyyMMddHHmmss
        $input->SetTime_expire(date("YmdHis", time() + Config::WX_ORDER_TIMEOUT));
        // 订单失效时间,格式为yyyyMMddHHmmss
        $input->SetGoods_tag(Config::WX_ORDER_TAG);
        // 设置商品标记
        $input->SetNotify_url(Config::API_NOTIFY_URL);
        // 接收微信支付异步通知回调地址
        $input->SetTrade_type("JSAPI");
        // 交易类型
        $input->SetOpenid($openId);
        // 微信用户的Openid
        $order = WxPayApi::unifiedOrder($input, Config::API_TIMEOUT, Config::API_NOTIFY_URL);
        // 创建预付订单
        $jsApiParameters = $tools->GetJsApiParameters($order);
        // 获取共享收货地址js函数参数
        //$editAddress = $tools->GetEditAddressParameters();
    } else {
        throw new Exception('order_info requrired,but empty be given');
    }
    //第四步:在支付成功回调通知中处理成功之后的事宜,见 notify.php
} catch (Exception $e) {
예제 #26
0
파일: native.php 프로젝트: lughong/shop
 * 1、调用统一下单,取得code_url,生成二维码
 * 2、用户扫描二维码,进行支付
 * 3、支付完成之后,微信服务器会通知支付成功
 * 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
 */
require_once 'getorderinfo.php';
try {
    $input = new WxPayUnifiedOrder();
    $input->SetBody($body);
    $input->SetAttach($body);
    $input->SetOut_trade_no($order_sn);
    $input->SetTotal_fee($money_paid);
    $input->SetTime_start($time_start);
    $input->SetTime_expire($time_expire);
    $input->SetGoods_tag($goods_tag);
    $input->SetNotify_url($notify_url);
    $input->SetTrade_type("NATIVE");
    $input->SetProduct_id($order_id);
    $result = $notify->GetPayUrl($input);
    $url2 = $result["code_url"];
} catch (Exception $e) {
    echo "系统繁忙,请稍后再试。";
    exit;
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="utf-8">
예제 #27
0
 public function index()
 {
     //初始化日志
     $this->load->library('wxpaylog');
     $this->logHandler = new CLogFileHandler(DIR_LOGS . "wxpaylogs/" . date('Y-m-d') . '.log');
     $log = WxPayLog::Init($this->logHandler, 15);
     $this->language->load('payment/wxpay');
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $item_name = $this->config->get('config_name');
     $amount = $order_info['total'];
     $currency_value = $this->currency->getValue('CNY');
     $price = $amount * $currency_value;
     $price = number_format($price, 2, '.', '');
     $notify_url = HTTPS_SERVER . 'catalog/controller/payment/wxpay_callback.php';
     //$total_fee = $price;
     $total_fee = "0.01";
     $out_trade_no = $this->session->data['order_id'];
     $subject = $item_name . ' ' . $this->language->get('text_order') . ' ' . $order_id;
     //打印输出数组信息
     function printf_info($data)
     {
         foreach ($data as $key => $value) {
             echo "<font color='#00ff55;'>{$key}</font> : {$value} <br/>";
         }
     }
     //①、获取用户openid
     $this->load->library('wxpayapipay');
     $this->tools = new WxPayApiPay();
     $openId = $this->tools->GetOpenid();
     //②、统一下单
     $input = new WxPayUnifiedOrder();
     $input->SetBody($subject);
     $input->SetAttach("YANKEE");
     $input->SetOut_trade_no(WxPayConfig::MCHID . date("YmdHis"));
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("test");
     $input->SetNotify_url($notify_url);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     //$input->SetOpenid("oCrCkwElKC4YuFiAYe0EvPKa-OEg");
     $this->load->library('wxpayapi');
     $this->wxpayapi = new WxPayApi();
     $order = $this->wxpayapi->unifiedOrder($input);
     //echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
     //printf_info($order);
     $jsApiParameters = $this->tools->GetJsApiParameters($order);
     //获取共享收货地址js函数参数
     $editAddress = $this->tools->GetEditAddressParameters();
     //③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
     /**
      * 注意:
      * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
      * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
      * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
      */
     //$data['html_text'] = $this->alipaydtsubmit->buildRequestForm($parameter,"get", $this->language->get('button_confirm'));
     $data['jsApiParameters'] = isset($jsApiParameters) ? $jsApiParameters : "111";
     $data['editAddress'] = isset($editAddress) ? $editAddress : "111";
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/wxpay.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/payment/wxpay.tpl', $data);
     } else {
         return $this->load->view('default/template/payment/wxpay.tpl', $data);
     }
 }
예제 #28
0
 public function index()
 {
     //echo "one";
     $this->load->library('wxpayexception');
     //echo "two";
     $this->load->library('wxpayconfig');
     //echo "three";
     $this->load->library('wxpaydata');
     //echo "four";
     $this->load->library('wxpayapi');
     //echo "five";
     $this->load->library('wxpayjsapipay');
     //echo "six";
     //echo "1";
     /*
     WxPayConfig::$APPID = $this->config->get('wxpay_appid');
     	    WxPayConfig::$MCHID = $this->config->get('wxpay_mchid');
     	    WxPayConfig::$KEY = $this->config->get('wxpay_key');
     WxPayConfig::$APPSECRET = $this->config->get('wxpay_appsecret');
     WxPayConfig::$SSLCERT_PATH = DIR_SYSTEM.'helper/wxpay_key/apiclient_cert.pem';
     WxPayConfig::$SSLKEY_PATH = DIR_SYSTEM.'helper/wxpay_key/apiclient_key.pem';
     */
     //echo "2";
     $this->language->load('payment/wxpay');
     $data['button_confirm'] = $this->language->get('button_confirm');
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $item_name = $this->config->get('config_name');
     $fullname = $order_info['payment_fullname'];
     $this->load->model('account/order');
     $shipping_cost = 0;
     $totals = $this->model_account_order->getOrderTotals($order_id);
     foreach ($totals as $total) {
         if ($total['title'] == 'shipping') {
             $shipping_cost = $total['value'];
         }
     }
     $notify_url = HTTPS_SERVER . 'catalog/controller/payment/wxpay_callback.php';
     $out_trade_no = $this->session->data['order_id'];
     $subject = $item_name . ' ' . $this->language->get('text_order') . ' ' . $order_id;
     $amount = $order_info['total'];
     $currency_value = $this->currency->getValue('CNY');
     $price = $amount * $currency_value;
     $price = number_format($price, 2, '.', '');
     $total_fee = $price * 100;
     //乘100去掉小数点,以传递整数给微信支付
     //$total_fee = 1;
     //echo "Total Fee: ".$total_fee."<br>";
     //echo "3";
     //①、获取用户openid
     $tools = new JsApiPay();
     //$openId = $tools->GetOpenid();
     $openId = $this->session->data['weixin_openid'];
     //echo "4<br>";
     //echo $openId;
     //②、统一下单
     $input = new WxPayUnifiedOrder();
     //echo "5";
     $input->SetBody($subject);
     $input->SetAttach("test by yang");
     $input->SetOut_trade_no($order_id);
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag("test goods tags");
     $input->SetNotify_url($notify_url);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     //echo "6";
     $order = WxPayApi::unifiedOrder($input);
     //print_r($order);
     //echo "7";
     //echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
     //printf_info($order);
     $data['jsApiParameters'] = $tools->GetJsApiParameters($order);
     //echo "8";
     //获取共享收货地址js函数参数
     $data['editAddress'] = $tools->GetEditAddressParameters();
     //echo "9";
     $data['return_url'] = $this->url->link('checkout/success');
     $data['checkout_url'] = $this->url->link('checkout/checkout');
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/wxpay.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/payment/wxpay.tpl', $data);
     } else {
         return $this->load->view('default/template/payment/wxpay.tpl', $data);
     }
 }
예제 #29
0
파일: native.php 프로젝트: lughong/test
    $str .= '手提袋x' . $bag . ',';
}
if ($battery != 0) {
    $str .= '移动电源x' . $battery . ',';
}
$body = trim($str, ',');
try {
    $input = new WxPayUnifiedOrder();
    $input->SetBody("奇艺果定制商品");
    $input->SetAttach("奇艺果定制商品");
    $input->SetOut_trade_no($order_sn);
    $input->SetTotal_fee($money_paid);
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag("test");
    $input->SetNotify_url(URL . "pays/wxpay_saoma/example/notify.php");
    $input->SetTrade_type("NATIVE");
    $input->SetProduct_id($order_id);
    $result = $notify->GetPayUrl($input);
    $url2 = $result["code_url"];
} catch (Exception $e) {
    echo "系统繁忙,请稍后再试。";
    exit;
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="utf-8">
예제 #30
0
파일: pay.php 프로젝트: ahmatjan/xinxintong
 /**
  *
  */
 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);
 }