Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter and PayPal IPN
#1

[eluser]Jatinder Thind[/eluser]
Hello,

I implemented a CI based E-Commerce site some months back. It uses PayPal for payment processing. I also setup a IPN (Instant Payment Notification) script for managing sales orders.

Although the IPN script works fine most of the time, it sometimes marks some of the IPN posts as invalid.

After a lot of research, I figured out that maybe the CI's Input library was modifying the POST variables so as to make them unusable for PayPal IPN.

Anyone else faced the same problem? Is there someway to skip Input library modifications during runtime?

Thanks,
Jatinder Thind
#2

[eluser]gunter[/eluser]
yes, the input library modifies some of the new lines? line feeds? carriage returns? whats the name in english??? ... all chr(13) to chr(10) or backwards - I don´t remember now...

anyway you can use this and it works (look at the str_replace line):

Code:
if (isset($_POST))
        {
            foreach ($_POST as $field=>$value)
            {       // str_replace("\n", "\r\n", $value)
                    // put line feeds back to CR+LF as that's how PayPal sends them out
                    // otherwise multi-line data will be rejected as INVALID

                $value = str_replace("\n", "\r\n", $value);
                $this->ipn_data[$field] = $value;
                $post_string .= $field.'='.urlencode(stripslashes($value)).'&';

            }
        }

another method would be to copy the $_POST array before the input library does it´s job...
and copy it back in your controller Tongue
#3

[eluser]Jatinder Thind[/eluser]
Thanks for the reply.

Have you actually tried out this solution for IPN or this just a suggestion that I should try out.
#4

[eluser]gunter[/eluser]
it works! its from the paypal lib from the wiki
the library itself is based on the script from Micah Carrick
#5

[eluser]Jatinder Thind[/eluser]
Thanks Gunter. You are a life saver.

I had my own PayPal script which I modified to work for CI. So I never looked up for a PayPal lib in the wiki. Will make sure to check the CI wiki for existing solutions in future.
#6

[eluser]taewoo[/eluser]
I ported the official PayPal SDK to a codeigniter lib

http://ellislab.com/forums/viewthread/109849/
#7

[eluser]alexatkeplar[/eluser]
Hi, I've written a PayPal IPN library for CodeIgniter which stores orders in your database. Here it is: CodeIgniter PayPal IPN library. :-)




Theme © iAndrew 2016 - Forum software by © MyBB