Skip to content

Add "cancel booking" endpoint returning a refund preview and applying policy per booking type #590

Description

@thlpkee20-wq

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
    • npm test
  • 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

Metadata

Metadata

Assignees

Labels

Stellar WaveStellar Wave issue batchapiAPI endpoints and request/response behaviorbackendBackend scopefeatureNew feature work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions