public ActionResult Create(FormCollection form) { int productId = 0; int paymentMethodId = 0; Int32.TryParse(form["productId"], out productId); Product product = db.Products.Find(productId); if (product != null) { if (Int32.TryParse(form["paymentMethod"], out paymentMethodId) && form["languagesList"] != null && form["countriesList"] != null) { Purchase purchase = null; try { PriceSetting ps = new PriceSetting(product.PriceSettingId); string locale = form["languagesList"] + "-" + form["countriesList"]; ps.LOCALE = locale; ps.PAYMENT_METHOD_ID = paymentMethodId; ps.PAYALOGUE_ID = product.PayalogueId; purchase = CreatePurchase(product); NameValueCollection options = new NameValueCollection(); options.Add("purchase_id", purchase.ID.ToString()); PaymentResponse payment = ps.CreatePayment(options); purchase.Update(payment); db.SaveChanges(); return(Redirect("https://secure.zaypay.com" + payment.PayalogueUrl())); } catch (Exception e) { string mesg = GetExceptionMessage(e); if (purchase != null) { RemovePurchase(ref purchase); } if (mesg == "") { throw e; } else { LogEntry(e.Message); TempData["error"] = mesg; return(RedirectToAction("Create", new { productId = product.ID })); } } } else { TempData["error"] = "Language , Country or Payment Method is not selected properly"; return(RedirectToAction("Create", new { productId = product.ID })); } } else { throw new HttpException(404, "Sorry, Resource Not Found"); } //return RedirectToAction("Details",new { id = purchase.ID}); }