public ActionResult SaveShippingDetails(ShippingDetailsDTO shippingDetails) { if (!ModelState.IsValid) { shippingDetails.CountryList = Helper.GetCountryList(); return(View("~/Views/ShippingDetails/Index.cshtml", shippingDetails)); } IShippingDetailsRepository shippingDetailsRepository = new ShippingDetailsRepository(); var shippingTransactionId = shippingDetailsRepository.SaveShippingDetails(shippingDetails); return(RedirectToAction("Index", "PaymentOptions", new { quantity = shippingDetails.ItemDetails?.Quantity, itemId = shippingDetails.ItemDetails?.ItemId, itemCost = shippingDetails.ItemDetails?.ItemCost, shipmentTransactionId = shippingTransactionId })); }
public ActionResult PaymentWithPayPal(double amount, int shipmentTransactionId) { // Get ShippingDetails By TransactionId IShippingDetailsRepository shippingDetailsRepository = new ShippingDetailsRepository(); var shippingDetails = shippingDetailsRepository.GetShippingDetailsById(shipmentTransactionId); //getting the apiContext as earlier APIContext apiContext = PaypalConfiguation.GetAPIContext(); string transactionGeneratedId = string.Empty; try { string payerId = Request.Params["PayerID"]; if (string.IsNullOrEmpty(payerId)) { string baseURI = Request.Url.Scheme + "://" + Request.Url.Authority + "/PaypalServer/PaymentRedirect?"; var guid = Convert.ToString((new Random()).Next(100000)); var createdPayment = this.CreatePayment(apiContext, baseURI + "guid=" + guid, amount); var links = createdPayment.links.GetEnumerator(); string paypalRedirectUrl = null; while (links.MoveNext()) { Links lnk = links.Current; if (lnk.rel.ToLower().Trim().Equals("approval_url")) { //saving the payapalredirect URL to which user will be redirected for payment paypalRedirectUrl = lnk.href; } } // saving the paymentID in the key guid Session.Add(guid, createdPayment.id); transactionGeneratedId = createdPayment.id; return(Redirect(paypalRedirectUrl)); } else { // This section is executed when we have received all the payments parameters // from the previous call to the function Create // Executing a payment var guid = Request.Params["guid"]; var executedPayment = ExecutePayment(apiContext, payerId, Session[guid] as string); if (executedPayment.state.ToLower() != "approved") { return(View("FailureView")); } transactionGeneratedId = executedPayment.id; } } catch (Exception ex) { return(View("FailureView")); } // Success view return(RedirectToAction("Index", "TranactionSuccess", new { transactionId = transactionGeneratedId })); }
public void CheckCurrencyFormat(Currency currency, string puttern) { HomePage homePage = LoadHomePage(); homePage = homePage.ChooseCurrency(currency); homePage.AddProductToCart(ProductRepository.GetIPhone()); cartPage = homePage.GotoShoppingCartPage(); SelectShippingMethodComponent ShippingMethod = cartPage.ApplySippingAndTaxes(ShippingDetailsRepository.GetUADetails()); cartPage = ShippingMethod.ApllyShippingMethod(); Thread.Sleep(2000); // for presentation ONLY Total = cartPage.GetPriceOption("Total:"); SubTotal = cartPage.GetPriceOption("Sub-Total:"); FlatShippingRate = cartPage.GetPriceOption("Flat Shipping Rate:"); FixedTestTax = cartPage.GetPriceOption(TaxRateRepository.GetFixTaxRate().Name + ":"); PercentageTestTax = cartPage.GetPriceOption(TaxRateRepository.GetPercentageTaxRate().Name + ":"); StringAssert.IsMatch(puttern, Total); StringAssert.IsMatch(puttern, SubTotal); StringAssert.IsMatch(puttern, FlatShippingRate); StringAssert.IsMatch(puttern, FixedTestTax); StringAssert.IsMatch(puttern, PercentageTestTax); // for presentation ONLY Console.WriteLine(Total); Console.WriteLine(SubTotal); Console.WriteLine(FlatShippingRate); Console.WriteLine(PercentageTestTax); Console.WriteLine(FixedTestTax); }
public void CheckFixedTaxHasTheSameValueAsInAdminPanel() { HomePage homePage = LoadHomePage(); homePage.AddProductToCart(ProductRepository.GetIPhone()); cartPage = homePage.GotoShoppingCartPage(); SelectShippingMethodComponent ShippingMethod = cartPage.ApplySippingAndTaxes(ShippingDetailsRepository.GetUADetails()); cartPage = ShippingMethod.ApllyShippingMethod(); Thread.Sleep(2000); // for presentation ONLY decimal fixedTestTax = cartPage.GetPriceOptionValue(TaxRateRepository.GetFixTaxRate().Name + ":"); decimal expectedResult = 2m; Assert.AreEqual(expectedResult, fixedTestTax); }