/** * Refund specified amount for payment * * @param Mage_Sales_Model_Order_Payment $payment * @param float $amount * * @return $this */ public function refund(Varien_Object $payment, $amount) { parent::refund($payment, $amount); /** @var Mage_Sales_Model_Order_Payment $payment */ $order = $payment->getOrder(); /** @var Rede_ClickPag_Model_Processor $processor */ $processor = $this->_processor(); $processor->setOrder($order); $validation = $this->_validateRefundParameters($processor->getRefundParams()); if ($validation !== true) { Mage::throwException($validation); } /** @var Rede_ClickPag_Model_Payments $payments */ $payments = Mage::getModel('rede_clickpag/payments')->loadByOrderId($order->getId()); $transactionId = $payments->getTransactionId(); if (!$transactionId) { Mage::throwException($this->_helper()->__('Transaction ID is empty for this order.'), 'adminhtml/session'); return $this; } /** @var Rede_ClickPag_Model_Api $api */ $api = Mage::getModel('rede_clickpag/api'); $api->refund($transactionId); $this->_validateRefundResult($api); if ($api->getResult()->getStatus() === 202 && Mage::app()->getStore()->isAdmin()) { $message = $this->_helper()->__('Your order was successfully refunded.'); $this->_getAdminSession()->addSuccess($message); } return $this; }
public function refund(Varien_Object $payment, $amount) { parent::refund($payment, $amount); $txn = $payment->getAuthorizationTransaction(); if ($txn) { try { $billnumber = $txn->getParentTxnId() ? $txn->getParentTxnId() : $txn->getTxnId(); $data = array('Merchant_ID' => urlencode($this->getConfigData('merchant')), 'Billnumber' => urlencode($billnumber), 'Login' => urlencode($this->getConfigData('api_login')), 'Password' => urlencode($this->getConfigData('api_password'))); $xml = $this->callAssist(self::CANCEL_URL, $data); if ((int) $xml['firstcode'] || (int) $xml['secondcode']) { Mage::throwException('error in call'); } if ('AS000' != (string) $xml->orders->order->responsecode) { Mage::throwException($this->getAssistErrors((string) $xml->orders->order->responsecode)); } if (Mage::helper('assist')->isServiceSecured()) { $y = implode("", array($this->getConfigData('merchant'), (string) $xml->orders->order->ordernumber, (string) $xml->orders->order->orderamount, (string) $xml->orders->order->ordercurrency, (string) $xml->orders->order->orderstate, (string) $xml->orders->order->packetdate)); $keyFile = Mage::getBaseDir('var') . DS . self::PEM_DIR . DS . $this->getConfigData('assist_key'); if ((string) $xml->orders->order->signature != $this->sign($y, $keyFile)) { Mage::throwException('Incorrect Signature.'); } } // success Mage::helper('assist')->debug($xml); } catch (Mage_Core_Exception $e) { Mage::helper('assist')->debug($e->getMessage()); throw $e; } } Mage::helper('assist')->debug('refund'); return $this; }
/** * Refunds a transaction * @param Varien_Object $payment * @param float $amount * @return Mage_Payment_Model_Method_Abstract */ public function refund(Varien_Object $payment, $amount) { $hash = $payment->getData('ebanx_hash'); Mage::log('Refund order ' . $hash); $response = \Ebanx\Ebanx::doRefund(array('hash' => $hash, 'operation' => 'request', 'amount' => $amount, 'description' => 'Order refunded')); return parent::refund($payment, $amount); }
/** * Refund capture * @param Varien_Object $payment * @param $amount * @return $this */ public function refund(Varien_Object $payment, $amount) { Mage::helper('partpayment/tools')->addToDebug('Action: Refund'); parent::refund($payment, $amount); if ($amount <= 0) { Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.')); } if (!$payment->getLastTransId()) { Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.')); } // Load transaction Data $transactionId = $payment->getLastTransId(); $transaction = $payment->getTransaction($transactionId); if (!$transaction) { Mage::throwException(Mage::helper('partpayment')->__('Can\'t load last transaction.')); } // Get Transaction Details $details = $this->fetchTransactionInfo($payment, $transactionId); //$details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); // Check for Capture and Authorize transaction only if ((int) $details['transactionStatus'] !== 6 && (int) $details['transactionStatus'] !== 0) { Mage::throwException(Mage::helper('partpayment')->__('This payment has not yet captured.')); } $transactionNumber = $details['transactionNumber']; $order_id = $details['orderId']; if (!$order_id) { $order_id = $payment->getOrder()->getId(); } // Call PXOrder.PXOrder.Credit5 $params = array('accountNumber' => '', 'transactionNumber' => $transactionNumber, 'amount' => round(100 * $amount), 'orderId' => $order_id, 'vatAmount' => 0, 'additionalValues' => ''); $result = Mage::helper('partpayment/api')->getPx()->Credit5($params); Mage::helper('partpayment/tools')->addToDebug('PxOrder.Credit5:' . $result['description'], $order_id); // Check Results if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') { // Add Credit Transaction $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND); $payment->setAmount($amount); $payment->setStatus(self::STATUS_APPROVED)->setTransactionId($result['transactionNumber'])->setIsTransactionClosed(0); // No-Closed // Add Transaction fields $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result); return $this; } // Show Error Mage::helper('partpayment/tools')->throwPayExException($result, 'PxOrder.Credit5'); return $this; }
/** * Refund * * @param Varien_Object $payment * @param float $amount * @return \Mage_Payment_Model_Abstract|void */ public function refund(Varien_Object $payment, $amount) { //If the refund will be created by OPS, Refund Create Method to nothing if (true === Mage::registry('ops_auto_creditmemo')) { Mage::unregister('ops_auto_creditmemo'); return parent::refund($payment, $amount); } $refundHelper = Mage::helper('ops/order_refund')->setAmount($amount)->setPayment($payment); $arrInfo = $refundHelper->prepareOperation($payment, $amount); $storeId = $payment->getOrder()->getStoreId(); $operation = $arrInfo['operation']; try { $requestParams = $this->getBackendOperationParameterModel()->getParameterFor(self::OPS_REFUND_TRANSACTION_TYPE, $this, $payment, $amount, $arrInfo); $response = Mage::getSingleton('ops/api_directlink')->performRequest($requestParams, Mage::getModel('ops/config')->getDirectLinkGatewayPath($storeId), $storeId); Mage::helper('ops/payment')->saveOpsStatusToPayment($payment, $response); if ($response['STATUS'] == self::OPS_REFUND_WAITING || $response['STATUS'] == self::OPS_REFUND_UNCERTAIN_STATUS) { Mage::helper('ops/payment')->saveOpsRefundOperationCodeToPayment($payment, $operation); $refundHelper->createRefundTransaction($response); } elseif ($response['STATUS'] == self::OPS_REFUNDED || $response['STATUS'] == self::OPS_REFUND_PROCESSED_MERCHANT) { //do refund directly if response is ok already Mage::helper('ops/payment')->saveOpsRefundOperationCodeToPayment($payment, $operation); $refundHelper->createRefundTransaction($response, 1); return parent::refund($payment, $amount); } else { Mage::throwException($this->getHelper()->__('The CreditMemo was not created. Barclaycard status: %s.', $response['STATUS'])); } Mage::getSingleton('core/session')->addNotice($this->getHelper()->__('The Creditmemo will be created automatically as soon as Barclaycard sends an acknowledgement.')); $this->getHelper()->redirect(Mage::getUrl('*/sales_order/view', array('order_id' => $payment->getOrder()->getId()))); } catch (Exception $e) { Mage::logException($e); Mage::getModel('ops/status_update')->updateStatusFor($payment->getOrder()); Mage::throwException($e->getMessage()); } }
public function refund(Varien_Object $payment, $amount) { parent::refund($payment, $amount); $this->cancel($payment, $amount); return $this; }
/** * Refund money */ public function refund(Varien_Object $payment, $amount) { $sendbaseamount = $this->getCommonConfigData('sendbaseamount'); if (!$sendbaseamount) { // Multiple currencies, multiple channels fix $amount = $amount * $payment->getOrder()->getBaseToOrderRate(); } parent::refund($payment, $amount); $params = $this->_initRequestParams(); if ($sendbaseamount) { $amount = $amount >= $payment->getOrder()->getBaseGrandTotal() ? $payment->getOrder()->getBaseGrandTotal() : $amount; $params['PRESENTATION.CURRENCY'] = $payment->getOrder()->getBaseCurrencyCode(); } else { $amount = $amount >= $payment->getOrder()->getGrandTotal() ? $payment->getOrder()->getGrandTotal() : $amount; // Multiple currencies, multiple channels fix $params['PRESENTATION.CURRENCY'] = $payment->getOrder()->getOrderCurrencyCode(); } $params['PRESENTATION.AMOUNT'] = round($amount, 2); $params['PAYMENT.CODE'] = $this->_getPaymentCode(self::PAYMENT_TYPE_REFUND); $params['IDENTIFICATION.REFERENCEID'] = $payment->getLastTransId(); $this->_getApi()->setStore($this->getStore()); $response = $this->_getApi()->request($params); $this->_processResponse($params, $response, $payment); return $this; }
/** * * @param Mage_Sales_Model_Order_Payment $payment * @param float $amount * @return @return Mage_Payment_Model_Abstract */ public function refund(Varien_Object $payment, $amount) { parent::refund($payment, $amount); $transactionId = $payment->getLastTransId(); $gatewayParams = array('operation' => 'refund', 'amount' => $amount); /* @var $request Allopass_Hipay_Model_Api_Request */ $request = Mage::getModel('hipay/api_request', array($this)); $action = Allopass_Hipay_Model_Api_Request::GATEWAY_ACTION_MAINTENANCE . $transactionId; $this->_debug($gatewayParams); $gatewayResponse = $request->gatewayRequest($action, $gatewayParams, $payment->getOrder()->getStoreId()); $this->_debug($gatewayResponse->debug()); switch ($gatewayResponse->getStatus()) { case "124": case "125": case "126": /* @var $creditmemo Mage_Sales_Model_Order_Creditmemo */ $creditmemo = $payment->getCreditmemo(); $creditmemo->setState(Mage_Sales_Model_Order_Creditmemo::STATE_OPEN); //State open = pending state break; default: Mage::throwException($gatewayResponse->getStatus() . " ==> " . $gatewayResponse->getMessage()); break; } return $this; }
/** * Refund * * @param Varien_Object $payment * @param float $amount * @return */ public function refund(Varien_Object $payment, $amount) { //If the refund will be created by PostFinance, Refund Create Method to nothing if (true === Mage::registry('postfinance_auto_creditmemo')) { Mage::unregister('postfinance_auto_creditmemo'); return parent::refund($payment, $amount); } /** @var $refundHelper PostFinance_Payment_Helper_Order_Refund */ $refundHelper = Mage::helper('postfinance/order_refund'); $refundHelper->setPayment($payment)->setAmount($amount); $operation = $refundHelper->getRefundOperation($payment, $amount); $requestParams = array('AMOUNT' => round($amount * 100), 'ORDERID' => $this->getConfig()->getConfigData('devprefix') . $payment->getOrder()->getQuoteId(), 'OPERATION' => $operation); try { $url = Mage::getModel('postfinance/config')->getDirectLinkGatewayPath(); $response = Mage::getModel('postfinance/api_directlink')->performRequest($requestParams, $url); Mage::helper('postfinance/payment')->savePostFinanceStatusToPayment($payment, $response); if ($response['STATUS'] == self::POSTFINANCE_REFUND_WAITING || $response['STATUS'] == self::POSTFINANCE_REFUND_UNCERTAIN_STATUS) { $refundHelper->createRefundTransaction($response); } elseif ($response['STATUS'] == self::POSTFINANCE_REFUNDED || $response['STATUS'] == self::POSTFINANCE_REFUND_PROCESSED_MERCHANT) { //do refund directly if response is ok already $refundHelper->createRefundTransaction($response, 1); return parent::refund($payment, $amount); } else { Mage::throwException($this->getHelper()->__('The CreditMemo was not created. PostFinance status: %s.', $response['status'])); } Mage::getSingleton('core/session')->addNotice($this->getHelper()->__('The Creditmemo will be created automatically as soon as PostFinance sends an acknowledgement.')); $this->getHelper()->redirect(Mage::getUrl('*/sales_order/view', array('order_id' => $payment->getOrder()->getId()))); } catch (Exception $e) { Mage::throwException($e->getMessage()); } }
/** * @param Varien_Object $payment * @param unknown_type $amount */ public function refund(Varien_Object $payment, $amount) { if ($this->_getConfigData('debug') === '1') { $this->writeLog('refund fx called'); } parent::refund($payment, $amount); return $this; }
/** * @param Mage_Sales_Model_Order_Payment|Varien_Object $payment * @param float $amount * @return $this */ public function refund(Varien_Object $payment, $amount) { parent::refund($payment, $amount); $order = $payment->getOrder(); if ($order) { $this->_callPostOrder($order); } return $this; }