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 173
Google Play
akarimova edited this page Nov 7, 2014
·
12 revisions
#How To add
-
Add the corresponding billing permission
<uses-permission android:name="com.android.vending.BILLING" />
-
Provide your public key
OpenIabHelper.Options.Builder builder = new OpenIabHelper.Options.Builder(); builder.addStoreKey(OpenIabHelper.NAME_GOOGLE, googlePlayPublicKey); mHelper = new OpenIabHelper(this, builder.build());
otherwise verify purchases on your server side.
-
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.**
-
Create OpenIabHelper with "Skip signature verification" option and no public keys. If you specify no public keys and forget VERIFY_SKIP option, an IllegalArgumentException will be thrown
OpenIabHelper.Options.Builder builder = new OpenIabHelper.Options.Builder(); builder.setVerifyMode(OpenIabHelper.Options.VERIFY_SKIP); mHelper = new OpenIabHelper(context, builder.build());
-
Get receipt data and signature from Purchase object and send it to your server
new IabHelper.OnIabPurchaseFinishedListener() { public void onIabPurchaseFinished(IabResult result, Purchase purchase) { // … different result checks ... String receiptData = purchase.getOriginalJson(); String receiptSignature = purchase.getSignature(); String storeName = purchase.getAppstoreName(); String urlToContent = yourRequestReceiptVerificationOnServer(receiptData, receiptSignature, storeName); // … further code ... } }
or use the following methods
To test .apk, please ensure
- your .apk is submitted to Google Play Developer Console
- your .apk is signed by the production key
- versionCode in AndroidManifest.xml of your .apk is equal to versionCode of .apk submitted to Developer Console