How to easily Integrate PayPal with Laravel

If you are regular operator in e-commerce circuit, you have definitely known

the importance of a secure online transaction. E-commerce is a platform anyone can buy or sell any product all around the world in a fastest mannerand securely settle the payments.

However, every coin has two sides, online transaction is a fastest and convenient it always questions payment security question for its buyers. Nevertheless, with a secure payment gateway options the threat is diminished and the robust payment methods are widely implemented and this is where the Laravel and PayPal comes in picture.

PayPal is a payment gateway platform which has made digital payment process secure and mainstream. It is present on more than 200 markets. Besides, it operates in more than 100 currencies and integrating with the laravel is a cherry on a cake.

Let us know in brief how to integrate the famous PayPal payment gateway in your Laravel application.

Follow below steps:

  1. Install Laravel Application
  2. Database Configuration
  3. Install Required Packages
  4. Configuration paypal.php file
  5. Create Route
  6. Create Controller
  7. Create View

Step 1: Install Laravel Application

Let’s start from the scratch, so we require a fresh Laravel application and to do so you can run below command in your terminal OR command prompt:

composer create-project –prefer-dist laravel/laravel blog

Step 2: Database Configuration

Now, we need to configure your database, you have to add following details in your .env file

  1. Database Username
  2. Database Password
  3. Database Name

The env file also has host and port details, so you can configure all the details in your system as below

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

Step 3: Install Required Packages

We require 2 packages for integrating PayPal in Laravel application.  So, add following 2 packages in your composer.json file

“guzzlehttp/guzzle”: “~5.4”,
“paypal/rest-api-sdk-php”: “*”,

 

Run the following command in your terminal.  Once you are done running the above command it will automatically create a paypal.php file in your config/paypal.php path

Next, you need to login to PayPal developer mode, create a sandbox account and get some keys like client_id and secret for testing integration.

Step 4: Configuring paypal.php file

<?php return array

(/** set your paypal credential **/
‘client_id’ =>’paypal client_id’,
‘secret’ => ‘paypal secret ID’,
/***
SDK configuration */
‘settings’=>; array(
/*** Available option ‘sandbox’ or ‘live’
*/
‘mode’ => ‘sandbox’,
/***
Specify the max request time in seconds
*/
‘http.ConnectionTimeOut’ => 1000,
/***
Whether want to log to a file
*/
‘log.LogEnabled’ => true,
/***
Specify the file that want to write on
*/
‘log.FileName’ => storage_path()
. ‘/logs/paypal.log’,
/***
Available option ‘FINE’, ‘INFO’, ‘WARN’ or ‘ERROR’
**
Logging is most verbose in the ‘FINE’ level and decreases as you
* proceed towards ERROR
*/
‘log.LogLevel’ => ‘FINE’
),
);

By |2019-05-25T12:07:59+00:00March 27th, 2019|Uncategorized|0 Comments

Ready to work with us? Tell us more.

Upload your Requirement

Email

contact@webiots.com

Phone No

072020 56789

Connect