As of late 2021, we are in the process of updating Stencylpedia and fixing up outdated & broken content. Thanks for your patience!







In-App Purchases for iOS

by Jon (Updated on 2015-10-26)


  • Introduction
  • Requirements
  • Walkthrough
    • Setting up on iTunes Connect
    • Setting up your iOS device
    • Setting up Purchases in Stencyl
    • Purchase Events
    • Consumables
    • Restoring Purchases
  • Troubleshooting


In-App Purchases (IAP) let you sell goods and services from within a game. This gives developers more opportunities to monetize the free app by providing downloadable, supplementary content (new levels or game modes), an unlock for the full game and much more.

What's Covered?

Most of the work involves setting up the purchases on iTunes Connect. Once you get past that part, it's just a matter of setting up a few blocks inside of Stencyl.

This guide will show you how to set up In-App Purchases in iTunes Connect and get you up to the critical point – getting iOS to display its standard prompt for purchasing an item.

Supported Features

Feature Supported?
Regular Purchases Yes
Consumables Yes
Restoring Purchases Yes
Susbcriptions No


  • An active iOS Developer License from Apple
  • All your certificates and provisioning profiles should be properly set up
  • For the App ID you will use, In-App Purchases must be enabled. Go to the iOS Provisioning Portal to check.
  • An active iOS Paid Applications Contract (check the Contracts, Tax & Banking section of iTunes Connect!)
  • A compatible iOS device – In-App Purchases cannot be tested in the iOS Simulator

Note: You do not need a Studio license with us to test this feature. You only need it to publish your game.

Setting Up on iTunes Connect

Disclaimer: Apple continually changes the process, making it difficult for us to maintain this portion. The general ideas should remain the same, but the specifics and names can and will change over time.

Step 1: Go to iTunes Connect

Step 2: Set up a Sandbox Account

  1. Click on Manage Users
  2. Click on Test User
  3. Define a user. This is the account you will test In-App Purchases with.

Step 3: Set up a new game with IAPs

  1. Create a new game entry in iTunes Connect.
  2. Click Manage In-App Purchases
  3. Click Create New
    • Pick Non-Consumable
    • Fill out the form
    • “Cleared for Sale” must be yes, and you must provide a screenshot. It’s OK for now to provide a blank screenshot.
  4. Repeat Step 3 for as many items as you need.

Note: What if you want to operate on an existing game? You can, but only under certain conditions that Apple dictates. Consult Apple's documentation for details.

Step 4: Mark Game as Ready to Upload

When you are ready to proceed, mark the game as Ready to Upload, but do NOT submit the binary yet.

Setting up your iOS Device

Step 1: Sign Out

Sign out of your “Store” account on your device (it’s under the Settings App as “Store” towards the bottom). Do NOT sign back in using the test account yet! You will sign in to the test account while you are testing your game.

Step 2: Delete the Existing Game

If you’re testing your game, it helps to delete the existing copy of the game from the device that never had IAPs to begin with.

Setting up Purchases in Stencyl

Making purchases in Stencyl requires two steps. One is setup related.

  1. First, you must declare what goods you want to sell upfront. Just once.
  2. Then, you can buy the goods using the buy block.

Step 1: Declare All Purchases

Use the request info for product block to declare a purchase. You can find it under Game > Mobile towards the bottom. The ID you use is the Product ID you entered into iTunes Connect.


Do this for each purchase in your game. You only have to do this ONCE, not every time you wish to make a purchase.

(In order to "know" when your request succeeded, use the when a product info request succeeds event under Add Event > Mobile > Purchases)


Step 2: Make a Purchase

Now, all you have to do is create a behavior that buys the product. You can find the buy product block under Game > Mobile towards the bottom. The ID you use is the Product ID you entered into iTunes Connect.


You should always check if a purchase succeeded (or failed) using the purchase events we provide (under Add Event > Mobile > Purchases). Only if a purchase succeeds should you proceed to unlock or provide the promised functionality.

Step 3: Test it Out

Now, run your game on your iOS device. If everything was properly set up, your app should prompt you to purchase your product. Congratulations!

If you are less fortunate and nothing happens after 30 seconds or so, read the Troubleshooting section.

Purchase Events

In prior versions of Stencyl, it was challenging to determine exactly when a purchase succeeded or failed. This is no longer the case. You now can use Events (all under Add Event > Mobile > Purchases) to react to various Purchase-related happenings.

  • Player can purchase goods.
  • A purchase succeeds.
  • A purchase fails.
  • A purchase is restored.
  • A purchase is canceled.
  • A product info request succeeds (required to get title/price/description, you can't use these blocks without this event)


Consumable purchases are products that can be used. More specifically, these are products that can be repurchased over and over again. This contrasts with regular (non-consumable) purchases that stay with the user forever.

A common example of a consumable purchase is virtual currency. Some games (particularly those that make you wait to progress), will sell a special currency that can be used in game to speed the game up or let you purchase special items that accomplish the same.


Consumables are "used" using the use product block (same block as buy product, click the dropdown). Make sure to check that the user has at least 1 of that product before using, as shown below.


If consumption was successful, you will receive a purchase-succeeded event. If it failed, you will receive a purchased-failed event. Be sure to handle these events - do not let the user consume the products immediately.

Restoring Purchases

If a user installs your app in a different device, or if the user has wiped their device, they'll want to get their purchases back for your app. Restoring Purchases is the feature that enables this. The way it works is that when a restore happens, the game acts as if the player made all those purchases again.


Use the restore purchases block under Game > Mobile to initiate this process (connect it to a button press, for example).


When this happens, you will receive a bunch of purchase is restored events (which you can receive via Add Event > Mobile > Purchases), each corresponding to a purchase. It's your task to react to these events in an appropriate manner.



So... something didn't quite go right. First, check your logs.

If you see something along the lines of "Cannot connect to the iTunes Store", then you know for certain that something didn’t quite go right along the way.

Here’s a list of everything we know that could go wrong.

Out of your control

  • Wait up to 24 hours for iTunes Connect to sync its data.

In your control

  • Is your iOS Paid Applications contract active? (Check Contracts, Tax and Banking in iTunes Connect)
  • Have you enabled In App Purchases for the App ID you are using?
  • Have you marked your app as ready to upload?
  • Did you remember to check “cleared for sale” for each product?
  • Did you member to submit a screenshot for each product?
  • Did you provide the correct product IDs, exactly as you entered them into iTunes Connect?
  • Did you remember to enter in the product IDs into StencylWorks?
  • Did you sign out of your live/real account?
  • Did you create a test account in iTunes Connect?
  • Did you sign in to the test account, only in the app-itself, NOT under Settings?
  • The “dumb” solutions that sometimes work
    • Are you testing your game on your device, not in the simulator? Is your device jailbroken? Can the device connect to the internet? Have you tried deleting and than reinstalling the app? (Not just installing it!) Have you tried rebooting your device?

Ask for help

If none of these solutions work, ask for help on the forums.

In-App Purchases are challenging to add because of the obtuse system of setting them up on iTunes Connect. Unfortunately, there's little we can do to make this process easier besides providing help and documenting solutions to common problems as they come along.

Print Article Edit Article How to Edit an Article
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!


This is horrible inadequate information. I have followed all the steps. I've read this over 100 times, and I can not figure out for the life of me why the In App Purchases do not work. App rejected 6 times now, and with the release in 3 days, I'm just gonna have to forgo having any IAP. I doubt there is any issue with Stencyl, however the apple technical support team is just as useless as ever :/
1 6 years, 10 months ago
If I have several IAP for different characters, is there a way of monitoring how many of each was purchased (to identify the most popular) or are they all lumped together. ie. IAP for different cars in a racing game. Could I find out how many of x cars were purchased?
0 6 years, 11 months ago
Please update this
0 7 years, 6 months ago
no idea how to "mark game as ready to upload"
1 8 years, 7 months ago
Not as far as I know. A separate extension would have to be made for the Mac case, even if it's similar.
0 8 years, 8 months ago
does it work with mac os x apps? apparently the mac store works similar to the app store regarding the inapps
0 8 years, 11 months ago
in order to test the app purchase of an app, must i have upgraded my account beforehand?
0 9 years, 10 months ago
This is a very useless tutorial, sorry. There are at least a dozen different settings among the blocks alone and you explain exactly 2.
4 9 years, 11 months ago
Hello Jon!

There is currently no mention of whether we should host the content with Apple or not. Ran into this is wasn't sure what to do!

0 10 years, 1 month ago
Article's been updated to 3.0 standards.
0 10 years, 5 months ago

Sign In to Comment