/** * Refund the Customer * * @param PaymentDBO $paymentDBO Previously authorized & captured payment DBO * @return boolean False on a processing error */ function refund(&$paymentDBO) { // Load transaction data if (null == ($transactionData = $this->loadTransaction($paymentDBO->getTransaction1()))) { return false; } // Build Authorize.net transaction record $message = $this->buildPOSTFields(array("x_login" => $this->getLoginID(), "x_version" => $this->getAPIVersion(), "x_delim_char" => $this->getDelimiter(), "x_delim_data" => "TRUE", "x_type" => "CREDIT", "x_method" => "CC", "x_tran_key" => $this->getTransactionKey(), "x_trans_id" => $paymentDBO->getTransaction1(), "x_card_num" => $transactionData['lastdigits'], "x_amount" => $paymentDBO->getAmount())); // Carry out the transaction $resp = $this->executeTransaction($message); // Parse the transaction response switch ($resp[AIM_RESP_CODE]) { case AIM_APPROVED: $paymentDBO->setStatus("Refunded"); $paymentDBO->setTransaction1($resp[AIM_RESP_TRANSACTION_ID]); $paymentDBO->setTransaction2($resp[AIM_RESP_APPROVAL_CODE]); break; case AIM_DECLINED: $paymentDBO->setStatus("Declined"); $paymentDBO->setStatusMessage(substr($resp[AIM_RESP_REASON_TEXT], 0, 255)); break; case AIM_ERROR: default: log_error("AuthorizeAIM::refund()", "An error occured while processing an Authorize.net transaction: " . $resp[AIM_RESP_REASON_TEXT]); return false; break; } return true; }