Document directory
Official interface documentation is king
FB. UI Overview
FB. UI is a generic helper Method for triggering dialogs which allow the user to take some action.
These dialogs include:
- The feed dialog allows a user to post a story to their timeline and to their friends 'news feeds
- The oauth dialog allows a user to authorize an application as part of an authentication flow.
- The add page tab dialog allows a user to add an application to a Facebook page which they administer.
- The Friends dialog allows a user to send a friend request to another user.
- The pay dialog allows a user to make a purchase using Facebook Credits.
- The requests dialog allows a user to send a request to one or more of their friends
- The send dialog allows a user to send a Facebook message to one or more of their friends.
Generally, the official js sdk is used to call out the FB payment page on the webpage.
A simple call method is as follows:
<HTML xmlns = "http://www.w3.org/1999/xhtml" xmlns: fb = "https://www.facebook.com/2008/fbml"> // Initialize the sdk fb of FB. init ({appid: "your_app_id", status: True, Cookie: true}); // The dialog only opens if you 've implemented the // credits callback payments_get_items. function buy () {var OBJ = {method: 'pay', Action: 'Buy _ item', // you can pass any string, but your payments_get_items must // be able to process and respond to this data. order_info: {'item _ id': '1a '}, // here is the payment information. In the payment agreement between the payment center and Fb, dev_purchase_params: {'osscif ': true }};
// Call the payment page FB. UI (OBJ, js_callback );}
// Feedback function, which is used for debugging. // This JavaScript callback handles FB. UI's return data and differs // from the credits callbacks. vaR js_callback = function (data) {If (data ['order _ id']) {// Facebook only returns an order_id if you 've implemented // The credits callback payments_status_update and settled // the user's placed order. // configure y the user that the purchased item has been delivered // without a comple Te reload of the game. write_callback_data ("<br> <B> transaction completed! </B> </br> </BR> "+" data returned from Facebook: </BR> "+" Order ID: "+ data ['order _ id'] +" </BR> "+" status: "+ data ['status']);} else if (data ['error _ Code']) {// appropriately alert the user. write_callback_data ("<br> <B> transaction failed! </B> </br> </BR> "+" error message returned from Facebook: </BR> "+ data ['error _ Code'] +"-"+ data ['error _ message']);} else {// appropriately alert the user. write_callback_data ("<br> <B> transaction failed! </B> ") ;}}; function write_callback_data (STR) {document. getelementbyid ('fb-ui-return-data '). innerhtml = STR ;}</SCRIPT> </body> Below is the corresponding URL request,
Https://www.facebook.com/dialog/pay? App_id = your_app_id & redirect_uri = your_redirect_uri & Action = buy_item & order_info = {"item_id": "1A"} & dev_purchase_params = {"oscif": true}
// Encode the URL string with urlencode ().
Properties
method |
The Valuepay . If usingDirect URL, This property and value areNotRequired becausepay Value is retrieved from the http get request to/dialog/pay Endpoint. |
app_id |
The developer's app ID. If usingJavascript SDK, This property and value are provided when initing the Javascript SDK. |
redirect_uri |
After the user interacts with the pay dialog, redirect the browser to this URI. If usingJavascript SDK, The value is supplied by the Javascript SDK. |
action |
One of the Valuesbuy_item ,buy_credits ,earn_credits ,earn_currency . |
order_info |
Developer provided data containing order information and is passed from the user's client to the developer's server via Facebook'spayments_get_items Request. Note not all usagesresult in Facebook issuingpayments_get_items Requests. If usingJavascript SDK, The data format isJavaScript Object. If usingDirect URL, The data format isJSON string. |
dev_purchase_params |
Configures whether the pay dialog displays prices in local currency (e.g. USD). If{'oscif': true} Is provided usingJavascript SDKOr{"oscif": true} Is provided usingDirect URL, The pay dialog displays prices in local currency. If usingJavascript SDK, The data format isJavaScript Object. If usingDirect URL, The data format isJSON string. You can also setshortcut Parameter here to export cut directly to a payment flow. acceptable values-{shortcut: mobile} . Learn more in Mobile shortcut docs. |
product |
A URL to an app currency object instance usedearn_currency Orders. |
Return data
After a developer settled order, the following data is returned.
order_id |
A Facebook order ID. |
status |
The Valuesettled . |
After an error, the following data is returned.
error_code |
An error code identifying the error. |
error_message |
An error message describing the error. |