if (function_exists($params['paymentmethod'] . "_3dsecure")) { $params['cccvv'] = $cccvv; $buttoncode = call_user_func($params['paymentmethod'] . "_3dsecure", $params); $buttoncode = str_replace("<form", "<form target=\"3dauth\"", $buttoncode); $smartyvalues['code'] = $buttoncode; $smartyvalues['width'] = "400"; $smartyvalues['height'] = "500"; if ($buttoncode == "success" || $buttoncode == "declined") { $result = $buttoncode; } else { $templatefile = "3dsecure"; outputClientArea($templatefile); exit; } } else { $result = captureCCPayment($invoiceid, $cccvv, true); } if ($params['paymentmethod'] == "offlinecc") { sendAdminNotification("account", "Offline Credit Card Payment Submitted", "<p>An offline credit card payment has just been submitted. Details are below:</p><p>Client ID: " . $_SESSION['uid'] . "<br />Invoice ID: " . $invoiceid . "</p>"); redir("id=" . $invoiceid . "&offlinepaid=true", "viewinvoice.php"); } if ($result == "success") { redir("id=" . $invoiceid . "&paymentsuccess=true", "viewinvoice.php"); exit; } else { $errormessage = "<li>" . $_LANG['creditcarddeclined']; $action = ""; if ($ccinfo == "new") { updateCCDetails($_SESSION['uid'], "", "", "", "", ""); } }
* @ Version : 5.2.15 * @ Author : MTIMER * @ Release on : 2013-12-24 * @ Website : http://www.mtimer.cn * **/ if (!defined("WHMCS")) { exit("This file cannot be accessed directly"); } if (!function_exists("captureCCPayment")) { require ROOTDIR . "/includes/ccfunctions.php"; } if (!function_exists("getClientsDetails")) { require ROOTDIR . "/includes/clientfunctions.php"; } if (!function_exists("processPaidInvoice")) { require ROOTDIR . "/includes/invoicefunctions.php"; } $result = select_query("tblinvoices", "id", array("id" => $invoiceid, "status" => "Unpaid")); $data = mysql_fetch_array($result); $invoiceid = $data['id']; if (!$invoiceid) { $apiresults = array("result" => "error", "message" => "Invoice Not Found or Not Unpaid"); return 1; } $result = captureCCPayment($invoiceid, $cvv); if ($result) { $apiresults = array("result" => "success"); return 1; } $apiresults = array("result" => "error", "message" => "Payment Attempt Failed");
if ($data[0] || $data[1]) { logActivity("Admin Initiated Payment Capture - Invoice ID: " . $id, $userid); if (captureCCPayment($id)) { infoBox($aInt->lang("invoices", "capturesuccessful"), $aInt->lang("invoices", "capturesuccessfulmsg"), "success"); } else { infoBox($aInt->lang("invoices", "captureerror"), $aInt->lang("invoices", "captureerrormsg"), "error"); } } else { infoBox($aInt->lang("invoices", "captureerror"), "No Credit Card Details are stored for this client so the capture could not be attempted", "info"); } } if ($sub == "initiatepayment") { check_token("WHMCS.admin.default"); $data = get_query_vals("tblclients", "gatewayid", array("id" => $userid)); logActivity("Admin Initiated Payment Attempt - Invoice ID: " . $id, $userid); if (captureCCPayment($id)) { infoBox($aInt->lang("invoices", "initiatepaymentsuccessful"), $aInt->lang("invoices", "initiatepaymentsuccessfulmsg"), "success"); } else { infoBox($aInt->lang("invoices", "initiatepaymenterror"), $aInt->lang("invoices", "initiatepaymenterrormsg"), "error"); } } } if ($sub == "refund" && $transid) { check_token("WHMCS.admin.default"); checkPermission("Refund Invoice Payments"); logActivity("Admin Initiated Refund - Invoice ID: " . $id . " - Transaction ID: " . $transid); if ($refundtype == "sendtogateway") { $sendtogateway = true; } else { if ($refundtype == "addascredit") { $addascredit = true;
function ccProcessing() { global $whmcs; global $cron; $chargedate = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $whmcs->get_config("CCProcessDaysBefore"), date("Y"))); $chargedates = array(); if (!$whmcs->get_config("CCAttemptOnlyOnce")) { $i = 1; while ($i <= $whmcs->get_config("CCRetryEveryWeekFor")) { $chargedates[] = "tblinvoices.duedate='" . date("Ymd", mktime(0, 0, 0, date("m"), date("d") - $i * 7 + $whmcs->get_config("CCProcessDaysBefore"), date("Y"))) . "'"; ++$i; } } $qrygateways = array(); $query = "SELECT gateway FROM tblpaymentgateways WHERE setting='type' AND value='CC'"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { $qrygateways[] = "tblinvoices.paymentmethod='" . db_escape_string($data['gateway']) . "'"; } if (count($qrygateways)) { $z = $y = 0; $query = "SELECT tblinvoices.* FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.userid WHERE (tblinvoices.status='Unpaid') AND (" . implode(" OR ", $qrygateways) . ") AND tblclients.disableautocc='' AND (tblinvoices.duedate='" . $chargedate . "'"; if (!$whmcs->get_config("CCAttemptOnlyOnce")) { if (0 < count($chargedates)) { $query .= " OR " . implode(" OR ", $chargedates); } else { $query .= " OR tblinvoices.duedate<'" . $chargedate . "'"; } } $query .= ")"; $result = full_query($query); while ($data = mysql_fetch_array($result)) { if (is_object($cron)) { $cron->logActivityDebug("Processing Capture for Invoice #" . $data['id']); } else { logActivity("Processing Capture for Invoice #" . $data['id']); } if (captureCCPayment($data['id'])) { ++$z; if (is_object($cron)) { $cron->logActivityDebug("Capture Successful"); } logActivity("Capture Successful"); } ++$y; if (is_object($cron)) { $cron->logActivityDebug("Capture Failed"); } logActivity("Capture Failed"); } if (is_object($cron)) { $cron->logActivity("Credit Card Payments Processed (" . $z . " Captured, " . $y . " Failed)", true); $cron->emailLog($z . " Credit Card Payments Processed (" . $y . " Failed)"); } else { logActivity("Credit Card Payments Processed (" . $z . " Captured, " . $y . " Failed)"); } return "" . $z . " Captured, " . $y . " Failed"; } return false; }