當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。