The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Reading IPN in ASP.Net Web API (C#)

Hi Folks,

I'm trying to read my FoxyCart IPN in an Web API. I'm getting the form data OK and responding with "foxy", but I'm having trouble decoding and/or decrypting it.

This is what I'm getting and I'm not sure if this is a decryption issue or a decoding issue.......

"C&­á:ý{h¼V¾ÓóÅY†wæK~u4b2ý¶*À Í¡á')1Œž¬Ì‘ÏÈ£ò¿ç(¦XPéÙ€Õ¹D)Eál_ßc“?3P@­!¤zkVØ<‚ˆ3šB(H´­wm‹ùžX…>Ÿ>?V¤…º×À`+;kÀ…BºøCÚÞ¡Ç"UöѲÔM3vÕ¬>Ö

This is my C# controller code and the text above is the value of 'feedDecrypted'
// POST: api/FoxyIPNs
public HttpResponseMessage PostFoxyIPN(HttpRequestMessage request)
var feedFormData = request.Content.ReadAsStringAsync().Result;

//decrypt and decode
byte[] feedBytes = Encoding.ASCII.GetBytes(feedFormData);
string feedUnencoded = HttpUtility.UrlDecode(feedBytes, Encoding.GetEncoding(1252));
string feedDecrypted = RC4.Decrypt(API_KEY, feedUnencoded, false);

//return to calling service. Foxy cart requires a plain string of "foxy" in order to consider the IPN transaction a success.
return new HttpResponseMessage()
Content = new StringContent("foxy")

The annoying thing is that this code is the exact same code that I've used with an older web forms solution which works well. Has anyone done this with Web API specfically.

Sign In or Register to comment.