Example #1
0
 protected function _isCaptchaCorrect()
 {
     if (!Mage::helper('aitcheckout/captcha')->checkIfCaptchaEnabled()) {
         return true;
         //not 1.7
     }
     $formId = $this->_getCheckoutCaptchaMethod();
     $helper = Mage::helper('aitcheckout/captcha');
     if ($helper->isCaptchaPassed($formId)) {
         return true;
     }
     $observer = new Varien_Object();
     $observer->setControllerAction($this);
     Mage::getSingleton('captcha/observer')->checkGuestCheckout($observer);
     Mage::getSingleton('captcha/observer')->checkRegisterCheckout($observer);
     $response = $this->getResponse();
     if ($response->getBody()) {
         $result = Mage::helper('core')->jsonDecode($response->getBody());
         if ($result['error'] == 1) {
             $result = new Varien_Object($result);
             $helper->renewCaptcha($result, $formId);
             $response->setBody(Mage::helper('core')->jsonEncode($this->_extractStepOutput('billing', $result->__toArray())));
             return false;
         }
     }
     $helper->setCaptchaAsConfirmed($formId);
     return true;
 }