Table of contents
- API
- Server
- Card binding
- Endpoints for clients
- Get list of venues
- Get menu
- Get promo info
- Save or update (by phone or emails) client info
- Get ID for new order
- Validate order and get active promos
- Post order
- Confirm the order is received
- Get status of orders
- Get orders history
- Cancel order
- Get wallet balance
- Deposit money from card to wallet
- Add return comment to canceled order
- Get shared info
- Endpoints for admins
- Constants
- Documents
Server is currently located at http://empatika-doubleb.appspot.com/.
POST /api/payment/register.php
Parameters:
clientId
orderNumber
: any alphanumeric string (eg current timestamp)amount
: number 100returnUrl
: url to redirect in web view
Response:
On failure, contains nonzero errorCode
.
On success, contains orderId
and formUrl
.
Open formUrl
in web view and wait for it to navigate to returnUrl
.
POST /api/payment/status.php
Parameters:
orderId
Response:
#!js
{
"ErrorCode": error_code, // numeric string
"OrderStatus": order_status, // int
"bindingId": binding_id, // GUID string
"Pan": card_pan // string in format 123456**1234
}
On success, ErrorCode
is 0
and OrderStatus
is 1
, then the client should save the bindingId
and last four digits of the Pan
.
Any other values of ErrorCode
and OrderStatus
indicate a failure.
POST /api/payment/reverse.php
Parameters:
orderId
On success, errorCode
of response is 0
.
GET /api/venues.php
Parameters:
ll
(optional): string with format"lat,lng"
, e.g."1.23456,-1.23456"
#!js
{
"venues": [
{
"id": venue_id, // numeric string
"title": venue_title, // string
"address": venue_address, // string
"pic": venue_pic, // string
"lat": venue_latitude, // float
"lon": venue_longitude, // float
"coordinates": venue_coordinates, // string with format "lat,lng"
"schedule": [
{
"days": schedule_item_days, // array of ints
"hours": schedule_item_hours // string
},
{
"days": [1, 2, 3, 4, 5], // example
"hours": "9-23"
},
...
],
"is_open": venue_is_open_now, // boolean
"takeout_only": venue_takeout_only, // boolean
"distance": distance_to_location // float, 0 if location not specified
},
...
]
}
If ll
is specified, venues are sorted by distance to this location.
GET /api/menu.php
Parameters:
client_id
(optional): intdevice_phone
(optional): string
#!js
{
"menu": {
category1_title: [ // keys are category titles
{
"id": menu_item_id, // numeric string
"title": menu_item_title, // string
"description": menu_item_description, // string
"price": menu_item_price, // int
"kal": menu_item_calories, // int
"pic": menu_item_pic // string
}
],
...
},
"client_id": client_id, // int
"client_name": client_name, // string, if exists
"client_phone": client_phone, // string, if exists
"demo": is_card_binding_required, // boolean
}
The client_id is issued according to the following table.
client_id |
device_phone |
Rule |
---|---|---|
Not provided | Not provided | Generates new client_id |
Not provided | Provided | If a client exists with this device_phone , it is returned, otherwise new is generated |
Provided | Not provided | If the given ID exists, it is returned |
Provided | Provided | Same as above, and device_phone is updated |
GET /api/promo_info
Parameters:
client_id
: int
#!js
{
"geopush": {
"id": geopush_id, // string
"send": should_send_geopush, // boolean
"expires": expiry_timestamp, // int
"radius": radius_to_send, // int, in meters
"text": geopush_text // string
},
"promo_enabled": promo_enabled, // boolean
"promo_end_date": promo_end_date, // int, timestamp
"promo_mastercard_only": promo_mastercard_only, // boolean
"points_per_cup": points_per_cup, // int
"has_mastercard_orders": client_has_mastercard_orders, // boolean
"bonus_points": client_bonus_points, // int
"news": [
{
"id": news_id, // int
"text": news_text, // string (html, may contain <b> tags)
"image_url": news_image_url, // string
"created_at": news_timestamp // int
},
...
]
}
POST /api/client.php
Parameters:
client_id
: intclient_name
: stringclient_phone
(optional): stringclient_email
(optional): string
#!js
{
"id": client id // int
"name": name // string
"surname": surname // string
"tel": phone // string
"email": email // string
}
GET /api/order_register.php
No parameters
#!js
{
"order_id": new_order_id // int
}
POST /api/check_order
Parameters:
client_id
: intvenue_id
(optional): intitems
: JSON string: array of objects with the following fields:id
: int|stringquantity
: int
payment
(optional): JSON string: object with the following fields:type_id
: int, see constantsmastercard
: bool
delivery_time
(optional): int
#!js
{
"valid": is_order_valid, // boolean
"total_sum": order_total_sum, // int
"items": [
{
"id": item_id, // int
"quantity": item_quantity, // int
"errors": item_errors, // array of strings, item-specific error messages
"promos": applied_promo_ids // array of strings, eg ["master","other_promo"]
},
...
],
"errors": order_errors, // order-wide error messages
"promos": [ // applied promos
{
"id": promo_id, // string
"text": promo_text // string
},
...
]
}
POST /api/orders.php
Parameters:
order
: JSON string: object with the following fields:order_id
: int|stringvenue_id
: int|stringcoordinates
: string with format"lat,lng"
comment
: stringdevice_type
: int, optional (0 for iOS, 1 for Android)delivery_time
: int (interval in minutes)total_sum
: intclient
: objectid
: int|stringname
: stringphone
: stringemail
: string
payment
: objecttype_id
: int- see below
items
: array of objectsitem_id
: int|stringquantity
: int
For payment by card from client (DEPRECATED), payment
must contain the following fields:
payment_id
: string
For payment by card from server, payment
must contain the following fields:
binding_id
: stringclient_id
: stringreturn_url
: stringmastercard
: boolean
Response:
#!js
{
"order_id": order_id // int
"shared_info": {
"text_share_new_order": sharing text // string
"text_share_about_app": text about doubleb // string
"app_url_ios": url // string
"app_url_android" url // string
}
}
POST /api/set_order_success
Parameters:
order_id
: int
Response:
#!js
{
}
POST /api/status.php
Parameters:
orders
: JSON string: array of order IDs (int)
Response:
#!js
{
"status": [
{
"order_id": order_id, // int
"status": order.status // int
},
...
]
}
GET /api/history
Parameters:
client_id
: string
#!js
{
"orders": [
{
"order_id": order_id, // int
"status": order_status, // int, see constants
"delivery_time": order_delivery_time, // int, timestamp
"payment_type_id": order_payment_type_id, // int
"total": order_total_sum, // int
"venue_id": order_venue_id, // int
"items": [
{
"id": item_id, // int
"title": item_title, // string
"price": item_price, // int
"quantity": item_quantity // int
},
...
]
},
...
}
}
POST /api/return.php
Parameters:
order_id
: int
Response on success:
#!js
{
"error": 0,
"order_id": order_id // int
}
Response on failure:
#!js
{
"error": 1,
"description": error_description // string
}
POST /api/wallet/balance
Parameters:
client_id
: string
#!js
{
"balance": client_new_balance // int
}
POST /api/wallet/deposit
Parameters:
client_id
: stringbinding_id
: stringamount
: int (in rubles)
Success response:
#!js
{
"balance": client_new_balance // int
}
Error response:
#!js
{
"description": error_description // string
}
POST /api/add_return_comment
Parameters:
order_id
: inttext
: string
#!js
{
}
No Parameters
#!js
{
"image_url": image url // string
"fb_android_image_url" image url for android facebook // string
"text_share_new_order": text about me // string
"text_share_about_app": text about app // string
"app_url": app url // string
"screen_title": title for screen // string
"screen_text": text for screen // string
}
POST /api/admin/login
Parameters:
email
: stringpassword
: stringlat
: floatlon
: float
#!js
{
"token": access_token // string
}
POST /api/admin/logout
Parameters:
token
: stringpassword
: string
#!js
{
}
POST /api/admin/ping
Parameters:
token
: stringlat
: floatlon
: floaterror_number
(optional): intsound_level_general
(optional): intsound_level_system
(optional): intis_in_charging
(optional): boolbattery_level
(optional): intis_turned_on
(optional): boolapp_version
(optional): string
#!js
{
}
GET /api/admin/orders/current
Parameters:
token
: string
#!js
{
"orders": [
{
"order_id": order_id, // int
"status": order_status, // int, see constants
"delivery_time": order_delivery_time, // int, timestamp
"actual_delivery_time": order_actual_delivery_time, // int|null
"payment_type_id": order_payment_type_id, // int
"pan": order_pan, // string
"comment": order_comment, // string
"return_comment": barista_return_comment, // string|null
"venue": {
"id": venue_id, // string
"title": venue_title, // string
"address": venue_address // string
},
"client": {
"name": client_name, // string
"surname": client_surname, // string
"phone": client_phone // string
},
"items": [
{
"title": item_title, // string
"price": item_price, // int
"quantity": item_quantity // int
},
...
]
},
...
],
"timestamp": current_server_timestamp // int
}
GET /api/admin/orders/updates
Parameters:
token
: stringtimestamp
: int
#!js
{
"new": new_orders, // list of objects, as above
"new_orders": new_orders, // same as new
"updated": updated_orders, // list of objects, as above
"timestamp": current_timestamp // int
}
GET /api/admin/orders/returns
Parameters:
token
: stringdate
: int (timestamp, time part is ignored)
#!js
{
"orders": orders // list of objects, as above
}
GET /api/admin/orders/history
Parameters:
token
: stringstart
: int (timestamp)end
: int (timestamp)search
(optional): string
#!js
{
"orders": orders // list of objects, as above
}
POST /api/admin/orders/<order_id>/cancel
Parameters:
token
: stringcomment
: string
On failure, status code is 400
#!js
{
}
POST /api/admin/orders/<order_id>/postpone
Parameters:
token
: stringmins
: int
#!js
{
}
POST /api/admin/orders/<order_id>/close
Parameters:
token
: string
#!js
{
"delivery_time": requested_delivery_time, // int, timestamp
"actual_delivery_time": actual_delivery_time // int, timestamp
}
0
: iOS (default)1
: Android
0
: cash1
: card2
: bonus
0
: new1
: ready2
: canceled by client3
: canceled by barista
List of documents:
- About:
/docs/about.html
- License agreement:
/docs/license_agreement.html
- NDA:
/docs/nda.html
- Payment rules:
/docs/payment_rules.html