$clientstate = $data['state']; $clientcountry = $data['country']; $date = fromMySQLDate($date); $duedate = fromMySQLDate($duedate); $datepaid = fromMySQLDate($datepaid, "time"); if (!$id) { $aInt->gracefulExit("Invoice ID Not Found"); } $currency = getCurrency($userid); $result = select_query("tblaccounts", "COUNT(id),SUM(amountin)-SUM(amountout)", array("invoiceid" => $id)); $data = mysql_fetch_array($result); $transcount = $data[0]; $amountpaid = $data[1]; $balance = $total - $amountpaid; $balance = $rawbalance = sprintf("%01.2f", $balance); loadGatewayModule($paymentmethod); if ($status == "Unpaid") { $paymentmethodfriendly = $gatewaysarray[$paymentmethod]; } else { if ($transcount == 0) { $paymentmethodfriendly = $aInt->lang("invoices", "notransapplied"); } else { $paymentmethodfriendly = $gatewaysarray[$paymentmethod]; } } if (0 < $credit) { if ($total == 0) { $paymentmethodfriendly = $aInt->lang("invoices", "fullypaidcredit"); } else { $paymentmethodfriendly .= " + " . $aInt->lang("invoices", "partialcredit"); }
function getGatewayVariables($gateway, $invoiceid = "", $amount = "0.00") { global $whmcs; global $CONFIG; global $_LANG; global $clientsdetails; $res = loadGatewayModule($gateway); if (!$res) { exit("Gateway Module '" . $gateway . "' is Missing or Invalid"); } $gateway = WHMCS_Gateways::makesafename($gateway); if (!function_exists($gateway . "_link")) { eval("function " . $gateway . "_link({$params}) { return '<form method=\"post\" action=\"" . $params['systemurl'] . "/creditcard.php\" name=\"paymentfrm\"><input type=\"hidden\" name=\"invoiceid\" value=\"" . $params['invoiceid'] . "\"><input type=\"submit\" value=\"" . $params['langpaynow'] . "\"></form>'; }"); } $GATEWAY = array(); $GATEWAY['paymentmethod'] = $gateway; $result = select_query("tblpaymentgateways", "", array("gateway" => $gateway)); while ($data = mysql_fetch_array($result)) { $gVgwsetting = $data['setting']; $gVgwvalue = $data['value']; $GATEWAY["" . $gVgwsetting] = "" . $gVgwvalue; } $GATEWAY['companyname'] = $CONFIG['CompanyName']; if ($CONFIG['SystemSSLURL']) { $GATEWAY['systemurl'] = $CONFIG['SystemSSLURL']; } else { $GATEWAY['systemurl'] = $CONFIG['SystemURL']; } $GATEWAY['returnurl'] = $GATEWAY['systemurl']; $GATEWAY['langpaynow'] = $_LANG['invoicespaynow']; if ($invoiceid) { $clientsdetails['fullstate'] = $clientsdetails['state']; if (!function_exists("convertStateToCode")) { require ROOTDIR . "/includes/clientfunctions.php"; } $clientsdetails['state'] = convertStateToCode($clientsdetails['state'], $clientsdetails['country']); $result = select_query("tblclients", "tblinvoices.invoicenum,tblclients.currency,tblcurrencies.code", array("tblinvoices.id" => $invoiceid), "", "", "", "tblinvoices ON tblinvoices.userid=tblclients.id INNER JOIN tblcurrencies ON tblcurrencies.id=tblclients.currency"); $data = mysql_fetch_array($result); $invoicenum = $data['invoicenum']; $invoice_currency_id = $data['currency']; $invoice_currency_code = $data['code']; if (!trim($invoicenum)) { $invoicenum = $invoiceid; } $GATEWAY['description'] = $CONFIG['CompanyName'] . " - " . $_LANG['invoicenumber'] . $invoicenum; $GATEWAY['invoiceid'] = $invoiceid; $GATEWAY['clientdetails'] = $clientsdetails; $GATEWAY['returnurl'] = $GATEWAY['systemurl'] . "/viewinvoice.php?id=" . $invoiceid; if ($GATEWAY['convertto']) { $result = select_query("tblcurrencies", "code", array("id" => $GATEWAY['convertto'])); $data = mysql_fetch_array($result); $converto_currency_code = $data['code']; $converto_amount = convertCurrency($amount, $invoice_currency_id, $GATEWAY['convertto']); $GATEWAY['amount'] = format_as_currency($converto_amount); $GATEWAY['currency'] = $converto_currency_code; $GATEWAY['basecurrencyamount'] = format_as_currency($amount); $GATEWAY['basecurrency'] = $invoice_currency_code; } if (!$GATEWAY['currency']) { $GATEWAY['amount'] = format_as_currency($amount); $GATEWAY['currency'] = $invoice_currency_code; } } return $GATEWAY; }