Part 3 - Setting up for Testing

By Richard Davey on 12th March 2019   @photonstorm

In order make any In App calls, even for testing purposes, your app must have the paymentsPurchaseAsync service available in the list of Supported APIS. If it doesn't have this, none of the plugin calls, such as getCatalog will work.

Testing API Calls

To have this API available you need to fulfill 3 criteria:


  1. You must have a Game Bundle uploaded.
  2. You must have a Game Page created.
  3. You must have a Product Registered.

Uploading a bundle is the easy part. Indeed, if you've built an Instant Game before, you've already done it. It just means having your game uploaded and set to "Production". Don't worry, as long as the App Status itself is set to "In Development", it won't be public, even if the bundle is "Production".

Having a Product Registered was covered in Part 2 of this tutorial. Make sure you've at least one product added to your app. Which just leaves creating a Game Page. It's actually exceptionally easy to do this part wrong! So please follow carefully.

To create a Page you need to go into the App Dashboard and pick "Details" from the Instant Games menu. On the right you'll see the option to set the page for your app. If you don't already have one, which is likely as it's the default, you need to create a new Page. There are two very important things to remember when doing this:

1) The Page Title must contain the name of your game, as set-up and displayed in the App Dashboard. If you game is called "Hero Quest" then the page title has to contain that exact string, such as "Welcome to Hero Quest". To avoid any confusion you could simply name the page exactly the same as your app title.

2) When you create the page it will ask you to type in which category it should be listed under. You must enter "App Page" here.

Once you've done this and created your page you will see it listed in your App Dashboard and can select it to associate it with your game:


If you fail to do either of the two steps above, then your game won't have a page associated with it, and In App purchases, even test ones, will fail.

Testing Purchases

When testing purchases you clearly don't want to be charged every time. To avoid this you can add test users in your App Dashboard. Click "In App Purchase" in the Instant Games menu on the left and at the top you'll see the ability to enter test users.

You can either just start typing the name of a user. As long as they're on your friends list, for the account you are logged in with, they will appear here and can be selected.


However, your own account won't do this, so you need to enter in your Facebook account ID instead. There are various ways to find this, but the npm package facebook-id-of works nicely from the command line and is super-easy to use. Once you have your ID and have added it to the list, save the changes.

There is one very important caveat:

Test Purchases only work from within the Facebook Android app

Yes, you read that right.

If you try and 'test' a purchase on desktop, it will actually charge you, and if your account is still being set-up and your app isn't approved, it won't even go through at all, even if you use valid card details to test with.

So, please do all your testing from within the Facebook Android app. The easiest way to do this is to go to your Game Details page in your App Dashboard and you'll see a section titled "Share Your Game on Facebook" which looks like this:


As counter-intuitive as it may seem, this is the easiest way to test on Android. If you click the button and share your game, it will be set to be shared with "Only you" by default. So it only appears on your timeline. Once you've shared it, you can open the Android app, look at your timeline and you'll see it on there. Click the name of the app and it will launch and you can test transactions. You can also add a short-cut to the app to your home screen from this page too, which will save you time in the future.

Testing from within the Android app is easy. Just tap to buy something, like you would normally, and it'll pop-up with a message confirming you are about to do a TEST transaction and do you want to proceed. If it doesn't say this, it's trying to do a real transaction, so double-check you've added yourself properly as a test user on your App Dashboard. Assuming you have done this, you can complete the test transaction and your game will get the success events.

Hint: The App uses the Bundle

Remember that when you test from the Facebook app, it's testing whatever bundle was most recently uploaded to Instant Games and productized (i.e. had its status changed to "Production"). If you're using a local dev server for testing most the time, then don't forget to push a new bundle up before testing from the app!