private ActionResult ProcessReceivePayment(BuyPointViewModel model) { try { model.Amount = decimal.Round(_PaymentService.AddProcessingFee(User.Identity.GetUserId(), model.Amount), 2); var createdPayment = _PaymentService.MakePayment(model.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; } } model.PaymentId = createdPayment.id; Session.Add("PaymentInfo", model); return(Redirect(paypalRedirectUrl)); } catch (Exception ex) { throw ex; } }
public ActionResult PaypalPaymentSuccess(bool cancel = false) { if (cancel) { return(RedirectToAction("Player", "Home", new { id = User.Identity.GetUserId() })); } string payerId = Request.Params["PayerID"]; BuyPointViewModel paymentInfo = Session["PaymentInfo"] as BuyPointViewModel; _PaymentService.ExecutePayment(payerId, paymentInfo.PaymentId); UserGameInfo gameInfo = _GameServices.GetGameInfoByUser(User.Identity.GetUserId()); _GameServices.SaveUserPoint(User.Identity.GetUserId(), gameInfo.Point + paymentInfo.Points); _PaymentService.SavePaymentTransaction(User.Identity.GetUserId(), PaymentMethodType.PayPal, payerId, paymentInfo.Amount, PaymentType.Deposit); return(RedirectToAction("Player", "Home", new { id = User.Identity.GetUserId() })); }
public ActionResult ReceivePayment(BuyPointViewModel model) { return(ProcessReceivePayment(model)); }