Search code examples
facebookfacebook-messenger-bot

Facebook Messenger bot Buy button


I'm trying to implement the buy button in my messenger bot, but getting these 2 errors:

{"error":{"message":"(#-1) Send API unexpected internal error","type":"OAuthException","code":-1,"error_subcode":2018012,"fbtrace_id":"BN47MpNqWNN"}} 

{"error":{"message":"(#100) Invalid button type","type":"OAuthException","code":100,"error_subcode":2018037,"fbtrace_id":"Agfk\/h+cEta"}}

Any ideas what the issue could be? Where can I look up these error codes? This is the message I'm sending to Facebook's messenger API:

{'message': {'attachment': {'type': 'template', 'payload': {'text': 'Please checkout.', 'template_type': 'button', 'buttons': [{'payment_summary': {'merchant_name': "Peter's Apparel", 'currency': 'USD', 'payment_type': 'FIXED_AMOUNT', 'price_list': [{'amount': '29.99', 'label': 'Subtotal'}, {'amount': '2.47', 'label': 'Taxes'}], 'requested_user_info': ['contact_name'], 'is_test_payment': True}, 'type': 'payment', 'payload': 'DEVELOPER_DEFINED_PAYLOAD', 'title': 'buy'}, {'type': 'postback', 'payload': '{"title": "Confirm Order", "event_value": "", "event_name": "confirm_order"}', 'title': 'Confirm Order'}, {'type': 'postback', 'payload': '{"title": "Add Coupon Code", "event_value": "", "event_name": "add_coupon"}', 'title': 'Add Coupon Code'}]}}}, 'recipient': {'id': '1232211580183568'}}

Solution

  • "The Buy Button only works with the Generic Template and List Template and it must be the first button."

    Your template type is 'button'. Try to change your template_type to generic or list. Also, make sure you have access to beta program for payments.

    Reference: https://developers.facebook.com/docs/messenger-platform/send-api-reference/buy-button