Description
Add POST /bookings/:id/cancel returning the computed refund per the booking's cancellation policy, and requiring an explicit confirm=true to actually cancel and refund.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/routes/bookings.ts, src/services/cancellationPolicy.ts
Suggested execution
- Fork the repo and create a branch
git checkout -b feat/booking-cancel-with-preview
- Implement changes
- Preview request (
confirm=false) returns refund amount + fee breakdown
- Confirm request (
confirm=true) issues refund via existing payments client
- Emit
booking_cancelled_total{policy} metric
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- policy = strict (no refund), booking already-completed, refund-fail path, replay of confirm request
- Include test output and notes
Example commit message
feat: cancel booking with refund preview
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
Add
POST /bookings/:id/cancelreturning the computed refund per the booking's cancellation policy, and requiring an explicitconfirm=trueto actually cancel and refund.Requirements and context
src/routes/bookings.ts,src/services/cancellationPolicy.tsSuggested execution
git checkout -b feat/booking-cancel-with-previewconfirm=false) returns refund amount + fee breakdownconfirm=true) issues refund via existing payments clientbooking_cancelled_total{policy}metricTest and commit
npm testExample commit message
feat: cancel booking with refund previewGuidelines