Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

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

Hi Folks,

I'm trying to read my FoxyCart IPN in an ASP.net 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Õ¬>Ö
úëÒN{’FnÈÓ¢hèù5¯]UAȦuú¢fÎP+…ã`ÂXŠ…ÞXð‚¦çwyÑ8f¦g"®Ýî
¾Éw8Ïcu|†…öÈ¿œäÜÞ(vh%òá\|ï„Âß5ª•0‘E¯q‹úÖˆ*›çñi”³¤ŸTŽ¿ŽZd”ï½åÛä¿à
—Œá“³þ¬+µ(¹qÅrk¬]ôMù>祲8¸ð<¥ŽBrÛëÒv(:+´œÇmióŠœ#
äÆ`}Ø}E­3©Ü¬3Cüx=ZžÃ§ýæH®“Å™&xinˆpL$Ús.ÕÓõoóNHšŠïíä
·Ÿ1)wJLŸm؃wU†àõ5áE›mG,É¢/Ù"

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 ASP.net web forms solution which works well. Has anyone done this with Web API specfically.

Regards
Comments
Sign In or Register to comment.