Buy Button Reference

The buy button enables you to build a checkout experience in Messenger. This button opens a native checkout dialog that enables people to make payments using their information stored in Messenger.

For more information on using the buy button, see Buy Button.

Contents

Button Syntax

{
  "type":"payment",
  "title":"<BUTTON_TEXT>",
  "payload":"<DEVELOPER_DEFINED_PAYLOAD>",
  "payment_summary":{
    "currency":"<CURRENCY_CODE>",
    "payment_type":"<FIXED_AMOUNT|FLEXIBLE_AMOUNT>",
    "is_test_payment" : <true|false>, 
    "merchant_name":"<BUSINESS_NAME>",
    "requested_user_info":[
      "shipping_address",
      "contact_name",
      "contact_phone",
      "contact_email"
    ],
    "price_list":[
      {
        "label":"<EX_SUBTOTAL>",
        "amount":"<AMOUNT>"
      }
    ]
  }
}

Example Usage

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient":{
    "id":"<PSID>"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"button",
        "text":"Try the buy button!",
        "buttons":[
          {
            "type":"payment",
            "title":"But Button",
            "payload":"DEVELOPER_DEFINED_PAYLOAD",
            "payment_summary":{
              "currency":"USD",
              "payment_type":"FIXED_AMOUNT",
              "is_test_payment" : true, 
              "merchant_name":"My Fake Business",
              "requested_user_info":[
                "shipping_address",
                "contact_name",
                "contact_phone",
                "contact_email"
              ],
              "price_list":[
                {
                  "label":"subtotal",
                  "amount":"12.75"
                }
              ]
            }
          }
        ]
      }
    }
  }
}' "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "m_AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}  

Properties

Property Type Description

type

String

Must be payment.

title

String

Title of Buy Button. Must be "buy".

payload

String

Developer defined metadata about the purchase.

payment_summary

Object

Fields used in the checkout dialog.

payment_summary

Property Type Description

currency

String

Currency for price.

is_test_payment

Boolean

Optional. Whether this is a test payment. Once set to true, the charge will be a dummy charge.

payment_type

Enum

Must be FIXED_AMOUNT or FLEXIBLE_AMOUNT.

merchant_name

String

Name of merchant.

requested_user_info

Array

Information requested from person that will render in the dialog. Valid values: shipping_address, contact_name, contact_phone, contact_email. You can config these based on your product need.

price_list

Array

List of objects used to calculate total price. Each label is rendered as a line item in the checkout dialog.

price_list

Property Type Description

label

String

Label for line item.

amount

String

Amount of line item.

Error Response

{
  "error":{"message":"(#200) The user is not eligible to receive payment messages.",
  "type":"OAuthException",
  "code":200,
  "error_subcode":2018112,
  "fbtrace_id":"DdAqW91SO+K"
}