In this post I am going to explain how to setup PayUmoney payment gateway in your web application. Integration of PayU gateway is a little confusing for the first time and also some of my readers request me for this tutorial. Most of the thing is already in PayU documentation I am just going to explain it in step so you will easily integrate without reading the whole document.
Payment gateway in PHP
We are going to use PayUmoney payment Gateway for this integration tutorial. With PayUmoney Payment Gateway we can easily accept credit cards directly on our website by integrating a checkout system and enabling payment.
To integrate PayUmoney payment gateway in your PHP web application you need to implement the following functionalities.
Prepare the HTML form to collect the required information.
Create a hash to securely redirect the user to the PayUmoney payment gateway.
User enter required information and confirms.
Once payment complete PayU redirects back the user to the site with confirmation message.
Step 2. At the time of sign up using your valid email.
Step 3. Fill all required business details. Use these details for PAN no. ABCDE1234F and DOB – 01/04/1990 .
Step 4. Add your bank detail, note you can add whatever bank name and details use this IFSC – ALLA0212632 in place of IFSC.
Step 5. Don’t worry about bank details verification this is your test account.
Step 6. Once your required steps are completed your account is live if not then write a mail to support team : techsupport@payumoney.com
Step 7. Now once the above steps are complete you can get your key go to Manage Account⇒ My Account ⇒ Merchant -Key Salt copy your key and paste in your code.
Once you follow the above step your setup for PayUMoney is complete.
<?php
$status=$_POST["status"];
$firstname=$_POST["firstname"];
$amount=$_POST["amount"];
$txnid=$_POST["txnid"];
$posted_hash=$_POST["hash"];
$key=$_POST["key"];
$productinfo=$_POST["productinfo"];
$email=$_POST["email"];
$salt="yIEkykqEH3";
If (isset($_POST["additionalCharges"])) {
$additionalCharges=$_POST["additionalCharges"];
$retHashSeq = $additionalCharges.'|'.$salt.'|'.$status.'|||||||||||'.$email.'|'.$firstname.'|'.$productinfo.'|'.$amount.'|'.$txnid.'|'.$key;
}
else {
$retHashSeq = $salt.'|'.$status.'|||||||||||'.$email.'|'.$firstname.'|'.$productinfo.'|'.$amount.'|'.$txnid.'|'.$key;
}
$hash = hash("sha512", $retHashSeq);
if ($hash != $posted_hash) {
echo "Invalid Transaction. Please try again";
}
else {
echo "<h3>Thank You. Your order status is ". $status .".</h3>";
echo "<h4>Your Transaction ID for this transaction is ".$txnid.".</h4>";
echo "<h4>We have received a payment of Rs. " . $amount . ". Your order will soon be shipped.</h4>";
}
?>
failure.php
plaintext
<?php
$status=$_POST["status"];
$firstname=$_POST["firstname"];
$amount=$_POST["amount"];
$txnid=$_POST["txnid"];
$posted_hash=$_POST["hash"];
$key=$_POST["key"];
$productinfo=$_POST["productinfo"];
$email=$_POST["email"];
$salt="yIEkykqEH3";
If (isset($_POST["additionalCharges"])) {
$additionalCharges=$_POST["additionalCharges"];
$retHashSeq = $additionalCharges.'|'.$salt.'|'.$status.'|||||||||||'.$email.'|'.$firstname.'|'.$productinfo.'|'.$amount.'|'.$txnid.'|'.$key;
}
else {
$retHashSeq = $salt.'|'.$status.'|||||||||||'.$email.'|'.$firstname.'|'.$productinfo.'|'.$amount.'|'.$txnid.'|'.$key;
}
$hash = hash("sha512", $retHashSeq);
if ($hash != $posted_hash) {
echo "Invalid Transaction. Please try again";
}
else {
echo "<h3>Your order status is ". $status .".</h3>";
echo "<h4>Your transaction id for this transaction is ".$txnid.". You may try making the payment by clicking the link below.</h4>";
}
?>
<!--Please enter your website homepagge URL -->
<p><a href=http://localhost/testing/success_failure/PayUMoney_form.php> Try Again</a></p>
Above code is also available in sdk you download from PayUMoney you need to replace key with your key. To test this code you can fill form and after that when you redirects to PayUMoney Payment gateway select debit card and enter bellow details in it:
Test Card Number: 5123456789012346Test CVV: 123Test Expiry: May 2017
Looking for the best 5G phone under 20000 in India? Check out our top picks for 2025, featuring amazing performance, stunning cameras, and excellent battery life. Read now!
Discover the best smartphones under ₹20,000 in India (2025). From the gaming powerhouse Poco X6 Pro to the stylish Motorola Edge 50 Neo and the sleek Nothing Phone 2A, find the perfect phone for your needs.
Discover the best affordable laptops for students in 2025, featuring top picks from Dell, Acer, and Lenovo. Compare specs, designs, and unique features to find the perfect match for your academic need
Explore the top laptops under ₹45,000 in 2025, including ASUS Vivobook, HP Pavilion, and Acer ALG Gaming Laptop. Find the best for gaming, work, or entertainment!