Changeset 1597

Show
Ignore:
Timestamp:
12/20/2007 06:12:59 PM (13 months ago)
Author:
zombor
Message:

Add Trident Payment Gateway driver.
Some formatting and cleanup in other files.

Location:
trunk/system/libraries
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Payment.php

    r1449 r1597  
    1616                // The driver string 
    1717                'driver'      => NULL, 
    18                 // Curl config, see http://us.php.net/manual/en/function.curl-setopt.php for details 
    19                 'curl_config' => array 
    20                 ( 
    21                         CURLOPT_HEADER         => FALSE, 
    22                         CURLOPT_RETURNTRANSFER => TRUE, 
    23                         CURLOPT_SSL_VERIFYPEER => FALSE 
    24                 ), 
    2518                // Test mode is set to true by default 
    2619                'test_mode'   => TRUE, 
     
    2821 
    2922        protected $driver = NULL; 
    30         private $fields = array(); 
    3123 
    3224        /** 
     
    121113        public function set_fields($fields) 
    122114        { 
    123                 $this->driver->set_fields(array_merge($this->fields, (array) $fields)); 
     115                $this->driver->set_fields((array) $fields); 
    124116                 
    125117                return $this; 
     
    135127        public function process() 
    136128        { 
    137                 $this->set_fields($this->fields); 
    138129                return $this->driver->process(); 
    139130        } 
  • trunk/system/libraries/drivers/Payment_Authorize.php

    r1297 r1597  
    8383                } 
    8484 
    85                 $fields = ""; 
     85                $fields = ''; 
    8686                foreach( $this->authnet_values as $key => $value ) 
    8787                { 
     
    9292                                        'https://certification.authorize.net/gateway/transact.dll' : // Test mode URL 
    9393                                        'https://secure.authorize.net/gateway/transact.dll'; // Live URL 
    94                  
     94 
    9595                $ch = curl_init($post_url);  
    96                  
     96 
    9797                // Set custom curl options 
    9898                curl_setopt_array($ch, $this->curl_config); 
    9999 
    100100                // Set the curl POST fields 
    101                 curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); 
     101                curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, '& ')); 
    102102 
    103103                //execute post and get results 
    104104                $resp = curl_exec($ch); 
    105105                curl_close ($ch); 
     106                if (!$resp) 
     107                        throw new Kohana_Exception('payment.gateway_connection_error'); 
    106108 
    107109                // This could probably be done better, but it's taken right from the Authorize.net manual 
    108110                // Need testing to opimize probably 
    109                 $h = substr_count($resp, "|"); 
    110                  
     111                $h = substr_count($resp, '|'); 
     112 
    111113                for($j=1; $j <= $h; $j++) 
    112114                { 
    113                         $p = strpos($resp, "|"); 
     115                        $p = strpos($resp, '|'); 
    114116 
    115117                        if ($p !== FALSE) 
     
    119121                                $pstr_trimmed = substr($pstr, 0, -1); // removes "|" at the end 
    120122 
    121                                 if($pstr_trimmed=="") 
     123                                if($pstr_trimmed=='') 
    122124                                { 
    123125                                        throw new Kohana_Exception('payment.gateway_connection_error'); 
     
    137139                } 
    138140        } 
    139 } 
     141} // End Payment_Authorize_Driver Class 
    140142 
    141143/** 
  • trunk/system/libraries/drivers/Payment_Paypal.php

    r1493 r1597  
    1616class Payment_Paypal_Driver { 
    1717 
    18         private $required_fields = array(  
    19                                                                           'API_UserName'  => FALSE, 
    20                                                                           'API_Password'  => FALSE, 
    21                                                                           'API_Signature' => FALSE, 
    22                                                                           'API_Endpoint'  => TRUE, 
    23                                                                           'version'       => TRUE, 
    24                                                                           'Amt'           => FALSE, 
    25                                                                           'PAYMENTACTION' => TRUE, 
    26                                                                           'ReturnUrl'     => FALSE, 
    27                                                                           'CANCELURL'     => FALSE, 
    28                                                                           'CURRENCYCODE'  => TRUE 
    29                                                                         ); 
    30  
    31         private $paypal_values = array(  
    32                                                                         'API_UserName'  => '', 
    33                                                                         'API_Password'  => '', 
    34                                                                         'API_Signature' => '', 
    35                                                                         'API_Endpoint'  => 'https://api-3t.paypal.com/nvp', 
    36                                                                         'version'       => '3.0', 
    37                                                                         'Amt'           => 0, 
    38                                                                         'PAYMENTACTION' => 'Sale', 
    39                                                                         'ReturnUrl'     => '', 
    40                                                                         'CANCELURL'     => '', 
    41                                                                         'error_url'     => '', 
    42                                                                         'CURRENCYCODE'  => 'USD', 
    43                                                                         'payerid'       => '' 
    44                                                                   ); 
     18        private $required_fields = array('API_UserName'  => FALSE, 
     19                                         'API_Password'  => FALSE, 
     20                                         'API_Signature' => FALSE, 
     21                                         'API_Endpoint'  => TRUE, 
     22                                         'version'       => TRUE, 
     23                                         'Amt'           => FALSE, 
     24                                         'PAYMENTACTION' => TRUE, 
     25                                         'ReturnUrl'     => FALSE, 
     26                                         'CANCELURL'     => FALSE, 
     27                                         'CURRENCYCODE'  => TRUE); 
     28 
     29        private $paypal_values = array('API_UserName'  => '', 
     30                                       'API_Password'  => '', 
     31                                       'API_Signature' => '', 
     32                                       'API_Endpoint'  => 'https://api-3t.paypal.com/nvp', 
     33                                       'version'       => '3.0', 
     34                                       'Amt'           => 0, 
     35                                       'PAYMENTACTION' => 'Sale', 
     36                                       'ReturnUrl'     => '', 
     37                                       'CANCELURL'     => '', 
     38                                       'error_url'     => '', 
     39                                       'CURRENCYCODE'  => 'USD', 
     40                                       'payerid'       => ''); 
    4541 
    4642        private $paypal_url = ''; 
     
    6460 
    6561                $this->paypal_url = ($config['test_mode'])  
    66                                                   ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='  
    67                                                   : 'https://www.paypal.com/webscr&cmd=_express-checkout&token='; 
     62                                  ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='  
     63                                  : 'https://www.paypal.com/webscr&cmd=_express-checkout&token='; 
    6864 
    6965                $this->required_fields['API_UserName']  = !empty($config['API_UserName']); 
     
    104100 
    105101                        $this->paypal_values[$key] = $value; 
    106                          
     102 
    107103                        if (array_key_exists($key, $this->required_fields) AND !empty($value)) 
    108104                        { 
     
    221217        { 
    222218                $final_data = 'METHOD='.urlencode($method). 
    223                                   '&VERSION='.urlencode($this->paypal_values['version']). 
    224                                   '&PWD='.urlencode($this->paypal_values['API_Password']). 
    225                                   '&USER='.urlencode($this->paypal_values['API_UserName']). 
    226                                   'SIGNATURE='.urlencode($this->paypal_values['API_Signature']).$data; 
     219                              '&VERSION='.urlencode($this->paypal_values['version']). 
     220                              '&PWD='.urlencode($this->paypal_values['API_Password']). 
     221                              '&USER='.urlencode($this->paypal_values['API_UserName']). 
     222                              'SIGNATURE='.urlencode($this->paypal_values['API_Signature']).$data; 
    227223 
    228224                $ch = curl_init($this->paypal_values['API_Endpoint']); 
     
    288284                return $nvpArray; 
    289285        } 
    290 } 
     286} // End Payment_Paypal_Driver Class 
  • trunk/system/libraries/drivers/Payment_Trustcommerce.php

    r1297 r1597  
    127127                        return Kohana::lang('payment.error', Kohana::lang('payment.errors.Trustcommerce.'.$result['status'].'.'.$result['error'])); 
    128128        } 
    129 } 
     129} // End Payment_Trustcommerce_Driver Class