Payments
How a payment becomes a booking, the Razorpay webhook, and what happens when a payment arrives too late.
A Leo Cal booking is paid through your own payment gateway account. The money goes from your customer to you; Leo Cal prices the slot, holds the court, and confirms the booking once your gateway proves it was paid.
Razorpay is the supported gateway
Leo Cal can take a payment with Razorpay today. Cashfree, PhonePe, PayU and Stripe can be connected for your counter, but each needs its own checkout and its own signature scheme on the website side, so each is added deliberately. A venue connected only to one of those sees a message telling customers to call to book.
The rule everything follows
Only money we have verified confirms a booking.
A browser can be made to say anything, so it is never believed. It never states a price, and it never says "I've paid". It asks Leo Cal to start a checkout; Leo Cal prices the slot and the booking becomes real only when your gateway's signed result is verified.
The life of a payment
The customer presses Confirm & Pay
The widget asks the API to check out that slot, sending only the court, the start time, the length and the customer's name, phone and email. It does not send a price — nothing about price is accepted from the browser.
The slot is held and priced
The API checks the venue's booking rules, prices the slot from your own rates (GST included), and holds the court for 15 minutes. Nobody else — not another website visitor, not your counter, not Playo — can take it while the hold lasts.
An order is raised with your gateway
Using your Razorpay credentials, the API raises an order for exactly that amount. The booking reference and your branch's name are attached as notes, so your Razorpay reports can be split by site.
If your gateway refuses the order, the hold is taken down with it — nobody is left holding a court they were never asked to pay for.
The customer pays
Razorpay's own window opens, inside the Leo Cal frame. Card, UPI, netbanking and wallets are whatever your Razorpay account has switched on.
The payment is verified
Razorpay hands the browser a payment id and a signature. The widget forwards both to the API, which checks the signature against your gateway secret before anything changes. A forged or mismatched signature is refused and the court stays held.
The booking is confirmed
The hold becomes a confirmed, paid booking. The dashboard records a Paid Online event with the amount and the payment id; the customer is linked to (or added as) a customer record; and, if they gave an email, a confirmation email is queued.
Two routes to confirmation
There are two independent ways a payment can confirm a booking:
- The customer's browser returning from checkout with Razorpay's signature — the normal route, and the one that shows the confirmation screen.
- Razorpay's webhook — for the customer who paid and then closed the tab, lost signal, or whose browser never made it back.
They race, and either one may be the only one to arrive. The second to arrive is a no-op: the payment record is locked and its status read before anything is written, so a booking is confirmed once, never twice, however many times each route fires.
The Razorpay webhook
Without the webhook, a customer who pays and closes the page in the same second is charged but not booked — the court is released when its 15-minute hold lapses, and the money sits in your Razorpay account. Set it up once per gateway account.
Get the URL and a secret
Dashboard → Settings → Integrations → Razorpay → Manage. Under Webhook for online bookings you will see your webhook URL. Generate a secret there.
The URL is specific to your venue — it ends in your venue's short name — so copy it from the dashboard rather than typing it:
<your API address>/api/v1/payments/webhooks/razorpay/<your-venue>Add it in Razorpay
In Razorpay: Account & Settings → Webhooks → + Add New Webhook. Paste the URL and the
secret. Tick the payment.captured event and save.
Use the same mode as your keys. Razorpay keeps Test and Live webhooks separate, so when you go live, add the webhook again in Live mode with the live secret.
If you run a separate Razorpay account per branch, one URL serves them all. Each webhook names the order it is about, and the order names the account that raised it, so each is verified against that account's own secret.
What the webhook endpoint answers
It answers 200 to anything it will never act on — an unknown venue, an event other
than payment.captured, a payment from another product on the same Razorpay account —
so Razorpay does not retry it for a day. It answers 500 only when a payment is
genuine and settling it failed, so that Razorpay does retry.
When the payment arrives too late
A hold lasts 15 minutes. A customer who takes longer — leaving the payment window open while they find their card — may find that your counter, or another channel, sold the court in the meantime. They have paid for nothing.
When that happens the booking cannot be confirmed (the database refuses an overlap), and the payment is refunded automatically, in full, on the spot. It is not left for someone to notice in a reconciliation. The customer is told:
Sorry — that slot was booked by someone else before your payment arrived. Your payment has been refunded in full; it can take 5–7 working days to reach your account.
The booking's history on your dashboard shows Online Payment Refunded, with the refund id and the reason. If Razorpay fails the refund itself, the operation is rolled back and left as pending, so the webhook's retry attempts the refund again rather than it being forgotten.
Per-branch accounts
If your venue collects payments per branch (Settings → Integrations, one gateway per branch), Leo Cal charges the account of the branch the court belongs to. If one branch has not set up online payments, that branch alone shows "(branch name) hasn't set up online payments yet. Please call to book." — the other branches still take bookings.
If every branch shares one account, all bookings go to it. See How branches choose a gateway.
Testing without moving money
Use Razorpay's Test mode and its test cards and UPI ids. Nothing is charged, and test and live connections are stored separately. A test booking appears on your dashboard like any other; cancel it from the Bookings page when you are done.