App Inventor Extensions


In-App Billing Extension

The App Inventor Extension feature has been released on June 15, 2016.
See the App Inventor Extensions document about how to use an App Inventor Extension.

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

Description

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: com.android.vending.BILLING

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.

Properties


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

Methods


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.


Subscribe.
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.

Events


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

Initialize

Product Details

Purchase

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.

Do you need help with your App Inventor project?

I can help you: for one hour I charge 25 USD.
Please contact me at info [at] puravidaapps [dot] com for details!
For questions about App Inventor, please use 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 extension (aix file) to you.
Thank you! Taifun


Please check your spam folder in case you did not receive the extension!
I usually will send the extension not later than 24 hours after having received your payment.

 

Terms and Conditions

Back to top of page ...


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