How to Integrate PayPal in Laravel

In this article, i am going to explain “How to Integrate Paypal in Laravel”. Here i give you full example of How to integrate paypal payment gateway step by step like create laravel project, migration, model, route, blade file etc.

Today paypal is major and world most very famous payment gateway which many websites integrated and many people want to integrate in website. So webprepration team show you “How to Integrate Paypal Payment Gateway in Laravel” in few steps.

There are many payment gateways integrate in web application, Previously I have written Stripe Payment Gateway Here I will tell you about paypal payment gateway.

We are here use paypal/rest-api-sdk-php package for integrate paypal with laravel, this is very good package for paypal. So you have just follow few steps which is given below:-

Step 1:- Here, we are create new one laravel project by using collowing command

Step 2:- After create new laravel project need to configure database setting in .env file like that

Step 3:- Now need to install Paypal SDK using Composer

Step 4:- Next , I need to login paypal developer mode, create a new sandbox account and get some keys like client_id and secret for testing this integration.

  • Login to to create a merchant account, so that you can sell or to credit funds to your account.
  • You can also create buyer account, to buy from some merchant.
  • You will need to create a new app to get the client_id and secret keys.
  • After creating your app click on the app it shows you client_id and secret keys.
  • Copy keys and paste those in your .env file for security.

Step 5:- Now create a new file paypal.php, at \config directory and paste below in created file.

Step 6:- Now, we are create one resources/views/paywithpaypal.blade.php for display paypal form, copy below code and paste in created file.


Step 7:- Now create route in routes/web.php file one is required for show paypal payment form view and one another is for make post HTTP request and third for check our payment return status response is true or false like this way

Step 8:- Now, I will create a new controller to manage all the PayPal related process using command

The above command create new controller PaymentController.php file in app/Http/Controllers folder.

Now we are ready to test paypal payment, So run below command

Now you can open below URL

I hope this post is very helpful for integration Paypal Payment Gateway in laravel. If you need Stripe or Cc Avenue payment gateway then you can read Stripe and CCAvenue etc.


Add a Comment

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