Jump to content

Is there any way to add captcha or re-captcha into checkout page?


ody

Recommended Posts

Hi,

 

I want to add mainly re-captcha verification into our checkout page or simple WHMCS captcha,

I don't want to have it into domaincheck only into our major pages as login, registration, ticket and most important checkout page?

 

Thank you in advance, Ody

Link to comment
Share on other sites

  • 4 months later...

you can try this hook, it's working for me.

 

first you need to add this line with your viewcart.tpl

<div class="g-recaptcha" data-sitekey="YOUR SITE KEY"></div>

Also add this to your template header: <script src='https://www.google.com/recaptcha/api.js'></script>

 

Replace "YOUR SITE KEY" and in hook script "ENTER YOUR KEY HERE" with your keys.

We use recaptcha v2 and it's only for CC payments, if you want to use for any payment method just make this changes in the code.

 

 

 

<?php

if (!defined("WHMCS"))

die("This file cannot be accessed directly");

 

 

function limitOrders($vars) {

 

$url = 'https://www.google.com/recaptcha/api/siteverify';

$privatekey = "ENTER YOUR KEY HERE";

$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);

$data = json_decode($response);

 

if (isset($data->success) AND $data->success==true) {

// everything is ok!

} else {

 

$pm = $vars['paymentmethod'];

 

if ($pm=="stripe")

{

global $errormessage;

$errormessage .= "<li> Please, confirm that you are not a robot! <br/></li>";

} //if CC

 

}

 

} //function

 

add_hook("ShoppingCartValidateCheckout", 1, "limitOrders");

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated