Example #1
0
 /**
  * Void payment
  *
  * @param   Varien_Object $invoicePayment
  * @return  Mage_Payment_Model_Abstract
  */
 public function void(Varien_Object $payment)
 {
     $error = false;
     // Void is not enabled.
     if (!$this->getConfigData('enable_void')) {
         return $this;
     }
     if (in_array($payment->getAdditionalInformation(self::PAYMENTMETHOD), $this->_directPaymentMethods)) {
         // Do not run financial transactions on directpayment.
         return $this;
     }
     if (!$payment->getAdditionalInformation(self::TRANSACTION_ID)) {
         if (!$payment->getBbsTransactionId()) {
             $this->getApi()->doLog(Mage::helper('bbsnetaxept')->__('Could not find transaction id.'));
             return $this;
         } else {
             $bbsTransId = $payment->getBbsTransactionId();
             // Make it compatible with old fashion BBSNetterminal.
         }
     } else {
         $bbsTransId = $payment->getAdditionalInformation(self::TRANSACTION_ID);
     }
     $order = $payment->getOrder();
     $this->_useMobile = $payment->getAdditionalInformation(self::MOBILE_CLIENT) === true;
     if ($order->getInvoiceCollection()->count() > 0) {
         // Do no try to annul orders that have invoices.
         return $this;
     }
     $InvoiceId = $order->getIncrementId() ? $order->getIncrementId() : 'Unknown';
     if ($this->getApi()->void($bbsTransId, $InvoiceId) == $bbsTransId) {
         $payment->setStatus(self::STATUS_SUCCESS);
     } else {
         $error = Mage::helper('bbsnetaxept')->__('Error void the payment: %s', $this->getApi()->getErrorMessage());
     }
     if ($error !== false) {
         $this->getApi()->doLog($error);
         //    Mage::throwException($error);
     }
     return $this;
 }