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óŠœ#
äÆ`}Ø}E3©Ü¬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
Unfortunately I'm not familiar with ASP to be able to assist here, but we do have a few pages on our wiki related to ASP and the datafeed:
https://wiki.foxycart.com/integration/asp.net
https://wiki.foxycart.com/integration/foxycart/datafeed_with_csharp
https://wiki.foxycart.com/integration/csharp-reading-xmldatafeed-with-xmlserializer
Hopefully one of those will help you get it working.