| Server IP : 10.200.247.200 / Your IP : 216.73.216.64 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/pcisecureform.com/php/ |
Upload File : |
<?php
//require_once("/var/www/surfcrm.com/php/Logger.php");
define("APPROVED", 1);
define("DECLINED", 2);
define("ERROR", 3);
class gwapi {
// Initial Setting Functions
function setLogin($username, $password, $proc_id) {/*{{{*/
$this->login['username'] = $username;
$this->login['password'] = $password;
$this->login['proc_id'] = $proc_id;
}/*}}}*/
function setOrder($orderid,
$orderdescription,
$tax,
$shipping,
$ponumber,
$ipaddress) {/*{{{*/
$this->order['orderid'] = $orderid;
$this->order['orderdescription'] = $orderdescription;
$this->order['tax'] = $tax;
$this->order['shipping'] = $shipping;
$this->order['ponumber'] = $ponumber;
$this->order['ipaddress'] = $ipaddress;
}/*}}}*/
function setBilling($firstname,
$lastname,
$company,
$address1,
$address2,
$city,
$state,
$zip,
$country,
$phone,
$fax,
$email,
$website) {/*{{{*/
$this->billing['firstname'] = $firstname;
$this->billing['lastname'] = $lastname;
$this->billing['company'] = $company;
$this->billing['address1'] = $address1;
$this->billing['address2'] = $address2;
$this->billing['city'] = $city;
$this->billing['state'] = $state;
$this->billing['zip'] = $zip;
$this->billing['country'] = $country;
$this->billing['phone'] = $phone;
$this->billing['fax'] = $fax;
$this->billing['email'] = $email;
$this->billing['website'] = $website;
}/*}}}*/
function setShipping($firstname,
$lastname,
$company,
$address1,
$address2,
$city,
$state,
$zip,
$country,
$email) {/*{{{*/
$this->shipping['firstname'] = $firstname;
$this->shipping['lastname'] = $lastname;
$this->shipping['company'] = $company;
$this->shipping['address1'] = $address1;
$this->shipping['address2'] = $address2;
$this->shipping['city'] = $city;
$this->shipping['state'] = $state;
$this->shipping['zip'] = $zip;
$this->shipping['country'] = $country;
$this->shipping['email'] = $email;
}/*}}}*/
// Transaction Functions
function doSale($amount, $ccnumber, $ccexp, $cvv="") {/*{{{*/
if(empty($this->order['tax'])) {
$this->order['tax'] = 0;
}
if(empty($this->order['shipping'])) {
$this->order['shipping'] = 0;
}
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Sales Information
$query .= "ccnumber=" . urlencode($ccnumber) . "&";
$query .= "ccexp=" . urlencode($ccexp) . "&";
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
$query .= "cvv=" . urlencode($cvv) . "&";
// Order Information
$query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
$query .= "orderid=" . urlencode($this->order['orderid']) . "&";
$query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
$query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
$query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
$query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
// Billing Information
$query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
$query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
$query .= "company=" . urlencode($this->billing['company']) . "&";
$query .= "address1=" . urlencode($this->billing['address1']) . "&";
$query .= "address2=" . urlencode($this->billing['address2']) . "&";
$query .= "city=" . urlencode($this->billing['city']) . "&";
$query .= "state=" . urlencode($this->billing['state']) . "&";
$query .= "zip=" . urlencode($this->billing['zip']) . "&";
$query .= "country=" . urlencode($this->billing['country']) . "&";
$query .= "phone=" . urlencode($this->billing['phone']) . "&";
$query .= "fax=" . urlencode($this->billing['fax']) . "&";
$query .= "email=" . urlencode($this->billing['email']) . "&";
$query .= "website=" . urlencode($this->billing['website']) . "&";
// Shipping Information
$query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
$query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
$query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
$query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
$query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
$query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
$query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
$query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
$query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
$query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
$query .= "type=sale";
return $this->_doPost($query);
}/*}}}*/
function doACH($amount, $checkname, $routing_number, $account_number) {/*{{{*/
if(empty($this->order['tax'])) {
$this->order['tax'] = 0;
}
if(empty($this->order['shipping'])) {
$this->order['shipping'] = 0;
}
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Sales Information
$query .= "checkname=" . urlencode($checkname) . "&";
$query .= "checkaba=" . urlencode($routing_number) . "&";
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
$query .= "checkaccount=" . urlencode($account_number) . "&";
$query .= "payment=check&";
// Order Information
$query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
$query .= "orderid=" . urlencode($this->order['orderid']) . "&";
$query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
$query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
$query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
$query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
// Billing Information
$query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
$query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
$query .= "company=" . urlencode($this->billing['company']) . "&";
$query .= "address1=" . urlencode($this->billing['address1']) . "&";
$query .= "address2=" . urlencode($this->billing['address2']) . "&";
$query .= "city=" . urlencode($this->billing['city']) . "&";
$query .= "state=" . urlencode($this->billing['state']) . "&";
$query .= "zip=" . urlencode($this->billing['zip']) . "&";
$query .= "country=" . urlencode($this->billing['country']) . "&";
$query .= "phone=" . urlencode($this->billing['phone']) . "&";
$query .= "fax=" . urlencode($this->billing['fax']) . "&";
$query .= "email=" . urlencode($this->billing['email']) . "&";
$query .= "website=" . urlencode($this->billing['website']) . "&";
// Shipping Information
$query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
$query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
$query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
$query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
$query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
$query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
$query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
$query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
$query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
$query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
$query .= "type=sale";
return $this->_doPost($query);
}/*}}}*/
function doAuth($amount, $ccnumber, $ccexp, $cvv="") {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Sales Information
$query .= "ccnumber=" . urlencode($ccnumber) . "&";
$query .= "ccexp=" . urlencode($ccexp) . "&";
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
$query .= "cvv=" . urlencode($cvv) . "&";
// Order Information
$query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
$query .= "orderid=" . urlencode($this->order['orderid']) . "&";
$query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
$query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
$query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
$query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
// Billing Information
$query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
$query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
$query .= "company=" . urlencode($this->billing['company']) . "&";
$query .= "address1=" . urlencode($this->billing['address1']) . "&";
$query .= "address2=" . urlencode($this->billing['address2']) . "&";
$query .= "city=" . urlencode($this->billing['city']) . "&";
$query .= "state=" . urlencode($this->billing['state']) . "&";
$query .= "zip=" . urlencode($this->billing['zip']) . "&";
$query .= "country=" . urlencode($this->billing['country']) . "&";
$query .= "phone=" . urlencode($this->billing['phone']) . "&";
$query .= "fax=" . urlencode($this->billing['fax']) . "&";
$query .= "email=" . urlencode($this->billing['email']) . "&";
$query .= "website=" . urlencode($this->billing['website']) . "&";
// Shipping Information
$query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
$query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
$query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
$query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
$query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
$query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
$query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
$query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
$query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
$query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
$query .= "type=auth";
return $this->_doPost($query);
}/*}}}*/
function doCredit($amount, $ccnumber, $ccexp) {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Sales Information
$query .= "ccnumber=" . urlencode($ccnumber) . "&";
$query .= "ccexp=" . urlencode($ccexp) . "&";
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
// Order Information
$query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
$query .= "orderid=" . urlencode($this->order['orderid']) . "&";
$query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
$query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
$query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
$query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
// Billing Information
$query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
$query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
$query .= "company=" . urlencode($this->billing['company']) . "&";
$query .= "address1=" . urlencode($this->billing['address1']) . "&";
$query .= "address2=" . urlencode($this->billing['address2']) . "&";
$query .= "city=" . urlencode($this->billing['city']) . "&";
$query .= "state=" . urlencode($this->billing['state']) . "&";
$query .= "zip=" . urlencode($this->billing['zip']) . "&";
$query .= "country=" . urlencode($this->billing['country']) . "&";
$query .= "phone=" . urlencode($this->billing['phone']) . "&";
$query .= "fax=" . urlencode($this->billing['fax']) . "&";
$query .= "email=" . urlencode($this->billing['email']) . "&";
$query .= "website=" . urlencode($this->billing['website']) . "&";
$query .= "type=credit";
return $this->_doPost($query);
}/*}}}*/
function doOffline($authorizationcode, $amount, $ccnumber, $ccexp) {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Sales Information
$query .= "ccnumber=" . urlencode($ccnumber) . "&";
$query .= "ccexp=" . urlencode($ccexp) . "&";
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
$query .= "authorizationcode=" . urlencode($authorizationcode) . "&";
// Order Information
$query .= "ipaddress=" . urlencode($this->order['ipaddress']) . "&";
$query .= "orderid=" . urlencode($this->order['orderid']) . "&";
$query .= "orderdescription=" . urlencode($this->order['orderdescription']) . "&";
$query .= "tax=" . urlencode(number_format($this->order['tax'],2,".","")) . "&";
$query .= "shipping=" . urlencode(number_format($this->order['shipping'],2,".","")) . "&";
$query .= "ponumber=" . urlencode($this->order['ponumber']) . "&";
// Billing Information
$query .= "firstname=" . urlencode($this->billing['firstname']) . "&";
$query .= "lastname=" . urlencode($this->billing['lastname']) . "&";
$query .= "company=" . urlencode($this->billing['company']) . "&";
$query .= "address1=" . urlencode($this->billing['address1']) . "&";
$query .= "address2=" . urlencode($this->billing['address2']) . "&";
$query .= "city=" . urlencode($this->billing['city']) . "&";
$query .= "state=" . urlencode($this->billing['state']) . "&";
$query .= "zip=" . urlencode($this->billing['zip']) . "&";
$query .= "country=" . urlencode($this->billing['country']) . "&";
$query .= "phone=" . urlencode($this->billing['phone']) . "&";
$query .= "fax=" . urlencode($this->billing['fax']) . "&";
$query .= "email=" . urlencode($this->billing['email']) . "&";
$query .= "website=" . urlencode($this->billing['website']) . "&";
// Shipping Information
$query .= "shipping_firstname=" . urlencode($this->shipping['firstname']) . "&";
$query .= "shipping_lastname=" . urlencode($this->shipping['lastname']) . "&";
$query .= "shipping_company=" . urlencode($this->shipping['company']) . "&";
$query .= "shipping_address1=" . urlencode($this->shipping['address1']) . "&";
$query .= "shipping_address2=" . urlencode($this->shipping['address2']) . "&";
$query .= "shipping_city=" . urlencode($this->shipping['city']) . "&";
$query .= "shipping_state=" . urlencode($this->shipping['state']) . "&";
$query .= "shipping_zip=" . urlencode($this->shipping['zip']) . "&";
$query .= "shipping_country=" . urlencode($this->shipping['country']) . "&";
$query .= "shipping_email=" . urlencode($this->shipping['email']) . "&";
$query .= "type=offline";
return $this->_doPost($query);
}/*}}}*/
function doCapture($transactionid, $amount =0) {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Transaction Information
$query .= "transactionid=" . urlencode($transactionid) . "&";
if ($amount>0) {
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
}
$query .= "type=capture";
return $this->_doPost($query);
}/*}}}*/
function doVoid($transactionid) {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Transaction Information
$query .= "transactionid=" . urlencode($transactionid) . "&";
$query .= "type=void";
return $this->_doPost($query);
}/*}}}*/
function doRefund($transactionid, $amount = 0) {/*{{{*/
$query = "";
// Login Information
$query .= "username=" . urlencode($this->login['username']) . "&";
$query .= "password=" . urlencode($this->login['password']) . "&";
// Transaction Information
$query .= "transactionid=" . urlencode($transactionid) . "&";
if ($amount>0) {
$query .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
}
$query .= "type=refund";
return $this->_doPost($query);
}/*}}}*/
// sends the request to the gateway for processing
function _doPost($query) {/*{{{*/
$c_url = "https://secure.networkmerchants.com/api/transact.php";
if ($this->login['username'] == 'synergyAPI' || $this->login['username'] == 'usagrantAPI' || $this->login['username'] == 'asfap')
{
$query = "processor_id=".$this->login['proc_id']."&".$query;
}
//message log
//$message_log = __METHOD__."() ".__FILE__." POST URL: ".$c_url." POST QUERY: ".$query;
/*$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $c_url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_POST, 1);
if (!($data = curl_exec($ch))) {
//$message_log .= " cURL Error: ".$cerror."\n";
//LogProcessorMessage($message_log);
return ERROR;
}
curl_close($ch);
unset($ch);
*/
$data = shell_exec('curl --tlsv1.2 --data "'.$query.'" '.$c_url);
//add the processor result to the debug message
//$message_log .= " RAW RESULT: ".$data;
$data = explode("&",$data);
for($i=0;$i<count($data);$i++) {
$rdata = explode("=",$data[$i]);
$this->responses[$rdata[0]] = $rdata[1];
}
if(empty($data)) {
mail('jeremy@synergytpsreports.com,heinz57@gmail.com','NMI refund empty debug',$query,"NoReply@surfcrm.com\r\n");
}
if($this->responses['response'] == '3' && $this->responses['responsetext'] == 'Authentication Failed') {
include_once($_SERVER['DOCUMENT_ROOT'].'/php/twilio_usa.php');
send_text('4358623428','NMI stopped working because we need to pay the merchant fees.');
send_text('4352295757','NMI stopped working because we need to pay the merchant fees.');
include_once('/var/www/surfcrm.com/php/mailgun.php');
mailgun_send_message('jeremy@usbusinessfundingsolutions.com','NoReply@surfcrm.com','NMI authentication failed','We sent: <pre>'.print_r($query,true).'</pre> They sent: <pre>'.print_r($this->responses,true).'</pre> File hit: '.$_SERVER['SCRIPT_FILENAME'],1,'NMI authentication issue');
}
//include our transaction response in the message and send it
//LogProcessorMessage($message_log);
return $this->responses['response'];
}/*}}}*/
}
?>