The core captcha system already have all the required functionality and ability to enable/disable the captcha for different forms on the frontend.  It actually works ok, but is damned ugly. 

I wanted to leverage the core functionality, but improve the look.

Thus I needed the implementation of reCaptcha to become a seemless drop-in replacement for Magento's internal core captcha system.

So lets analyze the core captcha system.

It looks like the developer(s) of the core captcha did have a bit of forward thinking in their implementation of the core functionality. If you look at the config.xml file you will see that you can set a TYPE variable, which will signify the model class to be used for generating the captcha system.

 

core captcha config.xml

 

Great, so in my module, I simply altered this in my config.xml. This then allowed me to load a custom captcha model, effectively replacing core captcha model

my config.xml
 

You can see I also adjusted the fact that user create, password reminder, guest checkout and register dyring checkout would always get captcha. I am not 100% sure why magnto coe made those all required. You can set them via admin, selectively, so made no sense to me.

but I digress, so back onto the ability to instantiate a custom captcha class (type).

Although it looked initially that the core magento team was forward thinking in allowing the captcha system to be expanded, I ran into the issue that yhey had locked down the location of the new captcha into the Mage_Captcha namespace (ugh) - I cannot fathom why they did this....

locked namespace

 

The code above then wants to instantiate the class file  Mage_Captcha_Model_Recaptcha.php, which of course does not exist. FAIL!
So, the logical recourse would be to rewrite the core Captcha class and adjust the getCaptcha method to allow us to breeak out of the namespace....but there is another way....

So first, I really don't like using rewrites. I tend to try and stay away from them, as they can, and will at some point cuase rewrite conflicts with other modules, and ultimately that ends up in the need to do support....so if I can get away with not using a rewrite, I do. Event observers is always the best way to go extending magento.

But in this case, there is no event to use, so a rewrite is the only way, BUT, it is possible to actually rewrite the model class of the new captcha model! The fact that the file doe snot exist is irrelavant - magento will do the 'rewrite' and load my class model in my module, as instructed by the rewrite. And I will not have a potential rewrite issue with any aother 3rd party modules, since the file I am rewriting does not exist in core.....

So I place a rewrite directive as such in my module:

<captcha>
<rewrite>
<recaptcha>ProxiBlue_ReCaptcha_Model_Recaptcha</recaptcha>
</rewrite>
</captcha>

this then effectively loads my model class of  ProxiBlue_ReCaptcha_Model_Recaptcha, and not Mage_Captcha_Model_Recaptcha.php - awesome! problem solved.

I have now effectively replaced the core captcha class with my own class that is used to load and render googles reCaptcha system

You will see that the capctha system implements the class Mage_Captcha_Model_Interface, which hs three methods used to build the captcha system.
I effectively re-used all thes emethods, as they are called from the core code. My module thus seamlessly integrates with the core functionality.

The end effect is a very clean and neat drop-in replacement of reCapctha to magento's core captcha 

public function generate(); - I use this method to simply popuplate internal defauls and configuration options.

public function isCorrect($word); - is used to do the callback to googles reCapcha verification system, and determine if the captcha was correct

public function getBlockName(); - this is used to return my modules block class, ehich is used to set the templates, and to generate the captcha display

I also adjusted the core configuration options, so only the configuration options related to the reCaptcha system appears in admin.

options

Now supports the new 'I am not a robot' reCaptcha API. Simply set the 'i am not a robot' as the active theme in admin setting.

The module is available via github - https://github.com/ProxiBlue/recaptcha

ref: http://magento.stackexchange.com/questions/30606/rewrite-in-custom-module-to-non-existing-core-class-model/30608#30608