Setup In Developer Console
Make sure that androidnative.jar and AndroidManifest.xml are inside your Assets/Plugins/Android folder.
To implement in-Apps in your application, you should create new android application in google developer console and pass some info to the plugin. See the instructions below how to set up and run a billing example scene.
1) Create new Application in Google Developer Console and get the public license key. See the step below:
Go to the Google Play Developer Console site and log in. You will need to register for a new developer account if you have not registered yet. To sell in-app items, you also need to have a Google Wallet merchant account.
Click on Try the new design to access the preview version of the Developer Console, if you have not been already logged on to that version.
In the All Applications tab, add a new application entry.
Click Add the new application.
Enter a name for your new In-app Billing application.
Click Prepare Store Listing.
In the Services & APIs tab, find and make a note of the public license key that Google Play generated for your application. This is a Base64 string that you will need to include in your application code.
Your application should now appear in the list of applications in Developer Console.
2) Pass the public license key to the plugin.
Open Window -> Android Native -> Edit Settings
And specify your Base64 key under the Billing tab:
Setting Up for Test Purchases
To test your In-app Billing implementation with actual in-app purchases, you will need to register at least one test account on the Google Play Developer Console. You cannot use your developer account to test the complete in-app purchase process because Google Wallet does not let you buy items from you. If you have not set up test accounts before, see Setting up test accounts.
Also, a test account can purchase an item in your product list only if the item is published. The application does not need to be published, but the item needs to be published.
To test your In-app Billing implementation with actual purchases, follow these steps:
Upload your application as a draft application to the Developer Console.
Previously, you could publish a "draft" version of your app for testing. This functionality is no longer supported. Instead, there are two ways you can test how to pre-release app functions on the Google Play store:
You can publish an app to the alpha or beta distribution channels. This makes the app available on the Google Play store, but only to the testers you put in a "whitelist".
In a few cases, you can test Google Play functionality with an unpublished app. For example, you can test an unpublished app's in-app billing support by using static responses, special reserved product IDs that always return a specific result (like "purchased" or "refunded").
Add items to the application's product list.
Make sure that you have published the items (the application can remain unpublished). See Creating a product list to learn how to do this.
Install your application on an Android-powered device.
You cannot use the emulator to test In-app Billing; you must install your application on a device to test In-app Billing.
Verify that your device is running a supported version of the Google Play application or the MyApps application.
If your device is running Android 3.0, In-app Billing requires version 5.0.12 (or higher) of the MyApps application. If your device is running any other version of Android, In-app Billing requires version 2.3.4 (or higher) of the Google Play application. To learn how to check the version of the Google Play application, see Updating Google Play.
Make in-app purchases in your application.
Note: The only way to change the primary account on a device is to do a factory reset, making sure you log on with your primary account first.
When you have finished testing your In-app Billing implementation, you are ready to publish your application on Google Play. You can follow the normal steps for preparing, signing and publishing on Google Play.
Signing and Uploading apk with Unity
To be able to create in-app purchases you should upload your apk file to the developer console. Apk must be signed with your private key. By default when you build apk file with Unity, it is signed with the debug key. It means that it is not suitable for uploading to the google developer console.
Next step is app configuration.
You have to choose your bundle ID
A bundle ID, which is known as a package in Android, is the unique identifier for all Android apps. It needs to be unique as when you upload it to Google Play it identifies and publishes your app using the package name as the unique app identification.
Really, it is the only thing which is necessary to identify your app, and generally it has 3 parts:
where an example is generally the company/publishers name, and the Test App is the app name.
You will not be able to upload an APK to the store, which has the same package as another app which is in the store.
When your bundle ID is ready, add it to the Unity application setting and to the AndroidManifest.xml.
Here is a screenshot of required setting in Unity.
You can build your signed apk file now. Just press build button.
Note: You should have the latest android SDK on your computer, to make Unity be able to build an apk file.
Note: Android plugin should be included to your application. If you build signed application without plugin included, application will not have permissions to use billing.
After signed apk is created, you can upload it to the Google. Choose your created application on Google Developer Console, open APK tab and press “Upload your First APK to Production” button.
After apk is uploaded, you can start testing the example scene and try to modify PaymnetManagerExample class to work with your products or create your own using PaymnetManagerExample as an example.
Testing for In-App Billing, Licensing, and APK Expansion Files Previously, you could use your Draft APKs to test these features. After a recent change, testing your features using Draft APKs is no longer supported. You must now publish your app to the alpha or beta distribution channels to test your implementation of these features. For more information, please, refer to the documentation which is available on the Android Developers site.