Make your first plugin - Facebook Payments

  • 20 favourites



9,120 visits, 22,434 views



This tutorial hasn't been translated.


This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.


So the actions are done. Let's create some expressions to reference.

An expression is basically a piece of information we can look at, manipulate, utilize in some way. Facebook is going to return some info to use when a user completes an action. So let's create some expressions to handle it.

Find and delete the following line

    AddExpression(0, ef_return_number, "Leet expression", "My category", "MyExpression", "Return the number 1337.");

Replace it with the following:

    AddExpression(0, ef_return_string, "Payment ID", "Payment Node", "PaymentSuccessID", "The Facebook-generated unique identification number for this payment. Use this to query additional details about the transaction through the Payment Graph API.");
    AddExpression(1, ef_return_string, "Payment Amount", "Payment Node", "PaymentSuccessAmount", "The total amount paid by the user.");
    AddExpression(2, ef_return_string, "Payment Currency", "Payment Node", "PaymentSuccessCurrency", "The currency in which the payment was made.");
    AddExpression(3, ef_return_string, "Payment Quantity", "Payment Node", "PaymentSuccessQuantity", "The quantity of the item the user purchase. Important Note - Due to Price Jumping it is possible the quantity provided when invoking the Pay Dialog is not the same as the final quantity purchased. Always be sure to handle this case.");
    AddExpression(4, ef_return_string, "Payment request ID", "Payment Node", "PaymentSuccessRequestID", "The developer-generated unique identifier for the transaction. This is only returned if it has been passed to the Pay Dialog at the point of purchase.");
    AddExpression(5, ef_return_string, "Payment Status", "Payment Node", "PaymentSuccessStatus", "The current status of the order. This is typically either initiated or completed at the time the callback is invoked. For full detail on this parameter, please refer to the Payment API Reference.");
    AddExpression(6, ef_return_string, "API Error Code",                         "User Node", "APIErrorCode",            "Code detailing the found error.");
    AddExpression(7, ef_return_string, "API Error Message",                      "User Node", "APIErrorMessage",            "Message explaining the found error.");
    AddExpression(8, ef_return_string, "API Error Type",                         "User Node", "APIErrorType",            "Type of error found.");

Let's pull apart one of them so you can see whats going on:

AddExpression(8, -- The numerical index of the expression. This number must be unique or it will generate an error.

ef_return_string, -- Tells the app that what we expect to be returned will be a string of human readable text. This could be any number of options. Refer to the examples above our expressions for a list of examples.

"API Error Type", -- Currently ignored but should read like you would want it to appear when selecting items in the event wizard.

"User Node", -- Category that our expression fits into.

"APIErrorType", -- Invisible name of our expression. We will reference this in a future file.

"Type of error found."); -- Description for our expression.

The rest of the file will not be used for our plugin, but please familiarize yourself with it while you are there. Properties are plugin specific information. For example in your Facebook plugin by Scirra, this would be the App ID setting.

Now that you have completed the edittime make sure to save it and move onto the next chapter.


  • Order by
Want to leave a comment? Login or Register an account!