Zaakpay Payment gateway Integration Tutorial PHP

  • 23-01-2023
  • 511
  • PHP
  • Haresh Chauhan

Watch Youtube Video (HINDI) :

Hello Artisan, In this post, I will tell you how to integrate the zaakpay payment gateway in the PHP application. below the zaakpay payment example code I have given all the sandbox credentials, for the production you need to get your real API keys and details from your merchant zaakpay account, I have given in this example the sandbox credentials details.

Zaakpay payment gateway service provided by "MOBIKWIK", collects payment vai credit card, debit card, UPI, net banking, and wallet balance as well as the pay later option provides. I have integrated this in a very simple way and very quick understanding.

Zaakpay is an Indian Payment Gateway, that provides a platform for merchants to accept and process online payments from customers. It offers a variety of payment options including credit cards, debit cards, net banking, UPI and other e-wallets. It also provides the merchants with a dashboard to manage and track transactions and also provides APIs to integrate it with their website or mobile application.

It enables merchants to accept payments from customers across India and also provides a secure and reliable platform for transactions. It also offers various features like recurring payments, refunds, and settlements.

It is a widely used Payment gateway in India and is trusted by many merchants and businesses.

In this zaakpay payment PHP tutorial I have given an example of payment using zaakpay, refund payment, and the status of the payment process. all the example codes I have given in the below example. also, I have included "SOURCE CODE" below with a full tutorial integration of the zaakpay in PHP.

Preview :

image

Config.php

Create a config file to set all the zaakpay credentials in one place together for better understanding and easy to change from one file place.

<?php

$merchantIdentifier = "fb2016ffd3a64b2994a6289dc2b671a4"; //Get your merchant identifier on Zaakpay.com

$secretKey = "0678056d96914a8583fb518caf42828a" ; //Get your secret key on Zaakpay.com

//Api URL
$environment = "https://zaakstaging.zaakpay.com" ; //For Live transaction use https://api.zaakpay.com

//Payment processing URL's
$transactApi = "/api/paymentTransact/V8" ;

//Transaction update URL's
$updateApi = "/updatetransaction" ;

//Transaction check status URL's
$checkStatusApi = "/checkTxn?v=5" ;

//Url for test response file
$returnUrl = "http://localhost/Zaakpay_PHP_Integration_Kit/src/com/zaakpay/api/Response.php" ; //Change this with your response file

Checksum.php

Create a "Checksum" file that has the payment link and sends a request to the zaakpay server with the encoded format.

<?php

Class Checksum {
    static function calculateChecksum($secret_key, $all) {
        $hash = hash_hmac('sha256', $all , $secret_key);
        $checksum = $hash;
        return $checksum;
    }
    
    static function getAllParams() {
        $all = '';
        //Compatible till version 8
        $checksumsequence= array("amount","bankid","buyerAddress",
                "buyerCity","buyerCountry","buyerEmail","buyerFirstName","buyerLastName","buyerPhoneNumber","buyerPincode",
                "buyerState","currency","debitorcredit","merchantIdentifier","merchantIpAddress","mode","orderId",
                "product1Description","product2Description","product3Description","product4Description",
                "productDescription","productInfo","purpose","returnUrl","shipToAddress","shipToCity","shipToCountry",
                "shipToFirstname","shipToLastname","shipToPhoneNumber","shipToPincode","shipToState","showMobile","txnDate",
                "txnType","zpPayOption");
        
        
        foreach($checksumsequence as $seqvalue)	{
            if(array_key_exists($seqvalue, $_POST))	{
                if(!$_POST[$seqvalue]=="")
                {
                    if($seqvalue != 'checksum') 
                    {
                        $all .= $seqvalue;
                        $all .="=";
                        $all .= $_POST[$seqvalue];
                        $all .= "&";
                        }
                }
                
            }
        }
        return $all;
    }
    static function getAllParamsCheckandUpdate() {
        //ksort($_POST);
        $all = '';
        foreach($_POST as $key => $value)	{
            if($key != 'checksum') {
                $all .= "'";
                $all .= $value;
                $all .= "'";
            }
        }
        
        return $all;
    }
    static function outputForm($checksum) {
        //ksort($_POST);
        foreach($_POST as $key => $value) {
            echo '<input type="hidden" name="'.$key.'" value="'.$value.'" />'."\n";
        }
        echo '<input type="hidden" name="checksum" value="'.$checksum.'" />'."\n";
    }
    
    static function verifyChecksum($checksum, $all, $secret) {
        $cal_checksum = Checksum::calculateChecksum($secret, $all);
        $bool = 0;
        if($checksum == $cal_checksum)	{
            $bool = 1;
        }
        return $bool;
    }
    
    static function outputResponse($bool) {
        foreach($_POST as $key => $value) {
            if ($bool == 0) {
                if ($key == "responseCode") {
                    echo '<tr><td width="50%" align="center" valign="middle">'.$key.'</td>
                        <td width="50%" align="center" valign="middle"><font color=Red>***</font></td></tr>';
                } else if ($key == "responseDescription") {
                    echo '<tr><td width="50%" align="center" valign="middle">'.$key.'</td>
                        <td width="50%" align="center" valign="middle"><font color=Red>This response is compromised.</font></td></tr>';
                } else {
                    echo '<tr><td width="50%" align="center" valign="middle">'.$key.'</td>
                        <td width="50%" align="center" valign="middle">'.$value.'</td></tr>';
                }
            } else {
                echo '<tr><td width="50%" align="center" valign="middle">'.$key.'</td>
                    <td width="50%" align="center" valign="middle">'.$value.'</td></tr>';
            }
        }
        echo '<tr><td width="50%" align="center" valign="middle">Checksum Verified?</td>';
        if($bool == 1) {
            echo '<td width="50%" align="center" valign="middle">Yes</td></tr>';
        }
        else {
            echo '<td width="50%" align="center" valign="middle"><font color=Red>No</font></td></tr>';
        }
    }
    static function getAllResponseParams() {
        //ksort($_POST);
        $all = '';
        $checksumsequence= array("amount","bank","bankid","cardId",
        "cardScheme","cardToken","cardhashid","doRedirect","orderId",
        "paymentMethod","paymentMode","responseCode","responseDescription",
        "productDescription","product1Description","product2Description",
        "product3Description","product4Description","pgTransId","pgTransTime");
        foreach($checksumsequence as $seqvalue)	{
            if(array_key_exists($seqvalue, $_POST))	{
                $all .= $seqvalue;
                $all .="=";
                $all .= $_POST[$seqvalue];
                $all .= "&";
            }
        }
        return $all;
    }
}
?>

style.css

This is just a simple style, this style is not necessary for your application. this is just for the understanding purpose I have written some style CSS.

.customtable,.customtable-all{
    border-collapse:collapse;
    border-spacing:0;
    width:100%;
    display:table
}
.customtable-all{
    border:1px solid #ccc
}
.w3-bordered tr,.customtable-all tr{
    border-bottom:1px solid #ddd
}
.w3-striped tbody tr:nth-child(even){
    background-color:#f1f1f1
}
.customtable-all tr:nth-child(odd){
    background-color:#fff
}
.customtable-all tr:nth-child(even){
    background-color:#f1f1f1
}
.w3-hoverable tbody tr:hover,.w3-ul.w3-hoverable li:hover{
    background-color:#ccc
}
.w3-centered tr th,.w3-centered tr td{
    text-align:center
}
.customtable td,.customtable th,.customtable-all td,.customtable-all th{
    padding:8px 8px;
    display:table-cell;
    text-align:left;
    vertical-align:top
}
.customtable th:first-child,.customtable td:first-child,.customtable-all th:first-child,.customtable-all td:first-child{
    padding-left:16px
}
.message {
    color: limegreen;
    text-align: center;
}
.card {
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
    transition: 0.3s;
    width: 40%;
}
.card:hover {
    box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.container {
    padding: 2px 16px;
}
td {
    word-break: break-word;
}

index.php

This is the root index file for running the PHP application. I have given all three payment APIs. payment and process, refund payment, and status payment. links I gave in this index file. by clicking, we will execute API.

<?php require_once('Config.php') ; ?>

<html>
    <head>
        <link rel="stylesheet" href="style.css">
        <title>Zaakpay PHP Integration Kit</title>
    </head> 
    <body>
            <br> <br> <img src="./img/Logo.png" alt="logo" /> <br> <br>
        <div>
            <table class="customtable-all card" style="margin: 10px 10px 10px 20px;float: left;" border="1">
            <tr>
                <th colspan="2" width="120px" style="text-align:center">CURRENT CONFIGURATIONS</th>
            </tr>
            <tr>
                <th> Api URL </th>
                <td> <?php echo $environment ; ?> </td>
            </tr>
            <tr>
                <th> Payment URL </th>
                <td> <?php echo $environment.$transactApi ; ?> </td>
            </tr>
            <tr>
                <th> Transaction Status Check URL </th>
                <td> <?php echo $environment.$checkStatusApi ; ?> </td>
            </tr>
            <tr>
                <th> Return URL <br> Response file path </th>
                <td> <?php echo $returnUrl ; ?> </td>
            </tr>
            <tr>
                <th> Refund URL </th>
                <td> <?php echo $environment.$updateApi ; ?> </td>
            </tr>
            </table>

            <table class="customtable-all card" style="margin: 10px 100px 10px 10px;float: right;" border="1">
                <tr>
                    <th> <br> <br> Process Payment <br> <br> </th>
                    <td>
                        <br>
                            This will initiate the payment by submitting the mandatory and optional parameters to Zaakpay which will proceed you further to the payment page.
                        <br>
                    </td>
                </tr>
                <tr>
                    <th colspan="2">
                        <br><div align="center">
                            <a href="./Payment.php"><button>Initiate Payment</button></a>
                        </div><br>
                    </th>
                </tr>
            </table>
            <table class="customtable-all card" style=" margin: 10px 100px 10px 100px; float: right" border="1">
                <tr>
                    <th> <br> <br> Refund Transaction <br> <br> </th>
                    <td>
            
                        <br>
                        This will allow you to refund ( full or partial ) the successful transaction.
                        <br>

                    </td>
                </tr>
                <tr>
                    <th colspan="2">
                        <br><div align="center">
                            <a href="./Refund.php"><button>Refund Transaction</button></a>
                        </div><br>
                    </th>
                </tr>
            </table>

            <table class="customtable-all card" style=" margin: 10px 100px 10px 100px; float: right" border="1">
                <tr>
                    <th> <br> <br> Transaction Status <br> <br> </th>
                    <td>
            
                        <br>
                        This will check the transaction status against a particular Order Id.
                        <br>

                    </td>
                </tr>
                <tr>
                    <th colspan="2">
                        <br><div align="center">
                            <a href="./TransactionStatus.php"><button>Transaction Status</button></a>
                        </div><br>
                    </th>
                </tr>
            </table>
    </body>
</html>

Payment.php

This is the payment file for the make payment when I click on the pay button in the index file, this link will redirect to this payment file for the redirect zaakpay payment platform.

<?php
if(array_key_exists('orderId', $_POST) and !(array_key_exists('checksum', $_POST))) {
    require_once('Checksum.php');
    require_once('Config.php');

    $checksumFlag = $environment != "https://api.zaakpay.com" ; //This should not be changed

    $all = Checksum::getAllParams();
    $checksum = Checksum::calculateChecksum($secretKey, $all); 	 //This is used to generate checksum
?>
<?php if ($checksumFlag) { ?>
<html>
<head>
	<link rel="stylesheet" href="style.css">
   	<title>Request Parameters</title>
</head>
<body>
	<div align="center">
		<form action="<?php echo $environment.$transactApi ; ?>" method="post">
			<table width="650px;" class="customtable-all card" >
				<tr>
					<th colspan="2">REQUEST PARAMETERS</th>
				</tr>
				<tr>
					<th>Order Id</th>
					<td><?php echo $_POST['orderId'] ?></td>
				</tr>
				<tr>
					<th>Checksum String</th>
					<td><?php echo htmlentities($all) ?></td>
				</tr>
				<tr>
					<th>Calculated Checksum</th>
					<td><?php echo $checksum ?></td>
				</tr>
				<tr>
					<div>
						<th colspan="2" align="left"><br><input type="submit" value="Process Payment"><br><br></th>
					</div>
				</tr>
			</table>
			<?php Checksum::outputForm($checksum); ?>
		</form>
	</div>

</body>
</html>
<?php } ?>

<?php if (!$checksumFlag) { ?>
<center>
<table width="500px;">
	<tr>
		<td align="center" valign="middle">Do Not Refresh or Press Back <br/> Redirecting to Zaakpay</td>
	</tr>
	<tr>
		<td align="center" valign="middle">
			<form action="<?php echo $environment.$transactApi ; ?>" method="post">
				<?php
				Checksum::outputForm($checksum);
				?>
			</form>
		</td>
	</tr>
</table>
</center>
<script type="text/javascript">
var form = document.forms[0];
form.submit();
</script>
<?php } ?>

<?php } ?>

<?php if(!array_key_exists('orderId', $_POST)) {
   	require_once('Config.php');
 ?>
<html>
<head>
	<link rel="stylesheet" href="style.css">
   	<title>Sample Input</title>
   	<script type="text/javascript">

	function autoPop(){
		document.getElementById("orderId").value= "ZPLive" + String(new Date().getTime());	//	Autopopulating orderId
		var today = new Date();
		var dateString = String(today.getFullYear()).concat("-").concat(String(today.getMonth()+1)).concat("-").concat(String(today.getDate()));
		document.getElementById("txnDate").value= dateString;
	};
 function submitForm(){
	 var form = document.forms[0];
	 var amt = document.getElementById("amount").value;
	 amt = amt.replace(new RegExp(",", 'g'),"");
	 var hiddenAmt = document.getElementById("amount");
	 hiddenAmt.value=parseInt(amt*100);
	 form.action = "Payment.php";
	 form.submit();
 };
   	</script>
</head>

<body onload="autoPop()">

<div align="center">
<form action="Payment.php" method="post">
<h2>Pay Now to see how Zaakpay will work on your website.</h2>
<p>Note: This page behaves like a shopping cart or checkout page on a website.</p>
<table width="650px;" class="customtable-all card">
<tr>
	<th colspan="2" >MANDATORY PARAMETERS</th>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Merchant Identifier</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="merchantIdentifier" value="<?php echo $merchantIdentifier ; ?>" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Order Id</td>
	<td width="50%" align="center" valign="middle"><input type="text" id="orderId" name="orderId" /></td>
</tr>
<tr>
	  <input type="hidden" name="returnUrl" value="<?php echo $returnUrl; ?>"/>
	  <input type="hidden" name="currency" value="INR" />
<!-- </tr>
<tr>
	<td width="50%" align="right" valign="middle">Amount In Paisa</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="amount" value="100" placeholder="In Paisa" /> </td>
</tr>-->

<tr>
	<td width="50%" align="right" valign="middle">Amount</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="amount" id="amount" value="100" placeholder="In Rupess" /> </td>
</tr>

<tr>
	<td width="50%" align="right" valign="middle">Buyer Email</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerEmail" value=""  /> </td>
</tr>
<!--<tr>
	<th align="center" colspan="2" style="text-align: center;"><br><input type="submit" value="Pay Now"><br><br></th>
</tr>-->

<tr>
	<th align="center" colspan="2" style="text-align: center;"><br><input onclick="javascript:submitForm()" type="submit" value="Pay Now"><br><br></th>
</tr>

</table>
<br><br>

<!-- ========================== OPTIONAL PARAMETERS ================================ --->

<table  width="650px;" class="customtable-all card">
<tr>
	<th colspan="2" >OPTIONAL PARAMETERS</th>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer First Name</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerFirstName" value="" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer Last Name</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerLastName" value="" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer Address</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerAddress" value="" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer City</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerCity" value="" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer State</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerState" value="" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer Country</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerCountry" value="" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer Pincode</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerPincode" value="" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Buyer Phone No</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="buyerPhoneNumber" value="" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Product Description</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="productDescription" /> </td>
</tr>
</table>

<!-- Not mandatory  -->
<!-- <tr>
	<td width="50%" align="right" valign="middle">Product1 Description</td>
	<td width="50%" align="center" valign="middle"><input type="hidden" name="product1Description" /></td>
</tr> -->
<!-- <tr>
	<td width="50%" align="right" valign="middle">IPaddress</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="merchantIpAddress" /> </td>
</tr> -->
<!-- <tr>
	<td width="50%" align="right" valign="middle">Purpose</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="purpose" /></td>
</tr> -->
<!-- <tr>
	<td width="50%" align="right" valign="middle">Txntype</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="txnType" value="1" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Zppayoption</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="zpPayOption" value="1" /></td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Mode</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="mode" value="1" /> </td>
</tr>
<tr>
	<td width="50%" align="right" valign="middle">Currency</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="currency" value="INR" /></td>
</tr>
 -->
<!--<tr>
	<td width="50%" align="right" valign="middle">Product2 Description</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="product2Description" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Product3 Description</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="product3Description" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Product4 Description</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="product4Description" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To Address</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToAddress" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To City</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToCity" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To State</td>
	<td width="50%" align="center" valign="middle"></td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToState" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To Country</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToCountry" /> -->

<!--<tr>
	<td width="50%" align="right" valign="midb6415a6443604ec59644a70c8b25a0f6dle">Ship To Pincode</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToPincode" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To Phone Number</td>
	<td width="50%" align="center" valign="middle"> </td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToPhoneNumber" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To Firstname</td>
	<td width="50%" align="center" valign="middle"></td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToFirstname" /> -->

<!--<tr>
	<td width="50%" align="right" valign="middle">Ship To Lastname</td>
	<td width="50%" align="center" valign="middle"></td>
</tr>-->
<!-- Not mandatory <input type="hidden" name="shipToLastname" /> -->
<!--
<tr>
	<td width="50%" align="right" valign="middle">Transaction Date "YYYY-MM-DD"</td>
	<td width="50%" align="center" valign="middle"><input type="text" name="txnDate" id="txnDate" /></td>
</tr> -->
</form>
</div>
<br><br><br><br><br>
</body>
</html>
<?php } ?>

Refund.php

Refund payment from the zaakpay, we will execute this refund.php file when you want to refund the payment to the customer.

<?php
   if(array_key_exists('orderId', $_POST) and !(array_key_exists('checksum', $_POST))) {
      require_once('Checksum.php');
         require_once('Config.php');  
   

        $checksumFlag = $environment != "https://api.zaakpay.com" ; //This should not be changed

      $all = Checksum::getAllParamsCheckandUpdate();
      $checksum = Checksum::calculateChecksum($secretKey, $all);
?>

<?php if ($checksumFlag) { ?>


<html>
<head>
   <link rel="stylesheet" href="style.css">
      <title>Request Parameters</title>
</head>
<body>
   <div align="center">
      <form action="<?php echo $environment.$updateApi ; ?>" method="post">
         <table width="650px;" class="customtable-all card" border="1">
            <tr>
               <td colspan="2" align="center" valign="middle">REQUEST PARAMETERS</td>  
            </tr>
            <tr>  
               <td width="50%" align="center" valign="middle">Order Id</td>
               <td width="50%" align="center" valign="middle"><?php echo $_POST['orderId'] ?></td> 
            </tr>
            <tr>
               <th>Checksum String <br> ( Raw Request )</th>
               <td><?php echo $all ?></td>
            </tr>
            <tr>
               <th>Calculated Checksum</th>
               <td><?php echo $checksum ?></td>
            </tr>
            <tr>
               <div>
                  <th colspan="2" align="left"><br><input type="submit" value="Refund"><br><br></th>
               </div>
            </tr>
         </table>
         <?php Checksum::outputForm($checksum); ?>
      </form>
   </div>
</body>
</html>
<?php } ?>

<?php if (!$checksumFlag) { ?>

<center>
<table width="500px;">
  <tr>
    <td align="center" valign="middle">Do Not Refresh or Press Back <br/> Redirecting to Zaakpay</td>
  </tr>
  <tr>
    <td align="center" valign="middle">
      <form action="<?php echo $environment.$updateApi ; ?>" method="post">
        <?php
        Checksum::outputForm($checksum);
        ?>
      </form>
    </td>
  </tr>
</table>
</center>
<script type="text/javascript">
var form = document.forms[0];
form.submit();
</script>

<?php } ?>
<?php } ?>

<?php require_once('Config.php'); ?>  
<?php if(!array_key_exists('orderId', $_POST)) { ?>
<html>
<head>
	<link rel="stylesheet" href="style.css">
   	<title>Refund Transaction</title>
</head>
<body>
<br><br>
<div align="center">
	<form action="Refund.php" method="post">
		<table class="customtable-all card" border="1">
   			<tr>
   				<th> <br> Full Refund <br><br></th>
   				<td>
   					<br>
   					This will initiate full refund for the transaction .
   					<br><br>
   				</td>
   			</tr>
   			<tr>
   				<th colspan="2">
   					<br><div align="center">
                     <pre>Merchant Identifier : <input type="text" name="merchantIdentifier" value="<?php echo $merchantIdentifier ?>" ></pre>
<input type="text" name="orderId" placeholder="Enter orderId">
<input type="hidden" name="mode" value="0">
<input type="hidden" name="updateDesired" value="14">
<input type="hidden" name="updateReason" value="Test reason">
<br><br>
<button>Initiate Full Refund</button>
</div><br>
</th>
</tr>
</table>
</form>
<br><br>

<form action="Refund.php" method="post">
    <table class="customtable-all card" border="1">
        <tr>
            <th> <br> Partial Refund<br><br> </th>
            <td>
                <br>
                This will initiate partial refund for the transaction .
                <br><br>
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <br>
                <div align="center">
                    <pre>Merchant Identifier : <input type="text" name="merchantIdentifier" value="<?php echo $merchantIdentifier ?>" ></pre>
                    <input type="text" name="orderId" placeholder="Enter orderId">
                    <input type="hidden" name="mode" value="0">
                    <input type="hidden" name="updateDesired" value="22">
                    <input type="hidden" name="updateReason" value="Test reason">
                    <input type="text" name="amount" placeholder="Enter Amount ( Paisa )">
                    <br><br>
                    <button>Initiate Partial Refund</button>
                </div><br>
            </th>
        </tr>
    </table>
</form>
</div>
<br><br><br><br><br>
</body>

</html>
<?php } ?>`

Response.php

After payment is made or refund payment is handel the response from the zaakpay payment is.

<?php require_once('Checksum.php'); ?>
<?php require_once('Config.php'); ?>  

<?php
    
    $checksumFlag = $environment != "https://api.zaakpay.com" ; //This should not be changed

    $recd_checksum = $_POST['checksum'];
    $all = Checksum::getAllResponseParams();
    $checksum_check = Checksum::verifyChecksum($recd_checksum, $all, $secretKey); //This is used to validate the received checksum
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" href="style.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Zaakpay Response</title>
</head>
<body>

<center><br>
<table width="500px;" class="customtable-all card">
    <?php Checksum::outputResponse($checksum_check);
    ?>
<?php if ($checksumFlag) { ?>
    <tr>
        <th width="50%" align="center" valign="middle">Response Checksum String</td></tr>
        <td width="50%" align="center" valign="middle"><font color=Blue><?php echo $all; ?></font></td></tr>
    </tr>
<?php } ?>
</table>
</center>
</body>
</html>

TransactionStatus.php

Check your zaakpay payment process status, and execute this "TransactionStatus.php" the check the payment status. This API goto the zaakpay server and take the actual payment status from there.

<?php
if(array_key_exists('orderId', $_POST) and !(array_key_exists('checksum', $_POST))) {
    require_once('Checksum.php');   
    require_once('Config.php');  

    $checksumFlag = $environment != "https://api.zaakpay.com" ; //This should not be changed

    $data = "{merchantIdentifier:".$_POST['merchantIdentifier'].",mode:0,orderDetail:{orderId:".$_POST['orderId']."}}" ;
    $checksum = Checksum::calculateChecksum($secretKey, $data);
?>

<?php if ($checksumFlag) { ?>

<html>
<head>
	<link rel="stylesheet" href="style.css">
   	<title>Request Parameters</title>
</head>
<body>
	<div align="center">
		<form action="<?php echo $environment.$checkStatusApi ; ?>" method="post">
			<table width="650px;" class="customtable-all card" border="1">
				<tr>
					<td colspan="2" align="center" valign="middle">REQUEST PARAMETERS</td>	
				</tr>
				<tr>	
					<td width="50%" align="center" valign="middle">Order Id</td>
					<td width="50%" align="center" valign="middle"><?php echo $_POST['orderId'] ?></td> 
				</tr>
				<tr>
					<th>Checksum String</th>
					<td><?php echo $data ?></td>
				</tr>
				<tr>
					<th>Calculated Checksum</th>
					<td><?php echo $checksum ?></td>
				</tr>
				<tr>
					<div>
						<th colspan="2" align="left"><br><input type="submit" value="Check Status"><br><br></th>
					</div>
				</tr>
			</table>
			<input type="hidden" name="data" value="<?php echo $data ; ?>" />
    		<input type="hidden" name="checksum" value="<?php echo $checksum ; ?>"/>
		</form>
	</div>
</body>
</html>
<?php } ?>

<?php if (!$checksumFlag) { ?>
<center>
<table width="500px;">
	<tr>
		<td align="center" valign="middle">Do Not Refresh or Press Back <br/> Redirecting to Zaakpay</td>
	</tr>
	<tr>
		<td align="center" valign="middle">
			<form action="<?php echo $environment.$checkStatusApi ; ?>" method="post">
				<input type="hidden" name="data" value="<?php echo $data ; ?>" />
    			<input type="hidden" name="checksum" value="<?php echo $checksum ; ?>"/>
			</form>
		</td>
	</tr>
</table>
</center>
<script type="text/javascript">
var form = document.forms[0];
form.submit();
</script>
<?php } ?>

<?php } ?>
<?php if(!array_key_exists('orderId', $_POST)) { 
   	require_once('Config.php');  
	?>
<!DOCTYPE html>
<html>
<head>
	<title>Check Transaction Status</title>
	<link rel="stylesheet" href="style.css">
</head>
<body>
	<div align="center"><br><br>
		<form action="TransactionStatus.php" method="post">
			<table width="650px;" class="customtable-all card" border="1">
				<tr>
					<td colspan="2" align="center" valign="middle">This Page behaves like testing input for status check api </td>	
				</tr>
				<tr>	
					<td width="50%" align="center" valign="middle">Merchant Identifier</td>
					<td width="50%" align="center" valign="middle"><input type="text" name="merchantIdentifier" value="<?php echo $merchantIdentifier ?>" /></td> 
				</tr>
				<tr>	
					<td width="50%" align="center" valign="middle">Order Id</td>
					<td width="50%" align="center" valign="middle"><input type="text" name="orderId" placeholder="Enter orderId" /> </td>
				</tr>
				<tr>
					<th align="center" colspan="2" style="text-align: center;"><br><input type="submit" value="Check Status"><br><br></th>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>
<?php } ?>

Test Card

Laravel Zaakpay Payment Gateway Integration Tutorial Example

Card No : 4012888888881881
Expirey Date : 12/21 // ENTER ANY FUTURE DATE
CVV : 123 

// OTP SHOULD BE : 123456

We always thanks to you for reading our blogs.


dharmesh-image

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-image

Haresh Chauhan

(Co-Founder)


We Are Also Recommending You :