<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// If 3ds method URL is empty,
// 3ds requestor can pass 3DS method processing and threeDSCompInd=U
var threeDSCompInd = "${threeDSCompInd}";
if (threeDSCompInd == "U") {
submitForm1(threeDSCompInd);
return;
}
// send 3DS Method request in iframe
var iframe = $("#3dsmethod");
var formContent = ""
.concat("<form name='form2' id='form2'
action = '${threeDSMethodUrl}'
method = 'post' > ")
.concat(" <input type='hidden' name='threeDSMethodData'
id = 'threeDSMethodData'
value = '${threeDSMethodData}' / > ")
.concat("</form>"); iframe.contents().find('body').html(formContent); iframe.contents().find('#form2').submit();
// monitor 3DS Method response
var t1 = window.setInterval(function() {
console.log('monitor method result.');
console.log($("#3dsmethod").attr("src"));
if ($("#3dsmethod").contents().find('#threeDSCompInd').val() == "Y") {
console.log('monitor method result GOTTEN.');
window.clearInterval(t1);
window.clearTimeout(t2);
threeDSCompInd = "Y";
submitForm1(threeDSCompInd);
}
}, 500);
// if reach timeout setting, set threeDSCompInd = N and go next step
var t2 = window.setTimeout(function() {
console.log('monitor timeout.');
if (threeDSCompInd != "Y")
threeDSCompInd = "N";
window.clearInterval(t1);
window.clearTimeout(t2);
submitForm1(threeDSCompInd);
}, 5 * 1000);
});
//next step
function submitForm1(threeDSCompInd) {
console.log('before form1 submited, threeDSCompInd =',
threeDSCompInd);
$("#threeDSCompInd").val(threeDSCompInd);
$("#form1").submit();
}
</script>
</head>
<body>
<div>
<form id="form1" name="form1" action="${next step URL}" method="post">
<input type="hidden" name="threedsIntegratorOid" id="threedsIntegratorOid" value="${threedsIntegratorOid}" />
<input type="hidden" name="threeDSCompInd" id="threeDSCompInd" value="" />
</form>
</div>
<div id="iframe_3dsmethod">
<iframe id="3dsmethod" src="about:blank" allow="geolocation" frameborder="0" allowfullscreen=true style="width: 100%; height: 0vh; position: relative; border-width:
0px">
</iframe>
</div>
</body>
</html>