public CreditsHero.Company.Dtos.CompanyConfigsDto GetCompanyConfig(CreditsHero.Common.Companies.Dtos.GetCompanyInput input) { var creditsHeroFormat = String.Format("{0}api/services/app/Company/GetCompanyConfig", System.Configuration.ConfigurationSettings.AppSettings["creditsHero:WebServiceApiPrefix"]); var timelineUrl = string.Format(creditsHeroFormat); CompanyConfigsDto companyConfigList; //Serialize object to JSON MemoryStream jsonStream = new MemoryStream(); string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(input); byte[] byteArray = Encoding.UTF8.GetBytes(jsonData); HttpWebRequest creditsHeroRequest = (HttpWebRequest)WebRequest.Create(timelineUrl); creditsHeroRequest.ContentType = "application/json;charset=utf-8"; creditsHeroRequest.ContentLength = byteArray.Length; creditsHeroRequest.Method = "POST"; Stream newStream = creditsHeroRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); newStream.Close(); WebResponse timeLineResponse = creditsHeroRequest.GetResponse(); using (timeLineResponse) { using (var reader = new StreamReader(timeLineResponse.GetResponseStream())) { var results = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(reader.ReadToEnd()); Newtonsoft.Json.Linq.JObject jObject2 = results.result; var itemResult = Newtonsoft.Json.JsonConvert.DeserializeObject <CompanyConfigsDto>(jObject2.ToString()); companyConfigList = itemResult; } } return(companyConfigList); }
public async Task<ActionResult> PurchaseCredits() { string role = GetUserRole(); Users.User user = await GetUser(); CreditsHero.Subscribers.Dtos.GetSubscribersInput input = await BuildCreditsHeroSubscriberInput(user); var companyInput = new CreditsHero.Common.Companies.Dtos.GetCompanyInput() { CompanyId = input.CompanyId.Value.ToString() }; //Get Company entity so we can use the cost per credits var company = _companyService2.GetCompany(companyInput); //Get Company Configuration var companyConfig = _companyService2.GetCompanyConfig(companyInput); //TODO:Determine type of payment //Build Stripe data payment PaymentStripeDto payment = new PaymentStripeDto() { AddressCity = Request.Form[""], AddressLine1 = Request.Form[""], AddressLine2 = Request.Form[""], }; //Build PaymentAuthorize.NET data object //PaymentAuthorizeNetDto payment = new PaymentAuthorizeNetDto() //{ // Credits = Int32.Parse(Request.Form["txtCredits"]), // SubscribersId = input.SubscribersId, // SubscribersEmail = input.SubscribersEmail, // SubscribersName = input.SubscribersName, // Amount = Decimal.Parse(Request.Form["txtTotal"]), // CardCode = Request.Form["txtCardCode"], // CompanyId = company.Id, // MarketType = 0, //Request.Form[], // ExpirationDate = Request.Form["txtExpirationDate"], // PaymentGatewayType = "AuthorizeNET", //Request.Form[], // PaymentMethod = "ChargeCreditCard", //Request.Form[], // PurchaseDescription = String.Format("Purchase made by {0}, email {1}, ID {2}", input.SubscribersName, input.SubscribersEmail, input.SubscribersId.ToString()), // TaxAmount = Decimal.Parse(Request.Form["txtAmount"]), // TransactionType = "AuthorizeAndCapture", // CardNumber = Request.Form["txtCardNumber"], // CompanyConfigurationSettings = companyConfig //}; var output = _memberAppService.MakePayment(payment); return Redirect((Url.Action("Index", "Home"))); }
public async Task<ActionResult> PostProcessPayment() { string role = GetUserRole(); Users.User user = await GetUser(); CreditsHero.Subscribers.Dtos.GetSubscribersInput input = await BuildCreditsHeroSubscriberInput(user); var companyInput = new CreditsHero.Common.Companies.Dtos.GetCompanyInput() { CompanyId = input.CompanyId.Value.ToString() }; //Get Company entity so we can use the cost per credits var company = _companyService2.GetCompany(companyInput); //Get Company Configuration var companyConfig = _companyService2.GetCompanyConfig(companyInput); PaymentResponseDto paymentResponse = new PaymentResponseDto(); PaymentDto payment = new PaymentDto(); //TODO: Determine type of payment //PayPal Post Payment Process payment = new PaymentPaypalDto() { CompanyConfigurationSettings = companyConfig, CompanyId = company.Id, PayerId = Request.QueryString["PayerID"], PaymentGuid = Request.QueryString["Guid"], PaymentId = Request.QueryString["PaymentId"], Token = Request.QueryString["Token"], PaymentGatewayType = "PayPal", PaymentMethod = "PayPal", SubscribersEmail = input.SubscribersEmail, SubscribersId = input.SubscribersId, SubscribersName = input.SubscribersName, TaxAmount = 0, TransactionType = "PayPalExecute" }; paymentResponse = _memberAppService.MakePayment(payment as PaymentPaypalDto); if (paymentResponse.AuthCode == "created") { return Redirect(paymentResponse.ResponseCode); } else { rooferlocator.com.Web.Models.ServiceResponse response = new Models.ServiceResponse() { FriendlyMessage = paymentResponse.MessageCode == "sale" ? String.Format("Payment accepted. Transaction #: ", paymentResponse.TransactionId) : String.Format("Processing Payment. Transaction #: ", paymentResponse.TransactionId) }; return Redirect((Url.Action("Index", "Home", response))); } //?guid = 3772 & paymentId = PAY - 5UN73352KF9557105K3KJ2JY & token = EC - 1BC22799SN423381H & PayerID = WWWCHTZE5U74L }