Payment and booking coupling
Why it matters
Without bidirectional references between the booking record and the payment provider transaction, any webhook processing failure becomes an irrecoverable data loss: you cannot look up the booking from the payment event, and you cannot look up the payment from the booking record. CWE-706 (use of incorrectly-resolved name or reference) and CWE-841 both apply. This is the root cause of "customer was charged but has no booking" incidents that require manual database forensics: the payment provider has the charge, the application has the booking, but there is no programmatic link between them. Every refund, rebooking, and dispute resolution becomes a manual operation.
Severity rationale
Critical because without bidirectional coupling, any webhook failure produces orphaned charges that cannot be programmatically reconciled, requiring manual intervention per incident.
Remediation
Add a paymentIntentId column to the Booking model and pass the booking ID in the payment provider's metadata. Add this in prisma/schema.prisma and your checkout handler.
// schema.prisma
model Booking {
id String @id @default(cuid())
paymentIntentId String? // Stripe PaymentIntent ID
}
// In checkout handler
const intent = await stripe.paymentIntents.create({
amount,
metadata: { bookingId: booking.id }, // payment -> booking
});
await db.booking.update({
where: { id: booking.id },
data: { paymentIntentId: intent.id }, // booking -> payment
});
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Booking Flow & Lifecycle Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-706 — Use of Incorrectly-Resolved Name or Reference
- cwe · CWE-841 — Improper Enforcement of Behavioral Workflow
- iso-25010:2011 · functional-suitability.functional-correctness
Taxons
History
- 2026-04-18·v1.0.0·Initial import from booking-flow-lifecycle·automated