Architecting Stripe Connect Hold and Capture Flows for Marketplace Apps
How to design commitment-first booking workflows, two-step authorization, and proof-of-service lifecycle states in on-demand service platforms.
In on-demand service marketplaces—whether connecting clients with hairstylists, physical trainers, or delivery providers—the greatest operational threat to platform viability is marketplace no-shows.
If a client books a slot without immediate commitment, providers frequently travel to locations or decline other paying clients only to face last-minute cancellations. Conversely, if you charge the customer upfront before service delivery, providers may fail to show up, forcing manual refund overhead and dispute handling.
During my product engineering work architecting high-throughput marketplaces, I tackled this challenge by designing a commitment-first booking workflow backed by Stripe Connect hold and capture logic combined with an explicit finite state machine.
Here is how to engineer this architecture securely.
1. The Core Principle: Two-Step Authorization
Standard e-commerce checkouts perform authorization and capture in a single step (capture_method: 'automatic'). In on-demand marketplaces, you must decouple these two phases:
- Pre-Authorization (Hold): When the booking is requested or accepted, place an authorization hold on the customer's card (
capture_method: 'manual'). The funds are reserved by the issuing bank, guaranteeing liquidity without settling the charge. - Post-Service Capture: Only when proof-of-service is verified (e.g., OTP exchange or provider check-in), your backend triggers the capture call, splitting the platform fee and transferring provider earnings via Stripe Connect.
Client App Your Backend / State Machine Stripe API
│ │ │
│── 1. Request Booking ──────────────>│ │
│ │── 2. Create PaymentIntent ────────>│
│ │ (capture_method: 'manual') │
│<── 3. Client Secret (Confirm) ──────│ │
│ │ │
│── 4. Card Pre-Authorized (Hold) ───>│ │
│ │ │
│ [Service Delivered / OTP] │ │
│ │ │
│── 5. Provider Verifies OTP ────────>│ │
│ │── 6. Capture PaymentIntent ───────>│
│ │ (Transfer to Provider) │
│<── 7. Booking Complete ─────────────│ │2. Managing the Booking Lifecycle with a Finite State Machine
Payment state must never exist independently from booking state. Trying to coordinate both with scattered if/else checks across API handlers inevitably leads to race conditions and orphaned authorizations.
Instead, model the lifecycle as an explicit state machine:
from enum import Enum
class BookingState(str, Enum):
DRAFT = "DRAFT"
PAYMENT_HELD = "PAYMENT_HELD"
PROVIDER_EN_ROUTE = "PROVIDER_EN_ROUTE"
SERVICE_IN_PROGRESS = "SERVICE_IN_PROGRESS"
COMPLETED = "COMPLETED"
CANCELLED = "CANCELLED"
EXPIRED = "EXPIRED"
ALLOWED_TRANSITIONS = {
BookingState.DRAFT: [BookingState.PAYMENT_HELD, BookingState.CANCELLED],
BookingState.PAYMENT_HELD: [BookingState.PROVIDER_EN_ROUTE, BookingState.CANCELLED],
BookingState.PROVIDER_EN_ROUTE: [BookingState.SERVICE_IN_PROGRESS, BookingState.CANCELLED],
BookingState.SERVICE_IN_PROGRESS: [BookingState.COMPLETED],
BookingState.COMPLETED: [],
BookingState.CANCELLED: [],
}Every state transition must validate that the required payment precondition is satisfied. For example, moving from PROVIDER_EN_ROUTE to SERVICE_IN_PROGRESS requires an active authorization hold on the card.
3. Implementing Two-Sided Proof of Service (OTP Verification)
To eliminate payment disputes, introduce a physical handover verification mechanism:
- The client receives a single-use 4-digit One-Time Password (OTP) in their mobile app when the provider arrives.
- The provider enters this OTP on their application.
- Your backend verifies the hash, transitions the booking state to
COMPLETED, and executes the Stripe capture call in a single atomic transaction.
async def complete_booking_and_capture(booking_id: str, entered_otp: str):
async with db.transaction():
booking = await get_booking(booking_id)
# Verify OTP proof of service
if not verify_otp_hash(booking.otp_hash, entered_otp):
raise InvalidOtpException("Verification code does not match.")
# Transition state
booking.state = BookingState.COMPLETED
await db.save(booking)
# Capture the authorization hold
stripe.PaymentIntent.capture(
booking.stripe_payment_intent_id,
amount_to_capture=booking.final_amount_cents,
)4. Handling Uncaptured Authorizations (The 7-Day Window)
Stripe card authorization holds generally expire after 7 days (depending on the card brand). In on-demand services, bookings typically conclude within hours, but edge cases must be handled:
- Provider Cancellation: Immediately release the uncaptured hold using
stripe.PaymentIntent.cancel(payment_intent_id)to restore the customer's available credit line instantly without waiting for auto-expiration. - Partial Charges: If a cancellation fee applies (e.g., client cancels after the provider arrived), capture only the cancellation amount and release the remaining authorization balance.
Conclusion
Combining two-step manual payment captures, Stripe Connect destination payouts, and a strict server-side state machine creates a transparent, dispute-resistant ecosystem. It protects service providers from wasted time while ensuring clients are only charged for verified results.
Need to engineer custom marketplace payment flows, subscription infrastructure, or on-demand dispatch architectures? Let's connect to map out your implementation.
Building a mobile app or web platform?
I take products from concept to a production release in 4–6 weeks. Let's talk through your goals.