Example #1
0
 public function refund(Varien_Object $payment, $amount)
 {
     parent::refund($payment, $amount);
     $error = false;
     if ($payment->getRefundTransactionId() && $amount > 0) {
         $this->setTransactionId($payment->getRefundTransactionId())->setPayment($payment)->setAmount($amount);
         if ($this->callDoRefund() !== false) {
             $payment->setStatus(self::STATUS_SUCCESS)->setCcTransId($this->getTransactionId());
         } else {
             $payment->setStatus(self::STATUS_ERROR);
             $e = $this->getError();
             if (isset($e['message'])) {
                 $error = $e['message'];
             } else {
                 $error = Mage::helper('paybox')->__('Error in refunding the payment');
             }
         }
     } else {
         $payment->setStatus(self::STATUS_ERROR);
         $error = Mage::helper('paybox')->__('Error in refunding the payment');
     }
     if ($error !== false) {
         Mage::throwException($error);
     }
     return $this;
 }