Stripe Payment Gateway Integration in Laravel (2025)

Payment gateways are an essential component of e-commerce. Learn about Laravel Stripe integration to make online payments

Today, in 2025, every modern web app must make providing a seamless and secure payment experience its top priority. Stripe remains one of the most robust and developer-friendly payment processors worldwide. If you are working with Laravel, implementing Stripe is easy and fast.

This post will walk you through Stripe payment gateway integration in Laravel based on the latest best practices.

Why choose Stripe?

Supports credit/debit cards, wallets (Apple Pay, Google Pay) and bank transfers and is easy to implement with clean APIs and SDKs. Secure with built-in PCI compliance and fraud detection capabilities. Supports one-time and recurring payments.

Read also:-

Step-by-Step Stripe Integration in Laravel

Step 1: Install Stripe PHP SDK

Run the following command to install Stripe via Composer:

bash:-

composer require stripe/stripe-php

Step 2: Set Up Stripe API Keys

env:

STRIPE_KEY=your_stripe_publishable_key

STRIPE_SECRET=your_stripe_secret_key

In config/services.php, add:

‘stripe’ => [

‘key’ => env(‘STRIPE_KEY’),

‘secret’ => env(‘STRIPE_SECRET’),

],

Step 3: Create Stripe Payment Form

Create a simple form in resources/views/checkout.blade.php:

<!DOCTYPE html>

<html>

<head>

<title>Stripe Payment in Laravel</title>

</head>

<body>

<formaction=”{{ route(‘stripe.payment’) }}”method=”POST”>

@csrf

<script

src=”https://checkout.stripe.com/checkout.js”class=”stripe-button”

data-key=”{{ env(‘STRIPE_KEY’) }}”

data-amount=”1000″

data-name=”Test Payment”

data-description=”Test Stripe Payment”

data-currency=”usd”>

</script>

</form>

</body>

</html>

Step 4: Create Routes

In routes/web.php:

use App\Http\Controllers\StripeController;

Route::get(‘/checkout’, [StripeController::class, ‘checkout’])->name(‘checkout’);

Route::post(‘/stripe/payment’, [StripeController::class, ‘payment’])->name(‘stripe.payment’);

Step 5: Create StripeController

Create a controller via:

bash:-

php artisan make:controller StripeController

Then, define the method:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Stripe\Stripe;

use Stripe\Charge;

classStripeControllerextends Controller

{

publicfunctioncheckout()

{

returnview(‘checkout’);

}

publicfunctionpayment(Request$request)

{

Stripe::setApiKey(config(‘services.stripe.secret’));

Charge::create([

‘amount’ => 1000, // amount in cents

‘currency’ => ‘usd’,

‘source’ => $request->stripeToken,

‘description’ => ‘Stripe Payment Laravel 2025’,

]);

returnredirect()->route(‘checkout’)->with(‘success’, ‘Payment Successful!’);

}

}

Step 6: Display Success Message

Modify checkout.blade.php to show a success message:

@if(session(‘success’)) <p style=”color: green;”>{{ session(‘success’) }}</p> @endif

Testing the Integration

Use Stripe’s test card to test:

  • Card Number: 4242 4242 4242 4242
  • Expiry: Any future date
  • CVC: Any 3-digit number

Stripe provides various test card numbers for different scenarios like failed payments, 3D Secure, etc.

 Conclusion:-

Stripe in Laravel is fast and flexible. Whether you are building a simple checkout for your site or an unlimited form subscription model, Stripe has got it all for you. Even in 2025, it will remain the choice of developers because it is easy, works, and is available worldwide.

So, now you are ready to receive payments on your Laravel website via Stripe.


Share this post :