Stripe Payment Gateway Integration In Laravel 5.8

In this tutorial you will learn about the Stripe Payment Gateway Integration In Laravel 5.8 and its application with practical example.

Stripe Payment Gateway Integration In Laravel 5.8

Stripe is one of the most popular payment gateway, that allows us to accept payment worldwide. Stripe is very simple, hassle free and easy to integrate payment gateway. Integrating stripe payment gateway with laravel is a breeze.

In this tutorial, you will learn to integrate stripe payment gateway in your laravel 5.8 project. Before starting with this tutorial you would require a stripe developer account, from there you will get the api key and secret key require for the integration. After the successful integration you will be able to collect payment via simple payment form which allow customer to provide card information like card number, expiry date and a CVC code. Follow this step by step tutorial to learn stripe payment gateway integration in laravel 5.8.

Install Laravel 5.8

First of all we need to create a fresh laravel project, download and install Laravel 5.8 using the below command

Make sure you have composer installed.

Create Stripe account and generate key and secret

Go to the official Stripe website and signup with basic details.

Set Stripe API Key and SECRET In .env file

Now, we need to set stripe key and secret key in our project’s .env file. In stripe dashboard switch to the test mode as per screenshot, and get the stripe key and secret.


Now, open .env file located in project’s root folder and set the stripe key and secret as following –

.env file

Install stripe-php Package via composer

Now, we need to install stripe-php package in our project. Open your terminal and switch to project directory and use the following composer command to install stripe-php package.

Create Controller and Methods

Now, lets create a payment controller using following command

Once the above command executed, it will create a controller file PaymentController.php in app/Http/Controllers/ directory. Open the PaymentController.php file and put the following code in it.


Create View/Blade File

In this step, we will create view/blade file to accept stripe payment. Lets create a “stripe.blade.php” file in “resources/views/stripe/” directory and put the following code in it.


Set Routes

After this, we need to add following two routes in “routes/web.php” to display stripe payment form and to post the form data. Lets open “routes/web.php” file and add following route.


Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –




Use the following test card details to test the payment.

Test Credit Card Info :-

Card No :- 4242424242424242 / 4012888888881881
Month :- Any future month
Year :- Any future Year
CVV :- Any 3 digit Number

On successful payment, you will get the “Payment Successful” message as per the screenshot –


In this tutorial we have learn about the Stripe Payment Gateway Integration In Laravel 5.8 and its application with practical example. I hope you will like this tutorial.