public HttpResponseMessage VerifyPasargad([FromUri] PasargadPaymentModel model) { try { StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.AppendFormat(@"<body><head><meta charset=""utf - 8""></ head ><Center>"); var res = _paymentManager.VerifyPasargadPayment(model); if (res.Result) { sb.AppendFormat("<H2 style='margin: 0px auto'>{0}</H2>", "تراکنش با موفقیت انجام شد"); sb.AppendFormat("<H3>{0}</H3>", res.ResultMessage); sb.AppendFormat("<H3>شماره پیگیری: {0}</H3>", res.TraceNumber); sb.AppendFormat("<H3>شماره ارجاع: {0}</H3>", res.ReferenceNumber); var reserve = _routeManager.ReserveSeat(model.In); if (reserve) { sb.AppendFormat("<H2 style='margin: 0px auto'>{0}</H2>", "سفر رزرو شد"); } /*else * { * * sb.AppendFormat("<H3>{0}</H3>", res.ResultMessage); * sb.AppendFormat("<H3>شماره پیگیری: {0}</H3>", res.TraceNumber); * sb.AppendFormat("<H3>شماره ارجاع: {0}</H3>", res.ReferenceNumber); * }*/ } else { sb.AppendFormat("<H2 style='margin: 0px auto'>{0}</H2>", "تراکنش ناموفق"); sb.AppendFormat("<H3>{0}</H3>", res.ResultMessage); } sb.Append("</Center></body>"); sb.Append("</html>"); return(new HttpResponseMessage() { Content = new StringContent( sb.ToString(), Encoding.UTF8, "text/html" ) }); //return Json(model); } catch (Exception e) { _logProvider.Log(Tag, "VerifyPasargad", e.Message); } return(new HttpResponseMessage() { Content = new StringContent( "خطای سرور- لطفا با پشتیبانی تماس بگیرید", Encoding.UTF8, "text/html" ) }); }
public PasargadResponseModel VerifyPasargadPayment(PasargadPaymentModel model) { var responseModel = new PasargadResponseModel(); using (var dataModel = new MibarimEntities()) { /* long payReqId; * long.TryParse(model.In,out payReqId);*/ var payreq = dataModel.PayReqs.FirstOrDefault(x => x.PayReqId == model.In); if (payreq != null && payreq.PayReqCreateTime.ToString("yyyy/MM/dd HH:mm") == model.Id) { payreq.PayReqRefID = model.Tref; dataModel.SaveChanges(); var check = _pasargadService.CheckPayment(payreq.PayReqId, payreq.PayReqRefID, payreq.PayReqCreateTime.ToString("yyyy/MM/dd HH:mm")); payreq.TraceNumber = check.TraceNumber; payreq.ReferenceNumber = check.ReferenceNumber; payreq.PayReqStatus = "1001"; dataModel.SaveChanges(); responseModel.Result = check.Result; responseModel.ReferenceNumber = check.ReferenceNumber; responseModel.TraceNumber = check.TraceNumber; responseModel.ResultMessage = "شماره تراکنش" + check.TraceNumber; if (check.Result) { var verify = _pasargadService.VerifyPasargadPayment(payreq.PayReqId, payreq.PayReqValue, payreq.PayReqCreateTime.ToString("yyyy/MM/dd HH:mm")); payreq.PayReqStatus = "100"; payreq.PayReqAuthority = check.ReferenceNumber; dataModel.SaveChanges(); responseModel.Result = verify.Result; responseModel.ResultMessage = verify.ResultMessage; } else { responseModel.Result = false; } } else { responseModel.Result = false; } } return(responseModel); }