Skip to content

Instantly share code, notes, and snippets.

@ramanathanrv
Created June 3, 2015 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ramanathanrv/31c0b687f0177c37b892 to your computer and use it in GitHub Desktop.
Save ramanathanrv/31c0b687f0177c37b892 to your computer and use it in GitHub Desktop.
Juspay web authentication
var juspayResponse = JSON.parse(res); // assuming that `res` holds the data return by JusPay API
var url = juspayResponse.payment.authentication.url
var method = juspayResponse.payment.authentication.method
var frm = document.createElement("form")
frm.style.display = "none"; // ensure that the form is hidden from the user
frm.setAttribute("method", method);
frm.setAttribute("action", url);
if(method === "POST") {
var params = juspayResponse.payment.authentication.params
for(var key in params) {
var value = params[key];
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", key);
field.setAttribute("value", value);
frm.appendChild(field);
}
}
document.body.appendChild(frm)
// form is now ready
frm.submit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment