Ejemplo n.º 1
0
        public static Custom Parse(string postData)
        {
            //string key, value;
            Custom custom = new Custom();
            try
            {
                string[] strArray = postData.Split('\n');
                for (int i = 1; i < strArray.Length; i++)
                {
                    if (strArray[i].StartsWith("custom"))
                    {
                        string[] param = strArray[i].Split('=');
                        string[] values = HttpUtility.UrlDecode(param[1]).Split('&');
                        if (values.Length > 1)
                        {
                            custom.productId = Convert.ToInt32(values[0]);
                            custom.subscriptionType = values[1];
                        }
                        else
                            custom.Amount = Convert.ToDecimal(values[0]);
                        if (values.Length == 3)
                            custom.WishlistId = values[2];
                        if (values.Length == 4)
                        {
                            custom.WishlistId = values[2];
                            custom.cpId = values[3];
                        }
                        if (values.Length == 5)
                        {
                            custom.WishlistId = values[2];
                            custom.cpId = values[3];
                            custom.userId = values[4];
                        }

                    }
                    if (strArray[i].StartsWith("txn_id"))
                    {
                        string[] param = strArray[i].Split('=');
                        custom.TransactionId = HttpUtility.UrlDecode(param[1]);
                    }

                    if (strArray[i].StartsWith("subscr_id"))
                    {
                        string[] param = strArray[i].Split('=');
                        custom.subscr_id = HttpUtility.UrlDecode(param[1]);
                    }
                }
                return custom;
            }
            catch (Exception e) { Debug.WriteLine(e.InnerException); throw; }
        }
Ejemplo n.º 2
0
 public static Custom ParseForReload(string postData)
 {
     Custom custom = new Custom();
     try
     {
         string[] strArray = postData.Split('\n');
         for (int i = 1; i < strArray.Length; i++)
         {
             if (strArray[i].StartsWith("custom"))
             {
                 string[] param = strArray[i].Split('=');
                 string[] values = HttpUtility.UrlDecode(param[1]).Split('&');
                 if (values.Length > 1)
                 {
                     custom.Amount = Convert.ToDecimal(values[0]);
                     custom.userId = values[1];
                 }
             }
             if (strArray[i].StartsWith("txn_id"))
             {
                 string[] param = strArray[i].Split('=');
                 custom.TransactionId = HttpUtility.UrlDecode(param[1]);
             }
             if (strArray[i].StartsWith("mc_currency"))
             {
                 string[] param = strArray[i].Split('=');
                 custom.CurrencyCode = HttpUtility.UrlDecode(param[1]);
             }
             if (strArray[i].StartsWith("mc_gross"))
             {
                 string[] param = strArray[i].Split('=');
                 custom.Amount = Convert.ToDecimal(HttpUtility.UrlDecode(param[1]));
             }
         }
         return custom;
     }
     catch (Exception e) { Debug.WriteLine(e.InnerException); throw; }
 }