Refund online button in magento custom payment method


In your custom payment module if you need to build any custom api to make refund from the magento backend. Make sure the following things added in your custom module.

In config.xml


The authorize function is very important in your source model file. Because the order amount should be authorized in the payment gateway before making refund. And enable the active variables to make refund.

class Namespace_Modulename_Model_Paymentname extends Mage_Payment_Model_Method_Abstract {
    protected $_canAuthorize = true;
    protected $_canCapture = true;
    protected $_canRefund = true; 

    public function authorize(Varien_Object $payment, $amount) {
        if (!$this->canAuthorize()){
        return $this;
    public function refund(Varien_Object $payment, $amount) {
      //your api code here for refund

The refund function will call back when you click refund button in the credit memo page of order invoice. Enjoy your work!! 🙂

No Comments yet, your thoughts are most welcome