In PayPal's reply to your post, the first line is SUCCESS or FAIL.
If the response contains the word FAIL, make sure that the transaction ID token and identity token on your post are correct.
function FetchOrder()
{
$transactionID=$_POST["txn_id"];
$item=$_POST["item_name"];
$amount=$_POST["mc_gross"];
$currency=$_POST["mc_currency"];
$datefields=explode(" ",$_POST["payment_date"]);
$time=$datefields[0];
$date=str_replace(",","",$datefields[2])." ".$datefields[1]." ".$datefields[3];
$timestamp=strtotime($date." ".$time);
$status=$_POST["payment_status"];
$firstname=$_POST["first_name"];
$lastname=$_POST["last_name"];
$email=$_POST["payer_email"];
$custom=$_POST["option_selection1"];
if ($transactionID AND $amount)
{
// query to save data
return $this->insertID;
}
else
{
return 0;
}
}