DEV Community

Cover image for Razorpay Payment Gateway Integration Laravel 8 Example [Simple coding]
Robert Look
Robert Look

Posted on

Razorpay Payment Gateway Integration Laravel 8 Example [Simple coding]

I will receive payments using the Razorpay payment gateway in laravel. Today We will implement Razorpay payment gateway in larvel 8 application. In this example, I will give an easy and simple way to integrate Razorpay payment gateway in laravel application.

Here, I am going to show you a full example of laravel 8 Razorpay payment gateway integration. So let's see the below example step by step.

Razorpay Payment Gateway Integration Laravel 8 Example [Simple coding]

<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>How To Integrate Razorpay Payment Gateway In Laravel 8 - phpcodingstuff.com</title>
    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}" defer></script>
    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
    <div id="app">
        <main class="py-4">
            <div class="container">
                <div class="row">
                    <div class="col-md-6 offset-3 col-md-offset-6">
                        @if($message = Session::get('error'))
                            <div class="alert alert-danger alert-dismissible fade in" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">×</span>
                                </button>
                                <strong>Error!</strong> {{ $message }}
                            </div>
                        @endif
                        @if($message = Session::get('success'))
                            <div class="alert alert-success alert-dismissible fade {{ Session::has('success') ? 'show' : 'in' }}" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">×</span>
                                </button>
                                <strong>Success!</strong> {{ $message }}
                            </div>
                        @endif
                        <div class="card card-default">
                            <div class="card-header">
                                How To Integrate Razorpay Payment Gateway In Laravel 8 - phpcodingstuff.com
                            </div>

                            <div class="card-body text-center">
                                <form action="{{ route('payment') }}" method="POST" >
                                    @csrf
                                    <script src="https://checkout.razorpay.com/v1/checkout.js"
                                            data-key="{{ env('RAZOR_KEY') }}"
                                            data-amount="1000"
                                            data-buttontext="product_price"
                                            data-name="Php Coding Stuff"
                                            data-description="Rozerpay"
                                            data-image="{{ asset('/image/phpcodingstuff.png') }}"
                                            data-prefill.name="name"
                                            data-prefill.email="email"
                                            data-theme.color="#ff752950">
                                    </script>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

More Information: Razorpay Payment Gateway Integration Laravel 8 Example [Simple coding]

Top comments (0)