Uploading Android apps to all the existing Android appstores is a painful process and AppDF project was designed to make it easier. But what is even more difficult for the developers is supporting different in-purchase APIs of different appstores. There are five different In-App Purchase APIs already and this number is increasing. We are going to create an open source library that will wrap appstore in-app purchase APIs of all the stores and provide an easy way for the developers to develop their apps/games in a way that one APK will work in all the stores and automatically use right in-app purchase API under each store. Plus we are going to develop an open in-app billing API that stores could implement to support all the built APK files using this library.
- Download library from GitHub
git clone https://github.com/onepf/OpenIAB.git
-
Link /library to project as Android Library
-
Instantiate
new OpenIabHelper
and callmHelper.startSetup()
. When setup is done callmHelper.queryInventory()
mHelper = new OpenIabHelper(this, storeKeys);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
complain("Problem setting up in-app billing: " + result);
return;
}
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});
-
Handle results of
mHelper.queryInventory()
in listener and update UI to show what is purchased https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L210 -
When in user requested purchase of item call
mHelper.launchPurchaseFlow()
https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L271 and handle results with listener https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L357 -
If user purchased consumable item call
mHelper.consume()
to exclude it from inventory. If item not consumed Store suppose it non-consumable item and doesn't allow to purchase it one more time. Also it will be returned bymHelper.queryInventory()
next time https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L237 and handle results with listener https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L399 -
Map Google Play SKU ids to Yandex/Amazon SKUs like this: https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L108
-
Specify keys for different stores like this: https://github.com/onepf/OpenIAB/blob/master/samples/trivialdrive/src/org/onepf/trivialdrive/MainActivity.java#L173
-
Add permissions required for OpenIAB in your AndroidManifest.xml
<uses-permission android:name="org.onepf.openiab.permission.BILLING" />
And register reciever for Amazon
<receiver android:name="com.amazon.inapp.purchasing.ResponseReceiver">
<intent-filter>
<action
android:name="com.amazon.inapp.purchasing.NOTIFY"
android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY"
/>
</intent-filter>
</receiver>
- Add the following strings to your proguard config
# TStore
-keep class com.skplanet.dodo.**{*;}
-keep class com.skplanet.internal.dodo.**{*;}
-keep class com.skplanet.internal.dodo.dev.**{*;}
-keep class com.skplanet.internal.dodo.util.**{*;}
-keep class com.skplanet.pmss.secure.**{*;}
-keep public class android.net.http.SslError
-keep public class android.webkit.WebViewClient
-keep class com.tmoney.aidl.**{*;}
-dontwarn android.webkit.WebView
-dontwarn android.net.http.SslError
-dontwarn android.webkit.WebViewClient
-keepattributes Signature
-dontshrink
# AMAZON
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
-dontoptimize
# GOOGLE
-keep class com.android.vending.billing.**
# SAMSUNG
-keep class com.sec.android.iap.**
There is also Unity engine plugin that will simplify integration for C#/JavaScript developers. No need to write any java code.
- An Android app developer integrates OpenIAB library in his/her Android code
- An Android app developer implements in-app purchases using OpenIAB API (which is very close to Google Play IAB API, just few changes in source code will be needed)
- OpenIAB Lib detects which appstore installed the app
- OpenIAB Lib redirects in-app purchase calls to the corresponding appstore IAB API (OpenIAB Lib wrapps IAB APIs of severall apstores)
- All In-App Billing logic is handled by the corresponding appstore, OpenIAB has no code to process in-app purchases and has no UI, it just wrapps In-App Billing APIs of different stores in one library
We have just started. We are creating a sample game that supports in-app billing of all existing appstores that support in-app purchasing. In the same time, we are designing Open In-App Billing API that appstores can use to easily integrate in-app billing functionality.
- As close to Google Play In-app Billing API as possible - we optimize the OpenIAB library by the following parameter "lines on code you need to change in an app that already works in Google Play to make it working in all the appstores"
- No middle man
- Modular architecture - adding new appstore should be just adding one more class imeplementing a fixed interface
- One APK file to work in all appstores - but OpenIAB should have an option to build separate APK files for appstores for developers who want to create APK without any overhead
- No additional functionality - OpenIAB does not make in-app billing easier to use, we just make it working in all the appstores with single code
OpenIAB is an open source library that wraps the already existing IAB APIs as well as an open API that appstores could implement. It is important to understand that all payments are processes directly by each store and there is no a middle man staying between the app developers and the appstores. OpenIAB will not do payments for the appstores. It is just an API how the apps communicate with appstores to request in-app billing. There is a common open API all the stores can use instead of each new store implement their own API and developers have to integrate all these different APIs in their apps.
The following Android application stores support in-app billing today:
If you know about other Android appstores that support in-app purchasing please let us know.
We are working on integrating their IAB APIs in one OpenIAB library. Here is information about Appstore IAB feature support:
Google Play | Amazon AppStore | Samsung Apps | SK-Telecom T-Store | |
---|---|---|---|---|
Link to IAB API description | Google IAB API | Amazon IAB API | Samsung IAB API | T-Store IAB API |
Processing code | Appstore | Appstore | Lib | Lib |
Subscription | Yes | Yes | No | Yes |
Consumable goods | Yes | Yes | Yes | Yes |
Non-consumable goods | Yes | Yes | No | Yes |
- If you are an Android app developer check the list of open tasks, check if any of these tasks is interesting for you, send a message to OpenIAB mailing list how you want to help. Fork OpenIAB on GitHub.
- If you are an appstore and already support In-App Billing then most probably we are already working on supporting your API in OpenIAB library, and your help is very welcome since you know your API better than anyone else! Just contact us by joining OpenIAB mailing list.
- If you are an appstore and do not support In-App Billing yet but plan to support it then we will be glad working with your on creating a common OpenIAB API and API. Join OpenIAB mailing list to be involved in OpenIAB API development.
Source code of the OpenIAB library and the samples is available under the terms of the Apache License, Version 2.0:
http://www.apache.org/licenses/LICENSE-2.0
The OpenIAB API specification and the related texts are available under the terms of the Creative Commons Attribution 2.5 license:
http://creativecommons.org/licenses/by/2.5/