I have been trying to add google recaptcha on magento checkout page where payment methods are toggled, I'm trying to invoke google re-captcha when a button is clicked but it goes through without captcha as required field before continuing, any help would be appreciated?
HTML
<button type="button" class="button" onclick="payment.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
Google Recaptcha Code
<script src='https://www.google.com/recaptcha/api.js'></script>
<?php if ($this->helper('recaptcha')->showOnOnepage() == 1) { ?>
<li id="rcode">
<div class="captcha">
<div class="g-recaptcha" data-sitekey="<?php echo $this->helper('recaptcha')->getKey(); ?>"
data-theme="<?php echo($this->helper('recaptcha')->getTheme()); ?>"></div>
</div>
<span id="captcha-required" style='display:none; color:#ff0000'><?php echo $this->__('Please Fill Recaptcha To Continue'); ?></span>
</li>
<?php } ?>
Onclick function
<script type="text/javascript">
jQuery('.btn').click(function () {
var payment = new Payment('co-payment-form', '<?php echo $this->getUrl('checkout/onepage/savePayment') ?>');
<?php
if($this->helper('recaptcha')->showOnOnepage() == 0){ ?>
payment.save();
<?php } else { ?>
if (grecaptcha.getResponse() != "") {
payment.save();
}
else {
document.getElementById("captcha-required").style.display = "block";
}
<?php } ?>
});
</script>