I'm learning how to implement Facebook Fulfillment flow.
I can't make sense of using request_id (steps 1 & 2). The idea is that my server generates request_id and later when the app get encoded response from Facebook, compare details in that response with the stored details on my server (using request_id as a key).
What is the purpose for this validation?
It says:
The most secure way to verify an order is to use the signed_request parameter from the JavaScript callback, as this has been encoded using the App Secret and can't be manipulated by the client.
So, if we trust this data and it can't be manipulated, why we need for the additional check? If, in other hand, it can be manipulated, how this measure prevents from simple passing the same request to my server and use returned request_id as part of creating manipulated signed_request.
There are tow reasons of using
request_idNote:
request_idis optional and you can definitely serve the purpose using alternative ways.By using
signed_requestthere are 2 ways to verify the payment.If you generate the
request_idyou can verify without having any further request to FB server because of therequest_idis reserved in your database. So it is one of the advantages of usingrequest_idthat you can avoid extra request like callingGraph API.If you have not any
request_idthen you have to use thePayment IDand make a request to FB again.See more on the Verification via Graph API section.