public ResultModel Order(Message message) { try { message.MessageType = MessageType.Order; int id = _formRequestService.ProcessMessage(message); if (message.PaymentType == PaymentType.Card && message.Amount.HasValue) { var settings = _settingsService.GetSettings(); string rootUrl = settings.RootUrl; // getting guid var fromRequest = _formRequestService.GetOneFormRequest(id); var relUrl = Url.Route("AcceptPayment", new { id = fromRequest.Guid }); var returnUrl = $"{rootUrl.Trim('/')}/{relUrl.Trim('/')}"; string redirectUrl = _paymentSystemService.ProcessPayment(id, message.Amount.Value, returnUrl); return(new ResultModel(true, new { RedirectUrl = redirectUrl })); } return(ResultModel.Success); } catch (Exception e) { _logService.LogError(e); return(new ResultModel(e)); } }
public ActionResult PaymentAccepted(string id) { Guid guid; bool parsed = Guid.TryParse(id, out guid); if (!parsed) { return(new HttpStatusCodeResult(403) { }); } var formRequestId = _formRequestService.GetOneFormRequest(guid).FormRequestId; _formRequestService.UpdatePaymentState(formRequestId, PaymentState.Paid, true); return(new RedirectResult("/")); }