Пример #1
0
 /**
  * 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();
     }
 }
Пример #2
0
 /**
  * Process payment reversal and cancelled reversal notification
  */
 protected function _registerPaymentReversal()
 {
     $reasonCode = isset($this->_request['reason_code']) ? $this->_request['reason_code'] : null;
     $reasonComment = $this->_info->explainReasonCode($reasonCode);
     $notificationAmount = $this->_order->getBaseCurrency()->formatTxt($this->_request['mc_gross'] + $this->_request['mc_fee']);
     $paymentStatus = $this->_filterPaymentStatus(isset($this->_request['payment_status']) ? $this->_request['payment_status'] : null);
     $orderStatus = $paymentStatus == Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED ? Mage_Paypal_Model_Info::ORDER_STATUS_REVERSED : Mage_Paypal_Model_Info::ORDER_STATUS_CANCELED_REVERSAL;
     /**
      * Change order status to PayPal Reversed/PayPal Cancelled Reversal if it is possible.
      */
     $message = Mage::helper('paypal')->__('IPN "%s". %s Transaction amount %s. Transaction ID: "%s"', $this->_request['payment_status'], $reasonComment, $notificationAmount, $this->_request['txn_id']);
     $this->_order->setStatus($orderStatus);
     $this->_order->save();
     $this->_order->addStatusHistoryComment($message, $orderStatus)->setIsCustomerNotified(false)->save();
 }