Code RoomExternal charge not rolled back
HardPrep Room Coding #4525

External charge not rolled back

Code reviewDatabases & SQLReliability & on-callSenior–Staff~22 min

Review this Java booking method that charges the customer, then persists the reservation.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1@Transactional
2public Booking book(BookingReq req) {
3 Charge c = paymentGateway.charge(req.getCardToken(), req.getAmount()); // external API
4 Booking b = new Booking(req, c.getId());
5 bookingRepo.save(b); // may throw on constraint violation
6 inventory.decrement(req.getRoomId()); // local DB
7 return b;
8}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.