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


PHP WxPayApi类代码示例

本文整理汇总了PHP中WxPayApi的典型用法代码示例。如果您正苦于以下问题:PHP WxPayApi类的具体用法?PHP WxPayApi怎么用?PHP WxPayApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_payurl

 /**
  * 组装包含支付信息的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"];
 }
开发者ID:dotku,项目名称:shopnc_cnnewyork,代码行数:30,代码来源:wxpay.php

示例2: GetOrderInfo

 public function GetOrderInfo($input)
 {
     if ($input->GetTrade_type() == "APP") {
         $result = WxPayApi::unifiedOrder($input, true);
         return $result;
     }
 }
开发者ID:lubaogui,项目名称:yii2-payment,代码行数:7,代码来源:WxPay.NativePay.php

示例3: Queryorder

 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     \Log::info("query:" . json_encode($result));
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         // 处理订单
         $pay = \App\Pay::find($result['out_trade_no']);
         $pay->pay($result['transaction_id']);
         if ($pay->state < 2) {
             $pay->state = '2';
             $pay->bak_id = '0';
             $pay->other_id = $result['transaction_id'];
             $pay->save();
         } else {
             if ($pay->state == 2) {
                 $pay->bak_id++;
                 $pay->save();
             }
         }
         return true;
     }
     return false;
 }
开发者ID:jiangchengbin,项目名称:weixin,代码行数:25,代码来源:notify.php

示例4: JsApiPay

 /**
  * jsapi支付
  * @param string  $user_id    用户id
  * @param int     $order_id
  * @param string  $order_sn   订单号
  * @param int     $total_fee  费用
  * @param string  $body       商品或支付单简要描述
  * @param string  $goods_tag  商品标记
  * @param string  $attach     自定义数据
  * @return array
  */
 public function JsApiPay($user_id, $order_id, $order_sn, $total_fee, $body = '', $goods_tag = '', $attach = '')
 {
     if (empty($user_id) || empty($total_fee)) {
         return ['status' => -1, 'message' => '数据错误'];
     }
     $tools = new JsApiPay();
     $openId = UserModel::instance()->getOpenId($user_id);
     if (empty($openId)) {
         $openId = $tools->GetOpenid();
         //             return ['status'=> -2 , 'message'=>'user_id错误'];
     }
     $input = new \WxPayUnifiedOrder();
     $input->SetBody($body);
     $input->SetAttach($attach);
     $input->SetOut_trade_no($order_sn);
     //\WxPayConfig::MCHID.date("YmdHis")
     $input->SetTotal_fee($total_fee);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag($goods_tag);
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($openId);
     $order = \WxPayApi::unifiedOrder($input);
     if ($order['return_code'] != 'SUCCESS') {
         return ['status' => -10, 'message' => $order['return_msg']];
     }
     $jsApiParameters = $tools->GetJsApiParameters($order);
     $this->addPayLog($openId, $order_id, $input);
     return ['status' => 1, 'message' => $jsApiParameters];
 }
开发者ID:xswolf,项目名称:dc,代码行数:41,代码来源:PayEvent.class.php

示例5: getAppPaymentParameters

 public function getAppPaymentParameters($order)
 {
     /*
     $order =null;
     $order = $this->queryOrder($out_trade_no);
     //        print json_encode($order)  .PHP_EOL;
         if ($order) {
             $input = new \WxPayReverse();
             $input->SetOut_trade_no($out_trade_no);
             $result = \WxPayApi::reverse($input);
             print('reserve:'.json_encode($result)) .PHP_EOL;
     //            $input = new \WxPayCloseOrder();
     //            $input->SetOut_trade_no($out_trade_no);
     //            $result = \WxPayApi::closeOrder($input);
     //            print('close:'.json_encode($result)) .PHP_EOL;
         }
     */
     $wxPayConfig = $this->wxPayApi->getWxPayConfig();
     //                print( json_encode($order ) ) .PHP_EOL;
     $prepay_id = $order['prepay_id'];
     $response = array('appid' => $wxPayConfig['APPID'], 'partnerid' => $wxPayConfig['MCHID'], 'prepayid' => $prepay_id, 'package' => 'Sign=WXPay', 'noncestr' => \WxPayApi::getNonceStr(), 'timestamp' => time());
     $response['sign'] = $this->calculateSign($response, $wxPayConfig['KEY']);
     // send it to APP
     return $response;
 }
开发者ID:fishlab,项目名称:wechat-sdk-php,代码行数:25,代码来源:WechatAppPayment.php

示例6: GetPayUrl

 /**
  * 
  * 生成直接支付url,支付url有效期为2小时,模式二
  * @param UnifiedOrderInput $input
  */
 public function GetPayUrl($input)
 {
     if ($input->GetTrade_type() == "NATIVE") {
         $result = WxPayApi::unifiedOrder($input);
         return $result;
     }
 }
开发者ID:superSN,项目名称:tyrolland,代码行数:12,代码来源:WxPayNativePay.php

示例7: Queryorder

 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     //		Log::DEBUG("query:" . json_encode($result));
     ilog(iLOG_INFO, 'Queryorder:' . json_encode($result), __LINE__);
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         $user_trade_no = $result['out_trade_no'];
         $transaction_id = $result['transaction_id'];
         $info1 = 'wxapp/interface/appnotify.php,operator success,session == trade_no,ordernum:' . $user_trade_no . ',wxno:' . $transaction_id;
         ilog(iLOG_INFO, $info1, __LINE__);
         $body_arr['order_no'] = $user_trade_no;
         $body_arr['pay_result'] = 2;
         //支付成功
         $body_arr['alipay_no'] = $transaction_id;
         //微信流水号
         $body_arr['channel'] = 'wxapp';
         //
         $ret = exec_procedure($body_arr, 'p_order_pay_result');
         if ($ret['status'] == 0 || $ret['status'] == 1040) {
             //成功,返回success
             return true;
         } else {
             //返回错误码,非success
             $info = 'wxapp/interface/appnotify.php,p_order_pay_result failed';
             ilog(iLOG_INFO, $info, __LINE__);
             return false;
         }
     }
     $info = 'wxapp/interface/appnotify.php,operator failed';
     ilog(iLOG_INFO, $info, __LINE__);
     //验证失败
     return false;
 }
开发者ID:yonglinchen,项目名称:shopping,代码行数:35,代码来源:appnotify.php

示例8: generateQrOrder

 /** 二维码订单 */
 public function generateQrOrder()
 {
     $input = $this->unifiedOrder();
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id("123456789");
     $order = \WxPayApi::unifiedOrder($input);
     $qrUrl = $order["code_url"];
     return $qrUrl;
 }
开发者ID:krissss,项目名称:YunDou-advanced,代码行数:10,代码来源:RechargeForm.php

示例9: myrefund

 public function myrefund($transid)
 {
     global $_W, $_GPC;
     include_once 'WxPay.Api.php';
     $WxPayApi = new WxPayApi();
     $input = new WxPayRefund();
     load()->func('communication');
     load()->model('account');
     $accounts = uni_accounts();
     $acid = $_W['uniacid'];
     $path_cert = '../addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_cert.pem';
     //证书路径
     $path_key = '../addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_key.pem';
     //证书路径
     $key = $this->module['config']['apikey'];
     //商户支付秘钥(API秘钥)
     $appid = $accounts[$acid]['key'];
     //身份标识(appid)
     //	 			$appsecret = $accounts[$acid]['secret'];//身份密钥(appsecret)
     $mchid = $this->module['config']['mchid'];
     //微信支付商户号(mchid)
     $order_out = pdo_fetch("select * from" . tablename('tg_order') . "where transid = '{$transid}'");
     $fee = $order_out['price'] * 100;
     //退款金额
     $refundid = $transid;
     //微信订单号
     message("key=" . $key . "appid=" . $appid . "mchid=" . $mchid . "fee=" . $fee . "refundid=" . $refundid);
     exit;
     /*$input:退款必须要的参数*/
     $input->SetAppid($appid);
     $input->SetMch_id($mchid);
     $input->SetOp_user_id($mchid);
     $input->SetOut_refund_no($mchid . date("YmdHis"));
     $input->SetRefund_fee($fee);
     $input->SetTotal_fee($fee);
     $input->SetTransaction_id($refundid);
     $result = $WxPayApi->refund($input, 6, $path_cert, $path_key, $key);
     if ($result['return_code'] == 'SUCCESS') {
         return 'success';
     } else {
         return 'fail';
     }
 }
开发者ID:ChainBoy,项目名称:wxfx,代码行数:43,代码来源:message.php

示例10: Queryorder

 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     return false;
 }
开发者ID:monkeychen,项目名称:website,代码行数:10,代码来源:qrcode_wxpay_notify.php

示例11: wxJsPay

 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);
 }
开发者ID:aising,项目名称:ding,代码行数:55,代码来源:PayController.php

示例12: Queryorder

 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     $log = Log::factory(NT_LOGS_PATH . 'wxpay_saoma/');
     $log->write('wxpay_saoma_notify_orderQuery', "订单查询失败\n" . json_encode($result) . "\n");
     return false;
 }
开发者ID:lughong,项目名称:test,代码行数:12,代码来源:notify.php

示例13: Queryorder

 public function Queryorder($mpid, $transaction_id)
 {
     //\TMS_APP::M('log')->log('debug', 'pay-Queryorder', '0');
     $input = new \WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = \WxPayApi::orderQuery($mpid, $input);
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     //\TMS_APP::M('log')->log('debug', 'pay-Queryorder', 'ok');
     return false;
 }
开发者ID:ahmatjan,项目名称:xinxintong,代码行数:12,代码来源:payok.php

示例14: generateQrOrder

 /** 二维码订单 */
 public function generateQrOrder($scheme)
 {
     $user = Yii::$app->session->get('user');
     $input = $this->unifiedOrder($scheme['payMoney']);
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id("123456789");
     $input->SetAttach($user['userId'] . "|" . $scheme['getBitcoin']);
     //传递用户id和获取到的云豆数
     $order = \WxPayApi::unifiedOrder($input);
     $qrUrl = $order["code_url"];
     return $qrUrl;
 }
开发者ID:krissss,项目名称:YunDou-advanced,代码行数:13,代码来源:WxPayFunctions.php

示例15: Queryorder

 public function Queryorder($data)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($data['transaction_id']);
     $input->SetTradeType($data['trade_type']);
     $result = WxPayApi::orderQuery($input, Config::API_TIMEOUT);
     $this->query_data = $result;
     Log::DEBUG("query:" . json_encode($result));
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     return false;
 }
开发者ID:OranTing,项目名称:gdby_github_repo,代码行数:13,代码来源:notify.php


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