Laravel Paytm Payment Gateway Integration Example Tutorial

Laravel Paytm Payment Gateway Integration Example Tutorial

How to integrate paytm payment gateway in laravel 5.7 application. In this tutorial, we’ll discuss step by step how to integrate paytm payment gateway in our laravel 5.7 App using anandsiddharth/laravel-paytm-wallet package. In this example we will integrate paytm payment gateway in simple and easy way. And this paytm payment gateway example also work with laravel 5.8 version.

Paytm is a very popular company. Paytm provide a payment gateway in many diffrent languages like PHP, Java, .Net, Node.js, Ruby on Rails, Perl, Python, Express.

Sometimes we found invalid checksum error in paytm payment gateway sdk. We have resolved invalid checksum error in integrate paytm payment gateway.

Laravel Paytm Payment Gateway Integration Example Tutorial

  • Install Laravel Fresh Setup
  • Configuration .env file
  • Install Anandsiddharth paytm package
  • Generate Migration and Create Model
  • Make Route
  • Create Controller
  • Create Blade View file
  • Start Development Server
  • Conclusion

Install Laravel Fresh Project

Firstly, you need to install Laravel fresh application using the below command, Open your command prompt and run the below command :

composer create-project --prefer-dist laravel/laravel LaravelPaytm

After successfully install laravel Application, Go to your project .env file and set up database credential and move next step.

Configuration in .env

In this step, you will set the database credentials in the .env file. Let’s open the .env file.

DB_DATABASE=your database name here
DB_USERNAME=database username here
DB_PASSWORD=database password here

Install Anandsiddharth paytm package

Use the below command and install the package:

composer require anandsiddharth/laravel-paytm-wallet

After successfully install package, you need to register provider and aliase. Go to the app/config/app.php and put the below lines here :

'providers' => [
// Other service providers…
'aliases' => [
// Other aliases
'PaytmWallet' => Anand\LaravelPaytmWallet\Facades\PaytmWallet::class,

Then you need to set paytm credential like below. Go to the app/config/services.php and set the paytm credential.

'paytm-wallet' => [
'env' => 'production', // values : (local | production)
'merchant_id' => 'YOUR_MERCHANT_ID',
'merchant_key' => 'YOUR_MERCHANT_KEY',
'merchant_website' => 'YOUR_WEBSITE',
'channel' => 'YOUR_CHANNEL',
'industry_type' => 'YOUR_INDUSTRY_TYPE',

All the credentials mentioned are provided by Paytm after signing up as merchant.

Generate Migration and Create Model

Now you will Create table name notes and it’s migration file. use the below command :

php artisan make:model Event -m

It command will create one model name Event and also create one migration file for events table. After successfully run the command go to database/migrations file and put the below here :

use Illuminate\Support\Facades\Schema; 
use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 
class CreateEventsTable extends Migration 
     * Run the migrations. 
     * @return void 
    public function up() 
        Schema::create('products', function (Blueprint $table) { 
     * Reverse the migrations. 
     * @return void 
    public function down() 

Next, migrate the table using the below command.

php artisan migrate

Now, add the fillable property inside Event.php file.

namespace App;
use Illuminate\Database\Eloquent\Model;
class Note extends Model
  protected $fillable = ['name','mobile_number',

Make Route


Route::get('event', 'EventController@bookEvent');
Route::post('payment', 'EventController@eventOrderGen');
Route::post('payment/status', 'EventController@paymentCallback');

Create Controller

Create the controller name EventController using the below command.

php artisan make:controller EventController

Go to app/http/Controller/EventController and put the below code :


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Event;
use PaytmWallet;

class EventController extends Controller

     * Redirect the user to the Payment Gateway.
     * @return Response
    public function bookEvent()
        return view('book_event');

     * Redirect the user to the Payment Gateway.
     * @return Response
    public function eventOrderGen(Request $request)
	 $this->validate($request, [
	      'name' => 'required',
	      'mobile_no' =>'required|numeric|digits:10|unique:events,mobile_number',

        $input = $request->all();
        $input['order_id'] = rand(1111,9999);
        $input['amount'] = 50;


        $payment = PaytmWallet::with('receive');
          'order' => $input['order_id'],
          'user' => 'user id',
          'mobile_number' => $request->mobile_number,
          'email' => $request->email,
          'amount' => $input['amount'],
          'callback_url' => url('payment/status')
        return $payment->receive();

     * Obtain the payment information.
     * @return Object
    public function paymentCallback()
        $transaction = PaytmWallet::with('receive');

        $response = $transaction->response();

          Event::where('order_id',$response['ORDERID'])->update(['status'=>'success', 'payment_id'=>$response['TXNID']]);

          dd('Payment Successfully Credited.');

        }else if($transaction->isFailed()){
          Event::where('order_id',$order_id)->update(['status'=>'failed', 'payment_id'=>$response['TXNID']]);
          dd('Payment Failed. Try again lator');

Create Blade View file

Now, you need to create blade views file, Go to app/resources/views/ and create one file name event.blade.php :

<!DOCTYPE html>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>Paytm Payment Gateway Integrate -</title>
    <link href="" rel="stylesheet">
            margin-top: 40px;
<div class="container">

<div class="row">
    <div class="col-lg-12 mt40">
        <div class="card-header" style="background: #0275D8;">
            <h2>Register for Event</h2>
@if ($errors->any())
    <div class="alert alert-danger">
        <strong>Whoops!</strong> Something went wrong<br>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
<form action="{{ route('') }}" method="POST" name="add_note">
    {{ csrf_field() }}
     <div class="row">
        <div class="col-md-12">
            <div class="form-group">
                <input type="text" name="name" class="form-control" placeholder="Enter Name">
        <div class="col-md-12">
            <div class="form-group">
                <strong>Mobile Number</strong>
                <input type="text" name="mobile_number" class="form-control" placeholder="Enter Mobile Number">
        <div class="col-md-12">
            <div class="form-group">
                <strong>Email Id</strong>
                <input type="text" name="email" class="form-control" placeholder="Enter Email id">
        <div class="col-md-12">
            <div class="form-group">
                <strong>Event Fees</strong>
                <input type="text" name="amount" class="form-control" placeholder="" value="100" readonly="">
        <div class="col-md-12">
                <button type="submit" class="btn btn-primary">Submit</button>

Start Development Server

In this step, you will use the php artisan serve command . It will start your server locally

php artisan serve

If you want to run the project diffrent port so use this below command

php artisan serve --port=8080

Now you are ready to run our example so run bellow command to quick run.


Or direct hit in your browser

http://localhost/LaravelPaytm /public/event

If you want to remove public or public/index.php from URL In laravel, Click Me

Testing Card Credential
 Card No : 4242424242424242
Month : any future month
Year : any future Year
CVV : 123
Password : 123123


In this tutorial, you have successfully integrate paytm payment gateway in laravel 5.7 Application. Our examples run quickly.

You may like

  1. Laravel Stripe Payment Gateway Integration Example Tutorial
  2. Razorpay Payment Gateway Integration Laravel 6 E.g
  3. Laravel Instamojo Payment Gateway Integration Example
  4. Angular Stripe Payment Gateway Example


If you found any invalid check sum issue in this laravel paytm package . Go to App/vendor/anandsiddharth/laravel-paytm-wallet/lib/encdec_paytm.php file. Next file the function checkString_e() and replace the function to below code here :

 function checkString_e($value) {
$myvalue = ltrim($value);
$myvalue = rtrim($myvalue);
if (in_array($myvalue, ['null', 'NULL']))
$myvalue = '';
return $myvalue;

after put the code and run your project again. if still found this issue contact on paytm customer support and active your wallet credential.

If you have any questions or thoughts to share, use the comment form below to reach us.


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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