Skip to content
Menu
DevSecOps Now!!!
  • About
  • Certifications
  • Contact
  • Courses
  • DevSecOps Consulting
  • DevSecOps Tools
  • Training
  • Tutorials
DevSecOps Now!!!

Laravel Webhook Handling with spatie/laravel-webhook-client

Posted on April 28, 2025

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

📦 What is This?

The spatie/laravel-webhook-client package:

  • Accepts incoming webhooks from any service
  • Validates webhook authenticity
  • Stores payloads
  • Processes the data via a queueable job

It’s especially useful when you’re not using Stripe, Paddle, or Laravel Cashier.


⚙️ Use Case Example: Paytm Payment Webhook

We’ll implement a webhook receiver for Paytm’s payment response using this package.


✅ Step-by-Step Tutorial


🪜 Step 1: Install the Package

Run:

composer require spatie/laravel-webhook-client

🪜 Step 2: Publish the Config and Migration Files

php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider"
php artisan vendor:publish --tag="webhook-client-migrations"
php artisan migrate

This will:

  • Create the webhook_calls table to store webhook logs
  • Publish the config file: config/webhook-client.php

🪜 Step 3: Create a Paytm Signature Validator

Paytm sends a CHECKSUMHASH in the payload that must be validated.

  1. Create the validator class:
php artisan make:class PaytmSignatureValidator
  1. Add the following code to the class:
namespace App\Validators;

use Illuminate\Http\Request;
use Spatie\WebhookClient\SignatureValidator\SignatureValidator;
use PaytmChecksum; // Ensure this is imported properly from Paytm SDK

class PaytmSignatureValidator implements SignatureValidator
{
    public function isValid(Request $request, array $config): bool
    {
        $paytmParams = $request->except('CHECKSUMHASH');
        $paytmChecksum = $request->input('CHECKSUMHASH');

        return PaytmChecksum::verifySignature(
            $paytmParams,
            $config['signing_secret'], // Your merchant key
            $paytmChecksum
        );
    }
}
  1. Install Paytm’s checksum utility via their SDK:
  • Download Paytm PHP SDK
  • Copy the PaytmChecksum.php class to your Laravel app (app/Helpers/PaytmChecksum.php) and autoload it via Composer if needed.

🪜 Step 4: Create Webhook Job

php artisan make:job ProcessPaytmWebhook

Then in app/Jobs/ProcessPaytmWebhook.php:

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Spatie\WebhookClient\Models\WebhookCall;

class ProcessPaytmWebhook implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public WebhookCall $webhookCall;

    public function __construct(WebhookCall $webhookCall)
    {
        $this->webhookCall = $webhookCall;
    }

    public function handle(): void
    {
        $payload = $this->webhookCall->payload;

        // Example: Check transaction status
        if ($payload['STATUS'] === 'TXN_SUCCESS') {
            // Mark order as paid
        }
    }
}

🪜 Step 5: Update config/webhook-client.php

return [
    'configs' => [
        [
            'name' => 'paytm',
            'signing_secret' => env('PAYTM_MERCHANT_KEY'), // Set this in .env
            'signature_header_name' => 'CHECKSUMHASH',
            'signature_validator' => \App\Validators\PaytmSignatureValidator::class,
            'webhook_profile' => \Spatie\WebhookClient\WebhookProfile\ProcessEverythingWebhookProfile::class,
            'webhook_model' => \Spatie\WebhookClient\Models\WebhookCall::class,
            'process_webhook_job' => \App\Jobs\ProcessPaytmWebhook::class,
        ],
    ],
];

In your .env file:

PAYTM_MERCHANT_KEY=your_paytm_merchant_key

🪜 Step 6: Set up Webhook Route

In routes/api.php or routes/web.php:

use Spatie\WebhookClient\Http\Controllers\WebhookController;

Route::post('/paytm-webhook', WebhookController::class);

Provide this URL to Paytm dashboard as the webhook endpoint.


🪜 Step 7: Run Your Queue Worker

Ensure jobs are processed:

php artisan queue:work

Or for testing without queues, use:

QUEUE_CONNECTION=sync

🔎 Optional: View Webhook Logs

Check the stored webhook logs in the database using:

use Spatie\WebhookClient\Models\WebhookCall;

$logs = WebhookCall::latest()->get();

Post Views: 1,343
  • laravel
  • webhook
Subscribe
Login
Notify of
guest
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
  • Master the Machine Learning Lifecycle:Guide to Becoming a Certified MLOps Architect
  • How to Build a Project-Level AI Memory System That Works Across Codex, Claude, and Other AI Coding Tools
  • Certified MLOps Professional: A Deep Dive into the Certified MLOps Professional Certification
  • Certified MLOps Engineer : The Comprehensive Guide to Mastering Machine Learning Operations
  • Codex vs Claude: A Complete Practical Guide for Modern Developers (2026)
  • Certified AIOps Professional Program A Guide to Career Growth
  • Keycloak Multi-Client Architecture with Project-Based Email Validation (Student, Trainer, Company, Consulting)
  • Incorrect definition of table mysql.column_stats
  • Mautic and PHP 8.3 Compatibility Guide (2026)
  • Certified AIOps Engineer: The Complete Career Path and Certification Guide
  • How to Rename Apache Virtual Host Files Safely (Step-by-Step Guide for Linux)
  • AIOps Foundation Certification: Everything You Need to Know to Get Certified
  • DevOps to Certified Site Reliability Professional: A Senior Mentor’s Guide
  • Certified Site Reliability Manager Training, Preparation, and Career Mapping
  • Certified Site Reliability Architect: The Complete Career Guide
  • What Is a VPN? A Complete Beginner-to-Advanced Tutorial
  • How to Install, Secure, and Tune MySQL 8.4 on Ubuntu 24.04 for Apache Event MPM and PHP-FPM
  • Complete Guide to Certified Site Reliability Engineer Career
  • Certified DevSecOps Professional Step by Step
  • Certified DevSecOps Manager: Complete Career Guide
  • Certified DevSecOps Engineer: Skills, Career Path and Certification Guide
  • Step-by-Step: Become a Certified DevSecOps Architect
  • Tuning PHP 8.3 for Apache Event MPM and PHP-FPM on Ubuntu: A Complete Step-by-Step Production Guide
  • Complete Step-by-Step Guide to Configure Apache Event MPM, Create index.php, Set Up VirtualHost, and Fix Ubuntu Default Page
  • Convert XAMPP Apache to Event MPM + System PHP-FPM
  • The Gateway to System Observability Engineering (MOE)
  • How to Finetune Apache and Prove It Works: A Real-World Guide to Testing Performance, Concurrency, HTTP/2, Memory, CPU, and Security
  • Building a High-Performance Apache Event MPM + PHP-FPM + MariaDB Stack (Advanced Server Optimization Guide)
  • Master Infrastructure as Code: The Complete Hashicorp Terraform Associate Guide
  • Building a High-Performance Apache Server with Event MPM + PHP-FPM (Step-by-Step Guide)

Recent Comments

  1. emmy day on SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘provider’ in ‘field list’
  2. digital banking on Complete Tutorial: Setting Up Laravel Telescope Correctly (Windows + XAMPP + Custom Domain)
  3. SAHIL DHINGRA on How to Uninstall Xampp from your machine when it is not visible in Control panel programs & Feature ?
  4. Abhishek on MySQL: List of Comprehensive List of approach to secure MySQL servers.
  5. Kristina on Best practices to followed in .httacess to avoid DDOS attack?

Archives

  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022

Categories

  • Ai
  • AI Blogging
  • AiOps
  • ajax
  • Android Studio
  • Antimalware
  • Antivirus
  • Apache
  • Api
  • API Security
  • Api Testing
  • APK
  • Aws
  • Bike Rental Services
  • ChatGPT
  • Code Linting
  • Composer
  • cPanel
  • Cyber Threat Intelligence
  • Cybersecurity
  • Data Loss Prevention
  • Database
  • dataops
  • Deception Technology
  • DeepSeek
  • Devops
  • DevSecOps
  • DevTools
  • Digital Asset Management
  • Digital Certificates
  • Docker
  • Drupal
  • emulator
  • Encryption Tools
  • Endpoint Security Tools
  • Error
  • facebook
  • Firewalls
  • Flutter
  • git
  • GITHUB
  • Google Antigravity
  • Google play console
  • Google reCAPTCHA
  • Gradle
  • Guest posting
  • health and fitness
  • IDE
  • Identity and Access Management
  • Incident Response
  • Instagram
  • Intrusion Detection and Prevention Systems
  • jobs
  • Joomla
  • Keycloak
  • Laravel
  • Law News
  • Lawyer Discussion
  • Legal Advice
  • Linkedin
  • Linkedin Api
  • Linux
  • Livewire
  • Mautic
  • Medical Tourism
  • MlOps
  • MobaXterm
  • Mobile Device Management
  • Multi-Factor Authentication
  • MySql
  • Network Traffic Analysis tools
  • Paytm
  • Penetration Testing
  • php
  • PHPMyAdmin
  • Pinterest Api
  • Quora
  • SAST
  • SecOps
  • Secure File Transfer Protocol
  • Security Analytics Tools
  • Security Auditing Tools
  • Security Information and Event Management
  • Seo
  • Server Management Tools
  • Single Sign-On
  • Site Reliability Engineering
  • soft 404
  • software
  • SuiteCRM
  • SysOps
  • Threat Model
  • Twitter
  • Twitter Api
  • ubuntu
  • Uncategorized
  • Virtual Host
  • Virtual Private Networks
  • VPNs
  • Vulnerability Assessment Tools
  • Web Application Firewalls
  • Windows Processor
  • Wordpress
  • WSL (Windows Subsystem for Linux)
  • X.com
  • Xampp
  • Youtube
©2026 DevSecOps Now!!! | WordPress Theme: EcoCoded
wpDiscuz