Paypal vil ikke virke efter endt betaling (Curl og PDT) altid failed betaling
Nu har jeg rodet i 4 dage proevet alt muligt og forskellige methoder til at faa mit script til at virke naar checkout er completed, men ak ak ak, altid failed.Check_out complete scriptet
<?php
error_reporting(-1);
require_once 'class2.php';
require_once (HEADERF);
Require 'databasconnect.php';
$ip= $_SERVER["REMOTE_ADDR"];
$result = mysqli_query($con,"SELECT * FROM e107_banlist where banlist_ip='".$ip."'");
while ($row=mysqli_fetch_array($result))
$ban=$row["banlist_ip"];
if ($ip==$ban){
echo "<h3>You are Banned, from use this function, if you mean this is a mistake, Please Contact admin at techboy992@yahoo.dk</h3>";
exit();
}
$id = isset($_GET['id']) ? $_GET['id'] : '';
$aff = $_GET['aff'];
$result = mysql_query("Select * FROM products WHERE id='".$id."'");
while ($row = mysql_fetch_array($result))
$product = $row["name"];
$result = mysql_query("Select * FROM products WHERE id='".$id."'");
while ($row = mysql_fetch_array($result))
$subs = $row["licences"];
$pp_hostname = "www.paypal.com"; // Change to www.sandbox.paypal.com to test against sandbox
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$auth_token = "Sample";
$req .= "&tx=$tx_token&at=$auth_token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
//set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
//if your server does not bundled with default verisign certificates.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
$res = curl_exec($ch);
curl_close($ch);
if(!$res){
//HTTP ERROR
echo $req;
echo $tx_token;
echo $auth_token;
}else{
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("Your transaction has been completed, and a receipt for your purchase has been emailed to you.<br> You may log into your account at <a href='www.paypal.com</a>" target="_blank">https://www.paypal.com'>www.paypal.com</a> to view details of this transaction.<br>");
//generate salt
function blowfishCrypt($password,$cost)
{
$chars='./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$salt=sprintf('$2a$%02d$',$cost);
//For PHP >= PHP 5.3.7 use this instead (as per martinstoeckli's suggestion)
// $salt=sprintf('$2y$%02d$',$cost);
//Create a 22 character salt -edit- 2013.01.15 - replaced rand with mt_rand
mt_srand();
for($i=0;$i<22;$i++) $salt.=$chars[mt_rand(0,63)];
return crypt($password,$salt);
}
// Genearate Password
function rand_string2( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}
$password = rand_string2(10);
//Generate Master license code
function rand_string3( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return substr(str_shuffle($chars),0,$length);
}
$mlicensecode1 = rand_string3(40);
function rand_string4( $length ) {
$chars = "0123456789";
return substr(str_shuffle($chars),0,$length);
}
$username = rand_string4(5);
$hash=blowfishCrypt('password',12); //This creates a more secure hash
# To get a shorter version of the hash, just use substr
//$hash = substr($hash, 0, 1000);
// md5 password
$password2 = md5($password);
mysqli_query($con,"INSERT INTO e107_user (user_name, user_loginname, user_password, user_class)
VALUES ('".$username."','".$username."','".$password2."','3')");
$result=mysqli_query($con,"SELECT * FROM e107_user where user_name='".$username."'");
while ($row=mysqli_fetch_array($result))
$user_id=$row["user_id"];
$ip23 = $_SERVER['REMOTE_ADDR'];
$days = '30' ;
$timenow = strtotime(date("Y-m-d"));
$expiry = strtotime("+$days days", $timenow);
$date1 = date("Y-m-d",$expiry);
$expiry = $date1;
//generate license.php, and make it ready for download
$path='licensefiles/';
mkdir ("$path$username");
//chmod ($path/$username,0777);
$content1 = '<?php
$user_id="'.$user_id.'";
$mlicencecode="'.$mlicensecode1.'";
$licensecode="insert the sublicensecode here";
';
$File = "$path/$username/license.php";
$Handle = fopen($File, 'w');
$Data = $content1;
fwrite($Handle, $Data);
fclose($Handle);
$disputa = "disputa/";
$path="$path$username";
// copy all files to folder
$file = $_SERVER['DOCUMENT_ROOT'] ."/ataptor/disputa/tomtom.php";
$newfile = $_SERVER['DOCUMENT_ROOT'] . "/ataptor/licensefiles/$username/tomtom.php";
if ( copy($file, $newfile) ) {
echo "Copy success!";
}else{
echo "Copy failed.";
}
$file = $_SERVER['DOCUMENT_ROOT'] ."/ataptor/disputa/readme.txt";
$newfile = $_SERVER['DOCUMENT_ROOT'] . "/ataptor/licensefiles/$username/readme.txt";
if ( copy($file, $newfile) ) {
echo "Copy success!";
}else{
echo "Copy failed.";
}
$files = array("licensefiles/$username/tomtom.php", "licensefiles/$username/license.php", "licensefiles/$username/readme.txt");
$zip = new ZipArchive;
$zip->open("licensefiles/$username/$mlicensecode1.zip", ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
mysqli_query($con,"INSERT INTO masters (user_id, pass, mlicensecode, ulicenses, status23, ltype23, licensepath, expire, reip23)
VALUES ('".$user_id."','".$hash."','".$mlicensecode1."','".$subs."','ok','".$product."','".$path."','".$expiry."','".$ip23."')");
//user soutput
echo "<div align='center'>
<table border='2' width='678' style='border-collapse: collapse' bordercolor='#FF0000'>
<tr>
<td>
<table border='0' width='100%' style='border-collapse: collapse'>
<tr>
<td width='207'><font color='red'><b>Your UserID is:</b></font></td>
<td>$user_id</td>
</tr>
<tr>
<td width='207'><font color='red'><b>Your Username is:</b></font></td>
<td>$username</td>
</tr>
<tr>
<td width='207'><font color='#FF0000'><b>Y</b></font><font color='red'><b>our
Password is:</b></font></td>
<td>$password</td>
</tr>
<tr>
<td width='207'><font color='red'><b>Your master licensecode
is:</b></font></td>
<td>$mlicensecode1</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
";
echo "<div align='center'>
<table border='2' width='678' style='border-collapse: collapse' bordercolor='#FF0000'>
<tr>
<td>
<div align='center'>
<table border='0' width='600' style='border-collapse: collapse'>
<tr>
<td>
<h3>After download rename license.zip to license.php,
and upload in root of your web.</h3>
<p align='center'>
<br><b>Click here to </b><a href='$path/$mlicensecode1.zip'><font color='red'><b>Download license</b></font></a>
<br><b>Click here to </b><a href='test/source.zip'><font color='red'><b>Download source files</b></font></a></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>";
if (!$aff){
}
else {
$result = mysqli_query($con,"SELECT * FROM affiliates where aff_id='".$aff."'");
while ($row=mysqli_fetch_array($result))
$aff_id= $row["user_id"];
$result = mysqli_query($con,"SELECT * FROM products where id='".$id."'");
while ($row=mysqli_fetch_array($result))
$product2= $row["pname"];
$result = mysqli_query($con,"SELECT * FROM products where id='".$id."'");
while ($row=mysqli_fetch_array($result))
$price2= $row["price"];
if ($id=='1'){
$proc='5';
}
elseif ($id=='2'){
$proc='5';
}
elseif ($id=='3'){
$proc='5';
}
elseif ($id=='4'){
$proc='5';
}
elseif ($id=='5'){
$proc='10';
}
elseif ($id=='6'){
$proc='10';
}
elseif ($id=='7'){
$proc='10';
}
elseif ($id=='8'){
$proc='10';
}
elseif ($id=='9'){
$proc='1';
}
elseif ($id=='10'){
$proc='1';
}
elseif ($id=='11'){
$proc='1';
}
elseif ($id=='12'){
$proc='1';
}
elseif ($id=='13'){
$proc='1';
}
elseif ($id=='14'){
$proc='1';
}
elseif ($id=='15'){
$proc='1';
}
elseif ($id=='16'){
$proc='1';
}
elseif ($id=='17'){
$proc='1';
}
$procent=$price2*$proc/100;
$earned_amount = $price2-$procent;
$t=$procent;
$t = number_format($t,2,".","."); // returns: 1,23
echo $t;
mysqli_query($con,"INSERT INTO affsales (user_id, aff_id, customer_id, product, amount, earned)
VALUES ('".$aff_id."','".$aff."','".$user_id."','".$product2."','".$price2."','".$t."')");
$ip23 = $_SERVER['REMOTE_ADDR'];
mysqli_query($con,"INSERT INTO log (ip23, action23)
VALUES ('".$ip23."','affiliate, $t')");
mysqli_query($con,"INSERT INTO transactions (user_id, invoice_id, product_id, product, amount, status)
VALUES ('".$userid."','".$txn_id."','".$id."','".$product2."','".$price2."','PAID')");
$now = date("Y-m-d");
mysqli_query($con,"INSERT INTO invoices (user_id, invoice_id, product_id, product, amount, due, status)
VALUES ('".$userid."','".$txn_id."','".$id."','".$product2."','".$price2."','".$now."','PAID')");
}
$result = mysqli_query($con,"SELECT * FROM affiliates where aff_id='".$aff."'");
while ($row=mysqli_fetch_array($result))
$rate = $row["earnings"];
$newamount = $rate+$t;
mysqli_query($con,"UPDATE affiliates set earnings =$newamount where aff_id='".$aff."'");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
echo $tx_token;
echo $auth_token;
}
}
?>