Reputation: 15934
I keep getting an INVALID
response from PayPal when sending the data back to verify it's come from them. I've read lots of other posts on SO with nothing helping so far. This is what I can verify:
cmd=_notify-validate&
to the request.This is some quick hacky code to post the data up:
using (WebClient client = new WebClient())
{
var nvc = new NameValueCollection { {"cmd", "_notify-validate"} };
foreach (var f in formCollectionData.AllKeys)
nvc.Add(f, formCollectionData[f]);
try
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
var response = client.UploadValues(_urls[payPalResponse.test_ipn], "POST", nvc);
var result = System.Text.Encoding.UTF8.GetString(response); //returns "INVALID"
}
catch (Exception e)
{
;
}
}
formCollectionData
is the data that is fed through to my Action (using MVC). I've verified this is correct by looking at the Request.Form.ToString()
data.
I've tried posting using a couple of other methods but get the same INVALID
result.
I've read about changing the language encoding in the paypal preferences to UTF-8
but I'm using the IPN Simulator so not sure how this would apply.
I appear to be going round in circles and don't know what to do.
EDIT I've just tried this from my sandbox paypal account by going into the IPN History and re-sending one and it has worked correctly. I get a status of verified back.
This means it's just the IPN Simulator that isn't working properly so I assume it's to do with the encoding. Is it possible to see / change the encoding of the simulator to UTF-8?
Upvotes: 0
Views: 92
Reputation: 15653
I've encountered the same problem. It does seem to be an error with the simulator.
Try clearing all the date fields in the simulator so they are blank. It seems to be that some of the special characters within the form are causing issues.
This is just a bug in the IPN simulator and real IPN messages will not be affected in the same way.
Upvotes: 1