This repository has been archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Google Play
Anastasiia Karimova edited this page Feb 25, 2015
·
12 revisions
-
Add the corresponding billing permission
<uses-permission android:name="com.android.vending.BILLING" />
-
If you want to delegate purchase verification to the library, set
verifyMode
to VERIFY_EVERYTHING and add your public keyOpenIabHelper.Options.Builder builder = new OpenIabHelper.Options.Builder(); builder.setVerifyMode(OpenIabHelper.Options.VERIFY_EVERYTHING); builder.addStoreKey(OpenIabHelper.NAME_GOOGLE, googlePlayPublicKey); mHelper = new OpenIabHelper(this, builder.build());
Or
if you don't want to keep public keys in the code, we strongly recommend you to verify purchases on a server side using Google Play Developer API. To do it, createOpenIabHelper
with VERIFY_SKIP option and no public key.OpenIabHelper.Options.Builder builder = new OpenIabHelper.Options.Builder(); builder.setVerifyMode(OpenIabHelper.Options.VERIFY_SKIP); mHelper = new OpenIabHelper(context, builder.build());
Then in the callback in case of success, just sent
new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { if(result.isOK) if (storeName.equals(OpenIABHelper.NAME_GOOGLE)) { youMethodToVerifyPurchaseViaServer(purchase); } } }
-
Map the SKUs if they are different for the supported stores
OpenIabHelper.mapSku(SKU_PREMIUM, OpenIabHelper.NAME_GOOGLE, "org.onepf.trivialdrive.gp.premium"); OpenIabHelper.mapSku(SKU_GAS, OpenIabHelper.NAME_GOOGLE, "org.onepf.trivialdrive.gp.gas"); OpenIabHelper.mapSku(SKU_INFINITE_GAS, OpenIabHelper.NAME_GOOGLE, "org.onepf.trivialdrive.gp.infinite_gas");
-
In the proguard configuration file add
-keep class com.android.vending.billing.**
Google instructions https://developer.android.com/google/play/billing/billing_testing.html
To test .apk, please ensure that
-
for Google Play environment
- your .apk is submitted to Google Play Developer Console
- versionCode in AndroidManifest.xml of your .apk is equal to versionCode of .apk submitted to Developer Console
-
for OpenIAB
# install for Google Play: adb install -i com.android.vending /path/to/YourApp.apk
- http://developer.android.com/google/play/billing/index.html
- http://developer.android.com/google/play/billing/billing_overview.html
- http://developer.android.com/google/play/billing/api.html
- http://developer.android.com/google/play/billing/billing_best_practices.html
- http://developer.android.com/google/play/billing/billing_testing.html
- http://developer.android.com/google/play/billing/billing_admin.html