Advertisement
Guest User

payoption.php

a guest
Jun 17th, 2019
1,631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.62 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @version 3.2.5
  5. * @package Joomla 3.x
  6. * @subpackage DT Register
  7. * @copyright Copyright (C) 2006 DTH Development
  8. * @copyright contact dthdev@dthdevelopment.com
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  10. */
  11.  
  12. defined( '_JEXEC' ) or die( 'Restricted access' );
  13.  
  14. class DtregisterModelPayoption extends DtrModel {
  15.  
  16.    function __construct($config = array()){
  17.  
  18.        parent::__construct($config);
  19.  
  20.        $this->table = DtrTable::getInstance('Payoption','DtrTable');  // new TablePayoption($this->getDBO());
  21.  
  22.   }
  23.  
  24. }
  25.  
  26. class DtrTablePayoption extends DtrTable {
  27.  
  28.    var $id;
  29.  
  30.    var $name;
  31.  
  32.    var $default = 0;
  33.    
  34.    var $user_id;
  35.    
  36.    var $public = 0;
  37.  
  38.     function __construct( $db = null ) {
  39.  
  40.       $db = JFactory::getDBO();
  41.  
  42.       $this->db = $db;
  43.  
  44.       parent::__construct( '#__dtregister_payment', 'id', $db );
  45.  
  46.       $this->TablePayoptionconfig = DtrTable::getInstance('Payoptionconfig','DtrTable');
  47.  
  48.       $this->TablePaylater = DtrTable::getInstance('paylater','DtrTable');
  49.  
  50.    }   
  51.  
  52.    function save($data, $orderingFilter = '', $ignore = ''){
  53.  
  54.       parent::save($data['payment']);
  55.  
  56.       $this->TablePayoptionconfig->payment_id = $this->id;
  57.  
  58.       $this->getPaylaterIds($data);
  59.  
  60.       $this->TablePayoptionconfig->removeByPaymentid();
  61.  
  62.       $this->TablePayoptionconfig->saveAll($data['config']);
  63.  
  64.    }
  65.  
  66.    function getPaylaterIds($data){
  67.  
  68.        $this->TablePaylater->truncate();
  69.  
  70.        $paylaters = array();
  71.        
  72.        if (is_array($data['paylater']))
  73.        foreach($data['paylater'] as $key=>$name){
  74.  
  75.          if($data['paylaterIds'][$key] != 'new'){
  76.  
  77.             $paylater = array('name'=>$name,'id'=>$data['paylaterIds'][$key]);
  78.  
  79.          }else{
  80.  
  81.             $paylater = array('name'=>$name);
  82.  
  83.          }
  84.  
  85.          $this->TablePaylater->save($paylater);
  86.  
  87.          if($data['paylaterIds'][$key] == 'new'){
  88.  
  89.              $data['paylaterIds'][$key] = $this->TablePaylater->_db->insertid();
  90.  
  91.              if(isset($data['config']['pay_later_options'][$key]))
  92.  
  93.                $data['config']['pay_later_options'][$key] = $this->TablePaylater->_db->insertid();
  94.  
  95.          }
  96.  
  97.        }
  98.  
  99.    }
  100.    
  101.      function loaddefault() {
  102.        
  103.         $query = 'Select id from #__dtregister_payment where `default` = 1';
  104.        
  105.         $this->db->setQuery($query);
  106.        
  107.         $id = $this->db->loadResult();
  108.         //$this->load($id);
  109.         $this->name = "";
  110.         $this->id = 0;
  111.         $this->default = 0;
  112.         $this->config = $this->get_blank_config($id);
  113.        
  114.    }
  115.    
  116.    public function load($id = null, $reset = true){
  117.          
  118.          parent::load($id,$reset);
  119.  
  120.          $this->config = $this->getConfig();
  121.  
  122.    }
  123.  
  124.    function getConfig(){
  125.  
  126.      $temp = array();
  127.  
  128.      $data = $this->TablePayoptionconfig->find(' payment_id = "'.$this->id.'"');
  129.  
  130.      $config_array = array(
  131.  
  132.                                  'paymentmethod',
  133.                                  'cardtype',
  134.                                  'pay_later_options',
  135.                                  'cardtype',
  136.                                  'field_options',
  137.                                  'paylater_field_options'
  138.  
  139.                                );
  140.                                
  141.      if (is_array($data))
  142.      foreach($data as $val){
  143.  
  144.        if(in_array($val->key,$config_array) && !is_array($val->value)){
  145.  
  146.           $val->value = explode(",",$val->value);
  147.  
  148.        }
  149.  
  150.        $temp[$val->key] = $val->value;
  151.  
  152.      }
  153.      $configs = $this->get_blank_config();
  154.      
  155.      foreach($configs as $key => $value) {
  156.         if(!isset($temp[$key])){
  157.             $temp[$key] = $value;
  158.         }
  159.      }
  160.      return $temp;
  161.  
  162.   }
  163.  
  164.   function get_blank_config($default_id = 0) { 
  165.        
  166.         return array (
  167.                         'payfast_merchant_id' => '',
  168.                         'worldpay_instId' => '',
  169.                         'payfast_merchant_key' => '',
  170.                         'payfast_accountname' => '',
  171.                         'pay_later_options' =>
  172.                                                 array (
  173.                                                 ),
  174.                         'quickbook_app_login' => '',
  175.                         'payfast_username' => '',
  176.                         'quickbook_connection_ticket' => '',
  177.                         'quickbook_app_ID' => '',
  178.                         'netdeposit_clientid' => '',
  179.                         'netdeposit_clientcode' => '',
  180.                         'sage_M_key' => '',
  181.                         'sage_M_id' => '',
  182.                         'idealLiteHashKey' => '',
  183.                         'idealLiteMerchantId' => '',
  184.                         'partner_id' => '',
  185.                         'usaepay_key' => '',
  186.                         'ewaytype' => '',
  187.                         'eway_username' => '',
  188.                         'psitype' => '',
  189.                         'eway_customerid' => '',
  190.                         'psi_live_url' => '',
  191.                         'psi_storeid' => '',
  192.                         'psi_passphrase' => '',
  193.                         'psi_merchantId' => '',
  194.                         'safe_pay_account_id' => '',
  195.                         'paypal_pro_country' => '',
  196.                         'paypal_api_user' => '',
  197.                         'paypalid' => '',
  198.                         'paypal_api_signature' => '',
  199.                         'paypal_api_password' => '',
  200.                         'transkey' => '',
  201.                         'merchid' => '',
  202.                         'field_options' =>
  203.                                             array (
  204.                                             ),
  205.                         'depend_on_field' => '',
  206.                         'offline_zero_credit' => '',
  207.                         'cardtype' =>
  208.                                       array (
  209.                                       ),
  210.                         'godaddy_hosting' => '',
  211.                         'paymentmethod' =>
  212.                                             array (
  213.                                             ),
  214.                         'paymentmode' => '',
  215.                         'currency_separator' => '',
  216.                         'currency_code' => '',
  217.                         'transfirst_merchid' => '',
  218.                         'transfirst_transkey' => '',
  219.                         'paylater_field' => '',
  220.                         'paylater_field_options' => array (
  221.                                             ),
  222.                         'korta_merchant' => '',
  223.                         'korta_terminal' => '',
  224.                         'korta_secretcode' => '',
  225.                         'authorizenet_type' => 'aim',
  226.                         'ps_store_id' =>'',
  227.                         'hpp_key' => '',
  228.                         'moneris_type' => 'hosted',
  229.                         'moneris_cvv_enable'=> '0',
  230.                         'pxpay_username'=>'',
  231.                         'pxpay_password'=>'',
  232.                         'epdq_id'=>'',
  233.                         'epdq_pass'=>'',
  234.                         'sagpay_email_to'=>'',
  235.                         'sagpay_etype'=>'AES',
  236.                         'sagpay_protocol'=>'2.23',
  237.                         'sagpay_password'=>'',
  238.                         'sagpay_vendor_email'=>'',
  239.                         'sagpay_vendor'=>'',
  240.                         'sofort_config_id'=>'',
  241.                         'sofort_project_id'=>'',
  242.                         'authorizenet_header_txt'=>''
  243.                       );       
  244.        
  245.   }
  246.  
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement