A reliable hotel API cancellation workflow coordinates a supplier reservation, a traveller's authorization, and a payment ledger without treating them as one transaction. A cancellation request may succeed while its network response fails. A supplier may calculate a penalty that differs from the amount retained from the traveller. A card refund may remain pending after a room is definitively cancelled. Software must represent these outcomes independently.
This guide uses fictional Paris reservation H-0333. Every fixture identifier, amount, event, timestamp, and hotel detail is illustrative, never customer history or an actual supplier transaction. The proposed data model is a TravelTech365 design example, not a supplier schema.
The central rule is narrow: cancel room A only after displaying a fresh penalty of EUR 100 and recording explicit room-specific consent. Preserve room B. Resolve an uncertain cancellation by retrieval, not blind repetition. Refund EUR 200 from the original EUR 720 merchant capture, while accounting for a separate EUR 170 supplier credit.
Booking identity and immutable starting facts
For the illustrative fixture, a traveller booked two rooms at the fictional Hôtel Exemple Seine in Paris for 2–5 November 2027. The merchant collected EUR 720 in one captured card payment. The stay and property names are placeholders; they must never appear as real guest history, inventory, or confirmed hotel availability.
| Field | Recorded value | Engineering interpretation |
|---|---|---|
| Booking | H-0333 | Parent reservation; currently active |
| Supplier reference | PAR-TEST-0333 | Fictional connector reference, not a live locator |
| Room A | H-0333-A; EUR 300 | Requested cancellation target |
| Room B | H-0333-B; EUR 420 | Must remain active and unchanged |
| Stay | 2027-11-02 to 2027-11-05 | Three illustrative nights, property in Paris |
| Merchant capture | CAP-0333; EUR 720 | One successful captured payment in EUR |
| Initial policy view | POL-0333-V1; penalty EUR 0 | Historical display, not executable authorization |
| Supplier A cost | EUR 250 | Separate business-to-business payable baseline |
| Operation | CAN-0333-A-01 | Stable internal cancellation intent |
Keep immutable room IDs, supplier locators, monetary allocations, and separate payment references. Preserve raw and normalized supplier payloads. A label such as “double room” is unsafe because multiple rooms can share a description.
The requested scope must be checked against supplier capability before presenting a final action. If a provider supports cancelling only an entire booking, a room-only request must stop for assisted handling; never substitute a whole-booking cancellation. The fixture's successful branch assumes a connector and reservation that explicitly support cancellation of A without altering B.
Policy interpretation and provider-specific boundaries
Retrieve policy at shopping, booking, postbooking, and cancellation. Retain original dates, offsets, currencies, penalty units, refundability labels, and response fingerprint. A search badge cannot guarantee the later fee.
Keep source semantics intact
For Expedia Group Rapid lodging, the cancellation policy guidance describes current_refundability, cancel_penalties, and optional nonrefundable_date_ranges. Its returned ISO 8601 offsets are authoritative; do not infer another offset from a hotel's street address. Nonrefundable stay dates can affect an otherwise favorable cancellation window. These are Rapid concepts, not universal hotel API fields.
Rapid Manage Booking documents retrieve, change, and cancel operations and describes room-cancellation links returned for supported bookings. Use the actual returned capability link and current itinerary context rather than assembling an endpoint from a fictional room ID. Scope and link availability depend on the particular booking.
For Booking.com Demand API, cancellation policy documentation distinguishes search-level summaries, booking preview schedules, and postbooking order details. It also distinguishes version-specific terminology, including special_conditions in v3.1 and partially_refundable in v3.2. Do not paste these labels into a Rapid or Hotelbeds payload. Display the cancellation fee returned by the applicable Demand operation rather than reconstructing its amount from marketing copy.
For Hotelbeds' hotel Booking API, availability can expose cancellation fee details, checkrates can refresh rates where required, and booking operations include cancellation and cancellation simulation. A simulation can inform a new quote; it does not itself prove that a reservation has been cancelled. Verify applicable transaction scope and permissions with the contracted integration.
| Connector | Documented relevant behavior | Required local validation |
|---|---|---|
| Rapid lodging | Rate policy windows and Manage Booking room links | Room A cancellation link present; B excluded |
| Demand Orders | Preview, current details, cancellation eligibility | Selected travel-service scope and version verified |
| Hotelbeds Booking API | Cancellation conditions and simulation capabilities | Partial-room operation supported for this booking |
| Merchant processor | Captured-charge refunds and state tracking | Original capture owned by merchant; refund permitted |
These interfaces are not interchangeable. Each contracted adapter needs explicit capabilities, status mapping, and tests. Missing scope evidence means fail closed.
Cutoff timing across the Paris daylight-saving transition
The fixture's supplier supplies a cancellation penalty cutoff of 2027-10-31T02:30:00+02:00. That instant equals 2027-10-31T00:30:00Z. On the autumn clock change, Paris repeats the local hour beginning at 02:00. The later occurrence, 2027-10-31T02:30:00+01:00, instead equals 2027-10-31T01:30:00Z: an entirely different instant, one hour later.
Neither a city-based time-zone conversion nor a naive timestamp without an offset can safely replace the supplier's original string. Store the original timestamp, parsed UTC instant, offset, policy source, and parsing outcome. Compare instants using UTC. Display a localized label with offset or zone clarification, especially when an hour repeats.
| Case | Supplier-offset instant | UTC instant | Expected treatment |
|---|---|---|---|
| Minus one second | 2027-10-31T02:29:59+02:00 | 2027-10-31T00:29:59Z | Before cutoff; illustrative old fee EUR 0 |
| Exact cutoff | 2027-10-31T02:30:00+02:00 | 2027-10-31T00:30:00Z | Penalty window begins; fresh quote EUR 100 |
| Follow-up second | 2027-10-31T02:30:01+02:00 | 2027-10-31T00:30:01Z | After cutoff; fee must be rechecked |
| Repeated local time | 2027-10-31T02:30:00+01:00 | 2027-10-31T01:30:00Z | Not equivalent to supplier cutoff |
This fixture charges at the exact cutoff; actual providers may define boundaries differently. Honor returned quote semantics. Test milliseconds, timeouts, clock drift, and delayed submission.
A checkout page opened before 00:30 UTC cannot freeze eligibility indefinitely. If a traveller confirms after a slow network request, retrieve current conditions. Never silently display “free cancellation” after receiving a chargeable quote. Showing EUR 100 before committing is mandatory even though the historical screen showed EUR 0.
Quote refresh, authorization, and room scope
At 00:29:59 UTC, the illustrative screen displays quote Q-0333-OLD with penalty EUR 0. At 00:30:00 UTC, a fresh supplier assessment yields Q-0333-NEW with penalty EUR 100 for A. The application must invalidate the previous confirmation, show the changed terms, and request a new affirmative decision. An earlier click based on zero penalty is not consent to a higher charge.
| Evidence field | Value | Enforcement |
|---|---|---|
| Fresh quote | Q-0333-NEW; issued 2027-10-31T00:30:00Z | Overrides Q-0333-OLD |
| Target | H-0333-A only | Explicit room identifier |
| Retail allocation | EUR 300 | Room A portion of captured order |
| Customer penalty | EUR 100 | Fresh, displayed amount |
| Proposed refund | EUR 200 | 300 minus 100 |
| Unchanged room | H-0333-B; EUR 420; active | Cannot be included in supplier mutation |
| Consent | CONS-0333-A; 2027-10-31T00:30:08Z | Explicit accept of Q-0333-NEW |
| Submission | CAN-0333-A-01; 2027-10-31T00:30:09Z | Single operation intent |
Consent is a bound authorization
Record the actor's authenticated identifier, consent method, timestamp, UI wording version, currency, exact room set, maximum penalty, anticipated refund, quote fingerprint, and relevant policy snapshot. The fixture's actor ID is GUEST-0333-TEST, with a positive confirmation labeled “Cancel room A; accept EUR 100 fee; refund EUR 200.” The consent must not authorize B, a greater penalty, or an unrelated payment.
If the fee increases, the quote expires, or scope changes, repeat review. Bind authorization to the accepted quote. Use a transactional check to prevent concurrent bypass.

Execute once, then reconcile an ambiguous timeout
Model the operation as a durable state machine: requested, quoted, authorized, submitted, outcome_unknown, supplier_confirmed, and closed, with an explicit failed or assisted-resolution path. These are proposed internal states, not supplier-defined enums. Append each transition with timestamp, source, correlation ID, and previous state.
Before the supplier call, take a short-lived lock on booking H-0333 and reserve operation CAN-0333-A-01 under a unique key formed from booking, room target, and action intent. Re-read current room state and consent. Submit only the target supported by the adapter. Save the outbound request digest and redacted correlation details before network execution so a worker crash can be investigated.
The illustrative supplier processes the A-only cancellation, but the response times out at 2027-10-31T00:30:11Z. A transport timeout means the client lacks acknowledgement; it does not mean supplier failure. Set outcome_unknown and block new cancellation submissions while fetching the latest authoritative booking representation.
At 2027-10-31T00:30:15Z, retrieval R-0333-01 confirms room A cancelled, room B active. Persist these two room states separately and set supplier outcome to confirmed. Do not repeat the cancellation call. The original consent remains linked to this resolution, and any delayed success or error response is recorded as evidence without reapplying effects.
| UTC time | Observation | Durable result |
|---|---|---|
| 00:30:09 | Submit A-only intent CAN-0333-A-01 | One outbound attempt recorded |
| 00:30:11 | HTTP client timeout; no definitive body | Outcome unknown; mutation locked |
| 00:30:15 | Retrieve R-0333-01: A cancelled, B active | Supplier result confirmed by read |
| 00:30:16 | Persist new A and B projections | No second supplier cancel |
| 00:30:17 | Authorize merchant refund workflow | EUR 200 eligible for processing |
Booking.com Demand cancellation error handling directs integrators to inspect the latest order details before deciding on retries. Its guidance discusses specific retriable server responses, but a generic retry suggestion must not override a successful retrieval or application-level idempotency. In this fixture, a repeat is prohibited because the desired supplier state is already established.
If retrieval remains inconclusive, reconcile through bounded reads and escalate. Never claim cancellation without supplier evidence or infer failure solely from a lost HTTP response.
Two ledgers: traveller refund versus supplier credit
The merchant originally captured EUR 720, allocated EUR 300 to A and EUR 420 to B. Accepted customer penalty for A is EUR 100. Therefore A's refundable retail amount is EUR 200, and the merchant retains EUR 520 across A's EUR 100 charge and B's EUR 420 active booking. The merchant must refund against the original successful capture, not manufacture a new disbursement or reduce B's allocation.
The supplier settlement is different. In the illustrative commercial arrangement, room A's original net supplier cost is EUR 250 and the supplier charges a separate EUR 80 cancellation penalty. Supplier credit is therefore EUR 170. Do not label that EUR 170 as the traveller's refund. The EUR 30 difference between merchant refund and supplier credit reflects different retail and wholesale baselines; it is not a payment-processing discrepancy.
| Ledger | Entry | Amount | Proof or formula |
|---|---|---|---|
| Merchant | Original card capture | 720.00 | CAP-0333 |
| Merchant | Refund for cancelled A | 200.00 | 300.00 less 100.00 |
| Merchant | Net retained retail | 520.00 | 720.00 less 200.00 |
| Merchant | Retained A plus active B | 100.00 + 420.00 | Matches 520.00 |
| Supplier | Original cost allocated to A | 250.00 | Supplier cost fixture |
| Supplier | Separate A cancellation penalty | 80.00 | Supplier penalty fixture |
| Supplier | Credit due for A | 170.00 | 250.00 less 80.00 |
Use integer minor units internally: capture 72000, refund 20000, merchant retained 52000, supplier cost 25000, supplier penalty 8000, supplier credit 17000. Store currency with every amount; disallow addition across currencies without an explicit conversion ledger. Record processor fees, taxes, commissions, and supplier settlement timing independently when they exist, rather than inventing values from this example.
Supplier credit may remain expected while the customer refund proceeds. Track expected, confirmed, settled, and disputed amounts. Do not infer B's cost or total booking margin.
Payment topology determines the corrective action
Captured merchant payment
For the main scenario, issue one EUR 200 partial refund against capture CAP-0333 after confirming the supplier cancellation. The Stripe refund guidance allows partial refunds against successful payments and describes asynchronous, pending, successful, and failed outcomes. This implementation treats Stripe as an illustrative processor; its specific objects and payment states must not be attributed to other gateways.
Attach local refund key REF-0333-A-01 to the cancellation operation and the original capture. Save the processor's returned refund identifier and inspect existing records before retrying a timed-out refund request. A local exactly-once business invariant needs deduplication and reconciliation even when a payment API offers its own idempotency controls. Never refund beyond captured funds or silently refund twice.
Pay at property
If the guest pays the property directly, the platform must not invent a EUR 720 merchant capture or attempt a card refund it does not control. Record the supplier's cancellation outcome and property-collected fee responsibility. Inform the guest whether the property handles any refund, and expose unresolved amounts as external settlement tasks. An API saying “cancelled” does not establish that the hotel has returned money.
Authorization not yet captured
When the platform holds only an uncaptured authorization, the corrective transaction is not a normal refund of a completed charge. For Stripe PaymentIntents in requires_capture, the documented flow cancels the intent rather than directly refunding an uncaptured charge. If B still requires payment, safely reassess the outstanding amount and payment authorization using the actual processor and merchant contract; do not cancel an entire payment intent without first protecting B's obligation.
For deposits, vouchers, installments, or split captures, use each instrument's permitted reversal path. The main EUR 200 refund assumes a fully captured EUR 720.
Independent supplier and processor state machines
After supplier retrieval confirms A cancelled, the refund may be submitted successfully but remain pending with the processor. Represent supplier=A_CANCELLED, room_B=ACTIVE, and refund=PENDING simultaneously. The traveller-facing update should say “Room A cancelled; EUR 200 refund processing,” not “Refund completed.” Escalation timing and final availability depend on processor responses and the payment method.
Later, a verified processor event or retrieval may move the refund to succeeded, or a failure may require finance follow-up. Neither transition changes the supplier cancellation result. Use separate monotonic version counters for supplier and refund projections so a delayed processor callback cannot rewrite room B or reactivate A.
| Event ID | Time UTC | Meaning | Expected handler behavior |
|---|---|---|---|
| SUP-E-0333-1 | 00:30:16 | A cancelled; B active | Store supplier confirmation once |
| PAY-E-0333-1 | 00:30:20 | Refund REF-0333-A-01 pending | Keep payment state pending |
| PAY-E-0333-1 | 00:30:22 | Duplicate pending event | Acknowledge; no second posting |
| PAY-E-0333-2 | 00:35:00 | Same refund succeeded | Finalize EUR 200 refund once |
| PAY-E-0333-1 | 00:35:03 | Delayed stale pending event | Preserve succeeded status |
Verify events with the provider's supported mechanism. These IDs are fictional. Deduplicate event and business-effect identities; reject stale transitions. Replays must not create refunds, cancellations, or confirmations.
Failure handling and operational controls
Classify failures before automatic action. Invalid identifiers and forbidden operations generally need data repair or support. An expired quote requires a new supplier assessment and potentially new consent. A transport failure after an irreversible call requires retrieval first. A completed supplier cancellation coupled with failed refund processing requires finance remediation, not a second supplier cancellation.
| Condition | Safe response | Forbidden shortcut |
|---|---|---|
| Room-only operation unsupported | Block mutation; open assisted scope review | Cancel entire H-0333 |
| Fresh fee exceeds consent | Show terms again; obtain authorization | Reuse EUR 0 confirmation |
| Supplier timeout | Retrieve latest states and reconcile | Blindly resubmit |
| Already cancelled | Verify matching room and existing operation | Create new cancellation charge |
| Processor refund pending | Poll or await verified status; notify accurately | Mark paid immediately |
| Refund failed | Escalate and resolve original refund intent | Erase supplier cancellation |
Set observable retry budgets and alert thresholds for unknown supplier outcomes, refund aging, mismatched amounts, and duplicate effects. Administrative overrides should require reason, role, approval, and evidence attachment. The system should preserve a human-readable incident timeline without exposing full payment credentials or unnecessary guest personal information.
Evidence package and audit trace
A support engineer must be able to reconstruct what the customer saw, what the supplier did, and what the merchant paid, without relying on a screenshot alone. Build an append-only evidence chain keyed by H-0333, room A, operation CAN-0333-A-01, and refund REF-0333-A-01. Keep access restricted and retention aligned with contractual, privacy, and financial obligations.
| Evidence ID | Captured material | Expected finding |
|---|---|---|
| EV-01 | POL-0333-V1; cutoff +02:00; old quote | EUR 0 originally displayed |
| EV-02 | Q-0333-NEW; UTC normalization; raw quote digest | EUR 100 for A at exact cutoff |
| EV-03 | CONS-0333-A; text version 3; actor and timestamp | Explicit A-only consent to EUR 100 |
| EV-04 | CAN-0333-A-01 outbound trace; timeout | One mutation attempt; unknown response |
| EV-05 | R-0333-01 authoritative retrieval snapshot | A cancelled and B active |
| EV-06 | CAP-0333 and REF-0333-A-01 ledger trace | EUR 720 capture, EUR 200 refund |
| EV-07 | Supplier settlement advice SC-0333-A | EUR 250 less EUR 80 equals EUR 170 |
| EV-08 | Event receipt keys and transition history | Duplicates ignored; final refund succeeded |
These are expected records, not actual receipts. Preserve redacted payloads and hashes where appropriate, linked to authenticated responses. Keep fixture evidence labeled synthetic in every export.
Acceptance criteria and release gates
Test at the adapter contract level, state-machine level, payment level, and end-to-end journey level. Each test must assert both the intended change and the protected nonchange. Mock the fictional provider behavior deterministically, then repeat applicable cases in an authorized supplier sandbox; do not use real guest records as fixtures.
| ID | Given and action | Required result |
|---|---|---|
| AC-01 | H-0333 starts with A 300, B 420 | Total equals EUR 720; both rooms active |
| AC-02 | Compare cutoff minus one second | 00:29:59Z precedes 00:30:00Z |
| AC-03 | Compare exact cutoff and next second | Both treated within fixture penalty window |
| AC-04 | Parse repeated 02:30 with +01:00 | 01:30:00Z; never equal to +02:00 instant |
| AC-05 | Old fee 0 changes to fresh fee 100 | Block submission until new A-only consent |
| AC-06 | Consent granted for A and fee 100 | One bounded operation; B excluded from request |
| AC-07 | Outbound response times out; retrieval confirms A cancelled | Reconcile once; zero repeated cancellations |
| AC-08 | Supplier returns A cancelled, B active | Room projections match; parent partly active |
| AC-09 | Refund initiated from captured EUR 720 | EUR 200 once; EUR 520 retained |
| AC-10 | Supplier A cost 250, penalty 80 | Credit EUR 170 in distinct supplier ledger |
| AC-11 | Property-collect payment without merchant capture | No platform refund initiated |
| AC-12 | Authorization uncaptured | No refund against uncaptured charge |
| AC-13 | Connector lacks room-scoped cancellation | No booking-wide mutation; assistance path |
| AC-14 | Supplier done; processor still pending | States independent; notice says processing |
| AC-15 | Duplicate and stale events delivered | One ledger posting; final success never regresses |
| AC-16 | Processor refund fails after supplier success | Finance case created; A remains cancelled |
Release requires all sixteen assertions, stable identifiers in logs, uniqueness under parallel workers, cutoff tests, and restart-safe replay handling. Incomplete capability, reconciliation, or consent evidence blocks activation.
Verification and handoff checklist
- Verify the contracted supplier version, room-level cancellation permission, live retrieval path, and documented fee source; attach adapter-specific test evidence.
- Verify
2027-10-31T02:30:00+02:00equals00:30:00Z, while the+01:00occurrence equals01:30:00Z; run all boundary fixtures. - Verify stale EUR 0 cannot authorize EUR 100; preserve consent CONS-0333-A with A-only scope and exact displayed refund.
- Verify timeout recovery proves A cancelled and B active from retrieval, records only one supplier mutation, and reports any inconclusive outcome.
- Verify merchant capture EUR 720, single partial refund EUR 200, retained EUR 520, and separate supplier credit EUR 170.
- Verify property-collect and uncaptured paths never manufacture refunds; confirm pending, succeeded, failed, duplicate, and out-of-order processor behavior.
- Verify AC-01 through AC-16, audit manifest EV-01 through EV-08, privacy redaction, ownership, alert routing, and assisted-resolution documentation.
Handoff owner: hotel connector engineering for supplier capability and retrieval; booking platform engineering for consent and state transitions; payments engineering for capture-linked refunds; finance operations for supplier credit reconciliation; quality engineering for boundary and replay tests. Release decision: approve the illustrative H-0333 path only when each owner signs its evidence and no room B mutation, duplicate cancellation, or duplicate refund is observed.
