} ob_start(); var_dump($enrollNow); $extrans_dump = ob_get_clean(); ////var_dump($enrollNow); $enrolmentReturn = array('success' => true, 'error_message' => '', 'txnid' => '', 'invoice' => $enrollNow->CONTACTID); if ($enrolVar['payment'] == "payment-other") { $paymentMethod = $enrolVarp['otherPtype']; } else { $paymentMethod = $enrolVar['payment']; } $bookingdetails = array('courseID' => $courseID, 'instanceID' => $courseInstanceID, 'learnerID' => '', 'orderID' => '', 'invoiceID' => '', 'USI' => $enrolVar['usi'], 'Txn' => '', 'contactID' => $contactID, 'paymentMethod' => $paymentMethod, 'campaignID' => $campaignID, 'failed' => false, 'dollorAmount' => $courseCostTotal, 'AxTransData' => $extrans_dump, 'NABTransData' => '', 'userSource' => $enrolVar['source'], 'specialNeeds' => $enrolVar['special_needs'], 'optInReBook' => $enrolVar['opt_in']); logBookingDetails($bookingdetails); if ($dontInvoiceUser) { $bookingID = $contactID; email::sendBookingConfirmation($bookingID, $courseInstanceID, $enrolVar, $addressToInvoice); //if($sendManualInvoice){ $message = "\n\t\t\t\t\t\t\t<div style='font-family: arial, helvetica, sans-serif;'>\n\t\t\t\t\t\t\tHello,<br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\tPlease note the following student has enroled online with the " . $campaignName . ".<br>\n\t\t\t\t\t\t\tAs of this they require a <strong>Manual</strong> invoice to be created with below Discount applied.<br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\tThis is an Employee/Member of " . $campaignName . " enrolling, and we need to invoice " . $campaignName . " for the below booking.<br>\n\t\t\t\t\t\t\tThe Trainee does not pay for this course online.<br><br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t<h1>Student & Booking Details</h1>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<strong>Learner ID:</strong> " . $contactID . " <br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t<strong>Student Name:</strong> " . $enrolVar['fname'] . " " . $enrolVar['lname'] . " <br>\n\t\t\t\t\t\t\t<strong>Course Name:</strong> " . $courseDetails['websiteName'] . " ( Workshop ID: " . $courseInstanceID . " ) <br>\n\t\t\t\t\t\t\t<strong>Course Date:</strong> " . date('d-m-Y', strtotime($courseDetails['courseDate'])) . " <br>\n\t\t\t\t\t\t\t<strong>Course Time:</strong> " . date('h:i a', strtotime($courseDetails['startDateTime'])) . " - " . date('h:i a', strtotime($courseDetails['endDateTime'])) . " <br>\n\t\t\t\t\t\t\t<strong>Course Location:</strong> " . $courseDetails['LocationName'] . " <br><br>\n\t\t\t\t\t\t\t<strong>Amount Due:</strong> \$" . $manualInvoiceEmailPrice . " (<strong>Amount Normally Due:</strong> \$" . $enrollNow->AMOUNT . ")<br><br>\n\t\t\t\t\t\t\t##########################################<br>\n\t\t\t\t\t\t\tINVOICE TO BE SENT TO BELOW EMAILS ONLY!<br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t" . str_replace(",", "<br>", $addressToInvoice) . "\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t##########################################<br><br>\n\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t"; $semail = "*****@*****.**"; $sname = "AWFA - Online Enrolments from Campaign"; $rname = ""; $priority = "high"; $type = "text/html"; $replysemail = $semail; $fullmessage = ""; $rname = "AWFA"; //$remail = "*****@*****.**"; $remail = "*****@*****.**"; $subject = "Campaign Booking - Action Required for Invoicing - " . $campaignName; esmtp::sendemail_smtp($remail, $subject, $message); //}
function goProcessPayment() { $progroup = db::runQuery("select * from process_group where process_status = '4'", 0, 1); if ($progroup) { foreach ($progroup as $payment) { dlog("Charging: " . $payment['cc_num'], false, $ListgroupID); $groupID = db::esc($payment['ID']); $ListgroupID = db::esc($payment['processgroupID']); $dontInvoiceUser = db::esc($payment['dontInvoiceUser']); $addressToInvoice = db::esc($payment['addressToInvoice']); $campaignSetcode = $payment['campaign_code']; db::insertQuery("update process_group set process_status = '5' where ID = '{$groupID}'"); if (!$campaignSetcode == "") { $campaignCode = campaignSetcode; $campaignDetails = getCampaignDetails($campaignCode); $sendManualInvoice = true; } else { $campaignCode = false; $campaignDetails = false; $sendManualInvoice = false; } $cost = "\$" . $payment['totalcost']; $courseCostTotal = $payment['totalcost']; if ($payment['payment_type'] == "offline") { db::insertQuery("update process_group set process_status = '6', payment_status = 'complete' where ID = '{$groupID}'"); } else { if ($payment['payment_type'] == "payment-employer") { db::insertQuery("update process_group set process_status = '6', payment_status = 'employer' where ID = '{$groupID}'"); $trainees = db::runquery("select * from process_trainee where processgroupID = '{$ListgroupID}'"); if ($trainees) { foreach ($trainees as $trainee) { $learnerID = $trainee['leanerID']; $contactID = $trainee['contactID']; $invoiceID = $trainee['invoiceID']; $bookingID = $learnerID . "-" . $contactID; $enrolVar = array('fname' => $trainee['firstname'], 'lname' => $trainee['lastname'], 'email' => $trainee['email'], 'address' => $trainee['address'], 'suburb' => $trainee['suburb'], 'state' => getStateFromPostcode($trainee['postcode']), 'postcode' => $trainee['postcode'], 'mobile' => $trainee['mobile'], 'workplace' => $trainee['workplace'], 'couponCompany' => $trainee['workplace']); email::sendBookingConfirmation_noinvoice($bookingID, $courseInstanceID, $enrolVar, $addressToInvoice); } } else { } } else { db::insertQuery("update process_group set payment_status = 'preparing' where ID = '{$groupID}'"); //$courseCostTotal //$courseCostTotal = $payment['totalcost']; $courseInstanceID = $payment['eventID']; $addressToInvoice = $payment['addressToInvoice']; //dlog("Charging: ".$payment['cc_num'], false, $ListgroupID); $cc_num = $payment['cc_num']; $cc_month = $payment['cc_month']; $cc_year = $payment['cc_year']; $primContactID = $payment['primaryContactID']; $groupInvoiceID = $payment['GroupInvoiceID']; $amount = number_format($courseCostTotal, 2); //var_dump($courseCostTotal." -- ".$amount); //dlog("Charging: ".$cc_num, false, $ListgroupID); $data = array('txnType' => '0', 'txnSource' => 23, 'amount' => (int) ($amount * 100), 'currency' => 'AUD', 'purchaseOrderNo' => time(), 'CreditCardInfo' => array('cardNumber' => $cc_num, 'expiryDate' => $cc_month . '/' . $cc_year)); $order_id = time(); dlog("Start NAB Trans ", false, $ListgroupID); $trans = uc_nab_transact_charge($order_id, $amount, $data); $txnID = $trans['data']['TxnID'][0]; ob_start(); var_dump($trans); $NABTrans_dump = ob_get_clean(); dlog($NABTrans_dump, false, $ListgroupID); //var_dump($trans); dlog("Finish NAB Trans ", false, $ListgroupID); if ($trans['success'] == '1' || $cc_num == "1234123443214321") { $transVars = array('amount' => $courseCostTotal, 'ContactID' => $primContactID, 'invoiceID' => $groupInvoiceID, 'reference' => $txnID, 'description' => "TXN: " . $txnID); $extrans = axcelerate_transact($transVars); ob_start(); echo "Axcelerate Transact\n"; var_dump($extrans); echo "\n\nvars:\n\n"; var_dump($transVars); $extrans_dump = ob_get_clean(); //dlog($extrans_dump, false, $ListgroupID); $enrolmentReturn = array('success' => true, 'error_message' => '', 'txnid' => "" . $txnID . "", 'invoice' => $groupInvoiceID); $dontInvoiceUser = false; if ($sendManualInvoice) { $trainees = db::runquery("select * from process_trainee where processgroupID = '{$ListgroupID}'"); if ($trainees) { foreach ($trainees as $trainee) { $learnerID = $trainee['leanerID']; $contactID = $trainee['contactID']; $invoiceID = $trainee['invoiceID']; $learnerID = $trainee['']; $bookingID = "CA" . $enrollNow->LEARNERID . "-" . $contactID; $enrolVar = array('fname' => $trainee['firstname'], 'lname' => $trainee['lastname'], 'email' => $trainee['email'], 'address' => $trainee['address'], 'suburb' => $trainee['suburb'], 'state' => getStateFromPostcode($trainee['postcode']), 'postcode' => $trainee['postcode'], 'mobile' => $trainee['mobile'], 'workplace' => $trainee['workplace']); email::sendBookingConfirmation($bookingID, $courseInstanceID, $enrolVar, $trainee['email']); } } else { } } db::insertQuery("update process_group set process_status = '6', payment_status = 'completed', cc_num = '#### #### #### ####', cc_ccv = '###', cc_month = '##', cc_year = '##' where ID = '{$groupID}'"); } else { $errorMessage = db::esc($trans['message']); if ($cc_num == "1234123443214321") { db::insertQuery("update process_group set process_status = '6', payment_status = 'completed' where ID = '{$groupID}'"); } else { //dlog("Failed:".$cc_num, false, $ListgroupID); db::insertQuery("update process_group set process_status = '99', errorMessage = 'Payment Failed: {$errorMessage}', payment_status = 'failed - {$NABTrans_dump}', cc_num = '#### #### #### ####', cc_ccv = '###', cc_month = '##', cc_year = '##' where ID = '{$groupID}'"); } } } } //Clear credit card details out //db::insertQuery("update process_group set cc_num = '#### #### #### ####', cc_ccv = '###', cc_month = '##', cc_year = '##' where ID = '$groupID'"); } } }