Esempio n. 1
0
 public static function instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 function AuthorizeAIMVoid($TransactionID)
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'class.connection.php';
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_osemsc' . DS . 'libraries' . DS . 'Authnet.class.php';
     $pConfig = oseMscConfig::getConfig('payment', 'obj');
     if (empty($pConfig->an_loginid) || empty($pConfig->an_transkey)) {
         return false;
     }
     if (!isset($pConfig->cc_testmode) || $pConfig->cc_testmode == true) {
         $test_mode = true;
     } else {
         $test_mode = false;
     }
     $subdomain = $test_mode ? 'test' : 'secure';
     $cc_payment = Authnet::instance();
     $cc_payment->url = $subdomain . ".authorize.net";
     $cc_payment->setParameter('x_login', $pConfig->an_loginid);
     $cc_payment->setParameter('x_tran_key', $pConfig->an_transkey);
     $cc_payment->setParameter('x_email_customer', $pConfig->an_email_customer);
     $cc_payment->setParameter('x_merchant_email', $pConfig->an_merchant_email);
     $cc_payment->setParameter('x_email_merchant', $pConfig->an_email_merchant);
     $cc_payment->setTransactionType('VOID');
     $cc_payment->setParameter('x_trans_id', $TransactionID);
     $cc_payment->process();
     $return['isApproved'] = $cc_payment->isApproved();
     $return['ResponseText'] = $cc_payment->getResponseText();
     return $return;
 }
Esempio n. 3
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));
 }
     }
 }
 if ($payment_mode == true) {
     $do_user_detail->free();
     $arr_user_info = $do_contact->getContactInfo_For_Invoice($do_recurrent->idcontact);
     $inv_info_arr = array();
     $inv_info_arr['description'] = $_SESSION['do_invoice']->description;
     $inv_info_arr['inv_num'] = $_SESSION['do_invoice']->num;
     $cc_number = $do_recurrent_cc->CCDecrypt($do_recurrent->cc_num);
     $payment_type = $do_recurrent->cc_type;
     $expire_year = $do_recurrent->cc_exp_year;
     $expire_month = $do_recurrent->cc_exp_mon;
     /* @param true = test mode
          @param false = non test mode i.e live  
        */
     $payment = new Authnet(false, $arr_user_info, $_SESSION['do_invoice']->authnet_login, $_SESSION['do_invoice']->authnet_merchant_id, $inv_info_arr);
     $cc_msg = $payment->validateCreditCard($cc_number, $payment_type, "", $expire_year, $expire_month, false);
     //echo '<br />'.$cc_msg;
     if ($cc_msg == "") {
         $invoice = uniqid('ofuz_', true);
         $expiration = $expire_month . $expire_year;
         $payment->transaction($cc_number, $expiration, $do_recurrent->net_total, "", $do_recurrent->idinvoice);
         $payment->process();
         if ($payment->isApproved()) {
             $transactionID = $payment->getTransactionID();
             echo '<br />Payment Processed for invoice ID::: ' . $do_recurrent->idinvoice . ' Transaction ID ::: ' . $transactionID . '<br />';
             $do_pay_log = new PaymentLog();
             $do_pay_log->addPaymentLog($transactionID, "AuthNet", $do_recurrent->idinvoice, $do_recurrent->net_total);
             $idpayment_log = $do_pay_log->getPrimaryKeyValue();
             $do_payment_inv = new PaymentInvoice();
             $do_payment_inv->addPaymentInvoice($idpayment_log, $_SESSION['do_invoice']->idinvoice, $do_recurrent->net_total);