How to integrate stripe payment with laravel 7

Hello World, Welcome to Today i am going to create a tutorial about stripe payment with laravel 7. This is a small and very easy tutorial. It is very easy to integrate stripe with laravel. I have divided this tutorial into the following parts.

  • Setup stripe account
  • Install stripe package in laravel
  • Integrate stripe with laravel
  • Make payment

I have assumed that you have average knowledge of laravel.

Setup stripe account

The first step is to create a stripe account on their official website and get the test credentials.

Install stripe package in laravel

Run the following command to install stripe package.

composer require stripe/stripe-php

For more information about this package, check this link.

Integrate stripe with laravel

  • Add the follownig code in view file.
  • <form method="post" action="{{url('payment')}}">
                        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
                src="" class="stripe-button"
                data-name="Example 1"
                data-description="Example 1 Description"
                data-label="Pay Now"
  • The above code will show the stripe button.
  • Create the PaymentController and add the following method in it.
  • function paymentProcess(){
                'description'=>'This is an example',
       return response('Payment has been successfull');
       return response('Some Error Occured!!');
  • Add the following code in routes/web.php file
  • Route::post('payment','PaymentController@paymentProcess');

Make Payment

  • Now open the URL with the defined route in the browser. You will see the following screen.

  • You can test the payment with the following card detail
Card Number: 4111 1111 1111 1111
Expiry: 06/2024
CVV: 123

I hope this tutorial helps you. Please add your feedback in the comment section. Thank you 🙂

Leave a Reply

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