Close

PayUMoney Payment Gateway Integration in PHP

payumoney-payment-gateway-integration-in-php

Image Credit: TechnoGripper India

Today, TechnoGripper India will give you steps for How to integrate PayUMoney Payment Gateway in PHP. Integration of PayUMoney Payment gateway is confusing for the first time and also some of my visitors request us for this tutorial. We are just trying to brief you in simple steps, Please have a look on this steps:

Step 1: Create PayUMoney Merchant Account at www.payumoney.com and follow the instructions over there to activate your PayUMoney account. Once the account is approved you can start integrating.

Step 2: Please find the code for PHP File to process the payment.

";
	$SALT = "";
	$PAYU_BASE_URL = "https://secure.payu.in/_payment";
	$action = '';
 
	$posted = array();
	if(!empty($_POST)) {
	  foreach($_POST as $key => $value) {    
	    $posted[$key] = $value; 
	  }
	}
	$formError = 0;
	if(empty($posted['txnid'])) {
	  $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
	} else {
	  $txnid = $posted['txnid'];
	}
	$hash = '';
	$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
	if(empty($posted['hash']) && sizeof($posted) > 0) {
	  if(
          empty($posted['key'])
          || empty($posted['txnid'])
          || empty($posted['amount'])
          || empty($posted['firstname'])
          || empty($posted['email'])
          || empty($posted['phone'])
          || empty($posted['productinfo'])
          || empty($posted['surl'])
          || empty($posted['furl'])
			  
	  ) {
	    $formError = 1;
 
	  } else {
		$hashVarsSeq = explode('|', $hashSequence);
	    $hash_string = '';	
		foreach($hashVarsSeq as $hash_var) {
	      $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
	      $hash_string .= '|';
	    }
	    $hash_string .= $SALT;
	    $hash = strtolower(hash('sha512', $hash_string));
	    $action = $PAYU_BASE_URL . '/_payment';
	  }
	} elseif(!empty($posted['hash'])) {
	  $hash = $posted['hash'];
	  $action = $PAYU_BASE_URL . '/_payment';
	}
?>

  
  
  
  
    

Payment System with PayUMoney - By TechnoGripper India (www.technogripper.net)

Amount: $50 First Name:
Email: Phone:
Product: Iphone 6C - 16GB

In this code, you need to replace  with your PayUMoney Merchant Key &  with your PaUMoney Salt key. You’ll get this in your PayUMoney Account.




Step 3:

Success Page: In the case of payment succeeded, the page will redirect to success.php page with $_POST method and success parameters. You can do the further process of success payment here.

Your Payment has been done. Your Transaction ID for this transaction is ".$txnid.".";
  }         
?>

Failure Page: In the case of payment failure, the page will redirect on failure.php page with post method and failure parameters. You can do the further process of failed payment here.

Sorry! Your Payment Canceled";
?>

That’s all. Now Check the Payment Process.

If you’ll get any error, you can reach us at info@technogripper.net



2 Comments

  1. hello, thank you so much for the demo code.
    I have payment integration on the website but now i want to allow only credit and debit card payment mode.
    All other payment modes as like UPI payment mode, Net banking, and EMI has to disable in the website. Please can you help me with it? I want to disable the UPI payment mode urgently.
    Please anyone help me
    Please reply ASAP.

    1. Hello,

      Thanks for investing time in a reading article on WEXT.in. Please share your contact or call at 9560850036, our lead developer. He will surely help you to get your bug fixed.

      Thanks & Regards
      WEXT.in

Leave a Reply

Your email address will not be published. Required fields are marked *

2 Comments
scroll to top