0

i created a login.php file where the user can will be navigated to instamojo payment page . After completing the transaction the user is getting the success message from instamojo , but i need to display the successful transaction in my domain or in own php file . so how can i get the transation related information to my webpage or to my login.php file

Ex: Redirecting from our login.php to instamojo(payment gateway)and response back (success message)to our login.php intimating the user that payment is success

var rootURL = "cgshealthcare.com/HealthCareSystem/";;
$(document).ready(function() {
  $('#login').click(function() {
    if ($('#username').val() == "" || $('#password').val() == "") {
      alert("Please enter username or password");
      return false;
    }
    cardloginUser($('#username').val(), $('#password').val());
  });
});

function forwardtoRegister() {
  window.location = "login.php?page=register";
}

function cardloginUser(userName, password) {
  console.log('userName: ' + userName);
  console.log('password: ' + password);
  if (userName.length < 1) {
    $('#errorlist').html("<font color='red'><b> Please enter User ID</b></font>");
    return false;
  }
  if (password.length < 1) {
    $('#errorlist').html(" <font color='red'><b> Please enter Password</b></font>");
    return false;
  }
  console.log(rootURL + '/authenticate/' + userName + '/' + password);
  $.ajax({
    type: 'GET',
    url: rootURL + '/authenticate/' + userName + '/' + password,
    dataType: "json",
    success: function(data) {
      console.log("hello" + data.responseMessageDetails);
      var list = data == null ? [] : (data.responseMessageDetails instanceof Array ? data.responseMessageDetails : [data.responseMessageDetails]);
      console.log("List : " + list);
      if ((list).length < 1) {
        $('#errorlist').html("<font color='red'><b> Invalid User Name and Password Combination </b></font>");
        $('#errorblock').css("visibility") == "visible";
      }
      $.each(list, function(index, responseMessageDetails) {
        console.log("Status " + responseMessageDetails);
        var message = responseMessageDetails.message;
        if (message.indexOf("]:") > 0) message = message.substring(0, message.indexOf("]:") + 2);
        console.log("message" + message);
        console.log("USer Data" + responseMessageDetails.status);
        console.log("USer Data" + responseMessageDetails.message);
        if (responseMessageDetails.status == "Success") {
          window.location = "imjo.in/NpKxN";;
        } else if (responseMessageDetails.status == "Fail") {
          window.location = "www.google.com";
          console.log("Fail1");
          $('#errorlist').html("<font color='red'><b>" + message + "</b></font>");
        } else {
          console.log("Fail111");
          $('#errorlist').html("<font color='red'><b> We are sorry some intermittent Issue. Please try after some time. </b></font>");
        }
      });
    },
    error: function(data) {
      console.log("data...." + data);
      var list = data == null ? [] : (data.responseMessageDetails instanceof Array ? data.responseMessageDetails : [data.responseMessageDetails]);
      console.log("data...." + data);
      $.each(list, function(index, responseMessageDetails) {
        console.log(responseMessageDetails);
        var message = responseMessageDetails.message;
        if (message.indexOf("]:") > 0) message = message.substring(0, message.indexOf("]:") + 2);
        $('#errorlist').html("<font color='red'><b>" + message + "</b></font>");
      });
    }
  });
}

function showLogin() {
  window.location = "login.php";
}
ambika.p
  • 1
  • 2
  • var rootURL = "http://cgshealthcare.com/HealthCareSystem/"; $(document).ready(function(){ $('#login').click(function() { if($('#username').val() == "" || $('#password').val() == ""){ alert("Please enter username or password"); return false; } cardloginUser($('#username').val(),$('#password').val());}); }); function forwardtoRegister(){ window.location = "login.php?page=register"; } – ambika.p Aug 27 '16 at 06:47
  • function cardloginUser(userName,password) { console.log('userName: ' + userName); console.log('password: ' + password); if(userName.length < 1){ $('#errorlist').html(" Please enter User ID"); return false; } if(password.length < 1){ $('#errorlist').html(" Please enter Password"); return false; } console.log(rootURL + '/authenticate/' + userName +'/'+password); $.ajax({ – ambika.p Aug 27 '16 at 06:48
  • type: 'GET', url: rootURL + '/authenticate/' + userName +'/'+password, dataType: "json", success: function(data){ console.log("hello"+data.responseMessageDetails); var list = data == null ? [] : (data.responseMessageDetails instanceof Array ? data.responseMessageDetails : [data.responseMessageDetails]); – ambika.p Aug 27 '16 at 06:48
  • console.log("List : "+list); if((list).length < 1 ){ – ambika.p Aug 27 '16 at 06:49
  • $('#errorlist').html(" Invalid User Name and Password Combination "); $('#errorblock').css("visibility") == "visible"; } $.each(list, function(index, responseMessageDetails) { console.log("Status "+responseMessageDetails); – ambika.p Aug 27 '16 at 06:49
  • var message = responseMessageDetails.message; if(message.indexOf("]:") > 0) message = message.substring(0,message.indexOf("]:")+2); console.log("message"+message); console.log("USer – ambika.p Aug 27 '16 at 06:50
  • Data"+responseMessageDetails.status); console.log("USer Data"+responseMessageDetails.message); if(responseMessageDetails.status == "Success"){ window.location = "https://imjo.in/NpKxN"; }else if(responseMessageDetails.status == "Fail"){ window.location = – ambika.p Aug 27 '16 at 06:50
  • "www.google.com"; console.log("Fail1"); $('#errorlist').html(""+message+""); }else { console.log("Fail111"); – ambika.p Aug 27 '16 at 06:50
  • $('#errorlist').html(" We are sorry some intermittent Issue. Please try after some time. "); } });}, error: function(data){ – ambika.p Aug 27 '16 at 06:50
  • console.log("data...."+data); var list = data == null ? [] : (data.responseMessageDetails instanceof Array ? data.responseMessageDetails : [data.responseMessageDetails]); console.log("data...."+data); $.each(list, function(index, responseMessageDetails) { console.log(responseMessageDetails); var message = responseMessageDetails.message; if(message.indexOf("]:") > 0) message = message.substring(0,message.indexOf("]:")+2); – ambika.p Aug 27 '16 at 06:51
  • $('#errorlist').html(""+message+""); }); } }); } function showLogin(){ window.location = "login.php"; } – ambika.p Aug 27 '16 at 06:51
  • please don't code here... add in your question we will format it – karan Aug 27 '16 at 06:54

1 Answers1

0

Please look at the integration guide here.

After user enters payment information on instamojo, they are redirected to a redirect-url which you specify (and is a url on your website). Instamojo appends transaction results to this url. You can make it a php url on your website and read the results using GET method. Depending upon the results, you can process your payment and display results to the end-user. More on GET method here...

Instamojo also provides for webhooks, which are like silent POSTs in the background and can be used as backups in case redirect urls in front-end fail for some reason. This way if end-users' redirection failed for any reason, the webhook will still receive information in the background which can be used you to update your database for success/failure of transaction. Of course you webserver has to be up and running to receive webhooks notifications. If that's the point of failure, nothing will work :)

The API link I shared has all those details.

Thanks