OpheliaDocs
Search docs⌘K
DashboardCreate an account
v3 · Guide

Pay

A booking that costs money needs a way to pay. This page shows the four ways to send one, and the rule that a booking takes exactly one.

Four ways to pay

You choose how the card reaches the site. Send one of these on POST /v3/bookings, never two.

WayWhat you sendWho types the card
A card in the request
card (or payment)
Ophelia types it at the site’s payment step.
A payment link
payment_collection: "link"
The cardholder types it on Ophelia's pay page. The booking starts once the card arrives.
The person’s Link wallet
payment_collection: "link_wallet" with link_wallet.access_token
Nobody. The person approves the purchase in Link, and Link issues a one-time card for this order that Ophelia types.
The person’s own account
authorize.payment: "account_on_file"
Nobody. The site uses the card saved on the person's connected account.

A card is typed only at commit. A booking at begin stops at the payment step with no card typed. A card is never sent back in any response.

A card at commit is charged as the site charges it. Ophelia does not take the payment. The site does, under its own terms: a store charges the order, and a hotel or restaurant may hold the card or charge it later. v3 cannot cancel a booking or refund a charge. Only the site can.

An order needs a ceiling, authorize.max_total with authorize.currency, whichever way it is paid, and so does a booking on a site whose booking may charge a fee. See Order from a store. A reservation's own card (dining, hotels, classes) needs none. Paying with the person's account always needs one, on any kind of booking.

max_total is in the currency's own units: 128 means $128.00. amount_cents on a booking is in minor units: 12800 is $128.00.

Send a card

Put the card and its billing address in card. The billing address goes here, never in customer. customer.address is where an order ships.

card fieldWhat it holds
number
The card number
exp
Expiry, MM/YY
cvv
The security code
name
The name on the card
street_address, address_line2, city, state, postal_code, country
The billing address

payment takes the same card under other names: card_number, exp_month, exp_year (a four-digit year is shortened), exp, cvv, name_on_card, address_line1, address_line2, city, state, postal_code, country. If you send both, they are merged field by field and card wins.

curl
curl -X POST https://api.opheliaos.com/v3/bookings \
-H "Authorization: Bearer YOUR_TEST_KEY" \
-H "Content-Type: application/json" \
-d '{
"entity_id": "ent_a8b29e41565ff90b71620e08",
"idempotency_key": "docs-order-commit",
"quantity": 2,
"customer": {
"name": "Jane Smith",
"email": "jane.smith.diner@gmail.com",
"phone": "+12124567890",
"address": { "street": "350 5th Ave", "line2": "Suite 4100", "city": "New York", "state": "NY", "zip_code": "10118", "country": "US" }
},
"card": {
"number": "4242424242424242",
"exp": "12/28",
"cvv": "123",
"name": "Jane Smith",
"postal_code": "10001",
"street_address": "350 5th Ave",
"city": "New York",
"state": "NY",
"country": "US"
},
"authorize": { "fill_identity": true, "max_total": 200, "currency": "USD" }
}'

The answer is the booking, with no card in it. What an order's answer carries is on Order from a store.

json
{
"status": "succeeded",
"booking_id": "bk_2fd46d3b4c709779e1af1723",
"confirmation_number": "PX-834126",
"amount_cents": 12800,
"currency": "USD",
"cancellable": false,
"cancel_via": "contact the venue directly using the confirmation on this booking"
}

Pay with the person's account

If the person has connected their own account on the site, the booking can sign in as them and pay with the card that account holds. Connect the account first: see Use a person's own account.

SendWhy
authorize.payment: "account_on_file"
Pay with the account’s saved card.
authorize.sign_in: true
The drive signs in as the person.
authorize.fill_identity: true
Signing in needs it.
end_user
The id you connected the account under.
authorize.max_total
The most it may cost, in the currency's units. Required with account_on_file on any kind of booking. The total is checked against it before the order is placed.
authorize.currency
The three-letter code of max_total, such as USD.
No card, no payment_collection
One way to pay.
curl
curl -X POST https://api.opheliaos.com/v3/bookings \
-H "Authorization: Bearer YOUR_TEST_KEY" \
-H "Content-Type: application/json" \
-d '{
"entity_id": "ent_ec79fac5b91a04424a47487c",
"idempotency_key": "docs-aof-001",
"end_user": "u_jane_1",
"customer": {
"name": "Jane Smith",
"email": "jane.smith.diner@gmail.com",
"phone": "+12124567890",
"address": { "street": "350 5th Ave", "line2": "Suite 4100", "city": "New York", "state": "NY", "zip_code": "10118", "country": "US" }
},
"authorize": {
"sign_in": true,
"fill_identity": true,
"payment": "account_on_file",
"max_total": 100,
"currency": "USD"
}
}'
json
{
"status": "succeeded",
"booking_id": "bk_08675cef3ee9821965ba856b",
"confirmation_number": "PX-509759",
"amount_cents": 1800,
"currency": "USD",
"cancellable": false,
"cancel_via": "contact the venue directly using the confirmation on this booking"
}

On the person's account an order can also press the item's own "Buy Now" (authorize.buy_now). It needs max_commitment: "commit" sent in the request: the default does not count. See Order from a store.

What can go wrong

In every case below, nothing was attempted and no card was typed.

json
{
"error": "send either a card or payment_collection \"link\", not both: the link is how the cardholder's card arrives",
"error_code": "card_with_payment_link"
}
AnswerWhat it means and what to do
400 card_with_payment_link
You sent a card and a link. Send one.
400 card_with_link_wallet
You sent a card and a Link wallet. Send one.
400 field card or payment_collection
You sent account_on_file with a card or a link. Send one way to pay.
400 field payment_collection
A value other than "link" or "link_wallet". Send one of those or leave it out.
400 field link_wallet or link_wallet.access_token
link_wallet without payment_collection: "link_wallet", or "link_wallet" without an access token.
400 field authorize.payment
A value other than "account_on_file".
400 field authorize.sign_in, authorize.fill_identity, end_user, authorize.max_total or authorize.currency
account_on_file is missing what it needs. It needs all of these on any kind of booking. detail says what to send.
400 invalid_input
A link or a Link wallet on a booking below commit. Both are only for commit.
422 max_total_required
An order, a booking on a site that may charge a fee, or any Link wallet booking, with no ceiling. Add authorize.max_total and authorize.currency. See Order from a store.
link_wallet_amount_over_limit
authorize.max_total is over Link's 500 USD per purchase. Pay another way.
payment_link_expired
No card arrived before the link lapsed, or Ophelia restarted while it waited. Nothing was attempted and nothing was charged. Start a new booking with a new idempotency_key.
link_wallet_expired
The person did not approve in Link in time, or Ophelia restarted while it waited. Nothing was attempted and nothing was charged. Start a new booking with a new idempotency_key.
payment_link_unavailable
Links cannot be served right now. Nothing was attempted. Send the card in the request instead.
link_wallet_unavailable
Link wallets cannot be used right now. Nothing was attempted. Send the card in the request instead.

The account refusal names the missing field:

json
{
"detail": "true: account_on_file pays from the person's own account, so the drive signs in as them",
"error": "invalid request body",
"field": "authorize.sign_in"
}

A failure after the card was typed is a different matter. card_declined means the store declined the card and placed no order. not_confirmed_after_otp and transaction_status_unknown mean it may have booked: never resend, tell the person, and check with the site. For any other code at commit, read GET /v3/bookings/{booking_id} and check with the site before you book again. See Handle errors.

Next: Order from a store.