PayPal Integration in Laravel 7/6 Example

PayPal Integration in Laravel 7/6 Example

In this post we will give you information about PayPal Integration in Laravel 7/6 Example. Hear we will give you detail about PayPal Integration in Laravel 7/6 ExampleAnd how to use it also give you demo for it if it is necessary.

Hi dev,

In this tutorial, i would like to guide you step by step laravel 7 paypal integration and laravel 6 paypal integration example. we can easily integrate paypal payment gateway in laravel 7/6. i written laravel 7/6 paypal integration so your user can easily payment vie paypal account and credit card information.

we are using integrate paypal api using srmklive laravel paypal package. srmklive/laravel-paypal package provide methods of paypal code api. we will use express checkout method in laravel 7/6 application.

As we know Paypal payment gateway is a more popular gateway in web development. almost client or people prefer to use paypal payment gateway for money transfer in his website. Paypal is a user friendly gateway to transfer word wide.

In this tutorial, we will use srmklive package for laravel paypal integrate in laravel 6. you just need to follow few steps to getting done payment integration in php laravel 6.

Step 1: Install Laravel 7/6

We are going from scratch so, If you haven’t installed laravel in your system then you can run bellow command and get fresh Laravel project.

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

Step 2: Install Composer Package

Now we require to install srmklive/paypal package for paypal integration, that way we can use it’s method. So Open your terminal and run bellow command.

composer require srmklive/paypal

Now open config/app.php file and add service provider and aliase.


'providers' => [





We can also custom changes on srmklive/paypal package, so if you also want to changes then you can fire bellow command and get config file in config/paypal.php.

php artisan vendor:publish --provider "SrmklivePayPalProvidersPayPalServiceProvider"

You can view paypal.php file like as bellow:




* PayPal Setting & API Credentials

* Created by Raza Mehdi .


return [

'mode' => env('PAYPAL_MODE', 'sandbox')

'sandbox' => [

'username' => env('PAYPAL_SANDBOX_API_USERNAME', ''),

'password' => env('PAYPAL_SANDBOX_API_PASSWORD', ''),

'secret' => env('PAYPAL_SANDBOX_API_SECRET', ''),

'certificate' => env('PAYPAL_SANDBOX_API_CERTIFICATE', ''),

'app_id' => 'APP-80W284485P519543T',


'live' => [

'username' => env('PAYPAL_LIVE_API_USERNAME', ''),

'password' => env('PAYPAL_LIVE_API_PASSWORD', ''),

'secret' => env('PAYPAL_LIVE_API_SECRET', ''),

'certificate' => env('PAYPAL_LIVE_API_CERTIFICATE', ''),

'app_id' => '',


'payment_action' => 'Sale',

'currency' => env('PAYPAL_CURRENCY', 'USD'),

'billing_type' => 'MerchantInitiatedBilling',

'notify_url' => '',

'locale' => '',

'validate_ssl' => false,


Also see:Laravel 6 CRUD Application Tutorial

Step 3: Add Routes

Here, we need to add resource route for paypal payment gateway. so open your “routes/web.php” file and add following route.


Route::get('payment', 'PayPalController@payment')->name('payment');

Route::get('cancel', 'PayPalController@cancel')->name('payment.cancel');

Route::get('payment/success', 'PayPalController@success')->name('payment.success');

Step 4: Create Controller

In this step, now we should create new controller as PayPalController. So run bellow command and create new controller. bellow controller for create with some methods.

php artisan make:controller PayPalController

After bellow command you will find new file in this path “app/Http/Controllers/PayPalController.php”.



namespace AppHttpControllers;

use IlluminateHttpRequest;

use SrmklivePayPalServicesExpressCheckout;

class PayPalController extends Controller



* Responds with a welcome message with instructions


* @return IlluminateHttpResponse


public function payment()


$data = [];

$data['items'] = [


'name' => '',

'price' => 100,

'desc' => 'Description for',

'qty' => 1



$data['invoice_id'] = 1;

$data['invoice_description'] = "Order #{$data['invoice_id']} Invoice";

$data['return_url'] = route('payment.success');

$data['cancel_url'] = route('payment.cancel');

$data['total'] = 100;

$provider = new ExpressCheckout;

$response = $provider->setExpressCheckout($data);

$response = $provider->setExpressCheckout($data, true);

return redirect($response['paypal_link']);



* Responds with a welcome message with instructions


* @return IlluminateHttpResponse


public function cancel()


dd('Your payment is canceled. You can create cancel page here.');



* Responds with a welcome message with instructions


* @return IlluminateHttpResponse


public function success(Request $request)


$response = $provider->getExpressCheckoutDetails($request->token);

if (in_array(strtoupper($response['ACK']), ['SUCCESS', 'SUCCESSWITHWARNING'])) {

dd('Your payment was successfully. You can create success page here.');


dd('Something is wrong.');



Step 5: Create View File

In this step, we need to update welcome.blade.php file. in this file we will put one button for paypal payment gateway. so let’s put bellow code:


<!doctype html>



<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel 6 PayPal Integration Tutorial -</title>

<!-- Fonts -->

<link href=",600" rel="stylesheet">

<link rel="stylesheet" href="" integrity="sha256-YLGeXaapI0/5IgZopewRJcFXomhRMlYYjugPLSyNjTY=" crossorigin="anonymous" />

<!-- Styles -->


html, body {

background-color: #fff;

color: #636b6f;

font-family: 'Nunito', sans-serif;

font-weight: 200;

height: 100vh;

margin: 0;


.content {

margin-top: 100px;

text-align: center;





<div >

<div >

<h1>Laravel 6 PayPal Integration Tutorial -</h1>

<table border="0" cellpadding="10" cellspacing="0" align="center"><tr><td align="center"></td></tr><tr><td align="center"><a href="" title="How PayPal Works" onclick="'','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); return false;"><img src="" border="0" alt="PayPal Logo"></a></td></tr></table>

<a href="{{ route('payment') }}" >Pay $100 from Paypal</a>





Step 6: Add Configuration

In this step, we will set configuration value like paypal username, secret and certificate key in .env file.








You can see bellow screen shot for getting above details:

Now we are ready to run our this application example with laravel 6 so run bellow command for quick run:

php artisan serve

Now you can open bellow URL on your browser:

Also see:Laravel 6 Admin Panel Tutorial


You can download code from git: Download Code from Github

I hope it can help you….

Hope this code and post will helped you for implement PayPal Integration in Laravel 7/6 Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

  +  11  =  19

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US