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


PHP Payment::loadMethod方法代碼示例

本文整理匯總了PHP中Payment::loadMethod方法的典型用法代碼示例。如果您正苦於以下問題:PHP Payment::loadMethod方法的具體用法?PHP Payment::loadMethod怎麽用?PHP Payment::loadMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Payment的用法示例。


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

示例1: Payment

 /**
  * 添加/修改支付方式插件
  */
 function payment_edit()
 {
     //支付方式插件編號
     $pluginId = IReq::get("id");
     //支付方式配置編號
     $payId = IReq::get("payid");
     //初始化支付插件類
     $payment = new Payment();
     $pay_info = array('type' => 1, 'poundage_rate' => 0, 'poundage_fix' => 0, 'poundage_type' => 1, 'config' => '', 'description' => ' ');
     //如果支付配置編號已存在,查找支付方式配置表
     if ($payId != null) {
         $paymentObj = new IModel('payment');
         $pay_info = $paymentObj->getObj("id = " . $payId);
         $pluginId = $pay_info['plugin_id'];
         if ($pay_info['poundage_type'] == 1) {
             $pay_info['poundage_rate'] = $pay_info['poundage'];
             $pay_info['poundage_fix'] = 0;
         } else {
             $pay_info['poundage_fix'] = $pay_info['poundage'];
             $pay_info['poundage_rate'] = 0;
         }
     }
     //初始化支付插件表
     $pay_pluginObj = new IModel('pay_plugin');
     //根據支付插件編號 獲取該插件的詳細信息
     $plugin_info = $pay_pluginObj->getObj("id = " . $pluginId);
     //根據支付插件file_path路徑獲取該支付插件的類
     $payObj = $payment->loadMethod($plugin_info['file_path']);
     if (!isset($pay_info['name'])) {
         $pay_info['name'] = $plugin_info['name'];
     }
     $config = isset($pay_info['config']) ? unserialize($pay_info['config']) : array();
     //獲取支付插件字段
     $aField = $payObj->getfields();
     //支持貨幣
     $pay_info['SupportCurrency'] = $payment->getSupportCurrency($payObj->supportCurrency);
     if ($aField) {
         //處理支付插件擴展屬性
         if (isset($config['ConnectType'])) {
             foreach ($aField['ConnectType']['extendcontent'] as $key => $val) {
                 foreach ($val['value'] as $ekey => $eval) {
                     if (isset($config['bankId'])) {
                         foreach ($config['bankId'] as $eitem) {
                             if ($eval['value'] == $eitem) {
                                 $aField['ConnectType']['extendcontent'][$key]['value'][$ekey]['checked'] = 'checked';
                                 break;
                             } else {
                                 $aField['ConnectType']['extendcontent'][$key]['value'][$ekey]['checked'] = '';
                             }
                         }
                     }
                 }
             }
         }
     }
     //插件類型
     $pay_info['file_path'] = $plugin_info['file_path'];
     $pay_info['config'] = $config;
     $pay_info['attr_list'] = $aField;
     $pay_info['plugin_id'] = $pluginId;
     $pay_info['pay_id'] = $payId;
     //把數據渲染到視圖
     $this->setRenderData($pay_info);
     $this->redirect('payment_edit');
 }
開發者ID:chenyongze,項目名稱:iwebshop,代碼行數:68,代碼來源:system.php

示例2: IModel

 function server_callback()
 {
     $payment_name = is_array($payment_name = IReq::get('payment_name')) ? IFilter::act($payment_name[0]) : IFilter::act(IReq::get('payment_name'));
     //初始化參數
     $money = null;
     $message = null;
     $tradeno = null;
     //獲取支付payment的id值
     $pObj = new IModel('payment as a,pay_plugin as b');
     $paymentRow = $pObj->getObj('b.file_path = "' . $payment_name . '" and a.plugin_id = b.id', 'a.id');
     //載入支付接口文件
     $paymentObj = new Payment();
     $payObj = $paymentObj->loadMethod($payment_name);
     if (!is_object($payObj)) {
         echo 'fail';
         exit;
     }
     //執行接口回調函數
     $return = $payObj->serverCallback(array_merge($_POST, $_GET), $paymentRow['id'], $money, $message, $tradeno);
     //判斷返回狀態
     if ($return == 1) {
         if (stripos($tradeno, 'recharge_') !== false) {
             $tradenoArray = explode('_', $tradeno);
             $recharge_no = isset($tradenoArray[1]) ? $tradenoArray[1] : 0;
             if (payment::updateRecharge($recharge_no)) {
                 echo 'success';
                 exit;
             } else {
                 echo 'fail';
             }
         } else {
             if (payment::updateOrder($tradeno)) {
                 echo 'success';
                 exit;
             } else {
                 echo 'fail';
             }
         }
     } else {
         echo 'fail';
     }
 }
開發者ID:chenyongze,項目名稱:iwebshop,代碼行數:42,代碼來源:block.php

示例3: intval

 function payment_balance()
 {
     $urlStr = '';
     $user_id = intval($this->user['user_id']);
     $return['attach'] = IReq::get('attach');
     $return['total_fee'] = IReq::get('total_fee');
     $return['order_no'] = IReq::get('order_no');
     $return['return_url'] = IReq::get('return_url');
     $sign = IReq::get('sign');
     if (stripos($return['order_no'], 'recharge_') !== false) {
         IError::show(403, '餘額支付方式不能用於在線充值');
         exit;
     }
     if (floatval($return['total_fee']) <= 0 || $return['order_no'] == '' || $return['return_url'] == '') {
         IError::show(403, '支付參數不正確');
     } else {
         $paymentObj = new Payment();
         $payObj = $paymentObj->loadMethod('balance');
         $pkey = $payObj->getConf(IFilter::act($return['attach']), 'PrivateKey');
         //md5校驗
         ksort($return);
         foreach ($return as $key => $val) {
             $urlStr .= $key . '=' . urlencode($val) . '&';
         }
         $urlStr .= $user_id . $pkey;
         if ($sign != md5($urlStr)) {
             IError::show(403, '數據校驗不正確');
         } else {
             $memberObj = new IModel('member');
             $memberRow = $memberObj->getObj('user_id = ' . $user_id);
             if (empty($memberRow)) {
                 IError::show(403, '用戶信息不存在');
                 exit;
             } else {
                 if ($memberRow['balance'] < $return['total_fee']) {
                     IError::show(403, '賬戶餘額不足');
                     exit;
                 } else {
                     $orderObj = new IModel('order');
                     $orderRow = $orderObj->getObj('order_no  = "' . IFilter::act($return['order_no']) . '" and pay_status = 0');
                     if (empty($orderRow)) {
                         IError::show(403, '訂單已經被處理過,請查看訂單狀態');
                         exit;
                     }
                     $dataArray = array('balance' => 'balance - ' . IFilter::act($return['total_fee']));
                     $memberObj->setData($dataArray);
                     $is_success = $memberObj->update('user_id = ' . $user_id, 'balance');
                     if ($is_success) {
                         $return['is_success'] = 'T';
                     } else {
                         $return['is_success'] = 'F';
                     }
                     ksort($return);
                     //返還的URL地址
                     $responseUrl = '';
                     foreach ($return as $key => $val) {
                         $responseUrl .= $key . '=' . urlencode($val) . '&';
                     }
                     $nextUrl = urldecode($return['return_url']);
                     if (stripos($nextUrl, '?') === false) {
                         $return_url = $nextUrl . '?' . $responseUrl;
                     } else {
                         $return_url = $nextUrl . '&' . $responseUrl;
                     }
                     //計算要發送的md5校驗
                     $urlStrMD5 = md5($responseUrl . $user_id . $pkey);
                     //拚接進返還的URL中
                     $return_url .= 'sign=' . $urlStrMD5;
                     header('location:' . $return_url);
                 }
             }
         }
     }
 }
開發者ID:chenyongze,項目名稱:iwebshop,代碼行數:74,代碼來源:ucenter.php


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