Laravel Zaakpay Payment Gateway Integration Tutorial Example

  • 05-02-2023
  • 993
  • Laravel 9
  • Haresh Chauhan

Watch Youtube Video (HINDI) :

Here In this post, I will tell you a general overview of the steps for integrating the Zaakpay payment gateway into a Laravel application, as well as I will tell you how to handle the zaakpay payment response after the payment made successfully, and also included refund payment zaakpay payment.

In this post, I have given all about the zaakpay payment integration tutorial in the laravel application from scratch also make a youtube video on it for more understanding you can refer this video too.

Here is some step for integration zaakpay payment in laravel:

  • Step 1. Make Payment Button
  • Step 2. Make Controller & Route
  • Step 3. Make Checksum Model
  • Step 4. Create PaymentController
  • Step 5. Make Blade File
  • Step 6. Start Development Server & Test

Step 1. Make Payment Button

In the video tutorial I gave a full HTML code description, but here UI just put a make payment link, by clicking this payment link payment gateway will open.

    <a href="{{ route('make.payment') }}">Make payment</a>

Step 2. Make Controller & Route

In this step we will create a PaymentController, in this PaymentController, we will define the make payment, the response from the payment gateway, refund payment method we will define.

Enter the below-provided command in your application terminal, this command will create a PaymentController in the controller directory.

php artisan make:controller PaymentController

After creating a controller, we will call that controller in the route file. we will create three routes from the make payment, response payment Handel and refund payment route. just copy the given route in your web.php file.


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PaymentController;

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!


Step 3. Make Checksum Model

After the route is successfully defined, we will add a model for the make payment checksum, this Checksum model will calculate the payment.

Run the below-provided command in the terminal and create a Checksum model.

php artisan make:model Checksum

After successfully creating a checksum model using the above-provided command, use the below example code in your model, just copy the whole model as the below-provided code and paste into your model.


namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Checksum extends Model
    static function calculateChecksum($secret_key, $all) {
        $hash = hash_hmac('sha256', $all , $secret_key);
        $checksum = $hash;
        return $checksum;
    static function getAllParams($data) {
        $all = '';
        //Compatible till version 8
        $checksumsequence= array("amount","bankid","buyerAddress",
        foreach($checksumsequence as $seqvalue) {
            if(array_key_exists($seqvalue, $data)) {
                    if($seqvalue != 'checksum') 
                        $all .= $seqvalue;
                        $all .="=";
                        $all .= $data[$seqvalue];
                        $all .= "&";
        return $all;
    static function outputForm($checksum,$data) {
        foreach($data as $key => $value) {
            echo ''."\n";
        echo ''."\n";
    static function verifyChecksum($checksum, $all, $secret) {
        $cal_checksum = Checksum::calculateChecksum($secret, $all);
        $bool = 0;
        if($checksum == $cal_checksum)  {
            $bool = 1;
        return $bool;

Step 4. Create PaymentController

Zaakpay Payment gateway Integration Tutorial PHP

Open PaymentController in your application and paste the below-given code into your application controller, there are three methods defined in this controller. The first method for the make zaakpay payment. the second method will handle the response from the zaakpay gateway. and the third method for the refund is your payment method.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Ixudra\Curl\Facades\Curl;

use App\Models\Checksum;
use Auth;

class PaymentController extends Controller
    public function index()
        $secretKey   = "0678056d96914a8583fb518caf42828a" ; //Get your secret key on
        $transactApi = "/api/paymentTransact/V8" ;
        $environment = "" ; //For Live transaction use
        $returnUrl = route('success.payment') ; //Change this with your response file

        $data['merchantIdentifier'] = "fb2016ffd3a64b2994a6289dc2b671a4";
        $data['orderId']            = time();
        $data['amount']             = (100*100);
        $data['buyerEmail']         = '';
        $data['currency']           = "INR";
        $data['returnUrl']          = $returnUrl;

        $all = Checksum::getAllParams($data);
        $checksum = Checksum::calculateChecksum($secretKey,$all);

        return view('payment',compact('data','environment','transactApi','checksum'));

    public function response(Request $request)
        $data = $request->all();

        $datas['merchantIdentifier'] = "fb2016ffd3a64b2994a6289dc2b671a4";
        $datas['mode']               = 0;
        $datas['orderDetail']['orderId']            = $data['orderId'];

        $secretKey   = "0678056d96914a8583fb518caf42828a";

        $checksum = Checksum::calculateChecksum($secretKey,json_encode($datas));

        $response = Curl::to('')
                ->withData(['data' => json_encode($datas),'checksum' => $checksum])


    public function refund()
        $datas['merchantIdentifier']        = "fb2016ffd3a64b2994a6289dc2b671a4";
        $datas['orderDetail']['orderId']    = '1675507346';
        $datas['orderDetail']['amount']     = "10000";

        $datas['mode']               = "0";
        $datas['updateDesired']      = "14";
        $datas['updateReason']       = "Refund";

        $secretKey   = "0678056d96914a8583fb518caf42828a";
        $checksum = Checksum::calculateChecksum($secretKey,json_encode($datas));

        $response = Curl::to('')
                ->withData(['data' => json_encode($datas),'checksum' => $checksum])

        // dd(json_decode($response));

        $datas1['merchantIdentifier'] = "fb2016ffd3a64b2994a6289dc2b671a4";
        $datas1['mode']               = 0;
        $datas1['orderDetail']['orderId']            = $datas['orderDetail']['orderId'];
        $checksums = Checksum::calculateChecksum($secretKey,json_encode($datas1));

        $responses = Curl::to('')
                ->withData(['data' => json_encode($datas1),'checksum' => $checksums])


Step 5. Make Blade File

Blade file for the make payment, this file will make checksum and then after it will submit form using javascript itself, once the form submits it will redirect to zaakpay payment gateway.

<!DOCTYPE html>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <table width="500px;">
            <td align="center" valign="middle">Do Not Refresh or Press Back <br/> Redirecting to Zaakpay</td>
            <td align="center" valign="middle">
                <form action="<?php echo $environment.$transactApi ; ?>" method="post">
    <script type="text/javascript">
    var form = document.forms[0];

Step 6. Start Development Server & Test

Using the below command start your application development server.

php artisan serve

Run the below-provided localhost URL and make a payment that it, we already make a payment button that you can make a payment by pressing the payment button.

We always thanks to you for reading our blogs.


Dharmesh Chauhan

(Swapinfoway Founder)

Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us


Haresh Chauhan


We Are Also Recommending You :