Example #1
0
 /**
  * Event Method for Authnet Payment Process
  * test with credit card 4111111111111111
  * American Express Card Test : 378282246310005
  * @param $evtcl -- Object
  */
 function eventProcessAuthNetPayment(Eventcontroler $evtcl)
 {
     $flag = true;
     if ($evtcl->tot_amt > $_SESSION['do_invoice']->amt_due) {
         $_SESSION['in_page_message'] = _("The Total Amount entered is greater than the invoice amount. Please re-enter.");
         $flag = false;
     }
     if ($flag) {
         // $this->Authnet_message = "";
         include_once 'class/Authnet.class.php';
         $payment_type = $evtcl->payment_type;
         $cc_number = $evtcl->cc;
         $cvv = trim($evtcl->cvv);
         $expire_year = $evtcl->expire_year;
         $expire_month = $evtcl->expire_month;
         $expiration = $evtcl->expire_month . $evtcl->expire_year;
         if ($evtcl->tot_amt > 0) {
             $total = $evtcl->tot_amt;
         } else {
             $total = $_SESSION['do_invoice']->amt_due;
         }
         $idinvoice = $_SESSION['do_invoice']->idinvoice;
         $idcontact = $_SESSION['do_invoice']->idcontact;
         $goto = $evtcl->goto;
         $do_contact = new Contact();
         $arr_user_info = $do_contact->getContactInfo_For_Invoice($idcontact);
         $auth_login = $_SESSION['do_invoice']->authnet_login;
         $inv_info_arr = array();
         $inv_info_arr['description'] = $_SESSION['do_invoice']->description;
         $inv_info_arr['inv_num'] = $_SESSION['do_invoice']->num;
         $auth_merchant_id = $_SESSION['do_invoice']->authnet_merchant_id;
         /* @param true = test mode
         			@param false = non test mode i.e live  
         			*/
         $payment = new Authnet(false, $arr_user_info, $auth_login, $auth_merchant_id, $inv_info_arr);
         $cc_msg = $payment->validateCreditCard($cc_number, $payment_type, $cvv, $expire_year, $expire_month);
         if ($cc_msg == "") {
             $invoice = uniqid('ofuz_', true);
             $payment->transaction($cc_number, $expiration, $total, $cvv, $invoice);
             $payment->process();
             if ($payment->isApproved()) {
                 $reason = $payment->getResponseText();
                 // Display a printable receipt
                 $_SESSION['in_page_message'] = _("This transaction has been approved. Thank you for your payment");
                 $transactionID = $payment->getTransactionID();
                 $do_pay_log = new PaymentLog();
                 $do_pay_log->addPaymentLog($transactionID, "AuthNet", $_SESSION['do_invoice']->idinvoice, $total);
                 $idpayment_log = $do_pay_log->getPrimaryKeyValue();
                 $do_payment_inv = new PaymentInvoice();
                 $do_payment_inv->addPaymentInvoice($idpayment_log, $_SESSION['do_invoice']->idinvoice, $total);
                 $this->updatePayment($total);
                 $this->sendPaymentApprovedEmail($total, "Authorized.net", $transactionID);
                 // Sending to customer
                 $this->sendPaymentApprovedEmail($total, "Authorized.net", $transactionID, true);
                 // Sending to user
                 /*
                 	Lets check if the invoice has an call back URL and process that
                 */
                 $do_inv_callback = new InvoiceCallback();
                 $do_User = $_SESSION['do_invoice']->getParentUser();
                 $do_inv_callback->processCallBack($this->idinvoice, $this->num, $total, $do_User->iduser, "ok", "AuthNet", $transactionID);
                 /*
                 Check if there is a next URL if so then set goto variable to that URL. Userful if we want the user to go to someother page
                 Than in the goto page. This is triggered only when full payment is done.
                 */
                 $next_url = $do_inv_callback->isNextUrl($this->idinvoice);
                 //if($next_url !== false){
                 //     $due_amt = $this->getDueAmount($this->idinvoice);
                 //     if($due_amt == '0.00'){
                 $goto = $next_url;
                 //     }
                 //}
                 $_SESSION['autologin_paid'] = True;
                 // Add the CC info in the RecurrentInvoiceCC
                 if ($evtcl->is_rec != 0 && $evtcl->is_cc == 0) {
                     $RecurrentInvoiceCC = new RecurrentInvoiceCC();
                     $RecurrentInvoiceCC->add_cc_info($cc_number, $expire_year, $expire_month, $evtcl->payment_type, $evtcl->is_rec);
                 }
             } else {
                 if ($payment->isDeclined()) {
                     $reason = $payment->getResponseText();
                     $do_inv_callback = new InvoiceCallback();
                     $do_inv_callback->processCallBack($this->idinvoice, $this->num, $total, $_SESSION['do_User']->iduser, "fail", "AuthNet", "", $reason);
                     $goto = $evtcl->error_page;
                     // As for another form of payment
                     $_SESSION['in_page_message'] = _("The transaction has been declined.'{$reason}'");
                 } else {
                     $reason = $payment->getResponseText();
                     //$reason .= $payment->getResponseCode();
                     $do_inv_callback = new InvoiceCallback();
                     $do_inv_callback->processCallBack($this->idinvoice, $this->num, $total, $_SESSION['do_User']->iduser, "fail", "AuthNet", "", $reason);
                     $goto = $evtcl->error_page;
                     // Ask the merchant to call us
                     $_SESSION['in_page_message'] = _("The transaction failed.'{$reason}'");
                 }
             }
         } else {
             $_SESSION['in_page_message'] = $cc_msg;
         }
     }
     $evtcl->setDisplayNext(new Display($goto));
 }
Example #2
0
$invoice_access = true;
if ($invoice_access) {
    if (!is_object($_SESSION['do_invoice'])) {
        //$do_invoice = new Invoice();
        //$do_invoice->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
        echo _('Your page session has been expired. Please go back to the Invoice page and try again.');
        exit;
    }
    $do_company = new Company();
}
$RecurrentInvoice = new RecurrentInvoice();
$id_rec = $RecurrentInvoice->checkIfInvoiceIsInRecurrent($_SESSION['do_invoice']->idinvoice);
// Check if recurrent
if ($id_rec) {
    $is_recurrent = $id_rec;
    $RecurrentInvoiceCC = new RecurrentInvoiceCC();
    $id_rec_cc = $RecurrentInvoiceCC->has_cc_info($id_rec);
    //Check if having CC in DB
    if (!$id_rec_cc) {
        $id_rec_cc = 0;
    } else {
        $id_rec_cc = 1;
    }
    //idrecurrentinvoice
} else {
    $is_recurrent = 0;
    $id_rec_cc = 0;
}
?>
<script type="text/javascript">
//<![CDATA[
/**
 * Process the CC on Authnet for the recurrent invoices
 * on due date
 * Recurrent Invoices which are paid monthly online are porcessed via this script
 * Will retrieve the encrypted CC info and will process the invoice payment if its the due date.
 * @see class/RecurrentInvoice.class.php
 * @see class/RecurrentInvoiceCC.class.php
 */
include_once 'config.php';
include_once 'class/Authnet.class.php';
set_time_limit(3600);
$do_recurrent = new RecurrentInvoice();
$do_invoice = new Invoice();
$do_inv_line = new InvoiceLine();
$do_contact = new Contact();
$do_recurrent_cc = new RecurrentInvoiceCC();
$do_recurrent->getRecInvoiceForCCProcess();
if ($do_recurrent->getNumRows()) {
    while ($do_recurrent->next()) {
        $do_user_detail = new User();
        $do_invoice = new Invoice();
        $do_invoice->getId($do_recurrent->idinvoice);
        $do_invoice->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
        $do_user_detail->getId($_SESSION['do_invoice']->iduser);
        $user_settings = $do_user_detail->getChildUserSettings();
        if ($user_settings->getNumRows()) {
            // Get the setting data for the user who has created the invoice
            while ($user_settings->next()) {
                $payment_mode = false;
                if ($user_settings->setting_name == 'invoice_logo' && $user_settings->setting_value != '') {
                    $_SESSION['do_invoice']->inv_logo = $user_settings->setting_value;