/** * execute if transaction was loss * * @param SofortLib_TransactionData $transData * @param Mage_Sales_Model_Order $order * @return void */ private function _transactionLoss($transData, $order) { $payment = $order->getPayment(); if ($transData->isLastschrift()) { $payment->setParentTransactionId($transData->getTransaction())->setShouldCloseParentTransaction(true)->setIsTransactionClosed(0)->registerRefundNotification($transData->getAmount()); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Customer returned payment'))->setIsVisibleOnFront(true); $order->save(); } elseif ($transData->isSofortrechnung()) { // be sure that order can cancel $order->setState('sofort'); $order->cancel(); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Successfully canceled invoice: %s', $transData->getTransaction()))->setIsVisibleOnFront(true); } elseif ($transData->isSofortueberweisung()) { $lossStatus = Mage::getStoreConfig('payment/sofort/pnsofort_order_status_loss'); $order->setState('sofort'); if ($newStatus == 'unchanged') { $order->addStatusHistoryComment($transData->getStatus() . " " . $transData->getStatusReason()); } else { $order->addStatusHistoryComment($transData->getStatus() . " " . $transData->getStatusReason(), $lossStatus); } } else { // be sure that order can cancel $order->setState('sofort'); $order->cancel(); $order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Customer canceled payment'))->setIsVisibleOnFront(true); } $order->save(); }