php - Magento - How can I run code when my order is canceled or refunded -


my payment module required sent notifications payment service if order canceled or refunded. assume "cancel" button on order page (in administration backend) cancel order, , "credit memo" button (after invoice has been created) refund order.

how run code on these events? tried using cancel() method in payment method model, code did not run.

seems payment method not using transactions or not create authorization transaction id. common beginner mistake in payment gateways development.

to enable payment gateway online actions need implement in payment method:

class mybest_payment_model_method extends mage_payment_model_method_abstract {     protected $_canauthorize            = true; // set true, if have authorization step.     protected $_cancapture              = true; // set true, if payment method allows perform capture transaction (usally credit cards methods)     protected $_canrefund               = true; // set true, if online refunds available     protected $_canvoid                 = true; // set true, if can cancel authorization via api online      public function authorize(varien_object $payment, $amount)     {           // ... payment method authorization goes here ...         // here goes retrieving or generation non-zero,          // non-null value transaction id.          $transactionid = $api->somecall();          // setting tranasaction id payment object         // improtant, if want perform online actions          // in future order!         $payment->settransactionid($transactionid);           // ... other actions ...          return $this;     }      public function void(varien_object $payment)     {         // ... actions sending cancel notification payment gateway     }      public function refund(varien_object $payment, $amount)     {         // ... actions performing online refund ...     } } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -