You referral link can only remove the code from payment list at check payment step.If you set error message at session (Mage::getSingleton('core/session')->addError(Mage::helper('payment')->__('Code is not avaliable.'))) on function isAvaliable it can be shown on next step.
According my concept it will be good idea to do something at methods.phtml where all payment method has been listing during the checkout.
<?php
$isCodeAvalibale=0;
foreach ($this->getMethods() as $_method):
$_code = $_method->getCode();
if($_code =='cashondelivery'):
$isCodeAvalibale=1;
endif;
endforeach;
if($isCodeAvalibale==0):
echo Mage::helper('payment')->__('Code is not avaliable.'));
endif;
?>
Best Answer
You can use below free extension for the same.
https://github.com/bragento/magento2-cash-on-delivery-fee
It will add configured extra fee for COD.