YouTube Icon

How to Integrate Payumoney Payment Gateway in Laravel 5




How to Integrate Payumoney Payment Gateway in Laravel 5

I am going to explain How to Integrate Payumoney Payment Gateway in Laravel 5. Most of thing are already in PayU documentation i am just going to explain it in step so you will easily integrate without reading whole document. In this example i have all value write static in input box. You may also like How to Integrate Payumoney Payment Gateway in PHP and How to integrate Paypal payment gateway using Laravel 5.

Steps For How to Integrate Payumoney Payment Gateway in Laravel 5

Also Read:- Cheapest and low cost online payment gateway for entrepreneur

Step 1. Create Payumoney account

Go to http://payumoney.com/ and sign up as a merchant account.

Step 2. At time of sign up use your valid email.

Step 3. Fill all required business details.

Also Read:- Laravel vs Codeigniter, Which is Better PHP Framework?

Step 4. Add your bank detail.

Step 5. Create route in laravel

We are required only three route to call controller.

Route::get('subscribe-process', [
    'as' => 'subscribe-process',
    'uses' => 'SigninController@SubscribProcess'
]);


Route::get('subscribe-cancel', [
    'as' => 'subscribe-cancel',
    'uses' => 'SigninController@SubscribeCancel'
]);

Route::get('subscribe-response', [
    'as' => 'subscribe-response',
    'uses' => 'SigninController@SubscribeResponse'
]);

Learn Ajax

Step 6. SigninController with SubscribProcess function

In this step load view page.

public function SubscribProcess()
{
    return view('payumoney');
}

Also Read:- Laravel vs Codeigniter, Which is Better PHP Framework?

Step 7. View page (payumoney.blade.php)

$MERCHANT_KEY = ""; // add your id
$SALT = ""; // add your id

//$PAYU_BASE_URL = "https://test.payu.in";
$PAYU_BASE_URL = "https://secure.payu.in";
$action = '';
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$posted = array();
$posted = array(
    'key' => $MERCHANT_KEY,
    'txnid' => $txnid,
    'amount' => 1000,
    'firstname' => Auth::user()->name,
    'email' => Auth::user()->email,
    'productinfo' => 'PHP Project Subscribe',
    'surl' => 'http://xyx.com/subscribe-response/',
    'furl' => 'http://xyx.com/subscribe-cancel/',
    'service_provider' => 'payu_paisa',
);

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) {
    $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';
}
<html>
  <head>
  <script>
    var hash = '<?php echo $hash ?>';
    function submitPayuForm() {
      if(hash == '') {
        return;
      }
      var payuForm = document.forms.payuForm;
           payuForm.submit();
    }
  </script>
  </head>
  <body onload="submitPayuForm()">
    Processing.....
        <form action="<?php echo $action; ?>" method="post" name="payuForm"><br />
            <input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" /><br />
            <input type="hidden" name="hash" value="<?php echo $hash ?>"/><br />
            <input type="hidden" name="txnid" value="<?php echo $txnid ?>" /><br />
            <input type="hidden" name="amount" value="1000" /><br />
            <input type="hidden" name="firstname" id="firstname" value="<?=Auth::user()->name?>" /><br />
            <input type="hidden" name="email" id="email" value="<?=Auth::user()->email?>" /><br />
            <input type="hidden" name="productinfo" value="PHP Project Subscribe"><br />
            <input type="hidden" name="surl" value="http://xyx.com/subscribe-response/" /><br />
            <input type="hidden" name="furl" value="http://xyx.com/subscribe-cancel/" /><br />
            <input type="hidden" name="service_provider" value="payu_paisa"  /><br />
            <?php
            if(!$hash) { ?>
                <input type="submit" value="Submit" />
            <?php } ?>
        </form>
  </body>
</html>

How to Develop a Blog App Using NextJS

Step 8. SigninController with SubscribeResponse function

public function Response(Request $request)
{
    dd('Payment Successfully done!');
}

Step 9. SigninController with SubscribeCancel function

public function SubscribeCancel()
{
     dd('Payment Cancel!');
}

Why choose PHP programming language for web development?



Author Biography.

Lokesh Gupta
Lokesh Gupta

Overall 3+ years of experience as a Full Stack Developer with a demonstrated history of working in the information technology and services industry. I enjoy solving complex problems within budget and deadlines putting my skills on PHP, MySQL, Python, Codeigniter, Yii2, Laravel, AngularJS, ReactJS, NodeJS to best use. Through Knowledge of UML & visual modeling, application architecture design & business process modeling. Successfully delivered various projects, based on different technologies across the globe.

Join Our Newsletter.

Subscribe to CrowdforThink newsletter to get daily update directly deliver into your inbox.

CrowdforGeeks is where lifelong learners come to learn the skills they need, to land the jobs they want, to build the lives they deserve.

CrowdforGeeks

CrowdforThink is a leading Indian media and information platform, known for its end-to-end coverage of the Indian startup ecosystem.

CrowdforThink

Our mission is "Har Koi Dekhe Video, Har Ghar Dekhe Video, Ghar Ghar Dekhe Video" so we Provide videos related to Tutorials, Travel, Technology, Wedding, Cooking, Dance, Festivals, Celebration.

Apna Video Wala
CFT

News & Blogs

Top Authors

Lamia Rochdi is the Marketing Manager at Bell Flavors & Fragrances EMEA. A successful family-...

Lamia Rochdi

I’m Mertin Wilson a technician in a camera company and certified expert of different P...

Mertin Wilson

Zakariya has recently joined the PakWheels team as a Content Marketing Executive, shortly after g...

Zakariya Usman

Pankaj Singh is a Senior Digital Marketing Consultant with more than 2 years of experience in SEO...

Pankaj Singh
CFT

Our Client Says

WhatsApp Chat with Our Support Team