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
POST /bookingsreturns a booking withstate: "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"
}
-
Open
pay_urlin an in-app browser: Chrome Custom Tabs on Android, SFSafariViewController or ASWebAuthenticationSession on iPhone, a browser window on desktop. Show the countdown tohold_expires_atnext to it. -
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). -
When the in-app browser closes (or its address reaches
/my/bookings/), callGET /bookings/{id}:state: "confirmed"andamount_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:
amountis the deposit (deposit_percentof 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:
amountis the whole price. amount_due_onlineon the booking always tells what is still due online now.
Things to avoid
- Do not open
pay_urlin 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_urlfor days. Ask for a fresh one with/payment-link.