Easy Paypal sandbox IPN subscription with PHP Codeigniter Library


July 18, 2011Code IgniterNo comments

CodeIgniter has a PayPal library that handles the request and response from PayPal.  But IPN Subscription is not supported in the CI PayPal Library. Creating IPN Subscription is pretty easy if you follow the below steps.

Step 1 :  To start with IPN subscription register / sign -in with PayPal sandbox using this URL https://developer.paypal.com/

Step2 :  Create Test Accounts after log in to the sandbox PayPal site from the Left sandbox menu. Click on ” New test account: Preconfigured” and create your seller/buyer account.  Once you are done with the test account creation your screen should look like below. Step 3:  Select the seller account and enter into sandbox test site with “Enter Sandbox Test Site” button.

Step4 : After entering to the sandbox seller account click on Profile. You can see three Information blocks available Account Information, Financial Information and Selling Preferences

Under ” Selling Preferences ” check for Instant Payment Notification Preferences add the URL of your website for performing IPN response handling it can be an empty file or just printing response array from PayPal as shown in right-side.

You can also turn off IPN for stop getting response from PayPal per each transaction.

Step 5: Add this function to your PayPal_Lib file in your CodeIgniter under application>>libraries>>PayPal_Lib.

This function allow PayPal to add the subscription amount , duration and cycle  for your subscription in PayPal.

Step 6: In your controller file you can call the subscription function as shown below with PayPal Lib

Step 7:These subscription can vary accordingly. The IPN will send back the details and using the configured IPN script in PayPal you can print the request array after saving to the Database or simply mail to your email id.

 Requirement :- Code Igniter