Home IPN validation doesn't fail when it should fail

# IPN validation doesn't fail when it should fail

user6572
1#
user6572 Published in September 21, 2018, 8:34 am

I am trying to set up PayPal to process payments. Everything is working OK except the fact that payments are not being cancelled when my IPN doesn't send a validation message to PayPal. As far as I understand if the IPN didn't validate the payment the transaction supposed to be cancelled. The code looks like that:

[HttpPost]
{
//Store the IPN received from PayPal
LogRequest(Request);

return new EmptyResult();
}

{
try
{
VerifyIpnParamsWithException(ipnRequest);
var verificationRequest = (HttpWebRequest)WebRequest.Create("https://www.paypal.com/cgi-bin/webscr");

//Set values for the verification request
verificationRequest.Method = "POST";
verificationRequest.ContentType = "application/x-www-form-urlencoded";
var strRequest = Encoding.ASCII.GetString(param);

strRequest = "cmd=_notify-validate&" + strRequest;
verificationRequest.ContentLength = strRequest.Length;

//Attach payload to the verification request
using (var streamOut = new StreamWriter(verificationRequest.GetRequestStream(), Encoding.ASCII))
{
streamOut.Write(strRequest);
streamOut.Close();
}
var verificationResponse = string.Empty;

//Send the request to PayPal and get the response
using (var streamIn = new StreamReader(verificationRequest.GetResponse().GetResponseStream()))
{
streamIn.Close();
}
ProcessVerificationResponse(verificationResponse);
}
catch (Exception exception)
{
DAL.LogError(exception, ipnRequest);
}
}


When I tested it, according to my log an exception was thrown before a verification message was sent to PayPal. It didn't change the fact that the money was transferred to the PayPal account and the transaction is completed. Did I misunderstand? Is there anything else I'm supposed to do in order to cancel the transaction?