public async Task <IActionResult> Index(string address) { var failRes = ""; var serviceResult = _userService.ConvertCartToOrder(UserId, address); if (serviceResult.IsSuccess) { var user = _userService.GetUser(UserId); var payment = new Payment(_httpClientFactory.CreateClient()); var obj = new Payment.Request(serviceResult.Data.Id.ToString()); obj.amount = decimal.Parse($"{serviceResult.Data.TotalPrice.ToString()}0"); obj.name = user.FullName; obj.phone = user.PhoneNumber; obj.mail = ""; obj.desc = $"خربد توسط {user.FullName}"; var res = await payment.RequestPayment(obj); if (res is Services.Payment.IdPay.Payment.RequestRespons_Success) { var sucRes = ((Services.Payment.IdPay.Payment.RequestRespons_Success)res); _userService.UpdateOrder(serviceResult.Data.Id, sucRes.id); return(RedirectPermanent(sucRes.link)); } else { failRes = ((Services.Payment.IdPay.Payment.RequestRespons_Fail)res).error_message; } } return(Content(failRes)); }
public async Task <JsonResult> Payment(string Amount) { string Link = "", Message = ""; try { var payment = new Payment(); var obj = new Payment.Request(null); obj.amount = decimal.Parse(Amount); obj.name = "مدیر"; obj.phone = "09124010603"; obj.mail = ""; obj.desc = "تست درگاه پرداخت"; var res = await payment.RequestPayment(obj); if (res is Payment.RequestRespons_Success) { Link = ((Payment.RequestRespons_Success)res).link; } else { Message = ((Payment.RequestRespons_Fail)res).error_message; } } catch (Exception ex) { } return(Json(new { PaymentUrl = Link, Message = Message }, JsonRequestBehavior.AllowGet)); }