/** * Process a refund or a chargeback */ protected function _registerPaymentRefund() { $this->_importPaymentInformation(); $reason = $this->getRequestData('reason_code'); $isRefundFinal = !$this->_info->isReversalDisputable($reason); $payment = $this->_order->getPayment()->setPreparedMessage($this->_createIpnComment($this->_info->explainReasonCode($reason)))->setTransactionId($this->getRequestData('txn_id'))->setParentTransactionId($this->getRequestData('parent_txn_id'))->setIsTransactionClosed($isRefundFinal)->registerRefundNotification(-1 * $this->getRequestData('mc_gross')); $this->_order->save(); // TODO: there is no way to close a capture right now if ($creditmemo = $payment->getCreatedCreditmemo()) { $creditmemo->sendEmail(); $comment = $this->_order->addStatusHistoryComment(Mage::helper('paypal')->__('Notified customer about creditmemo #%s.', $creditmemo->getIncrementId()))->setIsCustomerNotified(true)->save(); } }
/** * Process a refund or a chargeback */ protected function _registerPaymentRefund() { $this->_importPaymentInformation(); $reason = $this->getRequestData('reason_code'); $isRefundFinal = !$this->_info->isReversalDisputable($reason); /** @var Mage_Sales_Model_Order_Payment $payment */ $payment = $this->_order->getPayment(); $amount = $this->_order->getBaseCurrency()->formatTxt($payment->getBaseAmountRefundedOnline()); $transactionId = Mage::helper('paypal')->getHtmlTransactionId($payment->getMethodInstance()->getCode(), $this->getRequestData('txn_id')); $comment = $this->_createIpnComment($this->_info->explainReasonCode($reason)) . ' ' . Mage::helper('paypal')->__('Refunded amount of %s. Transaction ID: "%s"', $amount, $transactionId); $payment->setPreparedMessage($comment)->setTransactionId($this->getRequestData('txn_id'))->setParentTransactionId($this->getRequestData('parent_txn_id'))->setIsTransactionClosed($isRefundFinal)->registerRefundNotification(-1 * $this->getRequestData('mc_gross')); $this->_order->addStatusHistoryComment($comment, false); $this->_order->save(); // TODO: there is no way to close a capture right now $creditmemo = $payment->getCreatedCreditmemo(); if ($creditmemo) { $creditmemo->sendEmail(); $this->_order->addStatusHistoryComment(Mage::helper('paypal')->__('Notified customer about creditmemo #%s.', $creditmemo->getIncrementId()))->setIsCustomerNotified(true)->save(); } }