1page.title=In-app Billing Overview
2parent.title=In-app Billing
3parent.link=index.html
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8  <h2>Quickview</h2>
9  <ul>
10    <li>Use In-app Billing to sell digital goods, including one-time items and recurring subscriptions.</li>
11    <li>Supported for any app published on Google Play. You only need a Google Play publisher account and a Google Checkout Merchant account.</li>
12    <li>Checkout processing is automatically handled by Google Play, with the same look-and-feel as for app purchases.</li>
13  </ul>
14  <h2>In this document</h2>
15  <ol>
16    <li><a href="#api">In-app Billing API</a></li>
17    <li><a href="#products">In-app Products</a>
18       <ol>
19       <li><a href="#prodtypes">Product Types</a>
20       </ol>
21    </li>
22    <li><a href="#console">Google Play Developer Console</a></li>
23    <li><a href="#checkout">Google Play Purchase Flow</a></li>
24    <li><a href="#samples">Sample Apps</a></li> 
25    <li><a href="#migration">Migration Considerations</a></li>
26  </ol>
27   <h2>Related Samples</h2>
28  <ol>
29    <li><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">Sample Application (V3)</a></li>
30    <li><a href="{@docRoot}google/play/billing/v2/billing_integrate.html#billing-download">Sample
31    Application (V2)</a></li>
32  </ol> 
33</div>
34</div>
35
36<p>This documentation describes the fundamental In-app Billing components and 
37features that you need to understand in order to add In-app 
38Billing features into your application.</p>
39
40<h2 id="api">In-app Billing API</h2>
41<p>Your application accesses the In-app Billing service using an API that is 
42exposed by the Google Play app that is installed on the device. The Google Play 
43app then conveys billing requests and responses between your 
44application and the Google Play server. In practice, your application never 
45directly communicates with the Google Play server. Instead, your application 
46sends billing requests to the Google Play application over interprocess 
47communication (IPC) and receives responses from the Google Play app. 
48Your application does not manage any network connections between itself and 
49the Google Play server.</p>
50<p>In-app Billing can be implemented only in applications that you publish 
51through Google Play. To complete in-app purchase requests, the Google Play app 
52must be able to access the Google Play server over the network.</p>
53
54<p>Currently, Google Play supports two versions of the In-app Billing API. 
55To determine which version you should use, see <a href="#migration">Migration 
56Considerations</a>.</p>
57<h4><a href="{@docRoot}google/play/billing/api.html">Version 3</a> (recommended)</h4>
58<ul>
59<li>Requests are sent through a streamlined API that allows you to easily request 
60product details from Google Play, order in-app products, and quickly restore 
61items based on users' product ownership</li>
62<li>Order information is synchronously propagated to the device on purchase 
63completion</li>
64<li>All purchases are âmanagedâ (that is, Google Play keeps track of the user's 
65ownership of in-app products). The user cannot own multiple copies of an in-app 
66item; only one copy can be owned at any point in time</li>
67<li>Purchased items can be consumed. When consumed, the item reverts to the 
68"unowned" state and can be purchased again from Google Play</li>
69</ul>
70<h4><a href="{@docRoot}google/play/billing/v2/api.html">Version 2</a></h4>
71<ul>
72<li>Requests are sent via a single API interface ({@code sendBillingRequest})</li>
73<li>Responses from Google Play are asynchronous, in the form of broadcast intents</li>
74<li>No consumption model provided. You have to implement your own solution</li>
75<li>Provides support for subscriptions and unmanaged in-app purchase items, 
76as well as managed in-app products</li>
77</ul>
78<p>Both versions offer very broad compatibility across the range of Android 
79devices. In-app Billing Version 3 is supported on devices running Android 2.2 or 
80higher that have the latest version of the Google Play store installed 
81(over 90% of active devices). Version 2 offers similar compatibility. See 
82<a href="{@docRoot}google/play/billing/versions.html">Version Notes</a> for 
83more details.</p>
84
85<h2 id="products">In-app Products</h2>
86<p>In-app products are the digital goods that you offer for sale from inside your 
87application to users. Examples of digital goods includes in-game currency, 
88application feature upgrades that enhance the user experience, and new content 
89for your application.</p>
90<p>You can use In-app Billing to sell only digital content. 
91You cannot use In-app Billing to sell physical goods, personal services, or 
92anything that requires physical delivery. Unlike with priced applications, once 
93the user has purchased an in-app product there is no refund window.</p>
94<p>Google Play does not provide any form of content delivery. You are 
95responsible for delivering the digital content that you sell in your 
96applications. In-app products are always explicitly associated with one and 
97only one app. That is, one application cannot purchase an in-app product 
98published for another app, even if they are from the same developer.</p>
99
100<h3 id="prodtypes">Product types</h3>
101<p>In-app Billing supports different product types to give you flexibility in 
102how you monetize your application. In all cases, you define your products using 
103the Google Play Developer Console.</p>
104<p>You can specify these types of products for your In-app Billing application  
105â <em>managed in-app products</em>, <em>subscriptions</em>, and <em>unmanaged 
106in-app products</em>.  The term âmanagedâ indicates that Google Play handles and 
107tracks ownership for in-app products on your application on a per user account 
108basis, while âunmanagedâ indicates that you will manage the ownership  information yourself.</p>
109<p>To learn more about the product types supported by the different API versions, 
110see the related documentation for <a href="{@docRoot}google/play/billing/v2/api.html#billing-types">Version 2</a> and <a href="{@docRoot}google/play/billing/api.html#producttypes">Version 3</a>.</p>
111
112<h2 id="console">Google Play Developer Console</h2>
113<p>The Developer Console is where you can publish your 
114In-app Billing application, and manage the various in-app products that are 
115available for purchase from your application.</p>
116<p>You can create a product list of 
117digital goods that are associated with your application, including items for 
118one-time purchase and recurring subscriptions. For each item, you can define 
119information such as the itemâs unique product ID (also called its SKU), product 
120type, pricing, description, and how Google Play should handle and track 
121purchases for that product.</p>
122<p>You can also create test accounts to authorize 
123access for testing applications that are unpublished.</p>
124<p>To learn how to use the Developer Console to configure your in-app 
125products and product list, see 
126<a href="{@docRoot}google/play/billing/billing_admin.html">Administering 
127In-app Billing</a>.</p>
128
129<h2 id="checkout">Google Play Purchase Flow</h2>
130<p>Google Play uses the same checkout backend service as is used for application 
131purchases, so your users experience a consistent and familiar purchase flow.</p>
132<p class="note"><strong>Important:</strong> You must have a Google Checkout
133Merchant account to use the In-app Billing service on Google Play.</p>
134<p>To initiate a purchase, your application sends a billing request for a 
135specific in-app product. Google Play then handles all of the checkout details for 
136the transaction, including requesting and validating the form of payment and 
137processing the financial transaction.</p> 
138<p>When the checkout process is complete, 
139Google Play sends your application the purchase details, such as the order 
140number, the order date and time, and the price paid. At no point does your 
141application have to handle any financial transactions; that role is provided by 
142Google Play.</p>
143<img src="{@docRoot}images/in-app-billing/v3/iab_v3_checkout_flow.png" height="382" id="figure1" />
144<p class="img-caption">
145  <strong>Figure 1.</strong> Applications initiate In-app Billing requests 
146through their own UI (first screen). Google Play responds to the request by 
147providing the checkout user interface (middle screen). When checkout is 
148complete, the application resumes.
149</p>
150
151<h2 id="samples">Sample Applications</h2>
152<p>To help you integrate In-app Billing into your application, the Android SDK 
153provides two sample applications that demonstrate how to sell in-app products 
154from inside an app.</p>
155
156<dl>
157<dt><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">TrivialDrive sample for the Version 3 API</a></dt>
158<dd>This sample shows how to use the In-app Billing Version 3 API to implement 
159in-app product purchases for a driving game. The application demonstrates how to 
160send In-app Billing requests, and handle synchronous responses from Google Play. 
161The application also shows how to record item consumption with the API. The 
162Version 3 sample includes convenience classes for processing In-app Billing 
163operations as well as perform automatic signature verification.</dd>
164
165<dt><a href="{@docRoot}google/play/billing/v2/billing_integrate.html#billing-download">Dungeons sample for the Version 2 API</a></dt>
166<dd>This sample demonstrates how to use the In-app Billing Version 2 API to sell 
167standard in-app products and subscriptions for an adventuring game. It also 
168contains examples of the database, user interface, and business logic you might 
169use to implement In-app Billing.</dd>
170</dl>
171<p class="caution"><strong>Important</strong>: It's <em>strongly recommended</em> 
172that you obfuscate the code in your application before you publish it. For 
173more information, see
174<a href="{@docRoot}google/play/billing/billing_best_practices.html">Security 
175and Design</a>.</p>
176
177<h2 id="migration">Migration Considerations</h2>
178<p>The following considerations may be applicable if you are planning to create a new 
179in-app biling application, or migrate your existing In-app Billing implementation 
180from the <a href="{@docRoot}google/play/billing/v2/api.html">Version 2</a> or 
181earlier API to the <a href="{@docRoot}google/play/billing/api.html">Version 3</a> API.</p>
182<p>Google Play will continue to support both the Version 2 and Version 3 APIs for 
183some time, so you can plan to migrate to Version 3 at your own pace. The Google 
184Play team will give advance notice of any upcoming changes to the support 
185status of In-app Billing Version 2.</p>
186<p>You can use the following table to decide which version of the API to use, 
187depending on the needs of your application.</p>
188<p class="table-caption" id="table1">
189  <strong>Table 1.</strong> Selecting the In-app Billing API Version for Your 
190Project</p>
191
192<table>
193<tr>
194<th scope="col">Choose Version 3 if ...</th>
195<th scope="col">Choose Version 2 if ...</th>
196</tr>
197<tr>
198<td>
199  <ul>
200  <li>You want to sell in-app products only (and not subscriptions)</li>
201  <li>You need synchronous order confirmations when purchases complete</li>
202  <li>You need to synchronously restore a user's current purchases</li>
203  </ul>
204</td>
205<td>
206  <ul>
207  <li>You want to sell subscriptions in your app</li>
208  </ul>
209</td>
210</tr>
211</table>
212<p>If you have published apps selling in-app products, note that:</p>
213<ul>
214<li>Managed items that you have previously defined in the Developer Console will 
215work with Version 3 as before.</li>
216<li>Unmanaged items that you have defined for existing applications will be 
217treated as managed products if you make a purchase request for these items using 
218the Version 3 API. You do not need to create a new product entry in Developer 
219Console for these items, and you can use the same product IDs to purchase these 
220items. They will still continue to be treated as unmanaged items if you make a 
221purchase request for them using the Version 2 or earlier API. 
222</ul>
223
224
225
226
227
228