Hey guys! I can get the following code to work with my subscription button but it can't work with a paypal donate button. When I designed my donate button, I did add a notify_url to my file called donate.php but it just wouldn't say success in the ipn: Here is my code : <?php
ob_start();include_once __DIR__.'/header2.php';
if (!$_SESSION['u_uid']) { echo "<meta http-equiv='refresh' content='0;url=index.php?donation=notlogin'>";
exit();
} else {include_once __DIR__.'/includes/dbh.php';
if ($_SERVER['REQUEST_METHOD'] != 'POST') { header("Location: index.php");
exit();
} $ch = curl_init(); curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST)); $response = curl_exec($ch); curl_close($ch);
if ($response == "VERIFIED" && $_POST['receiver_email'] === "") { $cEmail = strip_tags($_POST['payer_email']); $firstname = strip_tags($_POST['first_name']); $lastname = strip_tags($_POST['last_name']);
$price = strip_tags($_POST['mc_gross']); $currency = strip_tags($_POST['mc_currency']); $item = strip_tags($_POST['item_number']); $paymentStatus = strip_tags($_POST['payment_status']);
if ($item == "Donation" && $currency == "USD" && $paymentStatus == "Completed" && $price == 100) { $sql = "INSERT INTO donation (user_email, firstname, lastname, amount) VALUES (?,?,?,?);"; $stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) { echo "SQL error";
} else { mysqli_stmt_bind_param($stmt, "sssi", $cEmail, $firstname, $lastname, $price);
mysqli_stmt_execute($stmt);
}
}
}
}
... View more