Changeset 1978

Show
Ignore:
Timestamp:
02/06/2008 09:40:02 PM (10 months ago)
Author:
zombor
Message:

Fixing a bug where Paypal cares about the order of variables it receives.

Files:
1 modified

Legend:

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

    r1938 r1978  
    3535                'API_Signature' => '', 
    3636                'API_Endpoint'  => 'https://api-3t.paypal.com/nvp', 
    37                 'version'       => '3.0', 
     37                'version'       => '3.2', 
    3838                'Amt'           => 0, 
    3939                'PAYMENTACTION' => 'Sale', 
     
    5959                $this->paypal_values['ReturnUrl']     = $config['ReturnUrl']; 
    6060                $this->paypal_values['CANCELURL']     = $config['CANCELURL']; 
     61                $this->paypal_values['error_url']     = $config['CANCELURL']; 
    6162                $this->paypal_values['CURRENCYCODE']  = $config['CURRENCYCODE']; 
    6263                $this->paypal_values['API_Endpoint']  = ($config['test_mode']) ? 'https://api.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; 
     
    158159        protected function paypal_login() 
    159160        { 
    160                 $data = '&Amt='.$this->paypal_values['Amt']. 
    161                         '&PAYMENTACTION='.$this->paypal_values['PAYMENTACTION']. 
    162                         '&ReturnURL='.$this->paypal_values['ReturnUrl']. 
    163                         '&CancelURL='.$this->paypal_values['CANCELURL']; 
     161                $data = '&AMT='.urlencode($this->paypal_values['Amt']). 
     162                        //'&PAYMENTACTION='.$this->paypal_values['PAYMENTACTION']. 
     163                        '&RETURNURL='.urlencode($this->paypal_values['ReturnUrl']). 
     164                        '&CANCELURL='.urlencode($this->paypal_values['CANCELURL']); 
    164165 
    165166                $reply = $this->contact_paypal('SetExpressCheckout', $data); 
     
    195196        protected function contact_paypal($method, $data) 
    196197        { 
    197                 $final_data = 'METHOD='.urlencode($method). 
     198                $final_data = 'USER='.urlencode($this->paypal_values['API_UserName']). 
     199                              '&PWD='.urlencode($this->paypal_values['API_Password']). 
     200                              '&SIGNATURE='.urlencode($this->paypal_values['API_Signature']). 
    198201                              '&VERSION='.urlencode($this->paypal_values['version']). 
    199                               '&PWD='.urlencode($this->paypal_values['API_Password']). 
    200                               '&USER='.urlencode($this->paypal_values['API_UserName']). 
    201                               'SIGNATURE='.urlencode($this->paypal_values['API_Signature']).$data; 
     202                              '&METHOD='.urlencode($method).$data; 
    202203 
    203204                Log::add('debug', 'Connecting to '.$this->paypal_values['API_Endpoint']); 
     
    218219                        // Moving to error page to display curl errors 
    219220                        $this->session->set_flash(array('curl_error_no' => curl_errno($ch), 'curl_error_msg' => curl_error($ch))); 
    220                         url::redirect($this->error_url); 
     221                        url::redirect($this->paypal_values['error_url']); 
    221222                } 
    222223                else