PayUmoney Payment Gateway Integration in PHP

Best Division

Best Division  @bestdivision

Published On - Last Updated -

PayUmoney Payment Gateway Integration Steps : -

  1. Creating Payment
  2. Webhook Integration

Here is a basic guide to integrating PayUmoney Payment Gateway into a PHP application:

Sign up for a PayUmoney account: To get started, sign up for a PayUmoney account and get your merchant key and salt.

Create a payment form: Create a payment form with input fields for the required payment details, such as the amount, product name, and customer name.

Hash calculation: To secure the transaction, PayUmoney requires a hash to be sent along with the payment details. The hash is calculated using the merchant key and salt, along with the payment details.

PHP code for generating the hash:

$merchant_key = "Your merchant key";
$salt = "Your salt";
$pay = array();
$pay['key'] = $merchant_key;
$pay['txnid'] = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$pay['amount'] = "100.00";
$pay['firstname'] = "John";
$pay['email'] = "[email protected]";
$pay['phone'] = "9999999999";
$pay['productinfo'] = "Product 1";
$pay['surl'] = "";
$pay['furl'] = "";
$pay['service_provider'] = "payu_paisa";
$hash = '';
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';  
foreach($hashVarsSeq as $hash_var) {
 $hash_string .= isset($pay[$hash_var]) ? $pay[$hash_var] : '';
 $hash_string .= '|';
$hash_string .= $salt;
$hash = strtolower(hash('sha512', $hash_string));

Submit the form to the PayUmoney server: The form should be submitted to the PayUmoney server using the action attribute of the form tag, with the URL set to

Handle success and failure responses: PayUmoney will send a response back to your website after the payment is processed. You should have separate PHP scripts to handle success and failure responses and update your database accordingly.

Test the integration: Test the integration thoroughly by making multiple test payments with different amounts and different payment options, such as credit card, debit card, and net banking.

This is just a basic guide to help you get started with integrating PayUmoney Payment Gateway into a PHP application. You may need to make additional modifications and optimizations to meet your specific requirements.

Similar Blogs
0 Commentssort Sort By

@abcd 1 days ago

Aquí los que apoyamos a Los del limit desde sus inicios..