public static IRestResponse SubmitDonation(string productId, string amount, WebShoppingCartProcessRequestViewModel processRequest, string auraId) { var apiUrl = string.Format("{0}/icpas/api/WebShoppingCartEx/ProcessNonMeetingSingleOrder?productId={1}&amount={2}", ConfigurationManager.AppSettings["ServicesUrl"], productId, amount); var client = new RestClient(apiUrl); var request = new RestRequest(Method.POST); request.AddHeader("x-aura-token", auraId); request.RequestFormat = DataFormat.Json; request.AddBody(processRequest); var response = client.Execute(request); return(response); }
public void ProcessOrder() { string baseUrl = ConfigurationManager.AppSettings["ServicesUrl"] + "/icpas/api/WebShoppingCartEx/ProcessShoppingCart"; WebShoppingCartProcessRequestViewModel obj = new WebShoppingCartProcessRequestViewModel { PaymentTypeId = string.IsNullOrEmpty(this.ddlCardType.SelectedValue) ? 0 : Convert.ToInt32(this.ddlCardType.SelectedValue), CardExpirationMonth = Convert.ToInt32(this.ddlMonth.SelectedValue), CardExpirationYear = string.IsNullOrEmpty(this.ddlYear.SelectedValue) ? 0 : Convert.ToInt32(this.ddlYear.SelectedValue), SavedShoppingCartId = Convert.ToInt32(this.hiddenCartId.Text), CardNumber = this.txtCardNumber.Text, CardSvn = this.txtCardSecurityNumber.Text, MarketingSourceId = 0 }; RestClient restClient = new RestClient(baseUrl); RestRequest restRequest = new RestRequest(Method.POST); string auraId = Helpers.GetAuraId(Convert.ToString(base.Session["AptifyUniqueId"])); if (string.IsNullOrEmpty(auraId)) { base.Response.Redirect("/Login?ReturnUrl=" + HttpUtility.UrlEncode(base.Request.Url.AbsoluteUri)); } restRequest.AddHeader("x-aura-token", auraId); restRequest.RequestFormat = DataFormat.Json; restRequest.AddBody(obj); IRestResponse restResponse = restClient.Execute(restRequest); if (restResponse.StatusCode == HttpStatusCode.InternalServerError) { string str = ""; if (restResponse.Content.Contains("Credit Card Verification Failed")) { str = "<br/><br/>The payment save failed: Credit Card Verification Failed. Please check your credit card input."; } this.AlertWindow.Visible = true; this.lblerrormsg.Text = "Error Proccessing Order." + str + "<br/><br/><strong>If you need assistance please send an email to [email protected] or call the ICPAS Member Service center at 800 - 993 - 0407 option 4.</strong>"; return; } WebShoppingCartProcessRequestViewModel webShoppingCartProcessRequestViewModel = JsonConvert.DeserializeObject <WebShoppingCartProcessRequestViewModel>(restResponse.Content); base.Session["CartDetails"] = null; base.Response.Redirect("/CustomerService/OrderConfirmation?id=" + webShoppingCartProcessRequestViewModel.Order.Id); }