Контроллер:
Код: Выделить всё
public IActionResult OrderConfirmation(int id)
{
OrderHeader orderHeader = _unitOfWork.OrderHeader.Get(u => u.Id == id, includeProperties: "ApplicationUser");
if (orderHeader.PaymentStatus != SD.PaymentStatusDelayedPayment)
{
var service = new Stripe.Checkout.SessionService();
Stripe.Checkout.Session session = service.Get(orderHeader.SessionId);
if (session.PaymentStatus.ToLower() == "paid")
{
_unitOfWork.OrderHeader.UpdateStripePaymentID(id, session.Id, session.PaymentIntentId);
_unitOfWork.OrderHeader.UpdateStatus(id, SD.StatusApproved, SD.PaymentStatusApproved);
_unitOfWork.Save();
}
}
List shoppingCarts = _unitOfWork.ShoppingCart
.GetAll(u => u.ApplicationUserId == orderHeader.ApplicationUserId).ToList();
_unitOfWork.ShoppingCart.RemoveRange(shoppingCarts);
_unitOfWork.Save();
return View(id);
}
Код: Выделить всё
public class OrderHeader
{
public int Id { get; set; }
public string? ApplicationUserId { get; set; }
[ForeignKey("ApplicationUserId")]
[ValidateNever]
public ApplicationUser? ApplicationUser { get; set; }
public DateTime OrderDate { get; set; }
public DateTime ShippingDate { get; set; }
public double OrderTotal { get; set; }
public string? OrderStatus { get; set; }
public string? PaymentStatus { get; set; }
public string? TrackingNumber { get; set; }
public string? Carrier { get; set; }
public DateTime PaymentDate { get; set; }
public DateOnly PaymentDueDate { get; set; }
public string? SessionId { get; set; }
public string? PaymentIntentId { get; set; }
[Required]
public string PhoneNumber { get; set; }
[Required]
public string StreetAddress { get; set; }
[Required]
public string City { get; set; }
[Required]
public string State { get; set; }
[Required]
public string PostalCode { get; set; }
[Required]
public string Name { get; set; }
[Required]
public int PostalCode1 { get; set; }
}


Я пытался найти ту же ошибку, но есть разные написаны коды, которые не подходят для моего решения.
Подробнее здесь: https://stackoverflow.com/questions/786 ... to-payment