/// <summary> /// Parses the specified context. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public static RBKMoneyRequest Parse(HttpContext context) { var result = new RBKMoneyRequest { eshopId = context.Request["eshopId"], orderId = Guid.Parse(context.Request["orderId"]), serviceName = context.Request["serviceName"], eshopAccount = context.Request["eshopAccount"], recipientAmount = decimal.Parse(context.Request["recipientAmount"]), recipientCurrency = context.Request["recipientCurrency"], paymentStatus = int.Parse(context.Request["paymentStatus"]), userName = context.Request["userName"], userEmail = context.Request["userEmail"], paymentData = DateTime.Parse(context.Request["paymentData"]), hash = context.Request["hash"] }; if (context.Request["MESSAGE"] != null) { result.MESSAGE = context.Request["MESSAGE"]; } if (context.Request["ERR"] != null) { result.ERR = context.Request["ERR"]; } return(result); }
/// <summary> /// Successes the specified context. /// </summary> /// <param name="context">The context.</param> public static void Success(HttpContext context) { var sbParams = new StringBuilder(); foreach (string key in context.Request.Params.AllKeys) { sbParams.AppendLine(string.Format("{0} = {1}", key, context.Request[key])); } Log.Error("Request params : " + sbParams); var response = RBKMoneyRequest.Parse(context); var dataManager = new DataManager(); var payment = dataManager.Payment.SelectById(response.orderId); var toHash = string.Format("{0}::{1}::{2}::{3}::{4}::{5}::{6}::{7}::{8}::{9}::{10}", EshopId, payment.ID, payment.Assignment, response.eshopAccount, payment.Total.ToString("##.##").Replace(",", "."), "RUR", response.paymentStatus, response.userName, response.userEmail, response.paymentData.ToString("yyyy-MM-dd HH:mm:ss"), SecretKey).ToLower(); Log.Debug("Строка для контрольной суммы : " + toHash); using (MD5 md5Hash = MD5.Create()) { string hash = GetMd5Hash(md5Hash, toHash); if (response.hash != hash) { Log.Error("Контрольные суммы не совпадают"); } else { //response.paymentStatus == 5 //payment.StatusID = } } context.Response.StatusCode = 200; }