frontend/models/VoucherForm.php
/**
     * Validate Google recaptcha response.
     *
     * @return void
     */
Validate Google recaptcha response.
@return void
Validate Google recaptcha response . @return void
public function validateReCaptchaResponse ()
    {
        if (!$this->hasErrors()) {
            $reCaptcha = new ReCaptcha(Yii::$app->config->get('GoogleReCaptcha.SecretKey'));
            $reCaptchaResp = $reCaptcha->verify($this->reCaptchaResp, $_SERVER['REMOTE_ADDR']);
            if (!$reCaptchaResp->isSuccess()) {
                $this->addError('recaptchaResponse','Invalid captcha');
            }
        }
    }
public function validateReCaptchaResponse ( ) { if ( ! $ this -> hasErrors ( ) ) { $ reCaptcha = new ReCaptcha ( Yii :: $ app -> config -> get ( 'GoogleReCaptcha.SecretKey' ) ) ; $ reCaptchaResp = $ reCaptcha -> verify ( $ this -> reCaptchaResp , $ _SERVER [ 'REMOTE_ADDR' ] ) ; if ( ! $ reCaptchaResp -> isSuccess ( ) ) { $ this -> addError ( 'recaptchaResponse' , 'Invalid captcha' ) ; } } }
Validate Google recaptcha response.
Validate Google recaptcha response .