angular/node.js POST for payumoney integration

payumoney integration in angular 2
payumoney integration in android
payumoney integration in xamarin forms
payumoney integration in spring boot
payumoney response handling
ionic 4 payumoney integration
angular 2 payment gateway integration
payment failed for hash not verified payumoney

I'm using angular/node.js stack for payumoney integration.

On the angular side, an order is placed using $http.post to a route endpoint at the server side (node.js) as follows:

$http.post('/placeOrder',order).success(function(data, status, headers, config){
      //handle responses on client side
      console.log("Successfully POSTED to payment gateway");
      window.location = "https://test.payu.in/_payment";
    }).error(function(data, status, headers, config) {
      console.log("Error in posting");
   });

The actual heavy lifting is done on the node.js (server side):

router.post('/placeOrder', function(req, res, next){

hash_data = MERCHANT_KEY+'|'+txnid+'|'+amount+'|'+productinfo+'|'+firstname+'|'+email+'|'+udf1+'|'+udf2+'|'+udf3+'|'+udf4+'|'+udf5+'||||||'+SALT;

var data = querystring.stringify({

      'key': MERCHANT_KEY,
      'txnid': txnid,
      'amount': amount,
      'productinfo': productinfo,
      'firstname': firstname,
      'email': email,
      'phone': phone,
      'surl': SUCCESS_URL,  
      'furl': FAILURE_URL,
      'curl': FAILURE_URL,
      'hash': hash,
      'service_provider': SERVICE_PROVIDER
      //'salt': SALT
    });

    //POST options
    var POST_OPTIONS = {
        hostname: PAYU_BASE_URL,
        port: 443,
        path: '/_payment',
        method: 'POST',
        //json: true,
        agent: false,
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            //'Content-Length': Buffer.byteLength(data)
            'Content-Length': data.length
        }
    };

    var resp_status = "";

    var req = https.request(POST_OPTIONS, function(response) {
        console.log('STATUS: ' + response.statusCode);
        console.log('HEADERS: ' + JSON.stringify(response.headers));
        response.setEncoding('utf8');
        response.on('data', function (chunk) {
            console.log("body: " + chunk);
            resp_status = 200;
            res.json(chunk);
        });
        response.on('error', function (err) {
            console.log("Got error: " + err.message);
            resp_status = 500;
            return res.send(err);
        });
    });
    req.end(data);

However, this doesn't seem to work as the POST doesnt seem to work using this approach. While debugging on the browser through the network tab, I always see:

Request URL:https://test.payu.in/_payment Request Method:GET Status Code:200 OK

Also, the test payment page (https://test.payu.in/_payment) shows: "Error Reason One or more mandatory parameters are missing in the transaction request."

Any help would be appreciated!!

As per the browser network tab which you have mentioned,

Request URL:https://test.payu.in/_payment Request Method:GET Status Code:200 OK

This means PayU is getting called with GET request instead of POST request somehow. PayU accepts data as a POST request only.

Also, the test payment page (https://test.payu.in/_payment) shows: "Error Reason One or more mandatory parameters are missing in the transaction request."

This is due to GET request. I have faced similar situation in my JSF based application wherein I was sending all parameters correctly but as a GET request. Later on when I switched to POST, the error got resolved automatically.

For information about sending POST request from angular, check below link.

https://www.devglan.com/angular/payumoney-integration-angular

angular/node.js POST for payumoney integration, I'm using angular/node.js stack for payumoney integration. On the angular side, an order is placed using $http.post to a route endpoint at the server side  This will be a POST call from PAYU with a MihpayId. This will be generated by Payu. Update the transaction as success in our system and redirect user to payment success page. On payment failure, we can redirect user to transaction failed page. For a quick integration guide, you can visit this PayU integration Dev guide. Angular 6 Project Structure

How did I implement this..

  1. Use Jquery and create a Form
  2. Use sha512 to create hashcode. (bower install js-sha512)

 var hashString = this.merchantKey+'|'+ options.uid +'|'+ options.totalPrice + '|'+'options.uid + '|' +
        options.recipient_name + '|'+ options.email +'|||||||||||'+ this.merchantSalt ;

    var hash = sha512(hashString);





    var key1 = $('<input></input>').attr('type', 'hidden').attr('name', "key").val("merchantKey");

    var key2 = $('<input></input>').attr('type', 'hidden').attr('name', "txnid").val(options.uid);

    var key3 = $('<input></input>').attr('type', 'hidden').attr('name', "amount").val(options.totalPrice);

    var key4 = $('<input></input>').attr('type', 'hidden').attr('name', "productinfo").val(options.uid);

    var key5 = $('<input></input>').attr('type', 'hidden').attr('name', "firstname").val(options.recipient_name);

    var key6 = $('<input></input>').attr('type', 'hidden').attr('name', "email").val(options.email);

    var key7 = $('<input></input>').attr('type', 'hidden').attr('name', "phone").val(options.phone);

    var key8 = $('<input></input>').attr('type', 'hidden').attr('name', "surl").val("http://192.168.43.121/payment/success");

    var key9 = $('<input></input>').attr('type', 'hidden').attr('name', "furl").val("http://192.168.43.121/payment/error");

    var key10 = $('<input></input>').attr('type', 'hidden').attr('name', "hash").val(hash);

    var key11 = $('<input></input>').attr('type', 'hidden').attr('name', "service_provider").val("payu_paisa");


    var form = $('<form/></form>');

    form.attr("id", "payuform");

    form.attr("action", this.payumoneyLink );

    form.attr("method", "POST");

    form.attr("style", "display:none;");

    form.append(key1, key2, key3, key4, key5, key6, key7, key8, key9,key10, key11);


    $("body").append(form);

    // submit form

    form.submit();

This is my first answer on StacksOverflow. Hope it helps!

PayUMoney, You can easily integrate PayUMoney at server side in NodeJs. First you need to create a html form in Angular 2 which will accept payment Once the payment is done, PayUMoney will make a post request to “surl” or “furl”  payU money integration at angular 2 application we want to integrate payU money payment gateway to our site in aws, angular 2 application Skills: Amazon Web Services , Angular.js , node.js

NOTE: If input type is hidden, angularjs has some issue connecting model and view. So please take a note of that. txnid and hash I am getting from AJAX get call so I had to bind it in seperate variable from scope.

Angular code is staright forward, just populate the variables. One more thing to remember as of today, if your account is not active then you need to use test salt/key provided by their customer support:

MID : 4934580
Key : rjQUPktU
Salt : e5iIg1jwi8
Authorization : y8tNAC1Ar0Sd8xAHGjZ817UGto5jt37zLJSX/NHK3ok=
Test Card : 5123456789012346
Expiry : 05/20                                                                     
CVV : 123

Integrate PayUMoney Payment Gateway In Node.js and Meteor.js , In 3Brain we keep exploring new things and keep sharing things with developers. This post will help you to integrate payumoney payment  Angular and Node.js Integration Download Free This is a very short course designed to help you integrate Angular and Node.js. We are going to create

PayUMoney Integration with Angular and Spring Boot, In this tutorial, we will be integrating PayuMoney payment gateway with a spring boot and Angular application. Here, we will This will be a POST call from PAYU with a MihpayId. This will be Further Reading on Angular JS. PayUmoney Redirect Checkout is a quick and easy way to integrate the payment checkout experience in your Website. Accept payments on your website, with built-in support for PayUmoney Wallet & Saved Cards. Checkout Pages are served from PayUmoney Servers which are PCI DSS compliant so that the merchant does not have to worry about the PCI DSS

payU money integration at angular 2 application | Angular.js, node.js & Angular.js Projects for ₹600 - ₹1500. we want to integrate payU money payment gateway to our site in aws, angular 2 application Different kits provide different APIs to automate a lot of tasks. PayUmoney provides developers two kinds of kits for easy integration– shopping cart integration kits and platform based integration kits. Shopping Cart Integration Kits. Shopping cart kits follow an easy payment gateway integration procedure with the help of codes and APIs.

navjotdhanawat/node-payumoney: Node js payumoney , Angular, Node js payumoney payment gateway integration example. How to run: Install the dependencies and start the server. $ npm install $ npm start. See The  API DOCUMENTATION PAYU PAYMENTS PVT. LTD. 4th Floor, Pearl Tower, Plot no 51, Sector 32, Gurgaon, 122002 Email: techsupport@payumoney.com

Comments
  • Please do not publish your email address in your answers