Skip to content
This repository was archived by the owner on Apr 28, 2022. It is now read-only.

How to use OpenIAB Unity Plugin with Google Play

pixxem edited this page Aug 10, 2014 · 21 revisions

1. Introduction

The purpose of this page is to guide you through setting in-app purchases on Google Play store, with Unity and the OpenIAB plugin.

We'll use the OpenIAB demo and modify code for a real product use.

2. Prerequisites

You need to have :

  1. a version of Unity (the free version is OK)
  2. the Android SDK up-to-date
  3. a Java JDK correctly installed on your computer ("visible" by Unity)
  4. and an Android Device for testing, with Internet access

For instance, the following set up works with these instructions : Unity 4.5.2, Java 1.7.0_65 64 bits on Windows 7, with a Google Nexus 7 on Android 4.4.4.

You'll also need a Google Developer account, with a bank account verified (Google Wallet > Payment settings). Besides that, to have a second Gmail account is more convenient for testing puposes. For instance, on the Nexus 7, you can create an additionnal user account with a different Gmail address for that.

You're supposed to be familiar with the Google Play Developer Console (GPDC) uploads, and the terms of in-app billing, by reading Official Google Play In-app Billing. You don't need to run all the Java code (OpenIAB-Unity-Plugin is a convenient C# wrapper of these Java functionalities) but at least to be aware of definition of SKU, License Key, in-app product prices, etc. .

3. GPDC - License Key

In the GPDC, create a new application (All applications > Add new application).

Grap the License Key, to put it in your code (> Services & APIs). It's a string like "MIIBIjANBg...(lots of characters)...E1rQIDAQAB" without a space.

4. Unity - Download & install

  1. Run a new Unity Project, you can also use an existing project but maybe it's safer to start from blank to understand the mechanics first. Grap the lastest version for Unity here : OpenIAB - Open In-App Billing Open the scene OpenIAB-demo (Assets > OpenIAB-demo).

  2. Set it for Android Platform, if needed. Set correctly the Bundle Identifier

5. Unity - AndroidManifest.xml, Publishing Settings and 1st test

  1. Set the Modify the AndroidManifest.xml (in Assets/Plugins/Android), be sure to have the following permissions:
	...
	</application>
	
	<!--all-->
	<uses-permission android:name="android.permission.INTERNET"/>
	<!--Google Play-->
	<uses-permission android:name="com.android.vending.BILLING" />
	<uses-permission android:name="org.onepf.openiab.permission.BILLING" />	
	
	<!-- for tablets, important ! -->
	<uses-feature android:name="android.hardware.telephony" android:required="false" />

    <permission android:name="com.tmoney.vending.INBILLING"/>
    
</manifest>
  1. Make a new Keystore and a Key with password.

  2. Build & Run on your device. All the tests functions must work (check the internet !), the "Test Purchase" works only once because the consumable product bought is not consumed. The "Purchase Real Product" should tell "The item you were attemting to purchase could not be found"

6. Unity - Modify the code for the real product

Set the real product

GPDC - Upload the APK

devices supported

GPDC - Google In-app Product

declare the product and price

Android device - Testing

wait and test