IPN Request.Body is empty so unable to Verify the response

JamesSouthall
Contributor
Contributor

Currently trying to implement Paypal integration on .NET Core. I get no issue with the checkout process, but having response problems now that I'm trying to handle the IPN.

I have followed the Paypal IPN code example for .Net Core here

 

Heres the code for just trying to get the response body:

        var formData = new Dictionary<string, string>();
        if (Request.ContentType == "application/x-www-form-urlencoded")
        {
            Request.Form.ForEach(f => formData.Add(f.Key, f.Value.ToString()));
        }

        var requestBody = "";
        using (var reader = new StreamReader(Request.Body, Encoding.ASCII))
        {
            requestBody = await reader.ReadToEndAsync();
        }

        var dto = new GatewayRequestDto
        {
            Body = requestBody,
            FormData = formData
        };

        var response = await _gatewayHandler.ProcessResponseAsync(gateway, dto);

Following from that code example I would expect the Request.Body to be populated but it is empty. To make sure I was just getting back a false response I retrieved the Request.Form successfully with the correct data but I believe its in the wrong order so unable to validate it.

 

Why is the Body empty? Anything that stands out as incorrect?

 

Thank you in advance!

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.