Receipt Messages
The Receipt Message is a Message that renders:
- a list of Products
- a shipping address
- a total price
- payment info

Standard Receipt Message
Name | Required | Type | Description |
---|---|---|---|
mime_type | Yes | String | application/vnd.layer.receipt+json |
currency | N | String | ISO 4217 currency codes; default is USD |
payment_method | Y | String | Arbirary string, often of the form “Visa ****-XXXX” |
order | N | Object | Object describing the Order |
order.number | N | String | Order Number / Order ID |
summary | Y | Object | Summary of the order |
summary.product_cost | N | Number | The sum of all costs for all products (not currently rendered) |
summary.total_tax | N | Number | Total taxes for the purchase (not currently rendered) |
summary.shipping_cost | N | Number | Shipping charges for the purchase (not currently rendered) |
summary.total_cost | N | Number | Sum of all costs; this is always rendered |
summary.subtitle | N | String | Summary of order (Not currently rendered) |
custom_data | No | Object | Data that will not be understood by any Layer provided Renderer, but which will allow additional context to be stored in the Message so your server can better understand it when next your server sees the Message |
Message Part Roles:
Name | Required | Type | Description |
---|---|---|---|
billing-address | N | Location Message | A billing address; not rendered in the basic Receipt Message View |
shipping-address | Y | Location Message | The shipping address; rendered in the basic Receipt Message View |
product-item | Y | Product Message | One or more Products (each represented by its Message Parts) that are part of the receipt |
A Receipt Message can be created using the following SAPI request:
{
"sender_id": "layer:///identities/frodo-the-dodo",
"parts": [
{
"mime_type": "application/vnd.layer.receipt+json;role=root",
"id": "layer:///messages/GENERATE_A_UUID/parts/" + id1,
"body": JSON.stringify({
"payment_method": "VISA ****1234",
"order": {
"number": "FRODO-DODO-ONE"
},
"summary": {
"subtitle": "Your Purchase is Complete",
"shipping_cost": 350.01,
"total_tax": 0.01,
"total_cost": 350.02
}
})
}, {
"mime_type": "application/vnd.layer.product+json;role=product-item;parent-node-id=" + id1,
"id": "layer:///messages/GENERATE_A_UUID/parts/" + id2,
"body": JSON.stringify({
"name": "Formal Strait Jacket",
"brand": "Prison Garb Inc",
"description": "The right choice for special occasions with your crazed inlaws. This will make you feel like you at last belong.",
"image_urls": ["http://l7.alamy.com/zooms/e33f19042cbe4ec1807bba7f3720ba62/executive-in-a-strait-jacket-aakafp.jpg"],
"price": 525,
"url": "http://l7.alamy.com/zooms/e33f19042cbe4ec1807bba7f3720ba62/executive-in-a-strait-jacket-aakafp.jpg"
})
}, {
"mime_type": "application/vnd.layer.choice+json;role=options;parent-node-id=" + id2,
"id": "layer:///messages/GENERATE_A_UUID/parts/" + id3,
"body": JSON.stringify({
"label": "Size",
"type": "label",
"enabled_for": "layer:///identities/174fe653-85a1-4667-b166-9c35c1caa0b7",
"choices": [{
"id": "small",
"text": "Small"
}, {
"id": "medium",
"text": "Medium"
}, {
"id": "large",
"text": "Large"
}]
})
}, {
"mime_type": "application/vnd.layer.location+json;role=shipping-address;parent-node-id=" + id1,
"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
"body": {
"description": "Description should not show",
"city": "San Francisco",
"postal_code": "94107",
"administrative_area": "CA",
"street1": "655 4th st"
}
}, {
"mime_type": "application/vnd.layer.initialresponsestate-v1+json;role=initial_response_state;parent-node-id=" + id3,
"id": "layer:///messages/GENERATE_A_UUID/parts/GENERATE_A_UUID",
"body": JSON.stringify([{
"operation": "add",
"type": "FWW",
"value": "small",
"name": "selection",
"id": "kBTjC_",
"identity_id": "layer:///identities/174fe653-85a1-4667-b166-9c35c1caa0b7"
}])
}
]
}