Skip to content

Commit

Permalink
Section 10 - Save Stripe Session ID and Payment Intent ID
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 26, 2021
1 parent 8ad3e49 commit f4155e6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public interface IOrderHeaderRepository : IRepository<OrderHeader>
{
void Update(OrderHeader obj);
void UpdateStatus(int id, string orderStatus, string? paymentStatus=null);
void UpdateStripePaymentID(int id, string sessionId, string paymentItentId);
}
}
8 changes: 8 additions & 0 deletions BulkyBook.DataAccess/Repository/OrderHeaderRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,13 @@ public void UpdateStatus(int id, string orderStatus, string? paymentStatus = nul
}
}
}

public void UpdateStripePaymentID(int id, string sessionId, string paymentItentId)
{
var orderFromDb = _db.OrderHeaders.FirstOrDefault(u => u.Id == id);

orderFromDb.SessionId = sessionId;
orderFromDb.PaymentIntentId = paymentItentId;
}
}
}
10 changes: 9 additions & 1 deletion BulkyBookWeb/Areas/Customer/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public IActionResult SummaryPOST()

var service = new SessionService();
Session session = service.Create(options);

_unitOfWork.OrderHeader.UpdateStripePaymentID(ShoppingCartVM.OrderHeader.Id,session.Id,session.PaymentIntentId);
_unitOfWork.Save();
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);

Expand All @@ -160,6 +161,13 @@ public IActionResult SummaryPOST()
//return RedirectToAction("Index","Home");
}

public IActionResult OrderConfirmation(int id)
{
OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(u => u.Id == id);

//check the stripe status
}

public IActionResult Plus(int cartId)
{
var cart = _unitOfWork.ShoppingCart.GetFirstOrDefault(u => u.Id == cartId);
Expand Down

0 comments on commit f4155e6

Please sign in to comment.