Menu
This tutorial tackles on how to download/force download files from your database in CodeIgniter. In this tutorial, we're gonna be using the forcedownload class of CodeIgniter to force download files. CodeIgniter is a lightweight PHP framework that uses MVC(Model-View-Controller) architecture. CodeIgniter PayPal Integration Demo Kit. Our FREE CodeIgniter PayPal Library includes basic samples of many PayPal API calls that work out of the box. These samples are simply the individual calls on their own, though, and may not provide the necessary guidance if you are not already familiar with the PayPal API calls you will be working with.
In this tutorial, we will learn Paypal payment gateway integration in Codeigniter source code. and also We’ll provide the PayPal payment gateway integration in Codeigniter source code some people call billdesk payment gateway integration in PHP. PayPal payment gateway integrates very easily.
Very simple and easy way to integrate PayPal payment gateway in the Codeigniter framework. This time learn step by step how to integrate PayPal payment gateway in Codeigniter with example.
Follow a few steps to create payment gateway integration in Codeigniter.
Follow the below-given steps and easily integrate PayPal payment gateway in Codeigniter:
- Download Paypal Payment Gateway Library
- Create Database Tables
- Build Paypal Controller
- Build a Paypal Model
- Create View
1. Download Paypal Payment Gateway Library
We will create payment gateway integration in Codeigniter. We need to download the PayPal payment gateway library for Codeigniter. And place this library into your Codeigniter project. PayPal payment gateway library here => Paypal Payment Gateway library for Codeigniter.
![Paypal Paypal](/uploads/1/1/9/8/119846850/854854457.jpg)
This library holds two files name paypal_lib, paypallib_config, you can put the file according to the below steps:
- paypal_lib.php file => will be placed in the application/libraries/ directory
- paypallib_config.php file => will be placed in the application/config/ directory.
How to add payment gateway in codeigniter. We need to create two tables in the database for fetching the product information and stored payment information in it.
PayPal integration in PHP step by step creates the first table name is products and it stored the product data like product name, image, price or product status, etc. So you can use the below SQL query for creating a product table in your database:
Next, how to make payment gateway in PHP then create Second table name is payments and it stored the payment data like user_id, payment_id, product_id, txt_id or currency code, etc. So you can use the below SQL query for creating a payments table in your database:
First of all, how to implement PayPal payment gateway so we need to create a new PayPal controller, So go to application/controller and create a new controller name paypal.php.
In paypal controller, we need to create five methods, index(), buyProduct(), success(), cancel(), and ipn().
Explanation of the following few methods:
- index() this method would fetch and display the product information.
- buyProudct() this method helps to generate the PayPal form and redirect buyer to the PayPal site once the Buy button is clicked.
- success() this method will be used to display transaction data after successful payment.
- cancel() this method is requested when the user cancels the payment.
- ipn() this method receives transaction data by PayPal IPN and inserts the transaction data into the database.
How to integrate payment gateway in Codeigniter. we need to create a new PayPal model, So go application/models and create a new model name paypal.php.
In PayPal model, we need to create two methods, getRows(), StoreTransaction().
Explanation of the following few methods:
- getRows() this method is used to fetch the product information data from the database table product.
- storeTransaction() When the transaction is successful then we will use The storeTransaction() this method to insert transaction data into a payment table.
In this step, we need to create two folders named products and PayPal. Write code payment gateway integration in codeigniter.
After that, we need to create views files that will show the product listing and payment-related information like payment success or cancel details. then how to make a payment gateway in PHP.
First of all, go to application/views/products and create a new file inside the products folder named index.php. Then update the HTML code below in your index.php file we create PayPal payment gateway integration in Codeigniter:
After that, we need to create two more views files to display the transaction details as if the transaction was successful or canceled in paypal payment gateway.
So go to application/views/Paypal folder, Create a new file name success.php and update the below code into your file:
Codeigniter Paypal Library Download Free
Create a second new file name cancel.php and update the below code into your file:
If your test PayPal transaction is worked properly using the PayPal sandbox account in payment gateway integration in Codeigniter. You want to make it live your PayPal payment gateway integration.
So Open the application/config/paypallib_config.php and change the following two configuration values
1. Change the SANDBOX environment to FALSE to make the PayPal payment gateway live.
$config['sandbox'] = FALSE;
2.Change the BUSINESS EMAIL with your live PayPal business email.
$config['business'] = '[email protected]';
Read Also: How To Remove Public/index.php/ From URL In Codeigniter 4
Read Also: How To Install Codeigniter 4 Using Manual, Composer, Git ?
Read Also: How To Send Email In Codeigniter Using Smtp?
Codeigniter Paypal Library Download Windows 7
I hope it can help you...