public IHttpActionResult AdminGetBackingDetail(int backingId) { var backingDetail = new ProjectBackDTO(); try { // Check authen. if (User.Identity == null || !User.Identity.IsAuthenticated) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } backingDetail = ProjectRepository.Instance.AdminGetBackingDetail(backingId); } catch (KeyNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_FOUND }); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.SUCCESS, Data = backingDetail }); }
public ActionResult Baokim(ProjectBackDTO backingData) { try { var bk = new BaoKimPayment(); var randomCode = CommonUtils.GenerateVerifyCode().Substring(0, 10); string totalPledge = backingData.PledgeAmount.ToString(); var paymentUrl = bk.createRequestUrl( int.Parse(backingData.ProjectCode.Substring(3,6)) + randomCode + DateTime.Now.ToString("hmmsstt"), "*****@*****.**", totalPledge, "0", "0", backingData.RewardPkgDesc, "http://dandelionvn.com/baokimcallback", "http://dandelionvn.com/#/project/detail/" + Request.QueryString["ProjectCode"], "http://dandelionvn.com/#/project/detail/" + Request.QueryString["ProjectCode"] ); // Inital cookie HttpCookie projectCodeCookie = new HttpCookie("ProjectCode"); HttpCookie emailCookie = new HttpCookie("Email"); HttpCookie backerNameCookie = new HttpCookie("BackerName"); HttpCookie rewardIdCookie = new HttpCookie("RewardId"); HttpCookie pledgeAmountCookie = new HttpCookie("PledgeAmount"); HttpCookie quantityCookie = new HttpCookie("Quantity"); HttpCookie descCookie = new HttpCookie("description"); HttpCookie addressCookie = new HttpCookie("Address"); HttpCookie phoneNumberCookie = new HttpCookie("Phonenumber"); DateTime now = DateTime.Now; // Set the cookie value. projectCodeCookie.Value = backingData.ProjectCode; emailCookie.Value = backingData.Email; backerNameCookie.Value = HttpUtility.UrlEncode(backingData.BackerName); rewardIdCookie.Value = backingData.RewardPkgID.ToString(); pledgeAmountCookie.Value = backingData.PledgeAmount.ToString(); quantityCookie.Value = backingData.Quantity.ToString(); descCookie.Value = HttpUtility.UrlEncode(backingData.Description); addressCookie.Value = HttpUtility.UrlEncode(backingData.Address); phoneNumberCookie.Value = backingData.PhoneNumber; // Set the cookie expiration date. projectCodeCookie.Expires = now.AddMinutes(30); emailCookie.Expires = now.AddMinutes(30); backerNameCookie.Expires = now.AddMinutes(30); rewardIdCookie.Expires = now.AddMinutes(30); pledgeAmountCookie.Expires = now.AddMinutes(30); quantityCookie.Expires = now.AddMinutes(30); descCookie.Expires = now.AddMinutes(30); addressCookie.Expires = now.AddMinutes(30); phoneNumberCookie.Expires = now.AddMinutes(30); // Add the cookie. Response.Cookies.Add(projectCodeCookie); Response.Cookies.Add(emailCookie); Response.Cookies.Add(backerNameCookie); Response.Cookies.Add(rewardIdCookie); Response.Cookies.Add(pledgeAmountCookie); Response.Cookies.Add(quantityCookie); Response.Cookies.Add(descCookie); Response.Cookies.Add(addressCookie); Response.Cookies.Add(phoneNumberCookie); return Redirect(paymentUrl); } catch (Exception) { return Redirect("/#/error"); } }
public ActionResult BaokimCallBack() { try { HttpCookie projectCodeCookie = Request.Cookies["ProjectCode"]; HttpCookie emailCookie = Request.Cookies["Email"]; HttpCookie backerNameCookie = Request.Cookies["BackerName"]; HttpCookie rewardIdCookie = Request.Cookies["RewardId"]; HttpCookie pledgeAmountCookie = Request.Cookies["PledgeAmount"]; HttpCookie quantityCookie = Request.Cookies["Quantity"]; HttpCookie descCookie = Request.Cookies["description"]; HttpCookie addressCookie = Request.Cookies["Address"]; HttpCookie phoneNumberCookie = Request.Cookies["Phonenumber"]; // Convert unixtime to datetime string createdSecond = Request.QueryString["created_on"]; double unixTimeStamp = Double.Parse(createdSecond); System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime createdTime = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(unixTimeStamp).ToLocalTime(); var projectBackDTO = new ProjectBackDTO { ProjectCode = projectCodeCookie.Value, Email = emailCookie.Value, BackerName = HttpUtility.UrlDecode(backerNameCookie.Value), RewardPkgID = Int32.Parse(rewardIdCookie.Value), PledgeAmount = Decimal.Parse(pledgeAmountCookie.Value), Quantity = Int32.Parse(quantityCookie.Value), Description = HttpUtility.UrlDecode(descCookie.Value), Address = HttpUtility.UrlDecode(addressCookie.Value), PhoneNumber = phoneNumberCookie.Value, BackedDate = createdTime, OrderId = Request.QueryString["order_id"], TransactionId = Request.QueryString["transaction_id"], }; int backingId = ProjectRepository.Instance.BackProject(projectBackDTO); ProjectRepository.Instance.CaculateProjectPoint(projectBackDTO.ProjectCode, DDLConstants.PopularPointType.BackingPoint); // Remove all cookies. var limit = Request.Cookies.Count; for (int i = 0; i < limit; i++) { var cookieName = Request.Cookies[i].Name; if (cookieName == projectCodeCookie.Name || cookieName == emailCookie.Name || cookieName == backerNameCookie.Name || cookieName == rewardIdCookie.Name || cookieName == pledgeAmountCookie.Name || cookieName == quantityCookie.Name || cookieName == descCookie.Name || cookieName == addressCookie.Name || cookieName == phoneNumberCookie.Name) { var cookie = new HttpCookie(cookieName) { Expires = DateTime.UtcNow.AddDays(-1) }; Response.Cookies.Add(cookie); } } return Redirect("/#/backingdetail/" + backingId); } catch (Exception) { return Redirect("/#/error"); } }
public IHttpActionResult BackProject(ProjectBackDTO backingData) { int backingId; try { // Check authen. if (User.Identity == null || !User.Identity.IsAuthenticated) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } if (!ModelState.IsValid) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } backingData.OrderId = int.Parse(backingData.ProjectCode.Substring(3,6)) + CommonUtils.GenerateVerifyCode().Substring(0,10) + DateTime.Now.ToString("hmmsstt"); backingData.TransactionId = CommonUtils.GenerateVerifyCode().Substring(0, 13); backingData.BackedDate = DateTime.Now; backingId = ProjectRepository.Instance.BackProject(backingData); ProjectRepository.Instance.CaculateProjectPoint(backingData.ProjectCode, DDLConstants.PopularPointType.BackingPoint); } catch (KeyNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_FOUND }); } catch (UserNotFoundException) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.NOT_AUTHEN }); } catch (Exception) { return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.ERROR, Message = "", Type = DDLConstants.HttpMessageType.BAD_REQUEST }); } return Ok(new HttpMessageDTO { Status = DDLConstants.HttpMessageType.SUCCESS, Message = "", Type = "", Data = backingId }); }