Thursday, 1 February 2018

Payumoney Integration on Supersite

Here I give you full information of payumoney integration on supersite resellerclub or logicbox.
You need first payumoney merchant key and salt .
For integration you need to create 6 pages on your server.
1. fail.php
2.form_process.php
3.functions.php
4.paymentpage.php
5.postpayment.php
6.success.php

Just copy and paste given codes. Must be change BLUE TEXT with your right details.

Download


1. fail.php


<?php 
session_start();
if(isset($_POST['status'])){
if($_POST['status']=="failure"){
/*echo "<p>Payment Failed.<br>Details Are Below.</p>";
echo "<p>Failure Reason: ".$_POST['unmappedstatus']."</p>";
echo "<p>Txn Id: ".$_POST['txnid']."</p>";
echo "<p>Name: ".$_POST['firstname']."</p>";
echo "<p>Email: ".$_POST['email']."</p>";
echo "<p>Amount: ".$_POST['amount']."</p>";
echo "<p>Phone No: ".$_POST['phone']."</p>";
echo "<p>Product Info: ".$_POST['productinfo']."</p>";
echo "<p>Acc_currency: ".$_POST['udf1']."</p>";*/
}
}
$redirectUrl = $_POST['udf2'];
$transId=$_POST['txnid'];
$status="N";
$_SESSION['status']= $status;
$sellingCurrencyAmount=$_POST['amount'];
$accountingCurrencyAmount=$_POST['udf1'];

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
<center>
<div><img src="logo.png"><br><br>
<h2>Payment Failure</h2>
</div>

<div>

<form action="postpayment.php" method="POST" >

<input type="submit" value="Click here to Continue"><BR>
<input type="hidden" name="transId" value="<?php echo $transId;?>">
    <!--<input type="hidden" name="status" value="<?php echo $status;?>">-->
<input type="hidden" name="redirectUrl" value="<?php echo $redirectUrl;?>">
    <input type="hidden" name="sellingCurrencyAmount" value="<?php echo $sellingCurrencyAmount;?>">
<input type="hidden" name="accountingCurrencyAmount" value="<?php echo $accountingCurrencyAmount;?>">
<!--<input type="submit"/> -->

</form>
</div>
<br/><br/>
<a href="http://sakhihosting.in" target="_blank"><u><b>Powered by Sakhi Hosting Payumoney page</b></u></a>
</center>
</body>
</html> 

2.form_process.php


<?php 
if(!isset($_POST['firstname'])){header("location: index.php");}
// Change the Merchant key here as provided by Payumoney
$MERCHANT_KEY = "WRITE YOUR PAYUMONEY MERCHANT KEY HERE";

// Change the Merchant Salt as provided by Payumoney
$SALT = "WRITE YOUR PAYUMONEY SALT HERE";


$firstname =$_POST['firstname'];
$email =$_POST['email'];
$phone =$_POST['phone'];
$productinfo =$_POST['productinfo'];
$service_provider =$_POST['service_provider'];
$amount =$_POST['amount'];
$txnid =$_POST['txnid'];
$productinfo =$_POST['productinfo'];
$surl =$_POST['surl'];
$furl =$_POST['furl'];
$udf1 =$_POST['udf1'];
$udf2 =$_POST['udf2'];
//$ =$_POST[''];

$hashseq=$MERCHANT_KEY.'|'.$txnid.'|'.$amount.'|'.$productinfo.'|'.$firstname.'|'.$email.'|'.$udf1.'|'.$udf2.'|||||||||'.$SALT;
$hash =strtolower(hash("sha512", $hashseq)); 


?>


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title>Payment Processing</title>
<script>
    function submitForm() {
      var postForm = document.forms.postForm;
      postForm.submit();
    }
</script>
</head>
<center>
<body onload="submitForm();">

<div><img src="logo.png"><br><br>
<h2>Payment Gateway</h2>
<table>
<tr><td>Transaction Id</td><td><strong><?php echo $_POST['txnid']; ?></strong></td><td>Amount: </td><td><strong>Rs. <?php echo $_POST['amount']; ?></strong></td>
</table>
<div>
<p>Please be patient. We are processing your payment options, This might take some time,<br /></p>
<br>
<p>please do not hit refresh or browser back button or close this window</p>
</div>
</div>
<a href="http://www.sakhihosting.in" target="_blank"><u><b>Powered by Sakhi Hosting Payumoney page</b></u></a>
</center>
<div><!-- production URL https://secure.payu.in/_payment -->
<form name="postForm" action="https://secure.payu.in/_payment" method="POST" >
<input type="hidden" name="key" value="<?php echo $MERCHANT_KEY; ?>" />
<input type="hidden" name="hash" value="<?php echo $hash;  ?>"/>
<input type="hidden" name="txnid" value="<?php echo $_POST['txnid'];  ?>" />
<input type="hidden" name="amount" value="<?php echo $_POST['amount'];  ?>" />
<input type="hidden" name="firstname" value="<?php echo $_POST['firstname'];  ?>" />
<input type="hidden" name="email" value="<?php echo $_POST['email'];  ?>" />
<input type="hidden" name="phone" value="<?php echo $_POST['phone'];  ?>" />
<input type="hidden" name="productinfo" value="<?php echo $_POST['productinfo'];  ?>" />
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
<input type="hidden" name="surl" value="<?php echo $_POST['surl'];  ?>" />
<input type="hidden" name="furl" value="<?php echo $_POST['furl'];  ?>" />
<input type="hidden" name="udf1" value="<?php echo $_POST['udf1'];  ?>" />
<input type="hidden" name="udf2" value="<?php echo $_POST['udf2'];  ?>" />
</form>
</div>

</body>
</html>

3.functions.php


<?php

function generateChecksum($transId,$sellingCurrencyAmount,$accountingCurrencyAmount,$status, $rkey,$key)
{
$str = "$transId|$sellingCurrencyAmount|$accountingCurrencyAmount|$status|$rkey|$key";
        $generatedCheckSum = md5($str);
return $generatedCheckSum;
}

function verifyChecksum($paymentTypeId, $transId, $userId, $userType, $transactionType, $invoiceIds, $debitNoteIds, $description, $sellingCurrencyAmount, $accountingCurrencyAmount, $key, $checksum)
{
$str = "$paymentTypeId|$transId|$userId|$userType|$transactionType|$invoiceIds|$debitNoteIds|$description|$sellingCurrencyAmount|$accountingCurrencyAmount|$key";
        $generatedCheckSum = md5($str);
// echo $str."<BR>";
// echo "Generated CheckSum: ".$generatedCheckSum."<BR>";
// echo "Received Checksum: ".$checksum."<BR>";
if($generatedCheckSum == $checksum)
return true ;
else
return false ;
}
?>

4.paymentpage.php


 <?php

require("functions.php"); //file which has required functions
?>
<html>
<head><title>Payment Page </title>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<script language="JavaScript">
        function successClicked()
        {
            document.paymentpage.submit();
        }
        function failClicked()
        {
            document.paymentpage.status.value = "N";
            document.paymentpage.submit();
        }
        function pendingClicked()
        {
            document.paymentpage.status.value = "P";
            document.paymentpage.submit();
        }
</script>
</head>
<body bgcolor="white">
<center><img src="logo.png"><br><br>
<?php

$key = "UxPykuraxk9MmGIrifnIJTaTSoxigfo5"; //replace ur 32 bit secure key , Get your secure key from your Reseller Control panel

//This filter removes data that is potentially harmful for your application. It is used to strip tags and remove or encode unwanted characters.
$_GET = filter_var_array($_GET, FILTER_SANITIZE_STRING);

//Below are the  parameters which will be passed from foundation as http GET request
$paymentTypeId = $_GET["paymenttypeid"];  //payment type id
$transId = $_GET["transid"];    //This refers to a unique transaction ID which we generate for each transaction
$userId = $_GET["userid"];               //userid of the user who is trying to make the payment
$userType = $_GET["usertype"];     //This refers to the type of user perofrming this transaction. The possible values are "Customer" or "Reseller"
$transactionType = $_GET["transactiontype"];  //Type of transaction (ResellerAddFund/CustomerAddFund/ResellerPayment/CustomerPayment)

$invoiceIds = $_GET["invoiceids"];    //comma separated Invoice Ids, This will have a value only if the transactiontype is "ResellerPayment" or "CustomerPayment"
$debitNoteIds = $_GET["debitnoteids"];    //comma separated DebitNotes Ids, This will have a value only if the transactiontype is "ResellerPayment" or "CustomerPayment"

$description = $_GET["description"];

$sellingCurrencyAmount = $_GET["sellingcurrencyamount"]; //This refers to the amount of transaction in your Selling Currency
        $accountingCurrencyAmount = $_GET["accountingcurrencyamount"]; //This refers to the amount of transaction in your Accounting Currency

$redirectUrl = $_GET["redirecturl"];  //This is the URL on our server, to which you need to send the user once you have finished charging him


$checksum = $_GET["checksum"]; //checksum for validation

//echo "File paymentpage.php<br>";
         echo "Secure Connection Verified..............";

if(verifyChecksum($paymentTypeId, $transId, $userId, $userType, $transactionType, $invoiceIds, $debitNoteIds, $description, $sellingCurrencyAmount, $accountingCurrencyAmount, $key, $checksum))
{

?>

<form method="post" action="http://YOURDOMAIN NAME/form_process.php">
<table>

<tr><td>Email</td><td><input type="text" name="email" placeholder="Enter Email" value="<?php echo $emailAddr;?>" /></td></tr>
<tr><td>Contact No.</td><td><input type="text" name="phone" placeholder="Enter Contact No." value="<?php echo $telNo;?>" /></td></tr>
<tr><td><br/></td><td><br/><input type="submit" /></td></tr>
<tr><td></td><td><input type="hidden" name="txnid" value="<?php echo $transId;?>" /></td></tr>
<tr><td></td><td><input type="hidden" name="amount" value="<?php echo $sellingCurrencyAmount;?>" /></td></tr>
<tr><td></td><td><input type="hidden" name="udf1" value="<?php echo $accountingCurrencyAmount;?>" /></td></tr>
<tr><td></td><td><input type="hidden" name="udf2" value="<?php echo $redirectUrl;?>" /></td></tr>
<tr><td></td><td><input type="hidden" name="firstname" value="<?php echo $userId;?>" /></td></tr>

<tr><td></td><td><input type="hidden" name="productinfo" value="<?php echo $userType;?>" /></td></tr>
<tr><td></td><td><input type="hidden" name="surl" value="http://YOURDOMAINNAME/success.php" size="64" /></td></tr>
<tr><td></td><td><input type="hidden" name="furl" value="http://YOURDOMAINNAME/fail.php" size="64" /></td></tr>


</table>

</form>

<?php

}
else
{
/**This message will be dispayed in any of the following case
*
* 1. You are not using a valid 32 bit secure key from your Reseller Control panel
* 2. The data passed from foundation has been tampered.
*
* In both these cases the customer has to be shown error message and shound not
* be allowed to proceed  and do the payment.
*
**/

echo "Checksum mismatch !";

}
?>
<a href="http://sakhihosting.in" target="_blank"><u><b>Powered by Sakhi Hosting Payumoney page</b></u></a>
</center>
</body>
</html>


5.postpayment.php


<?php 
session_start();
session_save_path("./"); //path on your server where you are storing session


//file which has required functions
require("functions.php");
 ?>
<html>
<head><title>Post Payment</title>

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" /></head>
<body bgcolor="white"><center><img src="logo.png"><br><br>
<font size=4>

<?php

$key = "UxPykuraxk9MmGIrifnIJTaTSoxigfo5"; //replace ur 32 bit secure key , Get your secure key from your Reseller Control panel
    

$redirectUrl = $_POST['redirectUrl'];  // redirectUrl received from foundation
$transId = $_POST['transId']; //Pass the same transid which was passsed to your Gateway URL at the beginning of the transaction.
$sellingCurrencyAmount = $_POST['sellingCurrencyAmount'];
$accountingCurrencyAmount = $_POST['accountingCurrencyAmount'];


$status = $_SESSION["status"]; // Transaction status received from your Payment Gateway
        //This can be either 'Y' or 'N'. A 'Y' signifies that the Transaction went through SUCCESSFULLY and that the amount has been collected.
        //An 'N' on the other hand, signifies that the Transaction FAILED.

/**HERE YOU HAVE TO VERIFY THAT THE STATUS PASSED FROM YOUR PAYMENT GATEWAY IS VALID.
    * And it has not been tampered with. The data has not been changed since it can * easily be done with HTTP request. 
*
**/
srand((double)microtime()*1000000);
$rkey = rand();


$checksum =generateChecksum($transId,$sellingCurrencyAmount,$accountingCurrencyAmount,$status, $rkey,$key);

echo "You'll now redirect to merchant page! <br>";
            /*echo "redirecturl: ".$redirectUrl."<br>";
            echo "List of Variables to send back<br>";
            echo "transid : ".$transId."<br>";         
            echo "accountingCurrencyAmount : ".$accountingCurrencyAmount."<br>";
echo "rkey : ".$rkey."<br>";
echo "sellingCurrencyAmount : ".$sellingCurrencyAmount."<br><br>";*/ 
echo "status : ".$status."<br>"; 

?>
<form name="f1" action="<?php echo $redirectUrl;?>">
<input type="submit" value="Click here to Continue"><BR>
<input type="hidden" name="transid" value="<?php echo $transId;?>">
    <input type="hidden" name="status" value="<?php echo $status;?>">
<input type="hidden" name="rkey" value="<?php echo $rkey;?>">
    <input type="hidden" name="checksum" value="<?php echo $checksum;?>">
    <input type="hidden" name="sellingamount" value="<?php echo $sellingCurrencyAmount;?>">
<input type="hidden" name="accountingamount" value="<?php echo $accountingCurrencyAmount;?>">

</form>
</font><br/><br/>
<a href="http://www.sakhihosting.in" target="_blank"><u><b>Powered by Sakhi Hosting payumoney page</b></u></a>
</center>
</body>
</html>

6.success.php


<?php 
session_start();
if(isset($_POST['status'])){
if($_POST['status']=="success"){
/*echo "<p>Payment Done Successfully.<br>Details Are Below.</p>";
echo "<p>Txn Id: ".$_POST['txnid']."</p>";
echo "<p>Name: ".$_POST['firstname']."</p>";
echo "<p>Email: ".$_POST['email']."</p>";
echo "<p>Amount: ".$_POST['amount']."</p>";
echo "<p>Phone No: ".$_POST['phone']."</p>";
echo "<p>Product Info: ".$_POST['productinfo']."</p>";
echo "<p>encryptedPaymentId: ".$_POST['encryptedPaymentId']."</p>";
echo "<p>1: ".$_POST['udf1']."</p>";
echo "<p>2: ".$_POST['udf2']."</p>";*/
}
}
$redirectUrl = $_POST['udf2'];
$transId=$_POST['txnid'];
$status="Y";
$_SESSION['status']= $status;
$sellingCurrencyAmount=$_POST['amount'];
$accountingCurrencyAmount=$_POST['udf1'];
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
<center>
<div><img src="logo.png"><br><br>
<h2>Payment Success</h2>
</div>

<div>
<form action="postpayment.php" method="POST" >
<input type="submit" value="Click here to Continue"><BR>
<input type="hidden" name="transId" value="<?php echo $transId;?>">
    <!--<input type="hidden" name="status" value="<?php echo $status;?>">-->
<input type="hidden" name="redirectUrl" value="<?php echo $redirectUrl;?>">
    <input type="hidden" name="sellingCurrencyAmount" value="<?php echo $sellingCurrencyAmount;?>">
<input type="hidden" name="accountingCurrencyAmount" value="<?php echo $accountingCurrencyAmount;?>">
<!--<input type="submit"/> -->
</form>
</div>
<br/><br/>
<a href="http://sakhihosting.in" target="_blank"><u><b>Powered by Sakhi Hosting Payumoney Payment page</b></u></a>
</center>
</body>
</html>

No comments:

Post a Comment