App Inventor Extensions

In-App Billing Extension

See the App Inventor Extensions document about how to use an App Inventor Extension.

For questions about this extension or bug reports please start a new thread in the App Inventor Extensions forum. Thank you.

For feature requests please contact me by email. To be a sponsor of a new method already is possible starting from only 10 USD! With your contribution you will help the complete App Inventor community. Thank you.

Aug 15th, 2016: Version 1: initial version of the Billing Extension released


This extension enables you to use Google In-App Billing in your App Inventor app for Products (both non-consumable and consumable) and Subscriptions.
Required permission:

This extension uses the Android In-App Billing v3 library V 1.0.32. Thank you Anj Lab!
Thank you Johannes for being the sponsor of this extension.


Returns whether In-app billing service is ready to purchase.


Initialize the In-App Billing service using your licency key and merchant id.
How to get this information, see chapter Preparation for your own app.

Note: The GotOwnItems event will be fired automatially after using that method.

Load Own Items.

Purchase Product.
Note: The purchase process takes a few seconds. You have to trigger the method LoadOwnItems to refresh the purchased items. You only can purchase a product once. Then you first have to consume it before being able to purchase it again.

Consume product.
Note: The GotOwnItems event will be fired automatially after using that method.

Note: The purchase process takes a few seconds. You have to trigger the method LoadOwnItems to refresh the subscribed items. You only can subscribe an item once.

Get Product Details.

Get Subscription Details.


Event indicating that own items have been loaded.
A list of own products and own subscriptions will be returned.

Event indicating that product details have been received.

Event indicating that subscription details have been received.

Event indicating that an error occurred.

Example App 1: As simple as possible

Let's assume, you like to offer a free version of your app and a premium version. After paying a small amount, the user can upgrade to the premium version to get additional features. So there is only one product to buy. After successful purchase, store the status (premium) in TinyDB, so you also can get the correct status of the app (free or premium) also if there is no internet connection. You can test the example using the test product android.test.purchased also in the companion app.

If you want to test again, first consume the product and clear the tag premium in TinyDB.

Example App 2: Pura Vida Airline


Product Details


Note: I'm located in Costa Rica, therefore I get the local currency CRC (Costa Rican Colones) displayed...

Further blocks used

Questions and Answers

Q1: I get the error message "Authentication is required"?
A: See this stackoverflow answer: Make sure your app is PUBLISHED to any version (alpha, beta or production). Also you must test using your apk file. Exception: you can purchase the test product android.test.purchased also using the companion app.

Q2: I get the error message "The Item you requested is not available for purchase"?
A: See this stackoverflow answer for some things to check.

Q3: How can I test the subscriptions?
A: See this stackoverflow answer.

Q4: I would like to remove ads after purchase. Should I publish 2 apps to Alpha (with ads and without ads) OR publish 1 app and code this: "After purchase, remove all ads (permanently, e.g. TinyDB)"?
A: I would publish one app only.

Q5: It would be nice to see publishing process step by step on forum or video.
A: There is loads of information online concerning Google In App Billing, just look around a little bit, see for example this Google Search result or this Youtube Search result and choose a step by step guide of your choice.

Q6: I did not understand the additional Security Recommendation? What does it mean "Retrieve it from an encrypted store"?
A: To keep it as simple as possible for you, just copy the licence key and your merchant id as they are into the corresponding variables. To have additional security, in App Inventor you 1) could write your own procedure to construct your license key string during runtime from substrings. 2) Also instead of storing the licence key itself, you could store the encrypted licence key using the AES extension inside your app. You would have to store additionally a password to be able to decrypt the license key again before using it.

Q7: How can I give the users instant access to the new features in my app right after they buy an item? What happens right after they purchase an item? Is there an event triggered?
A: There is no AfterPurchase event available. Therefore the suggestion is to follow "Example 1, as simple as possible", which uses a button "Continue" to call procedure "LoadOwnItems".

Q8:When I try to make a purchase, the android purchase popup will appear briefly, load for a moment, and then the app will crash. What can I do?
A: There is an issue with Play Store version 7.9.80.Q-all and test products, see also this stackoverflow question. For this Google Play version you might want to test using real product ids instead until Google fixed that issue.

Q9: What will happen if someone deletes the app then wants to reinstall it - what blocks do I need for a "Restore" button?
A: Google of course still knows, that the user bought the product, which means in the OwnItemsLoaded event (which fires after calling the Initialize method or also the LoadOwnPurchases method) you will receive the list of purchased products also if a user reinstalls the app and also if the user installs the app on another device using the same Google login.

For questions about App Inventor,
please ask in the App Inventor forum.Thank you.

Test the functionality of the Pura Vida Airline example app

The test app is available in Google Play for Beta testers. You can test the example following these steps

  1. Join the Taifun Test Google+ Group to be able to test the example app
  2. Then follow the opt-in URL to get access to the app and to be able to download it to your device. It might take a few hours for Google to enable you as beta tester!
  3. Start testing. You can use the test product android.test.purchased to purchase a product without having to pay. For the other available test products in the example, real money will be charged by Google! Let me know of your test payments and I will refund it to you later again.

Preparation for your own app

  1. Get your licence key
    In the Google Play Development Console create a new app, go to the APK tab and select "get licence key".
    Security Recommendation: It is highly recommended that you do not hard-code the exact public license key string value as provided by Google Play. Instead, you can construct the whole public license key string at runtime from substrings, or retrieve it from an encrypted store, before passing it to the constructor. This approach makes it more difficult for malicious third-parties to modify the public license key string in your APK file.
  2. Get your merchant id
    In the Google Play Development Console click Reports - Financial Reports. From there click Visit your merchant account for more details to go to the Payments Merchant Center. Go to Settings - Public Profile and copy your merchant id from there.
  3. Publish your app into Alpha testing
    Prepare the store listing for your app, add your in-app products (products and/or subscriptions), upload your apk file into alpha testing, then add the content-rating and pricing & distribution information and publish your app into Alpha testing.
  4. See this stackoverflow answer for some things to check before being able to test your app!

Buy the Billing extension for App Inventor

You can buy this extension (aix file).
With your payment you accept the terms and conditions below.

Payment options

1. Paypal

Please transfer 10 USD via Paypal
to Pura Vida Apps

2. Bitcoin

After having received your payment I will be happy to send the download link to you. Please let me know your Google account! I usually will send the download link not later than 24 hours after having received your payment.
Thank you! Taifun

Terms and Conditions

Back to top of page ...

Home | Snippets | Tutorials | Extensions | News | Forums | Links | Search | Contact