public ActionResult Create([Bind(Include = "Id,VehicleRegistration,VehicleMake,Email,ReferralCode,CardNumber,CvcSecurityCode,Expiry,IsAgree")] TaxInformationModel taxInformationModel) { if (ModelState.IsValid) { string retmsg = null; //int parameter = Convert.ToInt32(Session["Id"].ToString()); db.TaxInformationModels.Add(taxInformationModel); db.SaveChanges(); // payment section bool paymentSuccessful = PaypalPayment.PayWithCreditCard(taxInformationModel); if (!paymentSuccessful) { return(View(taxInformationModel)); } if (System.Web.HttpContext.Current.Session["token"] != null && System.Web.HttpContext.Current.Session["token"].ToString() != "") { return(RedirectToAction(retmsg)); } else { return(RedirectToAction("Details", new RouteValueDictionary( new { controller = "TaxInformation", action = "Details", Id = taxInformationModel.Id }))); } } return(View(taxInformationModel)); }
public async Task <ActionResult <TaxInformationModel> > Post(int employeeId, TaxInformationModel model) { try { //Make sure TaxInformationId is not already taken var existing = await _repository.GetTaxInformationAsync(employeeId, model.Id); if (existing != null) { return(BadRequest("TaxInformation Id in Use")); } //map var TaxInformation = _mapper.Map <TaxInformation>(model); //save and return if (!await _repository.StoreNewTaxInformationAsync(employeeId, TaxInformation)) { return(BadRequest("Bad request, could not create record!")); } else { var location = _linkGenerator.GetPathByAction("Get", "TaxInformation", new { employeeId = TaxInformation.EmployeeId, TaxInformation.Id }); return(Created(location, _mapper.Map <TaxInformationModel>(TaxInformation))); } } catch (Exception e) { _logger.LogError(e, e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public ActionResult TaxInformation(string type) { int curLang = Language.Id; string model = String.Empty; if (type == "1") { model = TaxInformationModel.GetTaxInformation(new Guid("fb22b24c-4872-457a-b2d3-68bf5cf1c112"), curLang); } else if (type == "2") { model = TaxInformationModel.GetTaxInformation(new Guid("aee7960d-bd6f-425e-b6a8-f2dac27f107b"), curLang); } else if (type == "3") { model = TaxInformationModel.GetTaxInformation(new Guid("29361d72-01c4-4057-ba28-8192c8dcad72"), curLang); } else if (type == "4") { model = TaxInformationModel.GetTaxInformation(new Guid("9ff3ca14-6041-4223-8eeb-bdc57cfcfd25"), curLang); } // TODO: Partial return(PartialView("~/Views/Finances/_Pragove.cshtml", model)); }
public ActionResult DeleteConfirmed(int id) { TaxInformationModel taxInformationModel = db.TaxInformationModels.Find(id); db.TaxInformationModels.Remove(taxInformationModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult TaxInformation([Bind(Include = "Id,VehicleRegistration,VehicleMake,Email,ReferralCode,CardNumber,CvcSecurityCode,Expiry,IsAgree")] TaxInformationModel taxInformation) { if (ModelState.IsValid) { db.TaxInformationModels.Add(taxInformation); db.SaveChanges(); return(RedirectToAction("ThankYou", "Home")); } return(View(taxInformation)); }
public ActionResult Edit([Bind(Include = "Id,VehicleRegistration,VehicleMake,Email,ReferralCode,CardNumber,CvcSecurityCode,Expiry,IsAgree")] TaxInformationModel taxInformationModel) { if (ModelState.IsValid) { db.Entry(taxInformationModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new RouteValueDictionary( new { controller = "TaxInformation", action = "Details", Id = taxInformationModel.Id }))); } return(View(taxInformationModel)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TaxInformationModel taxInformationModel = db.TaxInformationModels.Find(id); if (taxInformationModel == null) { return(HttpNotFound()); } return(View(taxInformationModel)); }
public async Task <ActionResult <TaxInformationModel> > Put(int employeeId, int Id, TaxInformationModel updatedModel) { try { var currentTaxInformation = await _repository.GetTaxInformationAsync(employeeId, Id); if (currentTaxInformation == null) { return(NotFound($"Could not find TaxInformation with Id of {Id}")); } _mapper.Map(updatedModel, currentTaxInformation); if (await _repository.UpdateTaxInformationAsync(employeeId, currentTaxInformation)) { return(_mapper.Map <TaxInformationModel>(currentTaxInformation)); } } catch (Exception e) { _logger.LogError(e, e.Message); return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public static bool PayWithCreditCard(TaxInformationModel taxInformationModel) { ItemList itemList = new ItemList { items = new List <Item> { new Item { name = "Tax", price = "1.99", currency = "USD", quantity = "1" } } }; //Address for the payment Address billingAddress = new Address(); billingAddress.city = "NewYork"; billingAddress.country_code = "US"; billingAddress.line1 = "23rd street kew gardens"; billingAddress.postal_code = "43210"; billingAddress.state = "NY"; //Now Create an object of credit card and add above details to it CreditCard creditCard = new CreditCard(); creditCard.billing_address = billingAddress; //creditCard.cvv2 = "874"; creditCard.expire_month = taxInformationModel.Expiry.Month; creditCard.expire_year = taxInformationModel.Expiry.Year; //creditCard.first_name = "Aman"; //creditCard.last_name = "Thakur"; //creditCard.number = "6011000990139424"; creditCard.number = taxInformationModel.CardNumber; creditCard.type = "discover"; // Specify details of your payment amount. Details details = new Details(); //details.shipping = "1"; details.subtotal = "1.99"; //details.tax = "1"; // Specify your total payment amount and assign the details object Amount amount = new Amount(); amount.currency = "USD"; // Total = shipping tax + subtotal. amount.total = "1.99"; amount.details = details; // Now make a trasaction object and assign the Amount object Transaction transaction = new Transaction(); transaction.amount = amount; transaction.description = "Description about the payment amount."; transaction.item_list = itemList; transaction.invoice_number = "your invoice number which you are generating"; // Now, we have to make a list of trasaction and add the trasactions object // to this list. You can create one or more object as per your requirements List <Transaction> transactions = new List <Transaction>(); transactions.Add(transaction); // Now we need to specify the FundingInstrument of the Payer // for credit card payments, set the CreditCard which we made above FundingInstrument fundInstrument = new FundingInstrument(); fundInstrument.credit_card = creditCard; // The Payment creation API requires a list of FundingIntrument List <FundingInstrument> fundingInstrumentList = new List <FundingInstrument>(); fundingInstrumentList.Add(fundInstrument); // Now create Payer object and assign the fundinginstrument list to the object Payer payer = new Payer(); payer.funding_instruments = fundingInstrumentList; payer.payment_method = "credit_card"; // finally create the payment object and assign the payer object & transaction list to it Payment payment = new Payment(); payment.intent = "sale"; payment.payer = payer; payment.transactions = transactions; //getting context from the paypal //basically we are sending the clientID and clientSecret key in this function //to the get the context from the paypal API to make the payment //for which we have created the object above. //Basically, apiContext object has a accesstoken which is sent by the paypal //to authenticate the payment to facilitator account. //An access token could be an alphanumeric string APIContext apiContext = PaypalConfiguration.GetAPIContext(); //Create is a Payment class function which actually sends the payment details //to the paypal API for the payment. The function is passed with the ApiContext //which we received above. //Payment createdPayment = null; //try //{ // createdPayment = payment.Create(apiContext); //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} Payment createdPayment = payment.Create(apiContext); //if the createdPayment.state is "approved" it means the payment was successful else not if (createdPayment != null && createdPayment.state.ToLower() != "approved") { return(true); } return(false); }