protected void ddlDeliType_SelectedIndexChanged(object sender, EventArgs e) { if (ddlDeliType.SelectedIndex != 0) { objCart = new CartDetails(); DataTable dtCart = objCart.SelectUserCartDetails(Convert.ToInt32(Session["UserId"].ToString())); double delPrice = 0; int intChargeId = int.Parse(ddlDeliType.SelectedItem.Value.ToString().Trim()); ChargeDetails chg = new ChargeDetails(); DataTable dt = chg.SelectChargeDetailsByID(intChargeId); string strType = ""; string strAmount = ""; if (dt.Rows.Count > 0) { strType = dt.Rows[0]["ChargeType"].ToString(); strAmount = dt.Rows[0]["AmountOrPercent"].ToString(); } double dblDeliAmount = Convert.ToDouble(strAmount); if (strType == "0") { delPrice = Convert.ToDouble(decTotalPrice) + dblDeliAmount; } else if (strType == "1") { dblDeliAmount = (Convert.ToDouble(decTotalPrice) * (dblDeliAmount / 100)); delPrice = Convert.ToDouble(decTotalPrice) + dblDeliAmount; } //decTotalPrice = 0; trDeliAmt.Visible = true; trTotalAmt.Visible = true; lblError.Visible = false; lblDeliAmt.Text = "$ " + String.Format("{0:0.00}", dblDeliAmount); lblTotalAmt.Text = "$ " + String.Format("{0:0.00}", delPrice); } else { trDeliAmt.Visible = false; lblError.Visible = true; trTotalAmt.Visible = false; } }
void LoadDeliveryType() { ChargeDetails cat = new ChargeDetails(); ddlDeliType.Items.Clear(); DataTable dt1 = cat.SelectChargeDetails(); ListItem listItem = new ListItem(); listItem.Text = "<Select Charge Type>"; listItem.Value = "0"; //listItem.Attributes.Add("style", "background-Black:white;color:White"); ddlDeliType.Items.Add(listItem); for (int i = 0; i < dt1.Rows.Count; i++) { listItem = new ListItem(); listItem.Text = dt1.Rows[i]["ChargeName"].ToString(); listItem.Value = dt1.Rows[i]["ChargeId"].ToString(); //listItem.Attributes.Add("style", "background-color:Black;color:white"); ddlDeliType.Items.Add(listItem); } }
public async Task <List <TaxLine> > CalculateTax(ChargeDetails details) { var taxableAmount = 0M; foreach (var item in details.Items) { if (item.Taxable) { taxableAmount += item.LineTotal; } } var taxRates = new List <TaxRate>(); if (_configuration.Testing) { taxRates.Add(new TaxRate("Testing Tex", 5M)); } else if (!string.IsNullOrEmpty(_configuration.FlakyServerBaseUrl)) { _logger?.LogInformation($"about to load tax details from server for state {details.Address.State}"); var taxClient = new Flaky.SDK.Client.TaxClient() { BaseUrl = _configuration.FlakyServerBaseUrl }; var stateRates = await taxClient.GetAsync(details.Address.State); _logger?.LogInformation($"tax details returned from server for state {details.Address.State}"); taxRates.AddRange(stateRates.Select(rate => _mapper.Map <TaxRate>(rate))); } else { throw new MissingConfiguration("Please set configuration as Testing or set ServerBaseUrl"); } return(taxRates.Select(taxRate => taxRate.Calculate(taxableAmount)).ToList()); }
public async Task <ChargeDetails> PrepareOrderForPayment(Order order, AddressViewModel shippingAddress, PaymentDetailsViewModel paymentDetails) { var details = new ChargeDetails { ID = order.Id, Items = order.OrderItems.Select(item => new ItemDetails() { Name = item.ItemOrdered.ProductName, ItemNumber = item.ItemOrdered.CatalogItemId, UnitPrice = item.UnitPrice, Amount = item.Units, LineTotal = item.UnitPrice * item.Units }).ToList(), Address = new Flaky.Data.Address() { FirstLine = shippingAddress.Street, City = shippingAddress.City, State = shippingAddress.State, Country = shippingAddress.Country, ZipCode = shippingAddress.ZipCode }, PaymentDetails = new Flaky.Data.PaymentDetails() { Brand = paymentDetails.Brand, CardNumber = paymentDetails.CardNumber, CardHolderName = paymentDetails.CardHolderName, CVC = paymentDetails.CVC, ExperationMonth = paymentDetails.ExperationMonth, ExperationYear = paymentDetails.ExperationYear } }; details.Taxes = await _billingClient.CalculateTax(details); details.TotalAmmount = details.Items.Sum(item => item.LineTotal) + details.Taxes.Sum(tax => tax.Amount); return(details); }
public async Task <Transcation> CompleteCharge(ChargeDetails detalis) { return(await _billingClient.CreateCharge(detalis)); }
protected void btnBuy_Click(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Login.aspx"); } else { if (ddlDeliType.SelectedIndex != 0) { #region .. GET HISTORY ID .. int intHistoryId = 0; objCart = new CartDetails(); DataTable dtMax = objCart.SelectMaxID(); if (dtMax.Rows.Count > 0) { string st = dtMax.Rows[0]["HistroyId"].ToString(); if (dtMax.Rows[0]["HistroyId"].ToString() == "") { intHistoryId = 0; } else { intHistoryId = Convert.ToInt32(dtMax.Rows[0]["HistroyId"].ToString()); } } intHistoryId++; #endregion #region .. BUY DETAILS .. DataTable dtCart = objCart.SelectUserCartDetails(Convert.ToInt32(Session["UserId"].ToString())); double delPrice = 0; int intChargeId = int.Parse(ddlDeliType.SelectedItem.Value.ToString().Trim()); ChargeDetails chg = new ChargeDetails(); DataTable dt = chg.SelectChargeDetailsByID(intChargeId); string strType = ""; string strAmount = ""; if (dt.Rows.Count > 0) { strType = dt.Rows[0]["ChargeType"].ToString(); strAmount = dt.Rows[0]["AmountOrPercent"].ToString(); } double dblDeliAmount = Convert.ToDouble(strAmount); if (strType == "0") { delPrice = Convert.ToDouble(decTotalPrice) + dblDeliAmount; } else if (strType == "1") { delPrice = Convert.ToDouble(decTotalPrice) + (Convert.ToDouble(decTotalPrice) * (dblDeliAmount / 100)); } string strLocationId = ""; string strLocationName = ""; if (Session["Location"] != null) { strLocationName = Session["Location"].ToString(); } City objCity = new City(); DataTable dtCity = objCity.SelectCityByName(strLocationName); if (dtCity.Rows.Count > 0) { strLocationId = dtCity.Rows[0]["CityId"].ToString(); } else { strLocationId = "0"; } for (int i = 0; i < dtCart.Rows.Count; i++) { objCart.CreateBuyDetails( Convert.ToInt32(dtCart.Rows[i]["AdPostId"].ToString()), intHistoryId, Convert.ToInt32(Session["UserId"].ToString()), Convert.ToDecimal(delPrice), int.Parse(ddlDeliType.SelectedItem.Value.ToString().Trim()), Convert.ToInt32(strLocationId), "BOUGHT", 1, ddlDeliType.SelectedItem.Text.ToString().Trim(), Convert.ToInt32(strType), Convert.ToDouble(strAmount) ); objCart.UpdateCartStatus(Convert.ToInt32(dtCart.Rows[i]["AdPostId"].ToString()), Convert.ToInt32(Session["UserId"].ToString())); } decTotalPrice = 0; #endregion Response.Redirect("MyPurchases.aspx"); } else { lblError.Visible = true; lblError.Text = "Select Delivery charges"; } } }