/**
  * Add Payment
  *
  * Create a PaymentDBO and add it to the database
  */
 function add_payment()
 {
     // If the use entered the Invoice ID directly, use that.  Otherwise, use the
     // Invoice selected from the drop-down menu
     $invoice = isset($this->post['invoiceint']) ? $this->post['invoiceint'] : $this->post['invoiceselect'];
     // Create a new payment DBO
     $payment_dbo = new PaymentDBO();
     $payment_dbo->setInvoiceID($invoice->getID());
     $payment_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $payment_dbo->setAmount($this->post['amount']);
     $payment_dbo->setType($this->post['type']);
     $payment_dbo->setTransaction1($this->post['transaction1']);
     $payment_dbo->setTransaction2($this->post['transaction2']);
     $payment_dbo->setStatus($this->post['status']);
     // Insert Payment into database
     add_PaymentDBO($payment_dbo);
     // Success
     $this->setMessage(array("type" => "[PAYMENT_ENTERED]"));
     $this->reload();
 }
 /**
  * Void an Authorized Transaction
  *
  * @param PaymentDBO $paymentDBO Previously authorized payment DBO
  * @return boolean False on a processing error
  */
 function void(&$paymentDBO)
 {
     $message = $this->buildPOSTFields(array("x_login" => $this->getLoginID(), "x_version" => $this->getAPIVersion(), "x_delim_char" => $this->getDelimiter(), "x_delim_data" => "TRUE", "x_type" => "VOID", "x_method" => "CC", "x_tran_key" => $this->getTransactionKey(), "x_trans_id" => $paymentDBO->getTransaction1()));
     // Carry out the transaction
     $resp = $this->executeTransaction($message);
     // Parse the transaction response
     switch ($resp[AIM_RESP_CODE]) {
         case AIM_APPROVED:
             $paymentDBO->setStatus("Voided");
             $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::void()", "An error occured while processing an Authorize.net transaction: " . $resp[AIM_RESP_REASON_TEXT]);
             return false;
             break;
     }
     return true;
 }
 /**
  * Add Payment
  *
  * Create a new PaymentDBO and add it to the database
  */
 function add_payment()
 {
     // Create a new payment DBO
     $invoice_id = isset($this->get['invoice']) ? $this->get['invoice']->getID() : $this->session['new_payment']['invoice']->getID();
     $payment_dbo = new PaymentDBO();
     $payment_dbo->setInvoiceID($invoice_id);
     $payment_dbo->setDate(DBConnection::format_datetime($this->post['date']));
     $payment_dbo->setAmount($this->post['amount']);
     $payment_dbo->setType($this->post['type']);
     $payment_dbo->setStatus("Completed");
     $payment_dbo->setTransaction1($this->post['transaction1']);
     $payment_dbo->setTransaction2($this->post['transaction2']);
     // Insert Payment into database
     add_PaymentDBO($payment_dbo);
     // Success
     $this->setMessage(array("type" => "[PAYMENT_ENTERED]"));
     $this->gotoPage("billing_view_invoice", null, "invoice=" . $payment_dbo->getInvoiceID());
 }