//[AcceptVerbs("Get", "Post")] //public async Task<IActionResult> SameUser([Bind(Prefix = "id")] int id) //{ // var user = await userManager.GetUserAsync(HttpContext.User); // var lostItem = await lostItemRepository.GetLostItemById(id); // if (user == null || user != lostItem.LostItemUser) // return RedirectToAction("Create", "LostItemClaim", new { Id = id }); // //.FindByEmailAsync(); // // return Json("You cant Claim to have Found what you declared you lost"); // return View(); //} public async Task <IActionResult> MakePayment() { var user = await userManager.GetUserAsync(User); if (user == null) { return(NotFound()); } CyberPay cyberPay = new CyberPay { Amount = 1500 * 100, Description = "Delivery Payment ", MerchantRef = Guid.NewGuid().ToString(), ReturnUrl = @"https://localhost:5001/User/LostItemClaim/Index", CustomerEmail = user.Email, CustomerMobile = user.PhoneNumber ?? "", CustomerName = $"{user.LastName} {user.FirstName}" }; var res = await Processing.MakePaymentAsync(cyberPay); if (res.Succeeded) { return(Redirect(res.Data.RedirectUrl)); } else { return(RedirectToAction("Index")); } }
public static async Task <PaymentStatus> MakePaymentAsync(CyberPay model) { PaymentStatus status = new PaymentStatus(); using (var httpClient = new HttpClient()) { StringContent content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); using (var response = await httpClient.PostAsync("https://cyberpay-payment-api.azurewebsites.net/api/v1/payments", content)) { string apiResponse = await response.Content.ReadAsStringAsync(); status = JsonConvert.DeserializeObject <PaymentStatus>(apiResponse); } } return(status); }