Exemple #1
0
 function save()
 {
     global $mainframe, $option;
     $task = JRequest::getCmd('task');
     JRequest::checkToken() or jexit('Invalid Token');
     $model =& $this->getModel('payment_method');
     $model->payment_id = JRequest::getVar('payment_id');
     $model->payment_enabled = JRequest::getInt('payment_enabled');
     $model->payment_method_name = JRequest::getVar('payment_method_name');
     $model->payment_method_code = JRequest::getVar('payment_method_code');
     $model->payment_class = JRequest::getVar('payment_class');
     $enable_processor = JRequest::getVar('enable_processor');
     $model->enable_processor = $enable_processor;
     if (empty($enable_processor)) {
         $model->is_creditcard = 1;
     } else {
         $model->is_creditcard = 0;
     }
     $model->payment_class = JRequest::getVar('payment_class');
     $creditcard = JRequest::getVar('creditcard');
     $model->creditcard = implode(',', $creditcard);
     $model->accepted_creditcards = JRequest::getVar('accepted_creditcards');
     $model->payment_extrainfo = JRequest::getVar('payment_extrainfo', '', JREQUEST_ALLOWHTML);
     $rs = $model->save();
     //write config
     $path = dirname(__FILE__) . DS . '..' . DS . 'paymentclass';
     if ($model->payment_class) {
         if (include_once $path . DS . $model->payment_class) {
             eval("\$_PAYMENT = new " . str_replace('.php', '', $model->payment_class) . "();");
         }
     } else {
         include $path . "ps_payment.php";
         $_PAYMENT = new ps_payment();
     }
     $_PAYMENT->write_configuration();
     //end write
     $this->setRedirect('index.php?option=' . $option . '&view=payment_method');
 }
 /**
  * Updates a Payment Entry
  *
  * @param array $d
  * @return boolean
  */
 function update(&$d)
 {
     global $VM_LANG;
     global $vmLogger, $VM_LANG;
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     $db = new ps_DB();
     if (!$this->validate_update($d)) {
         return False;
     }
     if (!empty($d["payment_class"])) {
         $payment_class = basename($d["payment_class"]);
         @(include CLASSPATH . "payment/" . $payment_class . ".php");
         if (class_exists($payment_class)) {
             $_PAYMENT = new $payment_class();
         } else {
             $GLOBALS['vmLogger']->err($VM_LANG->_('VM_PAYMENTMETHOD_CLASS_NOT_EXIST'));
             return false;
         }
     } else {
         include CLASSPATH . "payment/ps_payment.php";
         $_PAYMENT = new ps_payment();
     }
     if ($_PAYMENT->configfile_writeable() || $_PAYMENT->classname == 'ps_payment') {
         $_PAYMENT->write_configuration($d);
         $vmLogger->info($VM_LANG->_('VM_CONFIGURATION_CHANGE_SUCCESS', false));
     } else {
         $vmLogger->err(sprintf($VM_LANG->_('VM_CONFIGURATION_CHANGE_FAILURE', false), CLASSPATH . "payment/" . $_PAYMENT->classname . ".cfg.php"));
         return false;
     }
     $fields = array('payment_method_name' => vmGet($d, 'payment_method_name'), 'payment_class' => vmGet($d, 'payment_class'), 'shopper_group_id' => vmRequest::getInt('shopper_group_id'), 'payment_method_discount' => vmRequest::getFloat('payment_method_discount'), 'payment_method_discount_is_percent' => vmGet($d, 'payment_method_discount_is_percent'), 'payment_method_discount_max_amount' => (double) str_replace(',', '.', $d["payment_method_discount_max_amount"]), 'payment_method_discount_min_amount' => (double) str_replace(',', '.', $d["payment_method_discount_min_amount"]), 'payment_method_code' => vmGet($d, 'payment_method_code'), 'enable_processor' => vmGet($d, 'enable_processor'), 'list_order' => vmRequest::getInt('list_order'), 'is_creditcard' => vmGet($d, 'is_creditcard'), 'payment_enabled' => vmGet($d, 'payment_enabled'), 'accepted_creditcards' => vmGet($d, 'accepted_creditcards'), 'payment_extrainfo' => vmGet($_POST, 'payment_extrainfo', null, VMREQUEST_ALLOWRAW));
     $db->buildQuery('UPDATE', '#__{vm}_payment_method', $fields, 'WHERE payment_method_id=' . (int) $d["payment_method_id"] . ' AND vendor_id=' . $ps_vendor_id);
     $db->query();
     return True;
 }
$option = empty($option) ? vmGet($_REQUEST, 'option', 'com_virtuemart') : $option;
$vars['payment_enabled'] = "Y";
$default['payment_class'] = 'ps_payment';
if (!empty($payment_method_id)) {
    $q = "SELECT * FROM #__{vm}_payment_method WHERE vendor_id='{$ps_vendor_id}' AND ";
    $q .= "payment_method_id='{$payment_method_id}'";
    $db->query($q);
    $db->next_record();
}
if ($db->f("payment_class")) {
    if (include_once CLASSPATH . "payment/" . $db->f("payment_class") . ".php") {
        eval("\$_PAYMENT = new " . $db->f("payment_class") . "();");
    }
} else {
    include CLASSPATH . "payment/ps_payment.php";
    $_PAYMENT = new ps_payment();
}
//First create the object and let it print a form heading
$formObj = new formFactory($VM_LANG->_('PHPSHOP_PAYMENT_METHOD_FORM_LBL'));
//Then Start the form
$formObj->startForm();
?>
<br />
<?php 
$tabs = new vmTabPanel(0, 1, "paymentform");
$tabs->startPane("content-pane");
$tabs->startTab($VM_LANG->_('PHPSHOP_PAYMENT_METHOD_FORM_LBL'), "global-page");
?>
<table class="adminform">
    <tr class="row0">
      <td class="labelcell"><?php