Search code examples
facebook-graph-apipaymentfacebook-unity-sdk

Need steps to implement facebook payment in my unity game


I made a game for Facebook canvas in unity, Now i want to sell items in my game with Facebook payment, The problem is i am not a good programmer and Facebook documentations are very hard to understand, so i need some simple steps to integrate payment to my game,

i registered Facebook payment company,

Now how to define product in my unity codes?

How to prompt dialog box?

what to write in callback URL in php?

please make it simple and clear for me thanks


Solution

  • I think you need to investigate a bit more on how to achieve this, since there is a lot of information available. I'll try to clear some doubts of yours:

    • To define products for your game, you need to define an Open Graph Object, and upload it to a server (can be your own, or dropbox). Here is a guide from my blog, where I teach how to upload and host OG Objects for achievements, steps are similar.
    • The in-game code to use in Unity is the method Pay (FB.Canvas.Pay), which receives the url of your hosted OG Object, and some other parameters, and it prompts the user with the appropiate interface to pay (Keep in mind this only works when the game is inside the facebook canvas)

    I Hope this starts to guide you on how to approach the paymet system!

    I'll answer the questions in the comment here:

    • No, you don't need the Javascript SDK anymore. Just need to have the Unity SDK in your game.
    • I haven't found much information on the callback, but since I don't really use it, I just used this code inside a PHP script to just make it work:

      $hub_mode = $_GET['hub_mode'];

      $hub_challenge = $_GET['hub_challenge'];

      $hub_verify_token = $_GET['hub_verify_token'];

      if ($hub_verify_token =='YourToken')

      {

      echo $hub_challenge;

      }