function eventAjaxGetEmailTemplateText(Eventcontroler $evtcl)
 {
     if ($evtcl->temlid != '') {
         $do_user_email_tmpl = new EmailTemplateUser();
         $do_user_email_tmpl->getId($evtcl->temlid);
         $evtcl->addOutputValue($do_user_email_tmpl->bodyhtml);
     }
 }
Пример #2
0
 function eventCheckEmptyFields(Eventcontroler $evtcl)
 {
     $field_selected = $evtcl->field_selected;
     if (empty($field_selected)) {
         $_SESSION['in_page_message'] = _("Please select some labels");
         $evtcl->doSave = 'no';
         $evtcl->goto = 'settings_wf.php';
         $dispError = new Display("settings_wf.php");
         $dispError->addParam("e", 'yes');
         $evtcl->setDisplayNext($dispError);
     }
 }
Пример #3
0
 /**
  * Function to delete the git repository which is selected for the current project
  * @param Eventcontroller 
  **/
 function eventSelfDelProjectGitRepo(Eventcontroler $evtcl)
 {
     $goto = $evtcl->goto;
     $q = new sqlQuery($this->getDbCon());
     $q->query("delete from git_project where idgit_project='" . $evtcl->idgit_project . "' limit 1");
     $evtcl->setDisplayNext(new Display($goto));
 }
Пример #4
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));
 }
Пример #5
0
 /**
  * Event Method for Stripe Payment Process
  * test with credit card 4242424242424242
  * @param object $evtcl 
  */
 function eventProcessStripePayment(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) {
         include_once 'class/Stripe.class.php';
         include_once "stripe-lib/Stripe.php";
         $token = $evtcl->stripeToken;
         $name = $evtcl->name;
         //$email = $evtcl->email;
         $description = $name;
         $srtipecustomer_id = $evtcl->stripecustomer_id;
         if ($evtcl->tot_amt > 0) {
             $total = $evtcl->tot_amt;
         } else {
             $total = $_SESSION['do_invoice']->amt_due;
         }
         //Amount need to conver to cents
         $total = $total * 100;
         $idinvoice = $_SESSION['do_invoice']->idinvoice;
         $idcontact = $_SESSION['do_invoice']->idcontact;
         $goto = $evtcl->goto;
         $error_page = $evtcl->error_page;
         $updateStripecustomer = $evtcl->updateStripecustomer;
         $do_contact = new Contact();
         $arr_user_info = $do_contact->getContactInfo_For_Invoice($idcontact);
         $inv_info_arr = array();
         $inv_info_arr['description'] = $_SESSION['do_invoice']->description;
         $inv_info_arr['inv_num'] = $_SESSION['do_invoice']->num;
         $stripe_api_key = $evtcl->stripe_api_key;
         $payment = new StripeGateWay(false, $stripe_api_key);
         if (empty($srtipecustomer_id)) {
             $result = $payment->CreateCustomer($token, $name, $total, $email = "", $description);
         } else {
             if ($updateStripecustomer === 'Yes') {
                 $result = $payment->UpdateExistingCustomer($srtipecustomer_id, $token, $name, $total, $email = "", $description = "");
                 if ($result['update'] == 1) {
                     $payment = new StripeGateWay(false, $stripe_api_key);
                     $result = $payment->CreateCustomer($token, $name, $total, $email = "", $description);
                 }
             } else {
                 $result = $payment->ChargeExsistingCustomer($srtipecustomer_id, $total);
             }
         }
         if ($result['success'] == '1') {
             //set the amout back to $ value
             $total = $total / 100;
             //echo $result['customer_id'];die();
             //Add the customer id in to stripe details class
             if (isset($result['customer_id'])) {
                 $this->saveStripeCustomerId($_SESSION['do_invoice']->iduser, $_SESSION['do_invoice']->idcontact, $result['customer_id']);
             }
             // Display a printable receipt
             $_SESSION['in_page_message'] = _("This transaction has been approved. Thank you for your payment");
             $do_pay_log = new PaymentLog();
             $do_pay_log->addPaymentLog($result['response']['id'], "Stripe", $_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,"Stripe.com",$transactionID);// Sending to customer
             //$this->sendPaymentApprovedEmail($total,"Stripe.com",$transactionID,true); // Sending to user
             if (isset($_SESSION["upgrade"])) {
                 $do_user = new User();
                 $date = date('Y-m-d');
                 $do_user->query("update user set plan='paid', regdate = '{$date}' where iduser="******"Y-m-d"), $_SESSION['do_User']->iduser);
                 $do_ccdetails = new CcDetails();
                 $do_ccdetails->iduser = $_SESSION['do_User']->iduser;
                 $do_ccdetails->token = $result['customer_id'];
                 $do_ccdetails->type = 'Stripe';
                 $do_ccdetails->add();
                 $goto = 'index.php';
                 unset($_SESSION['upgrade']);
             } else {
                 /*
                   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", "Stripe", $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);
             }
             //$goto = $next_url;
             $_SESSION['autologin_paid'] = True;
         } else {
             $rr = json_decode($result, true);
             //echo'<pre>';print_r($rr);echo'</pre>';die();
             $r = $rr['error']['message'];
             $error_code = $rr['error']['code'];
             $error_type = $rr['error']['type'];
             if ($error_code == 'invalid_expiry_month' || $error_code == 'invalid_expiry_year' || $error_code == 'expired_card' || $error_code == 'missing') {
                 $goto = $error_page;
                 $_SESSION['updatecustomer'] = 'Yes';
             } elseif ($error_type == 'invalid_request_error') {
                 $goto = $error_page;
                 $_SESSION['updatecustomer'] = 'Yes';
             }
             $_SESSION['in_page_message'] = $r;
         }
     }
     $disp_next = new Display($goto);
     if (isset($_SESSION['upgrade'])) {
         $msg = "Thank You . Your payment has been apporved and now you are paid user.";
         $disp_next->addParam("message", $msg);
     }
     $evtcl->setDisplayNext($disp_next);
 }