Developer notes
Technical reference for developers who customize Uber Direct Same-Day Delivery.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_uber_direct |
| Function prefix | fn_kv_uber_direct_ |
| Language variables | kv_uber_direct.* |
| CSS scope | .kv-uber-direct |
| PHP namespace | Tygh\Addons\KvUberDirect |
| Preset | shipping (generated by kv new --kind integration) |
Structure
Section titled “Structure”| Class | Role |
|---|---|
Client\BaseClient |
HTTP (cURL, TLS verification, timeouts), JSON, OAuth2 client-credentials with an encrypted token cache, error mapping, masked logging |
Client\Api |
The Uber Direct calls (below) |
Client |
Client per company, the connection test |
Mapper |
Pure mappings: address JSON, E.164 phone, item size, quote and delivery bodies and answers, status to state, webhook to state. Unit-tested with the examples of the documentation |
Quotes |
The quote of a checkout: session store per company and dropoff address, saved with the order (?:kv_uber_direct_quotes), freshness rule (15 minutes minus 60 s) |
RateCalculator |
Shipping rate: Create Quote, fee in minor units to the store currency, surcharge, ETA, 2-minute cache, 5-minute memory of a refused address, flat fallback |
Shipments |
One row per delivery, created BEFORE the POST; create / adopt / cancel / track / webhook apply under per-order locks |
Webhook |
x-uber-signature HMAC-SHA256 check, event ids; the controller kv_uber_direct.webhook?c=<account> stores the event as a job |
Pickup |
Pickup address per company (saved, or the company address) |
Accounts, Secret |
Credentials (test and live) sealed with AES-256-GCM; one account per store owner or per vendor |
Config, Access |
Settings, owner mode, who may see and manage what |
Queue, Jobs, JobException |
Job queue: back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock |
Log |
Event log with masking, filters, CSV, retention |
Database tables
Section titled “Database tables”| Table | Purpose |
|---|---|
?:kv_uber_direct_accounts |
Credentials per company (secrets sealed), Customer ID and host per mode (extra), last connection check, token cache |
?:kv_uber_direct_log |
Log |
?:kv_uber_direct_jobs |
Queue |
?:kv_uber_direct_shipments |
Deliveries: provider_ref = Uber delivery id (del_...), quote_id, client_reference, tracking_url, state, courier |
?:kv_uber_direct_pickups |
Pickup address per company |
?:kv_uber_direct_quotes |
The quote saved with an order (quote_id, fee, currency, expires_at, hash of the dropoff address) |
Hooks used
Section titled “Hooks used”PHP hooks (registered in init.php, handlers in func.php): change_order_status_post (queue the booking / cancellation at the configured statuses), place_order (save the checkout quote with the order), delete_order (drop the quote), get_order_info (storefront: tracking line for the customer). Template hooks: orders:tabs_extra (admin, the order tab), index:styles (backend and storefront CSS), orders:totals_shipping (storefront order page: tracking link). Shipping service: Tygh\Shippings\Services\KvUberDirect (service code same_day).
Uber Direct API reference used
Section titled “Uber Direct API reference used”Official documentation: https://developer.uber.com/docs/deliveries (read 2026-11-13). “Verified” = the page we read states the path and fields; “To verify” = the public pages did not show it (the reference is rendered by a script or sits in the Postman workspace) and the shape is taken from the documented examples and the public OpenAPI summary: confirm it with the first real test account (tests/mock-server/server.js follows exactly what is written here).
Authentication (verified)
Section titled “Authentication (verified)”Page: guides/authentication and get-started.
POST https://auth.uber.com/oauth/v2/token,Content-Type: application/x-www-form-urlencoded.- Form fields:
client_id,client_secret,grant_type=client_credentials,scope=eats.deliveries. - Answer fields:
access_token,expires_in(2592000 = 30 days),token_type(Bearer),scope. The token is cached (encrypted) and sent asAuthorization: Bearer <access_token>; it cannot be refreshed, a new one is requested after it expires or after a 401. The page limits client-credential requests to 100 per hour. - Error codes of the endpoint:
invalid_request,invalid_client,invalid_scope,server_error,unauthorized.invalid_clientpauses the account (no automatic call for six hours). - Credentials (Customer ID, Client ID, Client Secret): Developer tab, Management section of the dashboard (get-started).
- API:
https://api.uber.com/v1/customers/<customer_id>/(get-started). In Test mode the guide’s create-delivery example answers"live_mode": falseon this host. - Sandbox host: not stated on the public pages (the FAQ mentions sandbox rate limits of 200 requests per 10 minutes per application and a rate limit added to the sandbox on 2025-10-27; a community report names
sandbox-api.uber.com). To verify. The host is the setting API host per mode (https belowuber.com, validated inClient\Api::validHost); tests redirect everything to a local mock with$config['kv_uber_direct_base_url'].
Create Quote (verified)
Section titled “Create Quote (verified)”POST /v1/customers/{customer_id}/delivery_quotes (get-started).
- Request:
pickup_address,dropoff_address: each a JSON-encoded string{"street_address": ["20 W 34th St", "Floor 2"],"state":"NY","city":"New York","zip_code":"10001","country":"US"}. Optional (change log 2023-05-09 on phone format):pickup_phone_number,dropoff_phone_numberin E.164. The FAQ asks for apartment or unit numbers as a separate street line and for the same address format in quote and delivery (otherwise a “delivery location changed” error):Mapper::address()builds one format for both,Quotes::cartDropoff()andShipments::dropoffAddress()use the same fields. - Answer fields:
kind(delivery_quote),id(dqt_...),created,expires(15 minutes aftercreated; FAQ: valid for 15 minutes),fee(minor units,558= 5.58),currency(usd),currency_type,dropoff_eta,duration(minutes),pickup_duration,dropoff_deadline. - Used:
id,fee,currency,expires,dropoff_eta,duration,pickup_duration(Mapper::quote).
Create Delivery (verified for the fields listed)
Section titled “Create Delivery (verified for the fields listed)”POST /v1/customers/{customer_id}/deliveries (get-started, guides/robocourier).
| Field we send | Source |
|---|---|
quote_id |
get-started: “it is essential to include the quote_id obtained from the previous step” |
pickup_name, pickup_address, pickup_phone_number, pickup_notes |
get-started, robocourier sample |
dropoff_name, dropoff_address, dropoff_phone_number, dropoff_notes |
get-started, robocourier sample |
manifest_items[]: name, quantity, size (small, medium, large, xlarge; the examples show small and large) |
get-started, SDK guide, webhook example |
manifest_reference, external_id, idempotency_key |
robocourier sample payload (“idempotency_key”, “external_id”, “manifest_reference”). Our value is kv<token>-<order id>-<attempt>. The change log mentions a default dedupe duration of 60 minutes for the key (to verify the exact rule) |
tip (minor units) |
robocourier sample ("tip": 500) |
undeliverable_action (return default, leave_at_door) |
robocourier page, “Undeliverable actions” |
dropoff_verification (signature, picture) |
robocourier sample ("dropoff_verification": {"signature": true}); change log 2024-07-01 for type / no_sobriety_check (not sent) |
test_specifications.robo_courier_specification.mode = "auto" |
robocourier page; sent only in Test mode when the setting is on |
Not sent (deliberately): manifest_items.weight (the unit is not stated on the pages we read), price, coordinates (Uber geocodes; a coordinate more than 1 km from the address is overwritten per the FAQ), pickup / dropoff windows (pickup_ready_dt etc., guides/delivery-window; this product books on-demand couriers).
Answer fields read (Mapper::deliveryInfo): id (del_...), quote_id, status, courier_imminent, tracking_url (the page says not to modify it), fee, currency, live_mode, external_id, manifest.reference, courier.name, courier.location.lat/lng, undeliverable_reason, cancelation_reason.secondary_reason (CUSTOMER_CANCEL, COURIER_CANCEL, MERCHANT_CANCEL, UBER_CANCEL; the Delivery Status webhook page says primary_reason “will always be #Uber”, so it is only the fallback).
Get Delivery, List deliveries, Cancel Delivery (to verify)
Section titled “Get Delivery, List deliveries, Cancel Delivery (to verify)”GET /v1/customers/{customer_id}/deliveries/{delivery_id}: Uber’s reference lists a “Get Delivery” endpoint (the Delivery Status webhook page says the delivery data can be fetched with it, and the change log names it); the path is the conventional one. To verify.GET /v1/customers/{customer_id}/deliveries?limit=<n>: listed by the public OpenAPI summary of the Direct API. The filter parameters are not shown on the pages we could read, so we sendlimitonly and match our reference ourselves (Mapper::matchDelivery: exactexternal_idormanifest.reference, never a loose or ignored filter). To verify.POST /v1/customers/{customer_id}/deliveries/{delivery_id}/cancel: the change log (2025-12-08) says optional reason fields were added to Cancel Delivery but does not name them, so we send an empty JSON object and keep the reason in our own log. Cancellation is possible only before pickup (statependingorpickup); Uber’s answer decides, a 4xx makes the add-on read the real state. To verify.- Error body shape: not printed on the pages we could read.
Client\Api::errorFromreads a message (message,error_description,detail,title) and a code (code,error) generically. A 4xx other than 401, 403, 408, 425, 429 on a quote is a refusal (the method is not offered, not retried); 429 and 5xx are retried. To verify with a real answer.
Webhooks (verified)
Section titled “Webhooks (verified)”Pages: guides/webhooks, Delivery Status Webhook, Courier Update Webhook. Webhooks are created in the dashboard (Developer tab), not through the API.
- Signature: header
x-uber-signature= hex HMAC-SHA256 of the raw body with the webhook’s “Webhook Signing Key” (dashboard: webhook menu > Edit).x-postmates-signatureis accepted by Uber only for Delivery Status and Courier Update; we accept both names.Webhook::authenticatehashes the body as received (a parser that re-encodes&breaks the hash, as the page warns) and compares in constant time. The sample of the page (keyc5c26d5a-70d6-46c7-a652-d7c09825ad29) is a unit test. event.delivery_status: top levelid(event id, our idempotency key),kind,delivery_id,status,live_mode,created,data{...}(delivery object). Statuses:pending,pickup,pickup_complete,dropoff,delivered,canceled,returned(the page also listsshopping_completed, ignored);courier_imminentaccompaniespickupanddropoff.event.courier_update: top levelkind,delivery_id,location{lat,lng},data.courier{name, location, vehicle_type, ...}; sent every 20 seconds once a courier is assigned. Position and courier name only; the state never moves from it.- Retries by Uber: HTTP 500, 502, 503, 504, timeouts and network errors, 10 s then 30 s, 60 s, 120 s, up to 3 events in total. For other statuses the page recommends Get Delivery: the scheduled check (
Jobs::schedule) does that. The expected success status is not stated; we answer200 OK. - Mode safety: the signing key that matched decides the mode (
test/live); an event whoselive_modedoes not fit that mode is ignored (Shipments::applyEvent).
Statuses to states
Section titled “Statuses to states”pending C (waiting) · pickup A (courier on the way; courier_imminent = arriving) · pickup_complete and dropoff T (package with the courier) · delivered D · returned P · canceled X. A state never moves backwards; D and X are final.
Idempotent delivery creation
Section titled “Idempotent delivery creation”Shipments::createtakesGET_LOCKper order and inserts the row (stateQ, reference) before any POST.- The reference is sent as
idempotency_key,external_idandmanifest_reference. sent_atis stored before the POST. After a timeout, a 5xx, a cut connection or a 409 / 422 the next attempt lists deliveries and adopts the one that carries our exact reference instead of creating another.- A refusal (4xx) marks the row
Ewith the reason; a manual retry reuses the same reference. - Webhooks and cron claim states under the same per-order lock; a late answer never downgrades a final state.
Test the HTTP layer without the provider
Section titled “Test the HTTP layer without the provider”The base URL can be overridden for tests in config.local.php (development only; the e2e refuses to run otherwise):
$config['kv_uber_direct_base_url'] = 'http://127.0.0.1:12891';node tests/mock-server/server.js 12891 starts a local stand-in that follows this page (token, quote with 15-minute expiry and unit check of E.164 phones and address JSON, delivery with idempotency_key dedupe, list, get, cancel, signed webhooks, failure and “answer lost” injection). node tests/e2e/e2e.mjs runs the HTTP end-to-end test against it; php tests/unit.php runs the unit tests (fixtures copied from the documentation: tests/fixtures/SOURCES.md).
Template overrides
Section titled “Template overrides”Admin templates live in design/backend/templates/addons/kv_uber_direct/. Do not edit them in a store; they are replaced on update.
The add-on uses the plain text “Uber Direct” (descriptive, nominative) and no Uber logo: the public pages we read give no logo licence for integrators (the developer design guidelines point to the Uber Newsroom assets and an “Integration Design guidelines” PDF). See research/brand-assets/uber_direct/SOURCE.md.