The receipt template allows you to send an order confirmation as a structured message. For implementation details, see Receipt Template.
https://graph.facebook.com/v21.0
/me/messages?access_token={PAGE_ACCESS_TOKEN}
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"<PSID>"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"receipt",
"recipient_name":"Stephane Crozatier",
"order_number":"12345678902",
"currency":"USD",
"payment_method":"Visa 2345",
"order_url":"http://originalcoastclothing.com/order?order_id=123456",
"timestamp":"1428444852",
"address":{
"street_1":"1 Hacker Way",
"street_2":"",
"city":"Menlo Park",
"postal_code":"94025",
"state":"CA",
"country":"US"
},
"summary":{
"subtotal":75.00,
"shipping_cost":4.95,
"total_tax":6.19,
"total_cost":56.14
},
"adjustments":[
{
"name":"New Customer Discount",
"amount":20
},
{
"name":"$10 Off Coupon",
"amount":10
}
],
"elements":[
{
"title":"Classic White T-Shirt",
"subtitle":"100% Soft and Luxurious Cotton",
"quantity":2,
"price":50,
"currency":"USD",
"image_url":"http://originalcoastclothing.com/img/whiteshirt.png"
},
{
"title":"Classic Gray T-Shirt",
"subtitle":"100% Soft and Luxurious Cotton",
"quantity":1,
"price":25,
"currency":"USD",
"image_url":"http://originalcoastclothing.com/img/grayshirt.png"
}
]
}
}
}
}' "https://graph.facebook.com/v21.0
/me/messages?access_token=<PAGE_ACCESS_TOKEN>"
{ "recipient_id": "1254477777772919", "message_id": "AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P" }
recipient
Description of the message recipient. All requests must include one of the following properties to identify the recipient.
Property | Type | Description |
---|---|---|
| String | Page Scoped User ID (PSID) of the message recipient. The user needs to have interacted with any of the Messenger entry points in order to opt-in into messaging with the Page. Note that Facebook Login integrations return user IDs are app-scoped and will not work with the Messenger platform. |
| String | Used for the checkbox plugin and customer chat plugin. |
| String | Used for Private Replies to reference the visitor post to reply to. |
| String | Used for Private Replies to reference the post comment to reply to. |
message
Property | Type | Description |
---|---|---|
| Object | An object describing attachments to the message. |
message.attachment
Property | Type | Description |
---|---|---|
| String | Value must be |
| Object |
|
message.attachment.payload
Property | Type | Description |
---|---|---|
| String | Value must be |
| Boolean | Optional. Set to |
| String | The recipient's name. |
| String | Optional. The merchant's name. If present this is shown as logo text. |
| String | The order number. Must be unique. |
| String | The currency of the payment. |
| String | The payment method used. Providing enough information for the customer to decipher which payment method and account they used is recommended. This can be a custom string, such as, "Visa 1234". |
| String | Optional. Timestamp of the order in seconds. |
| Array<element> | Optional. Array of a maximum of 100 |
|
| Optional. The shipping address of the order. |
| Object | The payment summary. See |
| Array< | Optional. An array of payment objects that describe payment adjustments, such as discounts. |
message.attachment.payload.address
Property | Type | Description |
---|---|---|
| String | The street address, line 1. |
| String | Optional. The street address, line 2. |
| String | The city name of the address. |
| String | The postal code of the address. |
| String | The state abbreviation for U.S. addresses, or the region/province for non-U.S. addresses. |
| String | The two-letter country abbreviation of the address. |
message.attachment.payload.summary
The property values of the summary
object should be valid, well-formatted decimal numbers, using '.
' (dot) as the decimal separator. Please note that most currencies only accept up to 2 decimal places.
Property | Type | Description |
---|---|---|
| Number | Optional. The sub-total of the order. |
| Number | Optional. The shipping cost of the order. |
| Number | Optional. The tax of the order. |
| Number | The total cost of the order, including sub-total, shipping, and tax. |
message.attachment.payload.adjustments
Property | Type | Description |
---|---|---|
| String | Required if the |
| Number | Required if the |
message.attachment.payload.elements
Property | Type | Description |
---|---|---|
| String | The name to display for the item. |
| String | Optional. The subtitle for the item, usually a brief item description. |
| Number | Optional. The quantity of the item purchased. |
| Number | The price of the item. For free items, '0' is allowed. |
| String | Optional. The currency of the item price. |
| String | Optional. The URL of an image to be displayed with the item. |