• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] testing paypal ipn

#1
[eluser]SPeed_FANat1c[/eluser]
Hi,

I am having trouble testing this thing. The function works when I access it from browser. But when I try to test it with ipn simulator, then I get an error

IPN delivery failed. HTTP error code 500: Internal Server Error

and have no idea what is wrong.

And I made a non CI test function for IPN, and tested it with simulator and it was succesful. Is there a way to get more information about the error, some log somewhere or something, why the delivery failed?

Edit:

something was wrong with the function code itself, when I commented it all out then I get
IPN successfully sent message.

I thought that it has so send the IPN for any code in the function. Will now debug the code in parts and try to catch the bug.

#2
[eluser]SPeed_FANat1c[/eluser]
And found where was the problem:

we have a logging function in helper:

Code:
function log_action($type, $description, $info = FALSE)
{
    $CI =& get_instance();
    
    $data = array('uid' => (isset($info['user'])) ? $info['user'] : $CI->session->userdata('user_id'),
                  'imone' => (isset($info['company'])) ? $info['company'] : $CI->session->userdata('imones_id'),
                  'tipas' => $type,
                  'info' => $description,
                  'ip' => $_SERVER['REMOTE_ADDR'],
                  'browser' => $_SERVER['HTTP_USER_AGENT'],
                  'referrer' => (@$_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "",
                  'data' => date("Y-m-d H:i:s")
                  );    
    
    $CI->db->insert('log',$data);
}

It works well everywhere. But when we use in the IPN function and run that function with simulator, it fails. Now I made the same function in the controller, slightly modiefied:

Code:
private function log_action($type, $description, $info = FALSE)
    {
        //$CI =& get_instance();
        
        $data = array('uid' => (isset($info['user'])) ? $info['user'] : $CI->session->userdata('user_id'),
                      'imone' => (isset($info['company'])) ? $info['company'] : $CI->session->userdata('imones_id'),
                      'tipas' => $type,
                      'info' => $description,
                      'ip' => $_SERVER['REMOTE_ADDR'],
                      'browser' => $_SERVER['HTTP_USER_AGENT'],
                      'referrer' => (@$_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "",
                      'data' => date("Y-m-d H:i:s")
                      );    
        
        $this->db->insert('log',$data);
    }

And now run the simulator - it also runs succesfully, though I don't see any new rows in database log table :/

If you have an idea why the original function from helper makes IPN delivery fail, you're welcome to tell Smile

#3
[eluser]SPeed_FANat1c[/eluser]
this line was causing problems:

Code:
'browser' => $_SERVER['HTTP_USER_AGENT'],

#4
[eluser]InsiteFX[/eluser]
If your using session library with database you need to change the user_agent field in the table from varchar(50) to varchar(120) they changed it but did not update the docs.

InsiteFX

#5
[eluser]SPeed_FANat1c[/eluser]
thanks for the info. But if that was for making the $_SERVER['HTTP_USER_AGENT'] know, that didn't work. This item is still not set. But that is not the problem, I just check with isset function and act accordingly.

BTW - now another problem - the payment status is always 'pending'? Is this a bug in paypal testing tools or I don't know something?

Edit: found why was it pending - the seller was not configured to convert the currency automatically, so it was pending until the seller manually converts the currency.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.