Chauffeur Circle Docs

Developers

Custom forms

ProBusiness Included on these plans

Build the booking form in your own HTML and design. Chauffeur Circle still does the pricing, availability and booking, and Square's secure card form appears in a frame you place. Your page never sees card numbers.

The flow

  1. Get prices: quotes.create() with the trip. You get each vehicle with its price.
  2. Book: bookings.create() with the chosen vehicle and the passenger's details. You get the booking and a payment_session.
  3. Save the card: payments.mount('#card', { session }) shows the secure card form. When the card is saved, the booking is confirmed and emails go out.

Complete example

<form id="trip">
  <select id="airport"></select>
  <input id="date" type="date" required> <input id="time" type="time" value="10:00" required>
  <input id="passengers" type="number" min="1" value="2">
  <button>Get prices</button>
</form>
<div id="vehicles"></div>
<form id="details" hidden>
  <input id="first_name" required> <input id="last_name" required>
  <input id="email" type="email" required> <input id="phone" type="tel" required>
  <label><input id="terms" type="checkbox" required> I agree to the booking terms</label>
  <button>Book</button>
</form>
<div id="card"></div>

<script src="https://cdn.chauffeurcircle.com/v1/sdk.js"></script>
<script type="module">
  const chauffeurCircle = ChauffeurCircle('cc_pk_live_…');
  const config = await chauffeurCircle.config();
  document.getElementById('airport').innerHTML =
    config.airports.map((a) => `<option value="${a.code}">${a.name}</option>`).join('');

  let quote, vehicleId;

  document.getElementById('trip').addEventListener('submit', async (e) => {
    e.preventDefault();
    quote = await chauffeurCircle.quotes.create({
      service_type: 'airport',
      pickup: { airport: airport.value },
      dropoff: { address: '350 5th Ave, New York, NY 10118', lat: 40.7484, lng: -73.9857 },
      pickup_at: `${date.value}T${time.value}`,   // in your time zone
      passengers: Number(passengers.value),
    });
    const v = quote.vehicles.find((v) => v.available && !v.quote_only);
    vehicleId = v.vehicle_type_id;
    vehicles.textContent = `${v.name}: $${(v.price.total_cents / 100).toFixed(2)}`;
    details.hidden = false;
  });

  document.getElementById('details').addEventListener('submit', async (e) => {
    e.preventDefault();
    const { booking, payment_session } = await chauffeurCircle.bookings.create({
      quote_id: quote.id,
      vehicle_type_id: vehicleId,
      customer: { first_name: first_name.value, last_name: last_name.value, email: email.value, phone: phone.value },
      terms_accepted: true,
      source: 'custom_form',
    });
    chauffeurCircle.payments.mount('#card', {
      session: payment_session,
      onSuccess: (card) => alert(`Booked ${card.reference} with ${card.brand} •••• ${card.last4}`),
      onError: (err) => console.warn(err.message),
    });
  });
</script>

Things to know

  • Addresses need coordinates. Pass lat and lng with every address (from Google Places or your own list). Airports only need the code from config().airports.
  • Quotes last 30 minutes. After that bookings.create() returns quote_expired; get a new quote.
  • Payment sessions last 60 minutes. If the passenger takes longer, the frame shows that the link has expired.
  • Quote-only vehicles (quote_only: true) have no price. Booking one creates a quote request with no payment_session.
  • Phone numbers must be valid; send them in international format (+12127363100) if you can.
  • Retries are safe. bookings.create() sends an Idempotency-Key, so a double click never creates two bookings.

See the SDK reference for every method and the API reference for every field.