예제 #1
0
 function sendBookingConfirmation($bookingID, $instanceID, $enrolVar, $ccEmail = false)
 {
     $enrolVar['state'] = getStateFromPostcode($enrolVar['postcode']);
     //$instanceID = "161835";
     $courseDetailObj = getEventDetails($instanceID);
     $courseDetails['name'] = $courseDetailObj['websiteName'];
     $courseDetails['date'] = date("l", strtotime($courseDetailObj['courseDate'])) . "<br>" . date("j", strtotime($courseDetailObj['courseDate'])) . "<sup>" . date("S", strtotime($courseDetailObj['courseDate'])) . "</sup> " . date("F Y", strtotime($courseDetailObj['courseDate']));
     $courseDetails['date_nb'] = date("l", strtotime($courseDetailObj['courseDate'])) . " " . date("j", strtotime($courseDetailObj['courseDate'])) . "<sup>" . date("S", strtotime($courseDetailObj['courseDate'])) . "</sup> " . date("F Y", strtotime($courseDetailObj['courseDate']));
     $courseDetails['time'] = date("g:i a", strtotime($courseDetailObj['startDateTime'])) . " to " . date("g:i a", strtotime($courseDetailObj['endDateTime']));
     $courseDetails['location'] = str_replace(", ", "<br>", str_replace("\n", "<br>", $courseDetailObj['StreetAddress']));
     $courseDetails['maplink'] = "https://www.google.com.au/maps?q=" . str_replace(" ", "+", str_replace("\n", " ", $courseDetailObj['StreetAddress']));
     //var_dump($courseDetails);
     //die();
     $emailKey = sha1(date("r", strtotime("now")) . generateRandomString(5) . $bookingID . $instanceID);
     //$bookingID = "123456789-123456789";
     $viewonlinelink = "https://www.australiawidefirstaid.com.au/email/?k=" . $emailKey;
     $livedata = $enrolVar['fname'] . " " . $enrolVar['lname'] . "|" . $enrolVar['email'] . "|" . $bookingID;
     $livechatURL = "https://www.australiawidefirstaid.com.au/?livechat=true&data=" . base64_encode($livedata);
     $html = getEmailTemplate("template_CouponEmailConfirmation_generic.htm");
     $html = varReplace("bookingID", $bookingID, $html);
     $html = varReplace("emailviewlink", $viewonlinelink, $html);
     $html = varReplace("livechatURL", $livechatURL, $html);
     $html = varReplace("user.firstname", $enrolVar['fname'], $html);
     $html = varReplace("user.lastname", $enrolVar['lname'], $html);
     $html = varReplace("user.address", $enrolVar['address'], $html);
     $html = varReplace("user.suburb", $enrolVar['suburb'], $html);
     $html = varReplace("user.state", $enrolVar['state'], $html);
     $html = varReplace("user.postcode", $enrolVar['postcode'], $html);
     $html = varReplace("user.phone", $enrolVar['mobile'], $html);
     $html = varReplace("user.email", $enrolVar['email'], $html);
     $html = varReplace("user.orginisation", $enrolVar['workplace'], $html);
     $html = varReplace("course.name", $courseDetails['name'], $html);
     $html = varReplace("course.date", $courseDetails['date'], $html);
     $html = varReplace("course.date_nb", $courseDetails['date_nb'], $html);
     $html = varReplace("course.time", $courseDetails['time'], $html);
     $html = varReplace("course.location", $courseDetails['location'], $html);
     $html = varReplace("course.maplink", $courseDetails['maplink'], $html);
     $message = $html;
     $semail = "*****@*****.**";
     $sname = "Australia Wide First Aid";
     $rname = "";
     $priority = "high";
     $type = "text/html";
     $replysemail = $semail;
     $fullmessage = "";
     //$remail = "*****@*****.**";
     $remail = $enrolVar['email'];
     $subject = "First Aid Course Booking Confirmation - " . $enrolVar['fname'] . " " . $enrolVar['lname'] . " - " . $enrolVar['workplace'];
     email::logEmail($remail, "", $ccEmail, $subjet, $message, $bookingID, $instanceID, $emailKey);
     esmtp::sendemail_smtp($remail, $subject, $message, $ccEmail);
 }
예제 #2
0
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'");
        }
    }
}