s01e05 - Google Recaptcha QUESTIONS/SUPPORT

Open to all! Ask other shopowners for help.
Post Reply
admin
Contributor
Posts: 217
Joined: Wed Oct 30, 2019 1:34 pm
Phoenix Version:
Has thanked: 20 times
Been thanked: 22 times

s01e05 - Google Recaptcha QUESTIONS/SUPPORT

Post by admin »

Questions/Support

Tags:


Join The Code Co-op to get access to your library in the Code Co-op Forum
zeeshop
Member
Posts: 71
Joined: Sun Jan 10, 2021 11:30 pm
Phoenix Version:
Has thanked: 15 times
Been thanked: 2 times

Re: s01e05 - Google Recaptcha

Post by zeeshop »

Hi,
Since installing this getting the below error on Create account page, and not creating an account:
Same for COntact us page/ not sending messages:
Notice: Undefined index: error-codes in /homepages/31/*********/htdocs/*********/includes/hooks/shop/siteWide/addRecaptcha.php on line 52

Notice: Trying to access array offset on value of type null in /homepages/31/*********/htdocs/*********/includes/hooks/shop/siteWide/addRecaptcha.php on line 52

Warning: constant(): Couldn't find constant in /homepages/31/*********/htdocs/*********/includes/hooks/shop/siteWide/addRecaptcha.php on line 52
Reffered Line 52 is as below:

Code: Select all

  $GLOBALS['messageStack']->add('header', constant($result['error-codes'][0]), 'error');
Thanks
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: s01e05 - Google Recaptcha

Post by ecartz »

zeeshop wrote: Sat Jan 08, 2022 12:51 pm

Code: Select all

  $GLOBALS['messageStack']->add('header', constant($result['error-codes'][0]), 'error');
You could change that line to

Code: Select all

  $GLOBALS['messageStack']->add('header', isset($result['error-codes'][0]) ? constant($result['error-codes'][0]) : $curlData, 'error');
It will still be broken, but it may give a more useful error message. That it's reaching that line at all means something is broken. Make sure that you've followed all the installation instructions from the README.md file. In particular, make sure that you have edited

Code: Select all

  public $_sitekey = '';
  public $_secret  = '';
to have the right values.
zeeshop
Member
Posts: 71
Joined: Sun Jan 10, 2021 11:30 pm
Phoenix Version:
Has thanked: 15 times
Been thanked: 2 times

Re: s01e05 - Google Recaptcha

Post by zeeshop »

Thanks @ecartz

After editing to the suggestion getting below message:
{ "success": true, "challenge_ts": "2022-01-08T15:30:01Z", "hostname": "www.mysite.com" }
Message not sent/ or account not created.
I have followed the instructions and entered the site/ secret key as required.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: s01e05 - Google Recaptcha

Post by ecartz »

You could try changing this line:

Code: Select all

      if ($result['success'] === 'true') {
to

Code: Select all

      if ($result['success'] === true) {
(Remove two apostrophes around true.)

If that doesn't work, before the messageStack line, try adding

Code: Select all

var_dump($result);exit();
That will really break it, but hopefully give useful feedback.
zeeshop
Member
Posts: 71
Joined: Sun Jan 10, 2021 11:30 pm
Phoenix Version:
Has thanked: 15 times
Been thanked: 2 times

Re: s01e05 - Google Recaptcha

Post by zeeshop »

The last change fixed the issue.

Another thing I am noticing is when the box for Recaptcha is not ticked the warning is coming as below.
Box not ticked.JPG
Seems like the message from the language file is not triggering/ appearing as required.

Language file is showing:

Code: Select all

define('missing-input-response', 'We cannot detect a Recaptcha - did you tick the box?');
define('invalid-input-response', 'Sorry, something has gone wrong with Recaptcha, please email us instead.');

define('missing-input-secret', 'Recaptcha: Missing Secret');
define('invalid-input-secret', 'Recaptcha: Invalid Secret');


Many Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
tessthepup
Certified Developer
Posts: 381
Joined: Mon Mar 01, 2021 5:55 pm
Phoenix Version:
Has thanked: 47 times
Been thanked: 62 times

Re: s01e05 - Google Recaptcha

Post by tessthepup »

Hi Guys,

Just wondering if anyone is using this on a 1.0.8.20 store as I am having an issue.

The contact us form submits without the recaptcha ticked box being ticked :?

Thanks

Mark


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply