public function partialRefund(Customweb_Payment_Authorization_ITransaction $transaction, $items, $close) { if (!$transaction instanceof Customweb_Saferpay_Authorization_Transaction) { throw new Exception("The given transaction is not instanceof Customweb_Saferpay_Authorization_Transaction."); } $amount = Customweb_Util_Invoice::getTotalAmountIncludingTax($items); // Check the transaction state $transaction->refundByLineItemsDry($items, $close); $builder = new Customweb_Saferpay_BackendOperation_Adapter_Refund_ParameterBuilder($transaction, $this->getConfiguration(), $this->container); $sendParameters = $builder->buildParameters($amount); $requestUrl = Customweb_Saferpay_Util::addParametersToUrl($this->getExecuteUrl(), $sendParameters); $response = Customweb_Saferpay_Util::sendRequest($requestUrl); $parameters = $this->getXmlParameters($response); if ($parameters['RESULT'] == 0) { $id = $parameters['ID']; $this->capture($transaction, $amount, $id); $refundItem = $transaction->refundByLineItems($items, $close, Customweb_I18n_Translation::__("The total amount of the transaction was refunded. Refund transaction ID: '!paymentId' .", array('!paymentId' => $id))); $refundItem->setRefundId($id); } else { if ($parameters['RESULT'] == '75') { throw new Exception(Customweb_I18n_Translation::__('Refund of !amount failed because no card reference id was provided. This most likely because you try to refund a transaction authorized over the payment page. (Code: !result).', array('!amount' => $amount, '!result' => $parameters['RESULT']))); } else { throw new Exception(Customweb_I18n_Translation::__('Refund of !amount failed with code: !result.', array('!amount' => $amount, '!result' => $parameters['RESULT']))); } } }