How to integrate PayUMoney Payment Gateway in php

payumoney 925739176s
<?php

// Merchant key here as provided by Payu
$MERCHANT_KEY = "bdASxs"; 

// Merchant Salt as provided by Payu
$SALT = "tghfYhd";

// End point - change to https://secure.payu.in for LIVE mode
$PAYU_BASE_URL = "https://test.payu.in";

$action = '';


$key = $MERCHANT_KEY;
$txnid = $_POST['txnid'];
$amount = $_POST['amount'];
$productinfo = $_POST['productinfo'];
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$udf1 = $_POST['udf1'];
$udf2 = $_POST['udf2'];
$udf3 = $_POST['udf3'];
$udf4 = $_POST['udf4'];
$udf5 = $_POST['udf5'];
$udf6 = "";
$udf7 = "";
$udf8 = ""; 
$udf9 = ""; 
$udf10 = "";

$phone = $_POST['phone'];
$lastname = $_POST['lastname'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$zipcode = $_POST['zipcode'];

$success_url = $_POST['surl'];
$failed_url = $_POST['furl'];
$cancel_url = $_POST['curl'];
$service_provider = "payu_paisa";



$hash = '';
//---------------------

$hasTemp = $key."|".$txnid."|".$amount."|".$productinfo."|".$firstname."|".$email."|".$udf1."|".$udf2."|".$udf3."|".$udf4."|".$udf5."|".$udf6."|".$udf7."|".$udf8."|".$udf9."|".$udf10;
$hasTemp .= "|".$SALT;
$hash = strtolower(hash('sha512', $hasTemp));

//------------------------
$action = $PAYU_BASE_URL . '/_payment';
?>

<html>
 <head> </head>
 <body >
 <h2>PayU Form</h2>
 <br/>
 
 
 <form action="<?php echo $action ?>" method="post" name="payuForm">
 <input type="text" name="key" value="<?php echo $MERCHANT_KEY ?>" />
 <input type="text" name="hash" value="<?php echo $hash ?>"/>
 <input type="text" name="txnid" value="<?php echo $txnid ?>" />
 <table>
 <tr>
 <td><b>Mandatory Parameters</b></td>
 </tr>
 <tr>
 <td>Amount: </td>
 <td><input name="amount" value="<?php echo $amount; ?>" /></td>
 <td>First Name: </td>
 <td><input name="firstname" id="firstname" value="<?php echo $firstname; ?>" /></td>
 </tr>
 <tr>
 <td>Email: </td>
 <td><input name="email" id="email" value="<?php echo $email; ?>" /></td>
 <td>Phone: </td>
 <td><input name="phone" value="<?php echo $phone; ?>" /></td>
 </tr>
 <tr>
 <td>Product Info: </td>
 <td colspan="3"><textarea name="productinfo"><?php echo $productinfo; ?></textarea></td>
 </tr>
 <tr>
 <td>Success URI: </td>
 <td colspan="3"><input name="surl" value="<?php echo $success_url; ?>" size="64" /></td>
 </tr>
 <tr>
 <td>Failure URI: </td>
 <td colspan="3"><input name="furl" value="<?php echo $failed_url; ?>" size="64" /></td>
 </tr>

 <tr>
 <td colspan="3"><input type="text" name="service_provider" value="payu_paisa" size="64" /></td>
 </tr>

 <tr>
 <td><b>Optional Parameters</b></td>
 </tr>
 <tr>
 <td>Last Name: </td>
 <td><input name="lastname" id="lastname" value="<?php echo $lastname; ?>" /></td>
 <td>Cancel URI: </td>
 <td><input name="curl" value="<?php echo $cancel_url; ?>" /></td>
 </tr>
 <tr>
 <td>Address1: </td>
 <td><input name="address1" value="<?php echo $address1; ?>" /></td>
 <td>Address2: </td>
 <td><input name="address2" value="<?php echo $address2; ?>" /></td>
 </tr>
 <tr>
 <td>City: </td>
 <td><input name="city" value="<?php echo $city; ?>" /></td>
 <td>State: </td>
 <td><input name="state" value="<?php echo $state; ?>" /></td>
 </tr>
 <tr>
 <td>Country: </td>
 <td><input name="country" value="<?php echo $country; ?>" /></td>
 <td>Zipcode: </td>
 <td><input name="zipcode" value="<?php echo $zipcode; ?>" /></td>
 </tr>
 <tr>
 <td>UDF1: </td>
 <td><input name="udf1" value="<?php echo $udf1; ?>" /></td>
 <td>UDF2: </td>
 <td><input name="udf2" value="<?php echo $udf2; ?>" /></td>
 </tr>
 <tr>
 <td>UDF3: </td>
 <td><input name="udf3" value="<?php echo $udf3; ?>" /></td>
 <td>UDF4: </td>
 <td><input name="udf4" value="<?php echo $udf4; ?>" /></td>
 </tr>
 <tr>
 <td>UDF5: </td>
 <td><input name="udf5" value="<?php echo $udf5; ?>" /></td>
 <td>PG: </td>
 <td><input name="pg" value="<?php echo (empty($posted['pg'])) ? '' : $posted['pg']; ?>" /></td>
 </tr>
 <tr>
 
 <td colspan="4"><input type="submit" value="Submit" /></td>
 
 
 </tr>
 </table>
 </form>
 </body>
</html>
payumoney
Please follow and like us:
0