{"id":1086,"date":"2015-12-04T08:07:16","date_gmt":"2015-12-04T08:07:16","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=1086"},"modified":"2020-09-22T06:58:50","modified_gmt":"2020-09-22T06:58:50","slug":"paypal-payment-gateway-integration-in-codeigniter","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/","title":{"rendered":"PayPal Payment Gateway Integration in CodeIgniter"},"content":{"rendered":"<p>Nowadays the payment gateway is hugely used for the e-commerce business and online service providers. It helps to accept payment online in the web application. Before integrating a payment gateway into the website, you need to choose the best payment gateway service provider to accept online payment without any interruption. PayPal is one of the world&#8217;s most popular internet payment solution. If you want to accept payment globally on your website, PayPal is the best choice for integrating the payment gateway into your web project.<\/p>\n<p>PayPal provides an easy way to <a href=\"https:\/\/www.codexworld.com\/paypal-standard-payment-gateway-integration-php\/\">integrate standard payment gateway in PHP<\/a>. If your web application built with CodeIgniter, PayPal PHP library and API needs to be integrated in the CodeIgniter application. In this tutorial, we will show you how to <b>integrate PayPal payment gateway in CodeIgniter<\/b>. Here we will provide the step by step guide on PayPal standard payment gateway integration for CodeIgniter application. Our example code will help you to integrate PayPal payment gateway in CodeIgniter.<\/p>\n<p>In this example script, the following functionality will be implemented to integrate PayPal payment gateway in CodeIgniter application.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Fetch products from the database and list them on the web page.<\/li>\n<li>Each product will have a <b>Pay with PayPal<\/b> button that allows the user to purchase the product.<\/li>\n<li>The Buy button redirects the user to the PayPal site to make the payment.<\/li>\n<li>After the payment on PayPal, the buyer will be redirected back to the website.<\/li>\n<li>The transaction will be validated using PayPal IPN (Instant Payment Notification) service and the payment information will be stored in the database.<\/li>\n<li>The transaction details and payment status will be shown to the buyer.<\/li>\n<\/ul>\n<h2>Create PayPal Sandbox Account<\/h2>\n<p>Before making the PayPal payment gateway live, it needs to be tested whether the payment process is working properly. PayPal provides a Sandbox environment to test the transaction process before accept payment from the buyers.<br \/>\nTo test the PayPal payment gateway, you need to <a href=\"http:\/\/www.codexworld.com\/creating-paypal-sandbox-test-account-website-payments-pro-account\/\">create PayPal sandbox account.<\/a><\/p>\n<ul class=\"bullet_disk_list\">\n<li>Go to the <a href=\"https:\/\/developer.paypal.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">PayPal Developer Portal<\/a> and Log into the Dashboard using your PayPal account credentials. If you don&#8217;t have any PayPal account, sign up for a PayPal account first.<\/li>\n<li>In the dashboard, click the <b>Accounts<\/b> under the <b>Sandbox<\/b> label from the left side menu panel.\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-1024x302.png\" alt=\"paypal-developer-sandbox-account-codeigniter-codexworld\" width=\"960\" height=\"283\" class=\"alignnone size-large wp-image-3363\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-1024x302.png 1024w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-300x88.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-768x226.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-200x59.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld-346x102.png 346w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/paypal-developer-sandbox-account-codexworld.png 1080w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/div>\n<\/li>\n<li>Click the <b>Create Account<\/b> to create buyer and merchant account. Under the Account type section, select <b>Personal<\/b> for buyer account or <b>Business<\/b> for a merchant account.\n<div><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld.png\" alt=\"create-paypal-sandbox-buyer-business-account-codeigniter-codexworld\" width=\"885\" height=\"609\" class=\"alignnone size-full wp-image-3364\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld.png 885w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld-300x206.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld-768x528.png 768w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld-200x138.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2018\/07\/create-paypal-sandbox-buyer-business-account-codexworld-334x230.png 334w\" sizes=\"auto, (max-width: 885px) 100vw, 885px\" \/><\/div>\n<\/li>\n<\/ul>\n<p>Before getting started to integrate <b>PayPal payment gateway in CodeIgniter<\/b>, take a look at the file structure.<\/p>\n<pre class=\"file-struc\">codeigniter_paypal_integration<span style=\"color:#794938\">\/<\/span>\r\n\u251c\u2500\u2500 application<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u251c\u2500\u2500 config<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u2514\u2500\u2500 paypal.php\r\n\u2502   \u251c\u2500\u2500 controllers<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u251c\u2500\u2500 Products.php\r\n\u2502   \u2502   \u2514\u2500\u2500 Paypal.php\r\n\u2502   \u251c\u2500\u2500 libraries<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u2514\u2500\u2500 Paypal_lib.php\r\n\u2502   \u251c\u2500\u2500 models<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u251c\u2500\u2500 Product.php\r\n\u2502   \u2502   \u2514\u2500\u2500 Payment.php\r\n\u2502   \u251c\u2500\u2500 views<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u251c\u2500\u2500 products<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502   \u2502   \u2514\u2500\u2500 index.php\r\n\u2502   \u2502   \u2514\u2500\u2500 paypal<span style=\"color:#794938\">\/<\/span>\r\n\u2502   \u2502       \u251c\u2500\u2500 success.php\r\n\u2502   \u2502       \u2514\u2500\u2500 cancel.php\r\n\u2514\u2500\u2500 assets<span style=\"color:#794938\">\/<\/span>\r\n    \u2514\u2500\u2500 css<span style=\"color:#794938\">\/<\/span>\r\n        \u251c\u2500\u2500 bootstrap.min.css\r\n        \u2514\u2500\u2500 style.css\r\n<\/pre>\n<h2>Create Database Tables<\/h2>\n<p>To store product and payment information two tables are required in the database. <\/p>\n<p>The following SQL creates a <code>products<\/code> table with some basic fields in the MySQL database.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`products`<\/span> (\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">255<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`image`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">200<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`price`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">float<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>,<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`currency`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'USD'<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`status`<\/span> enum(<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'1'<\/span>,<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'0'<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">'1'<\/span>,\r\n PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<p>The following SQL creates a <code>payments<\/code> table in the MySQL database to store the transaction information provided by PayPal.<\/p>\n<pre style=\"color: rgb(0, 0, 0);\"><span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CREATE<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">TABLE<\/span> <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`payments`<\/span> (\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span> AUTO_INCREMENT,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`product_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`user_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">int<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">11<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`txn_id`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`payment_gross`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">float<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">10<\/span>,<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">2<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`currency_code`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">5<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`payer_name`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">50<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`payer_email`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">100<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n <span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`status`<\/span> <span class=\"hljs-built_in\" style=\"color: rgb(0, 134, 179);\">varchar<\/span>(<span class=\"hljs-number\" style=\"color: rgb(64, 160, 112);\">20<\/span>) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span> utf8_unicode_ci <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">NOT<\/span> <span class=\"hljs-literal\" style=\"color: rgb(149, 65, 33);\">NULL<\/span>,\r\n PRIMARY <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">KEY<\/span> (<span class=\"hljs-string\" style=\"color: rgb(33, 145, 97);\">`id`<\/span>)\r\n) <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">ENGINE<\/span>=<span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">InnoDB<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">DEFAULT<\/span> <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">CHARSET<\/span>=utf8 <span class=\"hljs-keyword\" style=\"color: rgb(149, 65, 33);\">COLLATE<\/span>=utf8_unicode_ci;<\/pre>\n<h2>Config<\/h2>\n<p><b><code>paypal.php<\/code><\/b><br \/>\nThe configuration variables of the PayPal library are defined in this file.<\/p>\n<ul class=\"bullet_disk_list\">\n<li>Specify the PayPal environment (<code>sandbox<\/code>), business email (<code>business<\/code>), and currency code (<code>paypal_lib_currency_code<\/code>).<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/* <br \/>|&nbsp;------------------------------------------------------------------- <br \/>|&nbsp;&nbsp;PayPal&nbsp;API&nbsp;Configuration <br \/>|&nbsp;------------------------------------------------------------------- <br \/>| <br \/>|&nbsp;You&nbsp;will&nbsp;get&nbsp;the&nbsp;API&nbsp;keys&nbsp;from&nbsp;Developers&nbsp;panel&nbsp;of&nbsp;the&nbsp;PayPal&nbsp;account <br \/>|&nbsp;Login&nbsp;to&nbsp;PayPal&nbsp;account&nbsp;(https:\/\/developer.paypal.com\/) <br \/>|&nbsp;and&nbsp;navigate&nbsp;to&nbsp;the&nbsp;SANDBOX&nbsp;\u00bb&nbsp;Accounts&nbsp;page <br \/>|&nbsp;Remember&nbsp;to&nbsp;switch&nbsp;to&nbsp;your&nbsp;live&nbsp;business&nbsp;email&nbsp;in&nbsp;production! <br \/>| <br \/>|&nbsp;&nbsp;sandbox&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boolean&nbsp;&nbsp;PayPal&nbsp;environment,&nbsp;TRUE&nbsp;for&nbsp;Sandbox&nbsp;and&nbsp;FALSE&nbsp;for&nbsp;live <br \/>|&nbsp;&nbsp;business&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;&nbsp;&nbsp;PayPal&nbsp;business&nbsp;email <br \/>|&nbsp;&nbsp;paypal_lib_currency_code&nbsp;string&nbsp;&nbsp;&nbsp;Currency&nbsp;code. <br \/>*\/ <br \/> <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'sandbox'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;FALSE&nbsp;for&nbsp;live&nbsp;environment <br \/> <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'business'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #DD0000\">'Your_PayPal_Email'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_lib_currency_code'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #DD0000\">'USD'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;Where&nbsp;is&nbsp;the&nbsp;button&nbsp;located&nbsp;at?&nbsp;(optional) <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_lib_button_path'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #DD0000\">'assets\/images\/'<\/span><span style=\"color: #007700\">; <br \/> <br \/><\/span><span style=\"color: #FF8000\">\/\/&nbsp;If&nbsp;(and&nbsp;where)&nbsp;to&nbsp;log&nbsp;ipn&nbsp;response&nbsp;in&nbsp;a&nbsp;file <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_lib_ipn_log'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">; <br \/><\/span><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'paypal_lib_ipn_log_file'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">BASEPATH&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'logs\/paypal_ipn.log'<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<h2>Library<\/h2>\n<p><b>PayPal (<code>libraries\/Paypal_lib.php<\/code>)<\/b><br \/>\nThe Paypal CodeIgniter Library helps to integrate PayPal payment gateway in CodeIgniter 3 application. This library (<code>application\/libraries\/Paypal_lib.php<\/code>) has a dependency on a configuration file (<code>application\/config\/paypal.php<\/code>).<\/p>\n<ul class=\"bullet_disk_list\">\n<li><b>__construct()<\/b> &#8211; Load required helpers, set configure variables and initiate the Paypal_lib class.<\/li>\n<li><b>button()<\/b> &#8211; Set value of the PayPal form submit button.<\/li>\n<li><b>image()<\/b> &#8211; Set image to the PayPal form submit button.<\/li>\n<li><b>add_field()<\/b> &#8211; Add field to PayPal form.<\/li>\n<li><b>paypal_auto_form()<\/b> &#8211; Generate an entire HTML page consisting of a form with hidden elements which is submitted to paypal via the BODY element&#8217;s onLoad attribute.<\/li>\n<li><b>paypal_form()<\/b> &#8211; Build PayPal form.<\/li>\n<li><b>validate_ipn()<\/b> &#8211; Validate PayPal IPN request.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/><\/span><span style=\"color: #FF8000\">\/** <br \/>&nbsp;*&nbsp;PayPal&nbsp;Library&nbsp;for&nbsp;CodeIgniter&nbsp;3.x <br \/>&nbsp;* <br \/>&nbsp;*&nbsp;Library&nbsp;for&nbsp;PayPal&nbsp;payment&nbsp;gateway.&nbsp;It&nbsp;helps&nbsp;to&nbsp;integrate&nbsp;PayPal&nbsp;payment&nbsp;gateway <br \/>&nbsp;*&nbsp;in&nbsp;the&nbsp;CodeIgniter&nbsp;application. <br \/>&nbsp;* <br \/>&nbsp;*&nbsp;It&nbsp;requires&nbsp;PayPal&nbsp;configuration&nbsp;file&nbsp;and&nbsp;it&nbsp;should&nbsp;be&nbsp;placed&nbsp;in&nbsp;the&nbsp;config&nbsp;directory. <br \/>&nbsp;* <br \/>&nbsp;*&nbsp;@package&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodeIgniter <br \/>&nbsp;*&nbsp;@category&nbsp;&nbsp;&nbsp;&nbsp;Libraries <br \/>&nbsp;*&nbsp;@author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CodexWorld <br \/>&nbsp;*&nbsp;@license&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http:\/\/www.codexworld.com\/license\/ <br \/>&nbsp;*&nbsp;@link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http:\/\/www.codexworld.com <br \/>&nbsp;*&nbsp;@version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.0 <br \/>&nbsp;*\/ <br \/> <br \/><\/span><span style=\"color: #007700\">class&nbsp;<\/span><span style=\"color: #0000BB\">Paypal_lib <br \/><\/span><span style=\"color: #007700\">{ <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;<\/span><span style=\"color: #0000BB\">$last_error<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;holds&nbsp;the&nbsp;last&nbsp;error&nbsp;encountered <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_log<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;bool:&nbsp;log&nbsp;IPN&nbsp;results&nbsp;to&nbsp;text&nbsp;file? <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_log_file<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;filename&nbsp;of&nbsp;the&nbsp;IPN&nbsp;log <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_response<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;holds&nbsp;the&nbsp;IPN&nbsp;response&nbsp;from&nbsp;paypal&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array();&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;array&nbsp;contains&nbsp;the&nbsp;POST&nbsp;values&nbsp;for&nbsp;IPN <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$fields&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;array&nbsp;holds&nbsp;the&nbsp;fields&nbsp;to&nbsp;submit&nbsp;to&nbsp;paypal <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$submit_btn&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Image\/Form&nbsp;button <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$button_path&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;The&nbsp;path&nbsp;of&nbsp;the&nbsp;buttons <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">var&nbsp;<\/span><span style=\"color: #0000BB\">$CI<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI&nbsp;<\/span><span style=\"color: #007700\">=&amp;&nbsp;<\/span><span style=\"color: #0000BB\">get_instance<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">helper<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'url'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">helper<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'form'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$sanbox&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'sandbox'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;(<\/span><span style=\"color: #0000BB\">$sanbox&nbsp;<\/span><span style=\"color: #007700\">==&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #DD0000\">'https:\/\/www.sandbox.paypal.com\/cgi-bin\/webscr'<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #DD0000\">'https:\/\/www.paypal.com\/cgi-bin\/webscr'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">last_error&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_log_file&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib_ipn_log_file'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_log&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib_ipn_log'<\/span><span style=\"color: #007700\">);&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">button_path&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib_button_path'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;populate&nbsp;$fields&nbsp;array&nbsp;with&nbsp;a&nbsp;few&nbsp;default&nbsp;values. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;values&nbsp;can&nbsp;be&nbsp;overwritten&nbsp;by&nbsp;the&nbsp;calling&nbsp;script. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$businessEmail&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'business'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'business'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">$businessEmail<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'rm'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'2'<\/span><span style=\"color: #007700\">);&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Return&nbsp;method&nbsp;=&nbsp;POST <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'cmd'<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'_xclick'<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">CI<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">config<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">item<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib_currency_code'<\/span><span style=\"color: #007700\">)); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'quantity'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'1'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">button<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Pay&nbsp;Now!'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">button<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;changes&nbsp;the&nbsp;default&nbsp;caption&nbsp;of&nbsp;the&nbsp;submit&nbsp;button <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">submit_btn&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">form_submit<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'pp_submit'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">image<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$file<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">submit_btn&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;input&nbsp;type=\"image\"&nbsp;name=\"add\"&nbsp;src=\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">rtrim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">button_path<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'\/'<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">'\/'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$file<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">'\"&nbsp;border=\"0\"&nbsp;\/&gt;'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$field<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;adds&nbsp;a&nbsp;key=&gt;value&nbsp;pair&nbsp;to&nbsp;the&nbsp;fields&nbsp;array,&nbsp;which&nbsp;is&nbsp;what&nbsp;will&nbsp;be&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;sent&nbsp;to&nbsp;paypal&nbsp;as&nbsp;POST&nbsp;variables.&nbsp;&nbsp;If&nbsp;the&nbsp;value&nbsp;is&nbsp;already&nbsp;in&nbsp;the&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;array,&nbsp;it&nbsp;will&nbsp;be&nbsp;overwritten. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fields<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #0000BB\">$field<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">paypal_auto_form<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;this&nbsp;function&nbsp;actually&nbsp;generates&nbsp;an&nbsp;entire&nbsp;HTML&nbsp;page&nbsp;consisting&nbsp;of <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;a&nbsp;form&nbsp;with&nbsp;hidden&nbsp;elements&nbsp;which&nbsp;is&nbsp;submitted&nbsp;to&nbsp;paypal&nbsp;via&nbsp;the&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;BODY&nbsp;element's&nbsp;onLoad&nbsp;attribute. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">button<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Click&nbsp;here&nbsp;if&nbsp;you\\'re&nbsp;not&nbsp;automatically&nbsp;redirected...'<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;html&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;head&gt;&lt;title&gt;Processing&nbsp;Payment...&lt;\/title&gt;&lt;\/head&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;body&nbsp;style=\"text-align:center;\"&nbsp;onLoad=\"document.forms[\\'paypal_auto_form\\'].submit();\"&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&nbsp;style=\"text-align:center;\"&gt;Please&nbsp;wait,&nbsp;your&nbsp;order&nbsp;is&nbsp;being&nbsp;processed&nbsp;and&nbsp;you&nbsp;will&nbsp;be&nbsp;redirected&nbsp;to&nbsp;the&nbsp;PayPal&nbsp;website.&lt;\/p&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_form<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_auto_form'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;\/body&gt;&lt;\/html&gt;'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">paypal_form<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$form_name<\/span><span style=\"color: #007700\">=<\/span><span style=\"color: #DD0000\">'paypal_form'<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$str&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$str&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;form&nbsp;method=\"post\"&nbsp;action=\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_url<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\"&nbsp;name=\"'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$form_name<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'\"\/&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fields&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$name&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$str&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #0000BB\">form_hidden<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$name<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">)&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$str&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&gt;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">submit_btn&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;\/p&gt;'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$str&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #0000BB\">form_close<\/span><span style=\"color: #007700\">()&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$str<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">validate_ipn<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$paypalReturn<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_response&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">curlPost<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_url<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$paypalReturn<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">preg_match<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"\/VERIFIED\/i\"<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_response<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Valid&nbsp;IPN&nbsp;transaction. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">return&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Invalid&nbsp;IPN&nbsp;transaction.&nbsp;&nbsp;Check&nbsp;the&nbsp;log&nbsp;for&nbsp;details. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">last_error&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'IPN&nbsp;Validation&nbsp;Failed.'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">log_ipn_results<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">);&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">log_ipn_results<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$success<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_log<\/span><span style=\"color: #007700\">)&nbsp;return;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;is&nbsp;logging&nbsp;turned&nbsp;off? <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Timestamp <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'['<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">date<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'m\/d\/Y&nbsp;g:i&nbsp;A'<\/span><span style=\"color: #007700\">).<\/span><span style=\"color: #DD0000\">']&nbsp;-&nbsp;'<\/span><span style=\"color: #007700\">;&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Success&nbsp;or&nbsp;failure&nbsp;being&nbsp;logged? <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if&nbsp;(<\/span><span style=\"color: #0000BB\">$success<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"SUCCESS!\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">'FAIL:&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">last_error<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Log&nbsp;the&nbsp;POST&nbsp;variables <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"IPN&nbsp;POST&nbsp;Vars&nbsp;from&nbsp;Paypal:\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_data&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$key<\/span><span style=\"color: #007700\">=&gt;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #0000BB\">$key<\/span><span style=\"color: #DD0000\">=<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #DD0000\">,&nbsp;\"<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Log&nbsp;the&nbsp;response&nbsp;from&nbsp;the&nbsp;paypal&nbsp;server <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"\\nIPN&nbsp;Response&nbsp;from&nbsp;Paypal&nbsp;Server:\\n&nbsp;\"<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_response<\/span><span style=\"color: #007700\">; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Write&nbsp;to&nbsp;log <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$fp<\/span><span style=\"color: #007700\">=<\/span><span style=\"color: #0000BB\">fopen<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">ipn_log_file<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #DD0000\">'a'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">fwrite<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fp<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$text&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\\n\"<\/span><span style=\"color: #007700\">);&nbsp; <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">fclose<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$fp<\/span><span style=\"color: #007700\">);&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;close&nbsp;file <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">} <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">dump<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Used&nbsp;for&nbsp;debugging,&nbsp;this&nbsp;function&nbsp;will&nbsp;output&nbsp;all&nbsp;the&nbsp;field\/value&nbsp;pairs <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;that&nbsp;are&nbsp;currently&nbsp;defined&nbsp;in&nbsp;the&nbsp;instance&nbsp;of&nbsp;the&nbsp;class&nbsp;using&nbsp;the <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;add_field()&nbsp;function. <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">ksort<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fields<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;h2&gt;ppal-&gt;dump()&nbsp;Output:&lt;\/h2&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;code&nbsp;style=\"font:&nbsp;12px&nbsp;Monaco,&nbsp;\\'Courier&nbsp;New\\',&nbsp;Verdana,&nbsp;Sans-serif;&nbsp;&nbsp;background:&nbsp;#f9f9f9;&nbsp;border:&nbsp;1px&nbsp;solid&nbsp;#D0D0D0;&nbsp;color:&nbsp;#002166;&nbsp;display:&nbsp;block;&nbsp;margin:&nbsp;14px&nbsp;0;&nbsp;padding:&nbsp;12px&nbsp;10px;\"&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #DD0000\">\"\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach&nbsp;(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">fields&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$key&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">)&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;strong&gt;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$key&nbsp;<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #DD0000\">'&lt;\/strong&gt;:&nbsp;&nbsp;&nbsp;&nbsp;'<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">urldecode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">)&nbsp;.<\/span><span style=\"color: #DD0000\">'&lt;br\/&gt;'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;<\/span><span style=\"color: #DD0000\">\"&lt;\/code&gt;\\n\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">curlPost<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$paypal_url<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$paypal_return_arr<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$req&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'cmd=_notify-validate'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach(<\/span><span style=\"color: #0000BB\">$paypal_return_arr&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$key&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$value&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">urlencode<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">stripslashes<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #007700\">)); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$req&nbsp;<\/span><span style=\"color: #007700\">.=&nbsp;<\/span><span style=\"color: #DD0000\">\"&amp;<\/span><span style=\"color: #0000BB\">$key<\/span><span style=\"color: #DD0000\">=<\/span><span style=\"color: #0000BB\">$value<\/span><span style=\"color: #DD0000\">\"<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_site_url&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypal_url<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ch&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_init<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_URL<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$ipn_site_url<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_HEADER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POST<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_RETURNTRANSFER<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_setopt<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">CURLOPT_POSTFIELDS<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$req<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">curl_exec<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">curl_close<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$ch<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/> <br \/>}<\/span><\/pre>\n<h2>Controller<\/h2>\n<p>The Products and Paypal controllers will be used to handle the product listing and payment process.<\/p>\n<p><b>1. Products (<code>controllers\/Products.php<\/code>):<\/b><br \/>\nThe Products controller handles the product listing and payment request submission process.<\/p>\n<ul class=\"bullet_disk_list\">\n<li><b>__construct()<\/b> \u2013 Loads the PayPal library and Product model.<\/li>\n<li><b>index()<\/b> \u2013\n<ul>\n<li>Retrieve the products data from the database using getRows() function of the Product model.<\/li>\n<li>Pass data to the view and load the view file to list the products.<\/li>\n<\/ul>\n<\/li>\n<li><b>buy()<\/b> \u2013\n<ul>\n<li>Fetch the product data from the database based on the selected product ID.<\/li>\n<li>Generate the PayPal form with HTML variables and submit on the fly using <code>add_field()<\/code> and <code>paypal_auto_form()<\/code> methods of the PayPal library.<\/li>\n<li>Render PayPal form and redirect buyer to the PayPal site for payment.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/> <br \/>class&nbsp;<\/span><span style=\"color: #0000BB\">Products&nbsp;<\/span><span style=\"color: #007700\">extends&nbsp;<\/span><span style=\"color: #0000BB\">CI_Controller<\/span><span style=\"color: #007700\">{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">parent<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;paypal&nbsp;library <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">library<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;product&nbsp;model <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">model<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'product'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">index<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;products&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'products'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">product<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getRows<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Pass&nbsp;product&nbsp;data&nbsp;to&nbsp;the&nbsp;view <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">view<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'products\/index'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">buy<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$id<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Set&nbsp;variables&nbsp;for&nbsp;paypal&nbsp;form <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$returnURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">().<\/span><span style=\"color: #DD0000\">'paypal\/success'<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/payment&nbsp;success&nbsp;url <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$cancelURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">().<\/span><span style=\"color: #DD0000\">'paypal\/cancel'<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/payment&nbsp;cancel&nbsp;url <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$notifyURL&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">().<\/span><span style=\"color: #DD0000\">'paypal\/ipn'<\/span><span style=\"color: #007700\">;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/ipn&nbsp;url <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/&nbsp;Get&nbsp;product&nbsp;data&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$product&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">product<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getRows<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$id<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;current&nbsp;user&nbsp;ID&nbsp;from&nbsp;the&nbsp;session&nbsp;(optional) <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$userID&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$_SESSION<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'userID'<\/span><span style=\"color: #007700\">])?<\/span><span style=\"color: #0000BB\">$_SESSION<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'userID'<\/span><span style=\"color: #007700\">]:<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Add&nbsp;fields&nbsp;to&nbsp;paypal&nbsp;form <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'return'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$returnURL<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'cancel_return'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$cancelURL<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'notify_url'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$notifyURL<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'item_name'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'custom'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$userID<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'item_number'<\/span><span style=\"color: #007700\">,&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">add_field<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'amount'<\/span><span style=\"color: #007700\">,&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'price'<\/span><span style=\"color: #007700\">]); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Render&nbsp;paypal&nbsp;form <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_auto_form<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>}<\/span><\/pre>\n<p><b>2. Paypal (<code>controllers\/Paypal.php<\/code>):<\/b><br \/>\nThe Paypal controller handles the transaction and the IPN validation process.<\/p>\n<ul class=\"bullet_disk_list\">\n<li><b>__construct()<\/b> \u2013 Loads the PayPal library, Product &#038; Payment model.<\/li>\n<li><b>success()<\/b> \u2013\n<ul>\n<li>Retrieve the transaction data from the query string of the URL.<\/li>\n<li>Check if transaction data exists in the database with the same transaction ID.<\/li>\n<li>Pass the payment data to the view and load the view file.<\/li>\n<\/ul>\n<\/li>\n<li><b>cancel()<\/b> \u2013 Load the payment failed notification view.<\/li>\n<li><b>ipn()<\/b> \u2013 This method is called by the PayPal IPN (Instant Payment Notification).\n<ul>\n<li>Validate the transaction using validate_ipn() method of PayPal library.<\/li>\n<li>Insert the payment information in the database using insertTransaction() function of Payment model.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/> <br \/>class&nbsp;<\/span><span style=\"color: #0000BB\">Paypal&nbsp;<\/span><span style=\"color: #007700\">extends&nbsp;<\/span><span style=\"color: #0000BB\">CI_Controller<\/span><span style=\"color: #007700\">{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">parent<\/span><span style=\"color: #007700\">::<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;paypal&nbsp;library <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">library<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal_lib'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;product&nbsp;model <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">model<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'product'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;payment&nbsp;model <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">model<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'payment'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">success<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;the&nbsp;transaction&nbsp;data <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">input<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$productData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paymentData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'item_number'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'tx'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'amt'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'cc'<\/span><span style=\"color: #007700\">])&nbsp;&amp;&amp;&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'st'<\/span><span style=\"color: #007700\">])){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$item_name&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'item_name'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$item_number&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'item_number'<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$txn_id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"tx\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$payment_amt&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"amt\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$currency_code&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"cc\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$status&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"st\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Get&nbsp;product&nbsp;info&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$productData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">product<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getRows<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$item_number<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;if&nbsp;transaction&nbsp;data&nbsp;exists&nbsp;with&nbsp;the&nbsp;same&nbsp;TXN&nbsp;ID <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$paymentData&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">payment<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getPayment<\/span><span style=\"color: #007700\">(array(<\/span><span style=\"color: #DD0000\">'txn_id'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$txn_id<\/span><span style=\"color: #007700\">)); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Pass&nbsp;the&nbsp;transaction&nbsp;data&nbsp;to&nbsp;view <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'product'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$productData<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payment'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paymentData<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">view<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal\/success'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">cancel<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Load&nbsp;payment&nbsp;failed&nbsp;view <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">load<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">view<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'paypal\/cancel'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">ipn<\/span><span style=\"color: #007700\">(){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Retrieve&nbsp;transaction&nbsp;data&nbsp;from&nbsp;PayPal&nbsp;IPN&nbsp;POST <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">input<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">post<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Validate&nbsp;and&nbsp;get&nbsp;the&nbsp;ipn&nbsp;response <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$ipnCheck&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">paypal_lib<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">validate_ipn<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">); <br \/> <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;whether&nbsp;the&nbsp;transaction&nbsp;is&nbsp;valid <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if(<\/span><span style=\"color: #0000BB\">$ipnCheck<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Check&nbsp;whether&nbsp;the&nbsp;transaction&nbsp;data&nbsp;is&nbsp;exists <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$prevPayment&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">payment<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">getPayment<\/span><span style=\"color: #007700\">(array(<\/span><span style=\"color: #DD0000\">'txn_id'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"txn_id\"<\/span><span style=\"color: #007700\">])); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!<\/span><span style=\"color: #0000BB\">$prevPayment<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Insert&nbsp;the&nbsp;transaction&nbsp;data&nbsp;in&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'user_id'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"custom\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'product_id'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"item_number\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'txn_id'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"txn_id\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payment_gross'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"mc_gross\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"mc_currency\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_name'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">trim<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"first_name\"<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"last_name\"<\/span><span style=\"color: #007700\">],&nbsp;<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_email'<\/span><span style=\"color: #007700\">]&nbsp;&nbsp;&nbsp;&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"payer_email\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">$paypalInfo<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">\"payment_status\"<\/span><span style=\"color: #007700\">]; <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">payment<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">insertTransaction<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>}<\/span><\/pre>\n<p><b>Setup PayPal Instant Payment Notification (IPN):<\/b><br \/>\nThe <code>ipn()<\/code> function of the Paypal controller verifies each transaction and inserts the payment data into the database. The PayPal IPN must be enabled in PayPal business account to make the IPN working. You need to specify the IPN URL (<code>http:\/\/www.example.com\/paypal\/ipn\/<\/code>) in the Notification URL field where the PayPal will send the IPN messages.<\/p>\n<p>Follow this step-by-step guide to enable IPN in PayPal &#8211; <a href=\"http:\/\/www.codexworld.com\/how-to-enable-paypal-ipn\/\">How to enable PayPal Instant Payment Notification<\/a><\/p>\n<p><span class=\"note\">Note that:<\/span> The transaction data will not be inserted in the database without PayPal IPN setup.<\/p>\n<h2>Model<\/h2>\n<p>The Product and Payment models handle the database related operations (fetch and insert).<\/p>\n<p><b>1. Product (<code>models\/Product.php<\/code>)<\/b><\/p>\n<ul class=\"bullet_disk_list\">\n<li><b>__construct()<\/b> \u2013 Defines the database table name.<\/li>\n<li><b>getRows()<\/b> &#8211; Fetch the records from the <code>products<\/code> table and returns as an array.\n<ul>\n<li>If a specific ID is mentioned, return data of a single product.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/> <br \/>class&nbsp;<\/span><span style=\"color: #0000BB\">Product&nbsp;<\/span><span style=\"color: #007700\">extends&nbsp;<\/span><span style=\"color: #0000BB\">CI_Model<\/span><span style=\"color: #007700\">{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">()&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">proTable&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'products'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/* <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Fetch&nbsp;products&nbsp;data&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;id&nbsp;returns&nbsp;a&nbsp;single&nbsp;record&nbsp;if&nbsp;specified,&nbsp;otherwise&nbsp;all&nbsp;records <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">getRows<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$id&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">select<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'*'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">from<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">proTable<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">where<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'1'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(<\/span><span style=\"color: #0000BB\">$id<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">where<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$id<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">row_array<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">order_by<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'asc'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">result_array<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;return&nbsp;fetched&nbsp;data <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">return&nbsp;!empty(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>}<\/span><\/pre>\n<p><b>2. Payment (<code>models\/Payment.php<\/code>)<\/b><\/p>\n<ul class=\"bullet_disk_list\">\n<li><b>__construct()<\/b> \u2013 Defines the database table name.<\/li>\n<li><b>getPayment()<\/b> &#8211; Fetch the record from the <code>payments<\/code> table and returns as an array.<\/li>\n<li><b>insertTransaction()<\/b> &#8211; Insert transaction data in the <code>payments<\/code> table.<\/li>\n<\/ul>\n<pre><span style=\"color: #0000BB\">&lt;?php&nbsp;defined<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'BASEPATH'<\/span><span style=\"color: #007700\">)&nbsp;OR&nbsp;exit(<\/span><span style=\"color: #DD0000\">'No&nbsp;direct&nbsp;script&nbsp;access&nbsp;allowed'<\/span><span style=\"color: #007700\">); <br \/> <br \/>class&nbsp;<\/span><span style=\"color: #0000BB\">Payment&nbsp;<\/span><span style=\"color: #007700\">extends&nbsp;<\/span><span style=\"color: #0000BB\">CI_Model<\/span><span style=\"color: #007700\">{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">__construct<\/span><span style=\"color: #007700\">()&nbsp;{ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">transTable&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">'payments'<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/* <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Fetch&nbsp;payment&nbsp;data&nbsp;from&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;id&nbsp;returns&nbsp;a&nbsp;single&nbsp;record&nbsp;if&nbsp;specified,&nbsp;otherwise&nbsp;all&nbsp;records <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">getPayment<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$conditions&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array()){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">select<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'*'<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">from<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">transTable<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(<\/span><span style=\"color: #0000BB\">$conditions<\/span><span style=\"color: #007700\">)){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach(<\/span><span style=\"color: #0000BB\">$conditions&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$key<\/span><span style=\"color: #007700\">=&gt;<\/span><span style=\"color: #0000BB\">$val<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">where<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$key<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$val<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">get<\/span><span style=\"color: #007700\">(); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;(<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">num_rows<\/span><span style=\"color: #007700\">()&nbsp;&gt;&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">)?<\/span><span style=\"color: #0000BB\">$result<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">row_array<\/span><span style=\"color: #007700\">():<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/* <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Insert&nbsp;payment&nbsp;data&nbsp;in&nbsp;the&nbsp;database <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;data&nbsp;array <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*\/ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">public&nbsp;function&nbsp;<\/span><span style=\"color: #0000BB\">insertTransaction<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">){ <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$insert&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">db<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">insert<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$this<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">transTable<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">$data<\/span><span style=\"color: #007700\">); <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$insert<\/span><span style=\"color: #007700\">?<\/span><span style=\"color: #0000BB\">true<\/span><span style=\"color: #007700\">:<\/span><span style=\"color: #0000BB\">false<\/span><span style=\"color: #007700\">; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;} <br \/>&nbsp;&nbsp;&nbsp;&nbsp; <br \/>}<\/span><\/pre>\n<h2>View<\/h2>\n<p>The products and paypal directories hold the view files of Products and Paypal controllers.<\/p>\n<p><b>1. views\/products\/<\/b><br \/>\n<b>1.1. <code>index.php<\/code><\/b><br \/>\nIn this view, all the products are displayed on the web page with the Buy button.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\"><span class=\"hljs-comment\" style=\"color: rgb(108, 107, 90);\">&lt;!-- List all products --&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$products<\/span><span style=\"color: #007700\">)){&nbsp;foreach(<\/span><span style=\"color: #0000BB\">$products&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">){&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card\"<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'assets\/images\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'image'<\/span><span style=\"color: #007700\">]);&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span> \/&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card-body\"<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h5<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card-title\"<\/span>&gt;<\/span><span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h5<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"card-text\"<\/span>&gt;<\/span>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h6<\/span>&gt;<\/span>$<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'price'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h6<\/span>&gt;<\/span>\r\n            <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'products\/buy\/'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$row<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">]);&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"btn\"<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">base_url<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'assets\/images\/paypal-btn.png'<\/span><span style=\"color: #007700\">);&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\"<\/span> \/&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">a<\/span>&gt;<\/span>\r\n        <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;}else{&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>Product(s) not found...<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><\/pre>\n<p><b>2. views\/paypal\/<\/b><br \/>\n<b>2.1. <code>success.php<\/code><\/b><br \/>\nIn this view, the payment status and transaction details are displayed after the payment on PayPal.<\/p>\n<pre style=\"color: rgb(95, 94, 78);\">\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">if(!empty(<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">)){&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"success\"<\/span>&gt;<\/span>Your Payment has been Successful!<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Payment Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Reference Number:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> #<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Transaction ID:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'txn_id'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Paid Amount:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payment_gross'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency_code'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Payment Status:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n\t\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Payer Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Name:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Email:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$payment<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'payer_email'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n\t\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>Product Information<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h4<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Name:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'name'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span>Price:<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">b<\/span>&gt;<\/span> <span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">echo&nbsp;<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'price'<\/span><span style=\"color: #007700\">].<\/span><span style=\"color: #DD0000\">'&nbsp;'<\/span><span style=\"color: #007700\">.<\/span><span style=\"color: #0000BB\">$product<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'currency'<\/span><span style=\"color: #007700\">];&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">p<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}else{&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"error\"<\/span>&gt;<\/span>Transaction has been failed!<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>\r\n<span style=\"color: #0000BB\">&lt;?php&nbsp;<\/span><span style=\"color: #007700\">}&nbsp;<\/span><span style=\"color: #0000BB\">?&gt;<\/span>\r\n<\/pre>\n<p><b>2.2. <code>cancel.php<\/code><\/b><br \/>\nIf the user cancels the payment, the transaction failed notification is displayed.<\/p>\n<pre style=\"color: rgb(95, 94, 78); \"><span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"status\"<\/span>&gt;<\/span>\r\n    <span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\" style=\"color: rgb(125, 151, 38);\">\"error\"<\/span>&gt;<\/span>Your transaction was canceled!<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">h1<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\" style=\"color: rgb(186, 98, 54);\">&lt;\/<span class=\"hljs-name\" style=\"color: rgb(186, 98, 54);\">div<\/span>&gt;<\/span><\/pre>\n<h2>Test PayPal Transaction<\/h2>\n<ul class=\"bullet_disk_list\">\n<li>Open the Products controller URL (http:\/\/example.com\/application_folder\/products) on the browser. <\/li>\n<li>The products will be listed with the <b>Pay with PayPal<\/b> button.<\/li>\n<li>The <b>Pay with PayPal<\/b> button will redirect you to the PayPal site for the payment.<\/li>\n<li>Log into the PayPal with your Sandbox personal account and complete the payment.<\/li>\n<li>On payment success, you will be redirected back to the website&#8217;s payment success page and the transaction details will be shown.<\/li>\n<\/ul>\n<h2>Make PayPal Payment Gateway Live<\/h2>\n<p>When the payment flow testing process is completed with a sandbox account, do the following changes to make the PayPal payment gateway live.<br \/>\nIn the <code>application\/config\/paypal.php<\/code> file, specify the PayPal environment and business email.<\/p>\n<ul class=\"step_list\">\n<li>Set sandbox to FALSE for live environment.\n<pre><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'sandbox'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">FALSE<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<\/li>\n<li>Specify your live PayPal business email.\n<pre><span style=\"color: #0000BB\">$config<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'business'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #DD0000\">'live_paypal@email.com'<\/span><span style=\"color: #007700\">;<\/span><\/pre>\n<\/li>\n<\/ul>\n<p class=\"seeAlso\"><span><\/span><a href=\"https:\/\/www.codexworld.com\/paypal-express-checkout-integration-in-php\/\">PayPal Express Checkout Integration in PHP<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nowadays the payment gateway is hugely used for the e-commerce business and online service providers. It helps to accept payment online in the web application. Before integrating a payment gateway into the website, you need <\/p>\n","protected":false},"author":1,"featured_media":3442,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[55,166,76,73],"class_list":["post-1086","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeigniter","tag-codeigniter","tag-library","tag-payment-gateway","tag-paypal","cat-8-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PayPal Payment Gateway Integration in CodeIgniter - CodexWorld<\/title>\n<meta name=\"description\" content=\"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PayPal Payment Gateway Integration in CodeIgniter - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-04T08:07:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-22T06:58:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1366\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"37 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"PayPal Payment Gateway Integration in CodeIgniter\",\"datePublished\":\"2015-12-04T08:07:16+00:00\",\"dateModified\":\"2020-09-22T06:58:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/\"},\"wordCount\":1172,\"commentCount\":122,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png\",\"keywords\":[\"CodeIgniter\",\"Library\",\"Payment Gateway\",\"PayPal\"],\"articleSection\":[\"CodeIgniter\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/\",\"name\":\"PayPal Payment Gateway Integration in CodeIgniter - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png\",\"datePublished\":\"2015-12-04T08:07:16+00:00\",\"dateModified\":\"2020-09-22T06:58:50+00:00\",\"description\":\"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/12\\\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png\",\"width\":1366,\"height\":768,\"caption\":\"paypal-payment-gateway-integration-codeigniter-library-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/paypal-payment-gateway-integration-in-codeigniter\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PayPal Payment Gateway Integration in CodeIgniter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PayPal Payment Gateway Integration in CodeIgniter - CodexWorld","description":"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/","og_locale":"en_US","og_type":"article","og_title":"PayPal Payment Gateway Integration in CodeIgniter - CodexWorld","og_description":"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.","og_url":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-12-04T08:07:16+00:00","article_modified_time":"2020-09-22T06:58:50+00:00","og_image":[{"width":1366,"height":768,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"37 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"PayPal Payment Gateway Integration in CodeIgniter","datePublished":"2015-12-04T08:07:16+00:00","dateModified":"2020-09-22T06:58:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/"},"wordCount":1172,"commentCount":122,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","keywords":["CodeIgniter","Library","Payment Gateway","PayPal"],"articleSection":["CodeIgniter"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/","url":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/","name":"PayPal Payment Gateway Integration in CodeIgniter - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","datePublished":"2015-12-04T08:07:16+00:00","dateModified":"2020-09-22T06:58:50+00:00","description":"PayPal payment gateway integration in CodeIgniter - CodeIgniter PayPal library to integrate PayPal standard payment gateway in CodeIgniter. Example CodeIgniter application with PayPal payment gateway to accept payment online.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","width":1366,"height":768,"caption":"paypal-payment-gateway-integration-codeigniter-library-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/paypal-payment-gateway-integration-in-codeigniter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"PayPal Payment Gateway Integration in CodeIgniter"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/12\/paypal-payment-gateway-integration-codeigniter-library-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-hw","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/1086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=1086"}],"version-history":[{"count":25,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/1086\/revisions"}],"predecessor-version":[{"id":4507,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/1086\/revisions\/4507"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/3442"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=1086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=1086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=1086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}