当前位置: 首页>>代码示例>>PHP>>正文


PHP WxPayUnifiedOrder::SetAppid方法代码示例

本文整理汇总了PHP中WxPayUnifiedOrder::SetAppid方法的典型用法代码示例。如果您正苦于以下问题:PHP WxPayUnifiedOrder::SetAppid方法的具体用法?PHP WxPayUnifiedOrder::SetAppid怎么用?PHP WxPayUnifiedOrder::SetAppid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WxPayUnifiedOrder的用法示例。


在下文中一共展示了WxPayUnifiedOrder::SetAppid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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, $notify = '')
 {
     $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($notify);
         //异步通知url
     }
     if ($inputObj->GetTrade_type() == 'APP') {
         $inputObj->SetAppid(WxPayConfig::APP_APPID);
         //开放平台APPID
         $inputObj->SetMch_id(WxPayConfig::APP_MCHID);
         //商户平台商户号
     } else {
         $inputObj->SetAppid(WxPayConfig::APPID);
         //公众账号ID
         $inputObj->SetMch_id(WxPayConfig::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);
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
开发者ID:OranTing,项目名称:gdby_github_repo,代码行数:67,代码来源:WxPay.Api.php

示例2: 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

示例3: pay_get

 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);
 }
开发者ID:jkzleond,项目名称:alhelp_api,代码行数:37,代码来源:WxpayController.class.php

示例4: doMobileAjaxpay

 public function doMobileAjaxpay()
 {
     global $_GPC, $_W;
     load()->func('communication');
     $fromopenid = $_GPC['fromopenid'];
     $myopenid = $_W['openid'];
     $num = 1;
     $content = $_GPC['content'];
     include_once '../addons/beauty_zhongchou/WxPay.Api.php';
     $WxPayApi = new WxPayApi();
     $input = new WxPayUnifiedOrder();
     //				$key=$this->module['config']['apikey'];//商户支付秘钥(API秘钥)
     $key = 'xLeBESmggiQMGpba2ieADmRQDlDPmIL8';
     $account_info = pdo_fetch("select * from" . tablename('account_wechats') . "where uniacid={$_W['uniacid']}");
     //身份标识(appid)
     $appid = $account_info['key'];
     //$mchid=$this->module['config']['mchid'];//微信支付商户号(mchid)
     $mchid = '1239385202';
     $input->SetAppid($appid);
     $input->SetMch_id($mchid);
     $input->SetBody("test");
     $input->SetAttach("test");
     $input->SetOut_trade_no($mchid . date("YmdHis"));
     $input->SetTotal_fee($num);
     $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($myopenid);
     $result = $WxPayApi->unifiedOrder($input, 6, $key);
     //随机字符串
     $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
     $str = "";
     for ($i = 0; $i < 32; $i++) {
         $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
     }
     //签名
     $sign = $input->SetSign($key);
     $data = array();
     $data['pack'] = $result['prepay_id'];
     $data['appId'] = $appid;
     $data['timeStamp'] = TIMESTAMP;
     $data['nonceStr'] = $str;
     $data['signType'] = "MD5";
     $data['paySign'] = $sign;
     //生成订单
     //		$data2 = array(
     //			'uniacid' => $_W['uniacid'],
     //			'openid' => $myopenid,
     //			'ordersn' => date('Ymd').substr(time(), -5).substr(microtime(), 2, 5).sprintf('%02d', rand(0, 99)),
     //			'content'=>$content,
     //			'num' => $num,
     //			'status' => 0,//订单状态,-1取消状态,0普通状态,1为已付款,2为已发货,3为成功
     //			'fromopenid'=>$fromopenid,
     //			'content'=>
     //			'createtime' => TIMESTAMP
     //		);
     pdo_insert('beatuty_zhongchou_orders', $data2);
     $orderid = pdo_insertid();
     $order = pdo_fetch("SELECT * FROM " . tablename('beatuty_zhongchou_orders') . " WHERE id ={$orderid}");
     $params['tid'] = $order['ordersn'];
     $params['user'] = $_W['fans']['from_user'];
     $params['fee'] = $order['num'];
     $params['title'] = $_W['account']['name'];
     $params['ordersn'] = $order['ordersn'];
     $params['module'] = "beatuty_zhongchou";
     //转成json
     $dataall = array('data' => $data, 'params' => $params);
     return json_encode($dataall);
 }
开发者ID:noikiy,项目名称:mygit,代码行数:71,代码来源:site.php

示例5: setbalance


//.........这里部分代码省略.........
                                 //商品描述
                                 //自定义订单号,此处仅作举例
                                 $timeStamp = time();
                                 $out_trade_no = $payment_api_log['id'];
                                 $unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
                                 //商户订单号
                                 $unifiedOrder->setParameter("total_fee", $amt);
                                 //总金额
                                 $unifiedOrder->setParameter("notify_url", 'http://' . $host . $this->webroot . 'responds/weixin_balance');
                                 //通知地址
                                 $unifiedOrder->setParameter("trade_type", "JSAPI");
                                 //交易类型
                                 $prepay_id = $unifiedOrder->getPrepayId();
                                 $jsApi->setPrepayId($prepay_id);
                                 $jsApiParameters = $jsApi->getParameters();
                                 if (!empty($jsApiParameters)) {
                                     $json_result = json_decode($jsApiParameters);
                                     $code_url = isset($json_result->paySign) ? $jsApiParameters : '';
                                 }
                             } else {
                                 throw new SDKRuntimeException("支付失败,OpenId 获取失败");
                             }
                         } else {
                             Configure::write('debug', 0);
                             $this->layout = 'ajax';
                             $wechatpay_type = true;
                             App::import('Vendor', 'Weixinpay', array('file' => 'WxPay.Api.php'));
                             App::import('Vendor', 'Phpqcode', array('file' => 'phpqrcode.php'));
                             $input = new WxPayUnifiedOrder();
                             $input->SetKey($payment_config['KEY']);
                             $input->SetBody("用户充值[金额:" . $payment_amount . "]");
                             $input->SetAttach("用户充值");
                             $input->SetOut_trade_no($payment_api_log['id'] . "_" . time() . "_" . rand(0, 1000));
                             $input->SetAppid($payment_config['APPID']);
                             $input->SetMch_id($payment_config['MCHID']);
                             $input->SetTotal_fee($amt);
                             $input->SetTime_start(date("YmdHis"));
                             $input->SetTime_expire(date("YmdHis", time() + 600));
                             $input->SetGoods_tag("用户充值");
                             $input->SetNotify_url('http://' . $host . $this->webroot . 'responds/weixin_balance');
                             $input->SetProduct_id($payment_api_log['id']);
                             $input->SetTrade_type("NATIVE");
                             $notify = new NativePay();
                             $result = $notify->GetPayUrl($input);
                             $code_url = isset($result["code_url"]) ? $result["code_url"] : '';
                         }
                         $this->set('wechatpay_type', $wechatpay_type);
                         $message = '';
                         $code = '1';
                     } catch (Exception $e) {
                         $message = '支付失败,Caught exception: ' . $e->getMessage();
                         $code = '0';
                     }
                 } else {
                     //判断支付方式是否存在
                     $payment['Payment']['code'] = strtolower($payment['Payment']['code']);
                     try {
                         $payment_config = unserialize($payment['Payment']['config']);
                         App::import('Vendor', 'payments/' . $payment['Payment']['code']);
                         $balance_payment = new $payment['Payment']['code']();
                         if ($payment['Payment']['is_online'] == 1) {
                             //在线支付增加api日志
                             $payment_api_log = array('payment_code' => $payment['Payment']['code'], 'type' => 2, 'type_id' => $user_id, 'order_currency' => 'CHY', 'amount' => $this->data['pay']['money']);
                             $this->PaymentApiLog->save($payment_api_log);
                             //记录支付日志Id
                             $payment_api_log['id'] = $this->PaymentApiLog->id;
开发者ID:hobbysh,项目名称:seevia-opensource,代码行数:67,代码来源:users_controller.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";
     //检测必填参数
     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(WxPayConfig::NOTIFY_URL);
         //异步通知url
     }
     $inputObj->SetAppid(WxPayConfig::APPID);
     //公众账号ID
     $inputObj->SetMch_id(WxPayConfig::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);
     // 统一下单接口返回正常的prepay_id,再按签名规范重新生成签名后,将数据传输给APP。
     // 参与签名的字段名为appId,partnerId,prepayId,nonceStr,timeStamp,package。注意:package的值格式为Sign=WXPay
     $time_stamp = time();
     $pack = 'Sign=WXPay';
     //输出参数列表
     $prePayParams = array();
     $prePayParams['appid'] = $result['appid'];
     $prePayParams['partnerid'] = $result['mch_id'];
     $prePayParams['prepayid'] = $result['prepay_id'];
     $prePayParams['noncestr'] = $result['nonce_str'];
     $prePayParams['package'] = $pack;
     $prePayParams['timestamp'] = $time_stamp;
     //echo json_encode($prePayParams);
     $result = WxPayResults::InitFromArray($prePayParams, true)->GetValues();
     self::reportCostTime($url, $startTimeStamp, $result);
     //上报请求花费时间
     return $result;
 }
开发者ID:leidong666,项目名称:H5P.Server,代码行数:74,代码来源:WxPay.Api.php

示例7: balance_deposit2


//.........这里部分代码省略.........
                     //自定义订单号,此处仅作举例
                     $timeStamp = time();
                     $out_trade_no = $order_code;
                     $unifiedOrder->setParameter("out_trade_no", "{$out_trade_no}");
                     //商户订单号
                     $unifiedOrder->setParameter("total_fee", $amt);
                     //总金额
                     $unifiedOrder->setParameter("notify_url", 'http://' . $host . $this->webroot . 'responds/weixin_notify');
                     //通知地址
                     $unifiedOrder->setParameter("trade_type", "JSAPI");
                     //交易类型
                     $prepay_id = $unifiedOrder->getPrepayId();
                     $jsApi->setPrepayId($prepay_id);
                     $jsApiParameters = $jsApi->getParameters();
                     if (!empty($jsApiParameters)) {
                         $json_result = json_decode($jsApiParameters);
                         $code_url = isset($json_result->paySign) ? $jsApiParameters : '';
                         $this->set('url2', $code_url);
                     }
                 } else {
                     throw new SDKRuntimeException("支付失败,OpenId 获取失败");
                 }
             } else {
                 $this->layout = "ajax";
                 $wechatpay_type = true;
                 App::import('Vendor', 'Weixinpay', array('file' => 'WxPay.Api.php'));
                 App::import('Vendor', 'Phpqcode', array('file' => 'phpqrcode.php'));
                 $input = new WxPayUnifiedOrder();
                 $notify = new NativePay();
                 $input->SetKey($payment_config['KEY']);
                 $input->SetBody($order_code);
                 $input->SetAttach($order_code);
                 $input->SetOut_trade_no($order_code);
                 $input->SetAppid($payment_config['APPID']);
                 $input->SetMch_id($payment_config['MCHID']);
                 $input->SetTotal_fee($amt);
                 $input->SetTime_start(date("YmdHis"));
                 $input->SetTime_expire(date("YmdHis", time() + 600));
                 $input->SetGoods_tag($order_code);
                 $input->SetNotify_url('http://' . $host . $this->webroot . 'responds/weixin_notify');
                 $input->SetTrade_type("NATIVE");
                 $input->SetProduct_id($order_code);
                 $result = $notify->GetPayUrl($input);
                 $url2 = isset($result["code_url"]) ? $result["code_url"] : '';
                 $this->set('url2', $url2);
             }
             $this->set('order_code', $order_code);
             $this->set('wechatpay_type', $wechatpay_type);
         } else {
             $pay_form_txt = "";
             $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
             if ($this->RequestHandler->isMobile() && $payment['Payment']['code'] == 'alipay') {
                 //手机支付宝支付访问
                 $payment_api_log = array('payment_code' => $payment['Payment']['code'], 'type' => 1, 'type_id' => $orderid, 'order_id' => $order_code, 'order_currency' => 'CHY', 'amount' => $amount_money);
                 $this->PaymentApiLog->save($payment_api_log);
                 $alipay_config = array();
                 //合作身份者id,以2088开头的16位纯数字
                 $alipay_config['partner'] = isset($payment_config['partner']) ? $payment_config['partner'] : '';
                 //收款支付宝账号,一般情况下收款账号就是签约账号
                 $alipay_config['seller_id'] = isset($payment_config['partner']) ? $payment_config['partner'] : '';
                 //商户的私钥(后缀是.pen)文件相对路径
                 $alipay_config['private_key_path'] = ROOT . '/vendors/payments/alipaywap/key/rsa_private_key.pem';
                 //支付宝公钥(后缀是.pen)文件相对路径
                 $alipay_config['ali_public_key_path'] = ROOT . '/vendors/payments/alipaywap/key/rsa_public_key.pem';
                 //签名方式 不需修改
                 $alipay_config['sign_type'] = strtoupper('RSA');
开发者ID:hobbysh,项目名称:seevia-opensource,代码行数:67,代码来源:balances_controller.php


注:本文中的WxPayUnifiedOrder::SetAppid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。