There are two callbacks Facebook makes on the application back end. The application needs to verify the fb_sig parameter to make sure that the request is coming from facebook.
I then had to guess and use trial-and-error to get it to work. What the documentation should have said, but didn't say was
- The callback is an HTTP POST.
- The content-type of the posted content is
application/x-www-form-urlencoded. - The two callbacks are indicated by the
methodparameter. - The
fb_sigparameter only needs to be verified if the application does not have the OAuth 2.0 for Canvas setting enabled. If that setting is enabled, thefb_sigparameter is not sent, and all the parameters are in thesigned_request, which includes a signature that needs to be verified. - The
order_detailsparameter is a string containing the original JSON, which means it needs to be double parsed. - They provide an example for the response to the
payments_get_itemscallback, but not for thepayments_status_updatecallback. Following the given example for thepayments_status_updateresponse results in an unhelpful error message to the user, with no feedback pointing to the problem. As the documentation was unhelpful, and the Facebook developer forums had a few posts from someone facing the same problem with no response, I resorted to trial-and-error. (I'm not creating yet another account and password just to post to that forum.) The problem was that thecontentfield in thepayments_get_itemsresponse is supposed to be an array, but it is supposed to be a single item in thepayments_status_updateresponse.