Skip to main content

Online payment

The API does not take card details. Payment happens on the venue's Odoo payment page, with the payment providers the venue published (Stripe, Adyen, a local bank gateway and so on). The app opens that page in an in-app browser. This keeps card data out of the app, and the payment rules (amounts, 3-D Secure, receipts) stay the same as on the website.

The flow​

  1. POST /bookings returns a booking with state: "hold" and:
"payment": {
"required_online": true,
"amount": 20.63,
"pay_url": "https://booking.example.com/book/pay/78?access_token=5c1f0e9a-3b7d-4e62-a8f4-2d91c6b07e35"
}
  1. Open pay_url in an in-app browser: Chrome Custom Tabs on Android, SFSafariViewController or ASWebAuthenticationSession on iPhone, a browser window on desktop. Show the countdown to hold_expires_at next to it.

  2. The player pays. Odoo confirms the booking, posts the invoice and the payment, and sends the confirmation email. The page ends on the booking page of the website (/my/bookings/78?...&paid=1).

  3. When the in-app browser closes (or its address reaches /my/bookings/), call GET /bookings/{id}:

    • state: "confirmed" and amount_due_online: 0: paid. Show the confirmation.
    • still hold: the payment is not finished (some providers confirm a few seconds later). Ask again every 2 to 3 seconds for up to 30 seconds, then show "Payment not finished" with a Pay now button.

Paying later: POST /bookings/{id}/payment-link​

Returns a fresh payment link for what is still due online. Use it for the Pay now button of a booking in the list, and after the player closed the payment page without paying.

{
"data": {
"required_online": true,
"amount": 20.63,
"pay_url": "https://booking.example.com/book/pay/78?access_token=5c1f0e9a-3b7d-4e62-a8f4-2d91c6b07e35"
}
}

If the hold has expired in the meantime, the link takes the court again when it is still free, with a new payment time. When someone else booked it, the answer is 422 with "Sorry, this court was booked by someone else in the meantime."

When nothing is due online (paid already, or paid at the venue) the answer is 422 with nothing_due:

{
"error": {
"code": "nothing_due",
"message": "Nothing is due online for this booking."
}
}

Amounts​

  • Deposit: amount is the deposit (deposit_percent of the price, rounded to the currency). The rest (amount_due) is paid at the venue, usually at the Point of Sale, where the deposit is already counted.
  • Full: amount is the whole price.
  • amount_due_online on the booking always tells what is still due online now.

Things to avoid​

  • Do not open pay_url in a WebView you control: payment providers and 3-D Secure pages may refuse it, and Google and Apple ask for a real browser tab for payments.
  • Do not treat the booking as paid when the browser closes. Only GET /bookings/{id} says so.
  • Do not cache a pay_url for days. Ask for a fresh one with /payment-link.
Was this page helpful?