Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

PayPal Lib

Derek Jones edited this page · 19 revisions
Clone this wiki locally

Category:Library::Community | Category:Library::Paypal

Introduction

This library provides a neat and simple method to interface with PayPal and the PayPal Instant Payment Notification (IPN) interface. It requires the developer (that should be you) to understand the PayPal process and know the variables you want/need to pass to PayPal to achieve what you want.

Requirements

PayPal_Lib requires CI 1.5.0.1 and higher and the url and form helpers to be loaded.

Distributed under LGPL by Ran Aroussi (based on the Paypal PHP class by Micah Carrick).

Extensive documentation is available in the download and here.

Download

File:paypal_lib.zip

Cheers!

Ran Aroussi Web Consultant & Entrepreneur

EDIT:

Several people have had some problems getting the IPN function to work with this library. Gunther, Derek, Oscar, Joeles, and a guy from Japan were able to get it working. Here are the fixes:

[u]Controller:[/u] paypal.php Around Line 90: ** Change:

$data['pp_info'] = $this->input->post();

** to:

$data['pp_info'] = $_POST;

[u]Library:[/u] Paypal_Lib.php Around Line 153: ** Change:

if ($this->CI->input->post())
        {
            foreach ($this->CI->input->post() as $field=>$value)
            { 
                $this->ipn_data[$field] = $value;
                $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; 
            }
        }

** To:

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)).'&';

            }
        } 

If you are experiencing problem when testing this library on paypal sandbox with the following error log message : IPN Response from Paypal Server: HTTP/1.1 307 Temporary Redirect Server: NS8.0.45.4 Location: https://www.sandbox.paypal.com/cgi-bin/webscr Content Type: text/html Cache Control: private Connection: close

Please change Paypal_Lib.php around line 164


$fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30);

***to :


$fp = fsockopen('ssl://www.sandbox.paypal.com',443,$err_num,$err_str,30); 
Something went wrong with that request. Please try again.