To retrieve a receipt from the Alert Platform, you must use an HTTP GET request, and the URL format described below. If the receipt has
corresponding receipts for returned items, the receipts for returns are also retrieved.
Name Data type Description
transaction_id string The transaction ID.
code integer The error code. The possible values are as follows:
1 610: The receipt you are trying to replace does not exist.
2 611: One or more of the name/value pairs in the request body is an incorrect type, e.g. order_timestamp is a string with double value instead of an integer.
3 619: The receipt is invalid, for one or more of the following reasons:
• A customer with the given member_id or auid does not exist.
• The customer has returned one or more of the items that are listed in the original receipt.
• You are replacing a receipt for purchased items with a receipt for returned items. Use the API call to create a receipt for returned items instead. See Creating receipts, page 149.
• The replacement receipt contains a mix of purchases and returns.
Replacement receipts must contain all purchases. In terms of implementation, the values for quantity in the order_detail array should be positive. To create a receipt for returned items, see Creating receipts, page 149.
• The replacement receipt contains purchased items (quantity >
0), but the customer is losing loyalty points (amount_for_points
< 0).
• The transaction’s location (source) is not one of the permissible values. The permissible values are 1, 2, and 3. See the Request format for creating receipts, page 150.
• The payment type (payment_type) of the credit or debit card number (card_number) is longer than 20 characters.
• The store location ID is invalid.
4 1203: A required name/value pair is missing.
type string The type of error.
inner_error string A description of the error that occurred.
© 2014 MicroStrategy, Inc. Creating and managing receipts: Receipts API 173
Prerequisite
• Your application must use an existing Alert administration session token, or create a new one. For the request format to obtain a session token, see Obtaining an Alert administration session token, page 105.
Request format for retrieving receipts To retrieve receipts, use the following URL formats:
• To retrieve one receipt, use the following format:
Request type: GET
https://api.alert.com/admin/receipt/transaction_id?
token=admin_session_token
• To retrieve multiple receipts, use the following format:
Request type: GET
https://api.alert.com/admin/receipts?ids=transaction_
id_1,...,transaction_id_n&token=admin_session_token where transaction_id_n are transaction IDs that are in your data
warehouse, and admin_session_token is the Alert administration session token.
Response format for retrieving receipts
The Alert Platform sends a JSON response in the following format:
{
"error": {
"type": string,
"code": integer },
"response": {
"inexistent": array,
"found": array }
}
The name/value pairs in the response are described in the table below:
The retrieved receipt object
The format of the receipt object is shown below:
{
"order_detail": [ //array of items in the order { //item 1
Name Data type Description
error object Contains details of global errors, such as application errors or database errors.
type string The type of error. If no errors were encountered, the value is none.
code integer The error code. If no errors were encountered, the value is 0.
response object Contains the response.
inexistent array An array of transaction IDs for any receipts that could not be found. If all receipts were successfully retrieved, an empty array is sent.
found array An array of receipt objects, containing the receipts that were found on the Alert Platform, including receipts for returned items.
The receipt object is described in The retrieved receipt object, page 174.
© 2014 MicroStrategy, Inc. Creating and managing receipts: Receipts API 175 ...
} ],
"store": { object },
"sub_total": double,
"payments": [ //array of payment objects { //payment object 1
...
}, ...
{ //payment object n ...
} ] }
The name/value pairs of the receipt object are described in Request format for creating receipts, page 150.
Note the following differences in the structure of the receipt format:
• If the receipt was created using the customer’s loyalty membership ID (member_id), or the customer’s authentication account ID (customer_id) an automatically generated Alert user ID (auid) is sent in the response object above.
• The following additional name/value pairs are sent:
– aaid: Your Alert Application ID.
– org_id: The Facebook page ID for your Alert store.
– barcode: The URL for the bar code generated for the receipt.
Depending on whether the receipt you created included the shop_id, the store object may be included, which contains the description and address
of the store location from which the purchase was made. For information on adding a store location, see Creating and managing your store locations:
Store Location API, page 107. The store object is described in The store object, page 176.
The store object
The store object contains the information about the store location, as saved in the Alert Platform. The table below describes the name/value pairs used in the store object.
For information on adding store locations to the Alert Platform, see Creating and managing your store locations: Store Location API, page 107.
Name Data type Description
shop_id string The ID of the store location, taken from your data warehouse.
name string The name of the store location.
address string The street address of the store location.
city string The city of the store location.
state string The state for the store location.
zip_code string The postal code for the store location.
country string The country for the store location.
type string The type of store. The acceptable values are as follows:
0: Indicates a physical store location. If type is not sent, this is used as the default.
1: Indicates an online store.
hours array The working hours of the store location, as an array of JSON objects. The objects in the array are described in hours array, page 177.
phone_number string The phone number of the store location.
longitude string The longitude store location, used for the Store Locator in the Alert app.
latitude string The latitude of the store location, used for the Store Locator in the Alert app.
email string The email address of the store location.
© 2014 MicroStrategy, Inc. Managing your purchase-based loyalty program 177
hours array
The hours array allows you to define the working hours for the store location.
Depending on how you define the array, the working hours may be displayed in one or more columns in the Alert app’s Store Locator feature.
The format of the objects in the hours array is shown below:
{
"name": string,
"value": string,
"date": string }
The name/value pairs in the object are described in the table below: