Recaptcha and Ajax form submission


I’m, trying to use recapthca on a form that the submission is to be made by ajax. 

My problem is that I’m having always unknown error in the response from google. I know that i’m missing something but where… I need help on this.

My settings are, the module recaptcha is installed and enabled and configured with my site private and public keys, (for developing using the domain localhost).

My form has  

$form[‘captcha’] = array(
      ‘#type’ => ‘captcha’,
      ‘#captcha_type’ => ‘default’,

And it appears on the form ok, and my ajax is

$form[‘submission’] = array(
      ‘#type’ => ‘button’,
      ‘#value’ => ‘Submission’,
      ‘#attributes’=>array(‘class’=> array(‘btn-lg’)),
      ‘#ajax’ => array(
        ‘callback’ => ‘::submission_custom_ajax_handler’,
        ‘wrapper’ => ‘return_submission’,
        ‘event’ => ‘click’,
        ‘progress’ => array(
          ‘type’ => ‘throbber’,
          ‘message’ => ‘Working…’,

And my handler i’m trying to validate the recaptcha using the function that is on recaptha.module

public function submission_custom_ajax_handler(array &$form, FormStateInterface $form_state){
if(recaptcha_captcha_validation(‘solution’, ‘response’, ‘element’, ‘form_state’)==FALSE){ // why the function need parameters that aren’t used there??

return null;//later some warnings



But when the recaptcha is checked this function always gives the error on log ‘reCAPTCHA web service’ error Unknown error.

I inserted also some logs in recaptcha_captcha_validation function to debug the call and is seems that the secret, the response ans client ip are well sent. 

There is something missing on the configuration? How can I debug on the “google side” my requests to see if the request is wrong?

Any help is welcome.



Drupal version: