Merge "docs: Improved Google Play Developer Console documentation" into nyc-docs

This commit is contained in:
Kevin Hufnagle
2016-07-29 22:01:18 +00:00
committed by Android (Google) Code Review
4 changed files with 367 additions and 279 deletions

View File

@@ -10,30 +10,30 @@ Xnonavpage=true
<div id="qv"> <div id="qv">
<h2>Features</h2> <h2>Features</h2>
<ol> <ol>
<li><a href="#latest">Latest blog posts</a></li> <li><a href="#latest">Latest Blog Posts</a></li>
<li><a href="#publish">Publish with confidence</a></li> <li><a href="#publish">Publish with Confidence</a></li>
<li><a href="#aquire-users">Acquire users</a></li> <li><a href="#aquire-users">Acquire Users</a></li>
<li><a href="#insights">Actionable insights</a></li> <li><a href="#insights">Learn about Users and App Performance</a></li>
<li><a href="#manage">Manage your app</a></li> <li><a href="#manage">Manage Your App</a></li>
</ol> </ol>
</div> </div>
</div> </div>
<p> <p>
The <a href="https://play.google.com/apps/publish/">Google Play Developer The <a class="external-link" href="https://play.google.com/apps/publish/">Google Play Developer
Console</a> is your home for publishing operations and tools. Console</a> is your home for publishing and managing your apps.
</p> </p>
<img src="{@docRoot}images/distribute/googleplay/gp-devconsole-home.png" style="width:480px;"> <img src="{@docRoot}images/distribute/googleplay/gp-devconsole-home.png" style="width:480px;">
<p> <p>
Upload apps, build your product pages, configure prices and distribution, and You can manage all phases of publishing on Google Play through the Developer
publish. You can manage all phases of publishing on Google Play through the Console. Using any web browser, you can upload apps, build product pages, set
Developer Console, from any web browser. prices, configure distribution, and publish apps.
</p> </p>
<p> <p>
Once you've <a href= After you've <a href=
"{@docRoot}distribute/googleplay/start.html">registered</a> and received "{@docRoot}distribute/googleplay/start.html">registered</a> and received
verification by email, you can sign in to your Google Play Developer Console. verification by email, you can sign in to your Google Play Developer Console.
</p> </p>
@@ -44,7 +44,7 @@ Xnonavpage=true
<div class="dynamic-grid"> <div class="dynamic-grid">
<div class="headerLine"> <div class="headerLine">
<h2 id="latest">Latest blog posts</h2> <h2 id="latest">Latest Blog Posts</h2>
</div> </div>
<div class="resource-widget resource-flow-layout col-13" <div class="resource-widget resource-flow-layout col-13"
@@ -54,31 +54,10 @@ Xnonavpage=true
data-maxResults="3"></div> data-maxResults="3"></div>
</div> </div>
<h2 id="publish">Publish with confidence</h2> <h2 id="publish">Publish with Confidence</h2>
<p>The Developer Console provides rich testing features and staged rollouts that help you to
provide apps that satisfy your users.</p>
<div class="wrap"> <div class="wrap">
<h3 id="alpha-beta">Alpha and beta tests</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
Distribute your pre-release app to users as an open beta with a
one-click, opt-in URL or as a closed beta using an email list, Google
Group, or Google+ community. Users can then provide feedback, while not
affecting your app’s public reviews and rating. This valuable feedback
will help you test features and improve the quality of your app.
<a href="{@docRoot}distribute/engage/beta.html">Learn more</a>.
</p>
</div>
<div class="col-8of12 col-push-1of12">
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png 1x, {@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test_2x.png 2x"
width="500">
</div>
</div>
<h3 id="cloud-test">Cloud Test Lab</h3> <h3 id="cloud-test">Cloud Test Lab</h3>
@@ -87,8 +66,8 @@ Xnonavpage=true
<p> <p>
Get free automated testing of your app on physical devices covering Get free automated testing of your app on physical devices covering
nearly every brand, model, and version of the devices your users might nearly every brand, model, and version of the devices your users might
be using. The lab will help you quickly find compatibility issues you have. The lab helps you quickly find compatibility issues that you
may miss using only your available test devices. Sign-up in the might miss using only your available test devices. Sign up in the
Developer Console to become an early tester before this feature becomes Developer Console to become an early tester before this feature becomes
more widely available. <a href= more widely available. <a href=
"https://developers.google.com/cloud-test-lab/" class= "https://developers.google.com/cloud-test-lab/" class=
@@ -100,57 +79,85 @@ Xnonavpage=true
<img src= <img src=
"{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png" "{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png"
srcset= srcset=
"{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png 1x, {@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab_2x.png 2x" "{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab_2x.png 2x"
width="500"> width="500">
</div> </div>
</div> </div>
</div> </div>
<h3 id="alpha-beta">Alpha and beta tests</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
Collect user feedback on early versions of your app with alpha and beta testing.
Distribute your pre-release app to users as an open beta with a
one-click, opt-in URL or as a closed beta using an email list, Google
Group, or Google+ community. Users can provide feedback, while not
affecting your app’s public reviews and rating. This valuable feedback
helps you test features and improve the quality of your app.
<a href="{@docRoot}distribute/engage/beta.html">Learn more</a>.
</p>
</div>
<div class="col-8of12 col-push-1of12">
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test_2x.png 2x"
width="500">
</div>
</div>
<h3 id="staged-rollouts">Staged rollouts</h3> <h3 id="staged-rollouts">Staged rollouts</h3>
<p> <p>
Release app updates progressively to an increasing portion of your users and Discover and fix problems with a limited user base before making a wider release.
monitor for missed issues. Then take the opportunity to fix problems before With staged rollouts, you can release app updates progressively to an increasing portion of
all your users are affected. <a href= your users.
You can fix problems before your app reaches the broader user community. <a href=
"https://support.google.com/googleplay/android-developer/answer/3131213" "https://support.google.com/googleplay/android-developer/answer/3131213"
class="external-link">Learn more.</a> class="external-link">Learn more</a>.
</p> </p>
<p class="aside"> <p class="note">
<strong>Tip:</strong> If you find an issue during a rollout stage you can <strong>Tip:</strong> If you find an issue during a rollout stage, you can
halt the rollout to further minimize the effect, and then resume rollout once halt the rollout, make the fix, and then resume.
a fix has been made.
</p> </p>
<h2 id="aquire-users">Aquire users</h2> <h2 id="aquire-users">Acquire Users</h2>
<p>Using the Developer Console, you can configure targeted ads to present your app to more users.
<h3 id="adwords">AdWords Universal App Campaigns</h3> You can test variations of your Play Store listings and track user responses.</p>
<h3 id="adwords">Promote your app with AdWords</h3>
<p> <p>
Easily and conveniently buy AdWords app install ads, across Search Easily and conveniently buy AdWords app install ads. AdWords Universal App Campaigns
appear across Search
(including Play Search), YouTube, AdMob, and the Google Display Network. (including Play Search), YouTube, AdMob, and the Google Display Network.
Simply set a budget and cost per acquisition and Google takes care of the Set a budget and cost per acquisition, and Google takes care of the
rest. <a href="{@docRoot}distribute/users/promote-with-ads.html">Learn rest. <a href="{@docRoot}distribute/users/promote-with-ads.html">Learn
more</a>. more</a>.
</p> </p>
<div class="wrap"> <div class="wrap">
<h3 id="listing-experiments">Store Listing Experiments</h3> <h3 id="listing-experiments">Increase installs with improved store listings</h3>
<div class="cols" style="margin-top:2em;"> <div class="cols" style="margin-top:2em;">
<div class="col-3of12"> <div class="col-3of12">
<p> <p>With store listing experiments,
Test variations of the images and text used to promote and describe you can test variations of your app's Play Store listing.
your app on your Play store listing. Then when enough data has been You can try different combinations of images and text used to promote and describe
collected, choose to make the winning combination visible on Google your app on its Play Store listing. Collect data, choose the best combination, and make
it visible on Google
Play. <a href="{@docRoot}distribute/users/experiments.html">Learn Play. <a href="{@docRoot}distribute/users/experiments.html">Learn
more</a>. more</a>.
</p> </p>
<p class="aside"> <p class="note">
<strong>Tip:</strong> You can even try out different orders for your <strong>Tip:</strong> You can reorder your screenshots and other images in different ways
screenshots and other images to discover which grabs users’ attention to determine the arrangement that best attracts users.
the best.
</p> </p>
</div> </div>
@@ -158,20 +165,21 @@ Xnonavpage=true
<img src= <img src=
"{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png" "{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png"
srcset= srcset=
"{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png 1x, {@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment_2x.png 2x" "{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment_2x.png 2x"
width="500"> width="500">
</div> </div>
</div> </div>
<h3 id="user-perf-report">User Acquisition performance report</h3> <h3 id="user-perf-report">User acquisition performance report</h3>
<div class="cols" style="margin-top:2em;"> <div class="cols" style="margin-top:2em;">
<div class="col-3of12"> <div class="col-3of12">
<p> <p>
Discover where visitors to your Play Store listing come from, how many Discover information about visitors to your Play Store listing, such as where they come
go on to install your app, and how many buy your in-app products in the from, how many go on to install your app, and how many buy your in-app products. You
User Acquisition performance report; compare cohorts, examine can also compare cohorts, examine acquisition channels, and see details of users and
acquisition channels, and see details of users and buyers. <a href= buyers. <a href=
"{@docRoot}distribute/users/user-acquisition.html">Learn more</a>. "{@docRoot}distribute/users/user-acquisition.html">Learn more</a>.
</p> </p>
</div> </div>
@@ -180,14 +188,16 @@ Xnonavpage=true
<img src= <img src=
"{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png" "{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png"
srcset= srcset=
"{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png 1x, {@docRoot}images/distribute/googleplay/dev-console_conversion-funnel_2x.png 2x" "{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel_2x.png 2x"
width="500"> width="500">
</div> </div>
</div> </div>
</div> </div>
<h2 id="insights">Actionable insights</h2> <h2 id="insights">Learn about App Users and Performance</h2>
<p>Using the Developer console, you can gain valuable insights about app performance.
You can better understand user behavior and find out ways to optimize your app. </p>
<div class="wrap"> <div class="wrap">
<h3 id="player-analytics">Player Analytics</h3> <h3 id="player-analytics">Player Analytics</h3>
@@ -195,8 +205,10 @@ Xnonavpage=true
<div class="cols" style="margin-top:2em;"> <div class="cols" style="margin-top:2em;">
<div class="col-3of12"> <div class="col-3of12">
<p> <p>
With Google Play game services integration, discover more about the Google Play game services offers a comprehensive dashboard of player and engagement
behaviour of your game players; how they play and how they buy. Also get statistics.
With Player Analytics, discover more about the
behavior of your game users, including how they play and how they buy. Also get
help setting and monitoring revenue budgets. <a href= help setting and monitoring revenue budgets. <a href=
"{@docRoot}distribute/engage/game-services.html">Learn more</a>. "{@docRoot}distribute/engage/game-services.html">Learn more</a>.
</p> </p>
@@ -206,7 +218,8 @@ Xnonavpage=true
<img src= <img src=
"{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png" "{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png"
srcset= srcset=
"{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png 1x, {@docRoot}images/distribute/googleplay/dev-console_player-analytics_2x.png 2x" "{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_player-analytics_2x.png 2x"
width="500"> width="500">
</div> </div>
</div> </div>
@@ -216,74 +229,77 @@ Xnonavpage=true
<div class="cols" style="margin-top:2em;"> <div class="cols" style="margin-top:2em;">
<div class="col-3of12"> <div class="col-3of12">
<p> <p>
Get a wide range of reports on the performance of your app and behaviour Get a wide range of reports on the performance of your app and behavior
of users; such as installs, revenue, crashes, and more. Turn on email of users such as installs, revenue, and crashes. Turn on email
alerts to be notified of any sudden changes to important stats. <a href= alerts to receive notifications of any sudden changes to important stats. <a href=
"https://support.google.com/googleplay/android-developer/topic/3450942?ref_topic=3450986" "https://support.google.com/googleplay/android-developer/topic/3450942?ref_topic=3450986"
class="external-link">Learn more.</a> class="external-link">Learn more</a>.
</p> </p>
</div> </div>
<div class="col-8of12 col-push-1of12"> <div class="col-8of12 col-push-1of12">
<img src= <img src=
"{@docRoot}images/distribute/googleplay/dev-console_statistics.png" srcset= "{@docRoot}images/distribute/googleplay/dev-console_statistics.png" srcset=
"{@docRoot}images/distribute/googleplay/dev-console_statistics.png 1x, {@docRoot}images/distribute/googleplay/dev-console_statistics_2x.png 2x" "{@docRoot}images/distribute/googleplay/dev-console_statistics.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_statistics_2x.png 2x"
width="500"> width="500">
</div> </div>
</div> </div>
</div> </div>
<h3 id="optimization"> Optimization tips</h3> <h3 id="optimization">Optimization tips</h3>
<p> <p>
Get tips, based on automatic app scanning, on ways in which you can improve Automatic app scanning provides tips on ways to improve your apps&mdash;everything
your app, everything from updating old APIs to suggestions for languages you from updating old APIs to suggested languages for localization.
should consider localizing to.
</p> </p>
<h2 id="manage">Manage your app</h2> <h2 id="manage">Manage Your App</h2>
<h3 id="manage-apks">Manage your APKs</h3> <h3 id="manage-apks">Manage your APKs</h3>
<p> <p>
Upload and manage your Android application packages (APK) to the Developer Upload and manage your Android application packages (APK) to the Developer
Console as drafts or to your Alpha, Beta, or Production channels. <a href= Console as drafts or to your Alpha, Beta, or Production channels. <a href=
"https://support.google.com/googleplay/android-developer/answer/113469?ref_topic=3450986" "https://support.google.com/googleplay/android-developer/answer/113469?ref_topic=3450986"
class="external-link">Learn more.</a> class="external-link">Learn more</a>.
</p> </p>
<p class="aside"> <p class="note">
<strong>Tip:</strong> Ensure users get the best possible experience for the <strong>Tip:</strong> Ensure that users get the best possible experience for the
smallest app downloads by creating multiple APKs with just the right content smallest app downloads by creating multiple APKs with just the right content
for device screen size, hardware features and more. for hardware features such as screen size. For more information about using multiple APKs,
see <a href="https://developer.android.com/training/multiple-apks/index.html">
Maintaining Multiple APKs.</a>
</p> </p>
<h3 id="iap">In-app products and subscriptions</h3> <h3 id="iap">In-app products and subscriptions</h3>
<p> <p>
Manage your in-app products and price them for local markets accordingly. Manage your in-app products and price them for local markets.
Offer weekly, monthly, annual, or seasonal subscriptions and take advantage Offer weekly, monthly, annual, or seasonal subscriptions. Attract new users
of features such as grace periods and trials. <a href= with features such as grace periods and trials. <a href=
"https://support.google.com/googleplay/android-developer/topic/3452896?ref_topic=3452890" "https://support.google.com/googleplay/android-developer/topic/3452896?ref_topic=3452890"
class="external-link">Learn more.</a> class="external-link">Learn more</a>.
</p> </p>
<h3 id="pricing">Pricing and distribution</h3> <h3 id="pricing">Pricing and distribution</h3>
<p> <p>
Control the price of your app for each country you choose to distribute to. Control the price of your app for each country that you distribute to.
Make your app available to new audiences — opt-in to Android Auto, Android Make your app available to new audiences&mdash;opt-in to Android Auto, Android
TV, and Android Wear, as well as Designed for Families, Google Play for Work, TV, and Android Wear, as well as Designed for Families, Google Play for Work,
and Google Play for Education. <a href= and Google Play for Education. <a href=
"https://support.google.com/googleplay/android-developer/answer/113469#pricing" "https://support.google.com/googleplay/android-developer/answer/113469#pricing"
class="external-link">Learn more</a>. class="external-link">Learn more</a>.
</p> </p>
<p class="external-link"> <p class="note">
<strong>Tip:</strong> You can set prices in other countries automatically <strong>Note:</strong> When you distribute your app to countries that use other currencies,
based on current exchange rates using the <strong>auto-convert prices the Google Play Developer Console autofills country-specific prices based on current exchange
now</strong> feature. rates and locally-relevant pricing patterns. You can update the exchange rates manually by
selecting <strong>Refresh exchange rates</strong>.
</p> </p>
<p style="clear:both"> <p style="clear:both">

View File

@@ -7,19 +7,20 @@ parent.link=index.html
<div id="qv"> <div id="qv">
<h2>Quickview</h2> <h2>Quickview</h2>
<ul> <ul>
<li>Use In-app Billing to sell digital goods, including one-time items and <li>Use In-app Billing to sell digital products, including one-time products and
recurring subscriptions.</li> recurring subscriptions.</li>
<li>Supported for any app published on Google Play. You only need a Google <li>In-app Billing is supported for any app published on Google Play. You need only a
Google
Play Developer Console account and a Google payments merchant account.</li> Play Developer Console account and a Google payments merchant account.</li>
<li>Checkout processing is automatically handled by Google Play, with the <li>Google Play automatically handles checkout processing with the
same look-and-feel as for app purchases.</li> same look and feel as app purchases.</li>
</ul> </ul>
<h2>In this document</h2> <h2>In this document</h2>
<ol> <ol>
<li><a href="#api">In-app Billing API</a></li> <li><a href="#api">In-app Billing API</a></li>
<li><a href="#products">In-app Products</a> <li><a href="#products">In-app Products</a>
<ol> <ol>
<li><a href="#prodtypes">Product Types</a> <li><a href="#prodtypes">Product types</a>
</ol> </ol>
</li> </li>
<li><a href="#console">Google Play Developer Console</a></li> <li><a href="#console">Google Play Developer Console</a></li>
@@ -27,30 +28,33 @@ same look-and-feel as for app purchases.</li>
<li><a href="#samples">Sample App</a></li> <li><a href="#samples">Sample App</a></li>
<li><a href="#migration">Migration Considerations</a></li> <li><a href="#migration">Migration Considerations</a></li>
</ol> </ol>
<h2>Related Samples</h2> <h2>Related samples</h2>
<ol> <ol>
<li><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">Sample <li><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">Sample
Application (V3)</a></li> Application (V3)</a></li>
</ol> </ol>
<h2>Related Videos</h2> <h2>Related videos</h2>
<ol> <ol>
<li><a href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o">Implementing <li><a class="external-link" href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o">
Implementing
Freemium</a></li> Freemium</a></li>
</ol> </ol>
</div> </div>
</div> </div>
<p>This documentation describes the fundamental In-app Billing components and <p>This document describes the fundamental In-app Billing components and
features that you need to understand in order to add In-app features that you need to understand in order to add In-app
Billing features into your application.</p> Billing features into your application.</p>
<p class="note"><b>Note</b>: Ensure that you comply with applicable laws in the countries where you <p class="note"><b>Note</b>: Ensure that you comply with applicable laws in the countries where
distribute apps. For example, in EU countries, laws based on the you distribute apps. For example, in EU countries, laws based on the
<a href="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2005:149:0022:0039:EN:PDF"> <a class="external-link"
Unfair Commercial Practices Directive</a> prohibit direct exhortations to children to buy advertised href="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2005:149:0022:0039:EN:PDF">
products or to persuade their parents or other adults to buy advertised products for them. Unfair Commercial Practices Directive</a> prohibit direct exhortations to children to buy
See the advertised products or to persuade their parents or other adults to buy advertised products
<a href="http://ec.europa.eu/consumers/enforcement/docs/common_position_on_online_games_en.pdf"> for them. See the
<a class="external-link"
href="http://ec.europa.eu/consumers/enforcement/docs/common_position_on_online_games_en.pdf">
position of the EU consumer protection authorities</a> for more information on this and other position of the EU consumer protection authorities</a> for more information on this and other
topics. topics.
</p> </p>
@@ -61,75 +65,82 @@ exposed by the Google Play app that is installed on the device. The Google Play
app then conveys billing requests and responses between your app then conveys billing requests and responses between your
application and the Google Play server. In practice, your application never application and the Google Play server. In practice, your application never
directly communicates with the Google Play server. Instead, your application directly communicates with the Google Play server. Instead, your application
sends billing requests to the Google Play application over interprocess sends billing requests to the Google Play app over interprocess
communication (IPC) and receives responses from the Google Play app. communication (IPC) and receives responses from the Google Play app.
Your application does not manage any network connections between itself and Your application does not manage any network connections between itself and
the Google Play server.</p> the Google Play server.</p>
<p>In-app Billing can be implemented only in applications that you publish <p>You can implement In-app Billing only in applications that you publish
through Google Play. To complete in-app purchase requests, the Google Play app through Google Play. To complete in-app purchase requests, the Google Play app
must be able to access the Google Play server over the network.</p> must be able to access the Google Play server over the network.</p>
<p>In-app billing Version 3 is the latest version, and maintains very broad <p>In-app Billing Version 3 is the latest version, and it maintains very broad
compatibility across the range of Android devices. In-app Billing Version 3 is compatibility across the range of Android devices. In-app Billing Version 3 is
supported on devices running Android 2.2 or higher that have the latest version supported on devices running Android 2.2 (API level 8) or higher that have the latest version
of the Google Play store installed (<a of the Google Play app installed (<a
href="{@docRoot}about/dashboards/index.html">a vast majority</a> of active href="{@docRoot}about/dashboards/index.html">a vast majority</a> of active
devices).</p> devices).</p>
<h4>Version 3 features</h4> <h4>Version 3 features</h4>
<p>In-app Billing Version 3 provides the following features:</p>
<ul> <ul>
<li>Requests are sent through a streamlined API that allows you to easily request <li>Your app sends requests through a streamlined API that allows users to easily request
product details from Google Play, order in-app products, and quickly restore product details from Google Play and order in-app products. The API quickly restores
items based on users' product ownership</li> products based on the user's ownership.</li>
<li>Order information is synchronously propagated to the device on purchase <li>The API synchronously propagates order information to the device on purchase
completion</li> completion.</li>
<li>All purchases are “managed” (that is, Google Play keeps track of the user's <li>All purchases are <em>managed</em> (that is, Google Play keeps track of the user's
ownership of in-app products). The user cannot own multiple copies of an in-app ownership of in-app products). The user can't own multiple copies of an in-app
item; only one copy can be owned at any point in time</li> product; only one copy can be owned at any point in time.</li>
<li>Purchased items can be consumed. When consumed, the item reverts to the <li>Purchased products can be consumed. When consumed, the product reverts to the
"unowned" state and can be purchased again from Google Play</li> <em>unowned</em> state and can be purchased again from Google Play.</li>
<li>Provides support for <a <li>The API provides support for <a
href="{@docRoot}google/play/billing/billing_subscriptions.html">subscriptions</a></li> href="{@docRoot}google/play/billing/billing_subscriptions.html">subscriptions</a>.</li>
</ul> </ul>
<p>For details about other versions of In-app Billing, see the <p>For details about other versions of In-app Billing, see the
<a href="{@docRoot}google/play/billing/versions.html">Version Notes</a>.</p> <a href="{@docRoot}google/play/billing/versions.html">Version Notes</a>.</p>
<h2 id="products">In-app Products</h2> <h2 id="products">In-app Products</h2>
<p>In-app products are the digital goods that you offer for sale from inside your <p>In-app products are the digital products that you offer for sale to users from inside your
application to users. Examples of digital goods includes in-game currency, application. Examples of digital products include in-game currency,
application feature upgrades that enhance the user experience, and new content application feature upgrades that enhance the user experience, and new content
for your application.</p> for your application.</p>
<p>You can use In-app Billing to sell only digital content. <p>You can use In-app Billing to sell only digital content.
You cannot use In-app Billing to sell physical goods, personal services, or You can't use In-app Billing to sell physical products, personal services, or
anything that requires physical delivery. Unlike with priced applications, once anything that requires physical delivery. Unlike with priced applications, there is no refund
the user has purchased an in-app product there is no refund window.</p> window after
the user has purchased an in-app product.</p>
<p>Google Play does not provide any form of content delivery. You are <p>Google Play does not provide any form of content delivery. You are
responsible for delivering the digital content that you sell in your responsible for delivering the digital content that you sell in your
applications. In-app products are always explicitly associated with one and applications. In-app products are always explicitly associated with
only one app. That is, one application cannot purchase an in-app product only one app. That is, one application can't purchase an in-app product
published for another app, even if they are from the same developer.</p> that is published for another app, even if they are from the same developer.</p>
<h3 id="prodtypes">Product types</h3> <h3 id="prodtypes">Product types</h3>
<p>In-app Billing supports different product types to give you flexibility in <p>In-app Billing supports different product types to give you flexibility in
how you monetize your application. In all cases, you define your products using how you monetize your application. In all cases, you define your products using
the Google Play Developer Console.</p> the Google Play Developer Console.</p>
<p>You can specify these types of products for your In-app Billing application <p>You can specify two product types for your In-app Billing application:
— <em>managed in-app products</em> and <em>subscriptions</em>. Google Play <em>managed in-app products</em> and <em>subscriptions</em>. Google Play
handles and tracks ownership for in-app products and subscriptions on your handles and tracks ownership for in-app products and subscriptions for your
application on a per user account basis. application on a per-user basis.
<a href="{@docRoot}google/play/billing/api.html#producttypes">Learn more about <a href="{@docRoot}google/play/billing/api.html#producttypes">Learn more</a> about
the product types supported by In-app Billing Version 3</a>.</p> the product types supported by In-app Billing Version 3.</p>
<h2 id="console">Google Play Developer Console</h2> <h2 id="console">Google Play Developer Console</h2>
<p>The Developer Console is where you can publish your <p>The Developer Console is where you can publish your
In-app Billing application and manage the various in-app products that are In-app Billing application and manage the various in-app products that are
available for purchase from your application.</p> available for purchase from your application.</p>
<p>You can create a product list of <p>You can create a product list of
digital goods that are associated with your application, including items for digital products that are associated with your application, including products for
one-time purchase and recurring subscriptions. For each item, you can define one-time purchase and recurring subscriptions. You can define
information such as the item’s unique product ID (also called its SKU), product information for each product such as the following:</p>
type, pricing, description, and how Google Play should handle and track <ul>
purchases for that product.</p> <li>Unique product ID (also called its SKU).</li>
<li>Product type.</li>
<li>Pricing.</li>
<li>Description.</li>
<li>Google Play handling and tracking of purchases for that product.</li></p>
</ul>
<p>If you sell several of your apps or in-app products at the same price, you <p>If you sell several of your apps or in-app products at the same price, you
can add <em>pricing templates</em> to manage these price points from a can add <em>pricing templates</em> to manage these price points from a
centralized location. When using pricing templates, you can include local taxes centralized location. When using pricing templates, you can include local taxes
@@ -146,7 +157,7 @@ products and product list, see
In-app Billing</a>.</p> In-app Billing</a>.</p>
<h2 id="checkout">Google Play Purchase Flow</h2> <h2 id="checkout">Google Play Purchase Flow</h2>
<p>Google Play uses the same checkout backend service as is used for application <p>Google Play uses the same backend checkout service that is used for application
purchases, so your users experience a consistent and familiar purchase flow.</p> purchases, so your users experience a consistent and familiar purchase flow.</p>
<p class="note"><strong>Important:</strong> You must have a Google payments <p class="note"><strong>Important:</strong> You must have a Google payments
merchant account to use the In-app Billing service on Google Play.</p> merchant account to use the In-app Billing service on Google Play.</p>
@@ -157,8 +168,8 @@ processing the financial transaction.</p>
<p>When the checkout process is complete, <p>When the checkout process is complete,
Google Play sends your application the purchase details, such as the order Google Play sends your application the purchase details, such as the order
number, the order date and time, and the price paid. At no point does your number, the order date and time, and the price paid. At no point does your
application have to handle any financial transactions; that role is provided by application have to handle any financial transactions; that role belongs to
Google Play.</p> Google Play.</p>
<h2 id="samples">Sample Application</h2> <h2 id="samples">Sample Application</h2>
<p>To help you integrate In-app Billing into your application, the Android SDK <p>To help you integrate In-app Billing into your application, the Android SDK
@@ -166,16 +177,16 @@ provides a sample application that demonstrates how to sell in-app products and
from inside an app.</p> from inside an app.</p>
<p>The <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample"> <p>The <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">
TrivialDrive sample for the Version 3 API</a> sample shows how to use the In-app TrivialDrive for the Version 3 API</a> sample shows how to use the In-app
Billing Version 3 API Billing Version 3 API
to implement in-app product and subscription purchases for a driving game. The to implement in-app product and subscription purchases for a driving game. The
application demonstrates how to send In-app Billing requests, and handle application demonstrates how to send In-app Billing requests and handle
synchronous responses from Google Play. The application also shows how to record synchronous responses from Google Play. The application also shows how to record
item consumption with the API. The Version 3 sample includes convenience classes product consumption with the API. The Version 3 sample includes convenience classes
for processing In-app Billing operations as well as perform automatic signature for processing In-app Billing operations as well as perform automatic signature
verification.</p> verification.</p>
<p class="caution"><strong>Recommendation</strong>: Make sure to obfuscate the <p class="caution"><strong>Recommendation</strong>: Be sure to obfuscate the
code in your application before you publish it. For more information, see code in your application before you publish it. For more information, see
<a href="{@docRoot}google/play/billing/billing_best_practices.html">Security <a href="{@docRoot}google/play/billing/billing_best_practices.html">Security
and Design</a>.</p> and Design</a>.</p>
@@ -183,16 +194,17 @@ and Design</a>.</p>
<h2 id="migration">Migration Considerations</h2> <h2 id="migration">Migration Considerations</h2>
<p>The In-app Billing Version 2 API was discontinued in January 2015. <p>The In-app Billing Version 2 API was discontinued in January 2015.
If you have an existing In-app Billing implementation that uses API Version 2 or If you have an existing In-app Billing implementation that uses API Version 2 or
earlier, you must migrate to <a href="{@docRoot}google/play/billing/api.html">In-app Billing Version earlier, you must migrate to <a href="{@docRoot}google/play/billing/api.html">
3</a>.</p> In-app Billing Version 3</a>.</p>
<p>If you have published apps selling in-app products, note that:</p> <p>After migration, managed and unmanaged products are handled as follows:</p>
<ul> <ul>
<li>Managed items and subscriptions that you have previously defined in the Developer Console will <li>Managed products and subscriptions that you have previously defined in the
work with Version 3 as before.</li> Developer Console
<li>Unmanaged items that you have defined for existing applications will be work with Version 3 just as before.</li>
treated as managed products if you make a purchase request for these items using <li>Unmanaged products that you have defined for existing applications are
the Version 3 API. You do not need to create a new product entry in Developer treated as managed products if you make a purchase request for these products using
Console for these items, and you can use the same product IDs to purchase these the Version 3 API. You don't need to create a new product entry in the Developer
items. Console for these products, and you can use the same product IDs to manage these
products.
</ul> </ul>

View File

@@ -1,7 +1,7 @@
page.title=In-app Promotions page.title=In-app Promotions
parent.title=In-app Billing parent.title=In-app Billing
parent.link=index.html parent.link=index.html
page.metaDescription=Support promo codes in your app, which let you give content or features away to a limited number of users free of charge. page.metaDescription=Support promo codes in your app, which lets you give content or features away to a limited number of users free of charge.
page.image=/images/play_dev.jpg page.image=/images/play_dev.jpg
page.tags="promotions, billing, promo codes" page.tags="promotions, billing, promo codes"
meta.tags="monetization, inappbilling, promotions" meta.tags="monetization, inappbilling, promotions"
@@ -13,7 +13,7 @@ meta.tags="monetization, inappbilling, promotions"
<h2>In this document</h2> <h2>In this document</h2>
<ol> <ol>
<li><a href="#workflow">Creating and Redeeming Promo Codes</a></li> <li><a href="#workflow">Creating and Redeeming Promo Codes</a></li>
<li><a href="#supporting">Supporting Promo Codes In Your App</a></li> <li><a href="#supporting">Supporting Promo Codes in Your App</a></li>
<li><a href="#testing">Testing In-app Promotions</a></li> <li><a href="#testing">Testing In-app Promotions</a></li>
</ol> </ol>
<h2>See also</h2> <h2>See also</h2>
@@ -27,26 +27,26 @@ meta.tags="monetization, inappbilling, promotions"
<p> <p>
Promo codes let you give content or features away to a limited number of Promo codes let you give content or features away to a limited number of
users free of charge. Once you create a promo code, you can distribute it users free of charge. After you create a promo code, you can distribute it
subject to the subject to the
<!--TODO: Link to TOS when/if they're available as a web page --> terms of <!--TODO: Link to TOS when/if they're available as a web page --> terms of
service. The user enters the promo code in your app or in the Play Store app, service. The user enters the promo code in your app or in the Google Play Store app
and gets the item at no cost. You can use promo codes in many ways to and receives the item at no cost. You can use promo codes in many ways to
creatively engage with users. For example: creatively engage with users, such as the following:
</p> </p>
<ul> <ul>
<li>A game could have a special item, such as a character or decoration, <li>A game could have a special item, such as a character or decoration,
that's only available to players who attend an event. The developer could that's only available to players who attend an event. The developer could
distribute cards with promo codes at the event, and users would enter their distribute cards with promo codes at the event, and users would enter their
promo code to unlock the item. promo codes to unlock the item.
</li> </li>
<li>An app developer might distribute promo codes at local businesses, to <li>An app developer might distribute promo codes at local businesses to
encourage potential users to try the app. encourage potential users to try the app.
</li> </li>
<li>An app developer might give out "friends and family" codes to its employees to <li>An app developer might give <em>friends and family codes</em> to its employees to
share with their friends. share with their friends.
</li> </li>
</ul> </ul>
@@ -54,11 +54,11 @@ meta.tags="monetization, inappbilling, promotions"
<p> <p>
Every promo code is associated with a particular <em>product ID</em> (also Every promo code is associated with a particular <em>product ID</em> (also
known as a <em>SKU</em>). You can create promo codes for your existing in-app known as a <em>SKU</em>). You can create promo codes for your existing in-app
products. You can also keep a SKU off the Play Store, so the only way to get products. You can also keep an SKU off the Play Store, so that the only way to get
that item is by entering that SKU's promo code. When a user enters the promo that item is by entering that SKU's promo code. When a user enters the promo
code in the Play Store or in their app, the user gets the item, just as if code in the Play Store or in an app, the user gets the item, just as if
they paid full price for it. If your app already uses <a href= they paid full price for it. If your app already uses <a href=
"{@docRoot}google/play/billing/api.html">In-app Billing version 3</a> to "{@docRoot}google/play/billing/api.html">In-app Billing Version 3</a> to
support in-app purchases, it's easy to add support for promo codes. support in-app purchases, it's easy to add support for promo codes.
</p> </p>
@@ -67,12 +67,12 @@ meta.tags="monetization, inappbilling, promotions"
<p> <p>
You create promo codes through the <a href= You create promo codes through the <a href=
"https://play.google.com/apps/publish/" class="external-link">Google Play "https://play.google.com/apps/publish/" class="external-link">Google Play
Developer Console</a>. Each promo code is associated with a single product item Developer Console</a>. Each promo code is associated with a single product
registered in the developer console. registered in the developer console.
</p> </p>
<p> <p>
When a user gets a promo code, they redeem it in one of two ways: A user can redeem a promo code in one of these two ways:
</p> </p>
<ul> <ul>
@@ -85,33 +85,20 @@ meta.tags="monetization, inappbilling, promotions"
<li>The user can redeem the code in the Google Play Store app. Once the user <li>The user can redeem the code in the Google Play Store app. Once the user
enters the code, the Play Store prompts the user to open the app (if they have enters the code, the Play Store prompts the user to open the app (if they have
the latest version installed) or to download or update it. (We do not the latest version installed) or to download or update it. Google doesn't
currently support redeeming promo codes from the Google Play web store.) currently support redeeming promo codes from the Google Play web store.
</li> </li>
</ul> </ul>
<p> <h2 id="supporting">Supporting Promo Codes in Your App</h2>
If the promo code is for a <a href=
"{@docRoot}google/play/billing/api.html#consumetypes">consumable product</a>,
the user can apply an additional code for the same product <em>after</em> the first
product is consumed. For example, a game might offer promo codes for a bundle
of extra lives. Betty has two different promo codes for that bundle. She
redeems a single promo code, then launches the game. When the game launches,
the her character receives the lives, consuming the item. She can now redeem
the second promo code for another bundle of lives. (She cannot redeem the
second promo code until after she consumes the item she purchased with the
first promo code.)
</p>
<h2 id="supporting">Supporting Promo Codes In Your App</h2>
<p> <p>
To support promotion codes, your app should call the <a href= To support promotion codes, your app must call the <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
method whenever the app starts or resumes. This method returns a bundle of all method whenever the app starts or resumes. This method returns a bundle of all
current, unconsumed purchases, including purchases the user made by redeeming current, unconsumed purchases, including purchases the user made by redeeming
a promo code. This simplest approach is to call <a href= a promo code. The simplest approach is to call <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
in your activity's {@link android.app.Activity#onResume onResume()} method, in your activity's {@link android.app.Activity#onResume onResume()} method,
@@ -119,21 +106,21 @@ meta.tags="monetization, inappbilling, promotions"
activity is unpaused. Calling <a href= activity is unpaused. Calling <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
on startup and resume guarantees that your app will find out about all on startup and resume guarantees that your app finds out about all
purchases and redemptions the user may have made while the app wasn't purchases and redemptions the user may have made while the app wasn't
running. Furthermore, if a user makes a purchase while the app is running and running. Furthermore, if a user makes a purchase while the app is running and
your app misses it for any reason, your app will still find out about the your app misses it for any reason, your app still finds out about the
purchase the next time the activity resumes and calls <a href= purchase the next time the activity resumes and calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>. ><code>getPurchases()</code></a>.
</p> </p>
<p> <p>
In addition, your app should allow users to redeem promo codes inside the app Your app should allow users to redeem promo codes inside the app
itself. If your app supports the in-app purchase workflow (described in itself. If your app supports the in-app purchase workflow (described in
<a href= <a href=
"{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making "{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making
In-app Billing Requests</a>), your app automatically supports in-app In-app Billing requests</a>), your app automatically supports in-app
redemption of promo codes. When you launch the in-app purchase UI, redemption of promo codes. When you launch the in-app purchase UI,
the user has the option to pay for the purchase with the user has the option to pay for the purchase with
a promo code. Your activity's {@link android.app.Activity#onActivityResult a promo code. Your activity's {@link android.app.Activity#onActivityResult
@@ -141,9 +128,9 @@ meta.tags="monetization, inappbilling, promotions"
purchase was completed. However, your app should still call <a href= purchase was completed. However, your app should still call <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
on startup and resume, just in case the purchase and consumption workflow on startup and resume, in case the purchase and consumption workflow
didn't complete. For example, if the user successfully redeems a promo code, didn't complete. For example, if the user successfully redeems a promo code
and then your app crashes before the item is consumed, your app still gets and then your app crashes before the item is consumed, your app still receives
information about the purchase when the app calls <a href= information about the purchase when the app calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> on its next startup. ><code>getPurchases()</code></a> on its next startup.
@@ -160,8 +147,8 @@ meta.tags="monetization, inappbilling, promotions"
<p> <p>
To listen for the <code>PURCHASES_UPDATED</code> intent, dynamically create a To listen for the <code>PURCHASES_UPDATED</code> intent, dynamically create a
{@link android.content.BroadcastReceiver} object and register it to listen {@link android.content.BroadcastReceiver} object and register it to listen
for <code>"com.android.vending.billing.PURCHASES_UPDATED"</code>. Register for <code>com.android.vending.billing.PURCHASES_UPDATED</code>. Register
the receiver by putting code like this in your activity's {@link the receiver by inserting code similar to the following in your activity's {@link
android.app.Activity#onResume onResume()} method: android.app.Activity#onResume onResume()} method:
</p> </p>
@@ -172,36 +159,34 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p> <p>
When the user makes a purchase, the system invokes your broadcast receiver's When the user makes a purchase, the system invokes your broadcast receiver's
{@link android.content.BroadcastReceiver#onReceive onReceive()} method. That {@link android.content.BroadcastReceiver#onReceive onReceive()} method. That
method should call <a href= method must call <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
to see what purchases the user has made. to see what purchases the user has made.
</p> </p>
<p> <p>To reduce system overhead when your app
Your activity's {@link android.app.Activity#onPause onPause()} method should isn't running, your activity's {@link android.app.Activity#onPause onPause()} method must
unregister the broadcast receiver, to reduce system overhead when your app unregister the broadcast receiver:
isn't running:
</p> </p>
<pre>unRegisterReceiver(myPromoReceiver);</pre> <pre>unRegisterReceiver(myPromoReceiver);</pre>
<p class="note"> <p class="note">
<strong>Note:</strong> You should not register this broadcast receiver in the <strong>Note:</strong> Don't register this broadcast receiver in the
app manifest. Declaring the receiver in the manifest can cause the system to app manifest. Declaring the receiver in the manifest can cause the system to
launch the app to handle the intent if the user makes a purchase while the app launch the app to handle the intent if the user makes a purchase while the app
isn't running. This behavior is not necessary, and may be annoying to the isn't running. This behavior is not necessary and may be annoying to the
user. Instead, your app should call <a href= user.
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" To find out about any purchases the user made while the app wasn't running,
><code>getPurchases()</code></a> call <a href="{@docRoot}google/play/billing/billing_reference.html#getPurchases"
when the user launches it, to find out about any purchases the user made ><code>getPurchases()</code></a> when the user launches the app.
while the app wasn't running.
</p> </p>
<h2 id="testing">Testing In-app Promotions</h2> <h2 id="testing">Testing In-app Promotions</h2>
<p> <p>
If your app supports in-app promotions, you should test the following use If your app supports in-app promotions, test the following use
cases. cases.
</p> </p>
@@ -211,18 +196,18 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
If the user redeems a promo code within the app's purchase flow, as described If the user redeems a promo code within the app's purchase flow, as described
in <a href= in <a href=
"{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making "{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making
In-app Billing Requests</a>, the system invokes your activity's {@link In-app Billing requests</a>, the system invokes your activity's {@link
android.app.Activity#onActivityResult onActivityResult()} method to handle android.app.Activity#onActivityResult onActivityResult()} method to handle
the purchase. Verify that {@link android.app.Activity#onActivityResult the purchase. Verify that {@link android.app.Activity#onActivityResult
onActivityResult()} handles the purchase properly, whether the user uses cash onActivityResult()} handles the purchase properly, whether the user pays with money
or a promo code. or a promo code.
</p> </p>
<h3 id="test-playstore">User redeems promo code in the Play Store</h3> <h3 id="test-playstore">User redeems promo code in the Google Play Store</h3>
<p> <p>
If the user redeems a promo code in the Play Store, there are several If the user redeems a promo code in the Play Store, there are several
possible workflows. You should verify each one of these. possible workflows. Verify each one of these workflows.
</p> </p>
<h4 id="test-app-uninstalled">App is not installed</h4> <h4 id="test-app-uninstalled">App is not installed</h4>
@@ -231,16 +216,16 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
If the user redeems a promo code for an app that is not installed on the If the user redeems a promo code for an app that is not installed on the
device, the Play Store prompts the user to install the app. (If the app is device, the Play Store prompts the user to install the app. (If the app is
installed but not up-to-date, the Play Store prompts the user to update the installed but not up-to-date, the Play Store prompts the user to update the
app.) You should test the following sequence on a device that does not app.) Test the following sequence on a device that doesn't
have your app installed. have your app installed.
</p> </p>
<ol> <ol>
<li>User redeems a promo code for the app in the Play Store. The Play Store <li>The user redeems a promo code for the app in the Play Store. The Play Store
prompts the user to install your app. prompts the user to install your app.
</li> </li>
<li>User installs and launches your app. Verify that on startup, the app <li>The user installs and launches your app. Verify that on startup, the app
calls <a href= calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
@@ -252,16 +237,16 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p> <p>
If the user redeems a promo code for an app that is installed on the device, If the user redeems a promo code for an app that is installed on the device,
the Play Store prompts the user to switch to the app. You should test the the Play Store prompts the user to switch to the app. Test the
following sequence on a device that has your app installed but not running: following sequence on a device that has your app installed but not running:
</p> </p>
<ol> <ol>
<li>User redeems a promo code for the app in the Play Store. The Play Store <li>The user redeems a promo code for the app in the Play Store. The Play Store
prompts the user to switch to your app. prompts the user to switch to your app.
</li> </li>
<li>User launches your app. Verify that on startup, the app calls <a href= <li>The user launches your app. Verify that on startup the app calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> ><code>getPurchases()</code></a>
and correctly detects the purchase the user made with the promo code. and correctly detects the purchase the user made with the promo code.
@@ -274,15 +259,15 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p> <p>
If the user redeems a promo code for an app that is currently running on the If the user redeems a promo code for an app that is currently running on the
device, the Play Store notifies the app via a <code>PURCHASES_UPDATED</code> device, the Play Store notifies the app via a <code>PURCHASES_UPDATED</code>
intent. You should test the following sequence: intent. Test the following sequence:
</p> </p>
<ol> <ol>
<li>User launches the app. Verify that the app has properly registered itself to <li>The user launches the app. Verify that the app has properly registered itself to
receive the <code>PURCHASES_UPDATED</code> intent. receive the <code>PURCHASES_UPDATED</code> intent.
</li> </li>
<li>User launches the Play Store app and redeems a promo code for the app. The Play <li>The user launches the Play Store app and redeems a promo code for the app. The Play
Store fires a <code>PURCHASES_UPDATED</code> intent. Verify that your app's Store fires a <code>PURCHASES_UPDATED</code> intent. Verify that your app's
{@link android.content.BroadcastReceiver#onReceive {@link android.content.BroadcastReceiver#onReceive
BroadcastReceiver.onReceive()} callback fires to handle the intent. BroadcastReceiver.onReceive()} callback fires to handle the intent.
@@ -291,11 +276,11 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<li>Your {@link android.content.BroadcastReceiver#onReceive onReceive()} <li>Your {@link android.content.BroadcastReceiver#onReceive onReceive()}
method should respond to the intent by calling <a href= method should respond to the intent by calling <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases" "{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>. Verify that it calls this method, and that ><code>getPurchases()</code></a>. Verify that your app calls this method and that
it correctly detects the purchase the user made with the promo code. it correctly detects the purchase the user made with the promo code.
</li> </li>
<li>User switches back to your app. Verify that the user has the purchased <li>The user switches back to your app. Verify that the user has the purchased
item. item.
</li> </li>
</ol> </ol>

159
docs/html/training/in-app-billing/preparing-iab-app.jd Executable file → Normal file
View File

@@ -31,23 +31,32 @@ next.link=list-iab-products.html
</div> </div>
<a class="notice-developers-video wide" <a class="notice-developers-video wide"
href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o"> href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o" class="external-link">
<div> <div>
<h3>Video</h3> <h3>Video</h3>
<p>Implementing Freemium</p> <p>Implementing Freemium</p>
</div> </div>
</a> </a>
<p>Before you can start using the In-app Billing service, you'll need to add the library that contains the In-app Billing Version 3 API to your Android project. You also need to set the permissions for your application to communicate with Google Play. In addition, you'll need to establish a connection between your application and Google Play. You should also verify that the In-app Billing API version that you are using in your application is supported by Google Play.</p> <p>Before you can start using the In-app Billing service, you need to add the library that
contains the In-app Billing Version 3 API to your Android project. You also need to set the
permissions for your application to communicate with Google Play. In addition, you need to
establish a connection between your application and Google Play. You must also verify that
the In-app Billing API version that you are using in your application is supported
by Google Play.</p>
<h2 id="GetSample">Download the Sample Application</h2> <h2 id="GetSample">Download the Sample Application</h2>
<p>In this training class, you will use a reference implementation for the In-app Billing Version 3 API called the {@code TrivialDrive} sample application. The sample includes convenience classes to quickly set up the In-app Billing service, marshal and unmarshal data types, and handle In-app Billing requests from the main thread of your application.</p> <p>In this training class, you use a reference implementation for the In-app Billing
<p>To download the sample application:</p> Version 3 API
called the {@code TrivialDrive} sample application. The sample includes convenience classes to
quickly set up the In-app Billing service, marshal and unmarshal data types, and handle In-app
Billing requests from the main thread of your application.</p>
<p>To download the sample application, follow these steps:</p>
<ol> <ol>
<li>Open Android Studio and then close any open projects until you are <li>Open Android Studio and then close any open projects until you are
presented with the welcome screen.</li> presented with the welcome screen.</li>
<li>Choose <strong>Import an Android code sample</strong> from the <li>From the <strong>Quick Start</strong> list on the right side of the window, choose
<strong>Quick Start</strong> list on the right side the window.</li> <strong>Import an Android code sample</strong>.</li>
<li>Type {@code Trivial Drive} into the search bar and select the <li>Type {@code Trivial Drive} into the search bar and select the
<strong>Trivial Drive</strong> sample.</li> <strong>Trivial Drive</strong> sample.</li>
<li>Follow the rest of the instructions in the <strong>Import Sample</strong> <li>Follow the rest of the instructions in the <strong>Import Sample</strong>
@@ -56,66 +65,121 @@ presented with the welcome screen.</li>
</ol> </ol>
<p>Alternatively, you can use {@code git} to manually clone <p>Alternatively, you can use {@code git} to manually clone
the repository from <a the repository from the <a
href="https://github.com/googlesamples/android-play-billing" href="https://github.com/googlesamples/android-play-billing"
class="external-link">https://github.com/googlesamples/android-play-billing</a></p> class="external-link">Google Samples</a> GitHub site.</p>
<h2 id="AddToDevConsole">Add Your Application to the Developer Console</h2> <h2 id="AddToDevConsole">Add Your Application to the Developer Console</h2>
<p>The Google Play Developer Console is where you publish your In-app Billing application and manage the various digital goods that are available for purchase from your application. When you create a new application entry in the Developer Console, it automatically generates a public license key for your application. You will need this key to establish a trusted connection from your application to the Google Play servers. You only need to generate this key once per application, and don’t need to repeat these steps when you update the APK file for your application.</p> <p>The Google Play Developer Console is where you publish your In-app Billing application
<p>To add your application to the Developer Console:</p> and manage the various digital products that are available for purchase from your
application.
When you create a new application entry in the Developer Console, it automatically generates
a public license key for your application. You need this key to establish a trusted connection
from your application to the Google Play servers. You need to generate this key only once
per application, and you don’t need to repeat these steps when you update the APK file for
your application.</p>
<p>To add your application to the Developer Console, follow these steps:</p>
<ol> <ol>
<li>Go to the <a href="http://play.google.com/apps/publish">Google Play Developer Console</a> site and log in. You will need to register for a new developer account, if you have not registered previously. To sell in-app items, you also need to have a <a href="http://www.google.com/wallet/merchants.html">Google payments</a> merchant account.</li> <li>Go to the <a href="http://play.google.com/apps/publish" class="external-link">
<li>Click on <strong>Try the new design</strong> to access the preview version of the Developer Console, if you are not already logged on to that version. </li> Google Play Developer Console</a>
<li>In the <strong>All Applications</strong> tab, add a new application entry. site and log in. If you have not registered previously, you need to register for a new
developer account. To sell in-app products, you also need a
<a href="http://www.google.com/wallet/merchants.html" class="external-link">
Google payments</a> merchant account.</li>
<li>In the <strong>All Applications</strong> tab, complete these steps to add a new
application entry:
<ol type="a"> <ol type="a">
<li>Click <strong>Add new application</strong>.</li> <li>Click <strong>Add new application</strong>.</li>
<li>Enter a name for your new In-app Billing application.</li> <li>Enter a name for your new In-app Billing application.</li>
<li>Click <strong>Prepare Store Listing</strong>.</li> <li>Click <strong>Prepare Store Listing</strong>.</li>
</ol> </ol>
</li> </li>
<li>In the <strong>Services & APIs</strong> 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 later.</li> <li>In the <strong>Services & APIs</strong> 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 need to
include in your application code later.</li>
</ol> </ol>
<p>Your application should now appear in the list of applications in Developer Console.</p> <p>Your application should now appear in the list of applications in Developer Console.</p>
<h2 id="AddLibrary">Add the In-app Billing Library</h2> <h2 id="AddLibrary">Add the In-app Billing Library</h2>
<p>To use the In-app Billing Version 3 features, you must add the {@code IInAppBillingService.aidl} file to your Android project. This Android Interface Definition Language (AIDL) file defines the interface to the Google Play service.</p> <p>To use the In-app Billing Version 3 features, you must add the
<p>You can find the {@code IInAppBillingService.aidl} file in the provided sample app. Depending on whether you are creating a new application or modifying an existing application, follow the instructions below to add the In-app Billing Library to your project.</p> {@code IInAppBillingService.aidl}
<h3>New Project</h3> file to your Android project. This Android Interface Definition Language
<p>To add the In-app Billing Version 3 library to your new In-app Billing project:</p> (AIDL) file defines the
interface to the Google Play service.</p>
<p>You can find the {@code IInAppBillingService.aidl} file in the provided sample app.
To add the
In-app Billing library to your project, follow the instructions below for a new or
existing project.</p>
<h3>Adding in-app billing to a new project</h3>
<p>To add the In-app Billing Version 3 library to a new project, follow these steps:</p>
<ol> <ol>
<li>Copy the {@code TrivialDrive} sample files into your Android project.</li> <li>Copy the {@code TrivialDrive} sample files into your Android project.</li>
<li>Modify the package name in the files you copied to use the package name for your project. In Android Studio, you can use this shortcut: right-click the package name, then select <strong>Refactor</strong> > <strong>Rename</strong>.</li> <li>Modify the package name in the files that you copied to use the package name
<li>Open the {@code AndroidManifest.xml} file and update the package attribute value to use the package name for your project.</li> for your project.
<li>Fix import statements as needed so that your project compiles correctly. In Android Studio, you can use this shortcut: press <strong>Ctrl+Shift+O</strong> in each file showing errors.</li> In Android Studio, you can right-click the package name and then
<li>Modify the sample to create your own application. Remember to copy the Base64 public license key for your application from the Developer Console over to your {@code MainActivity.java}.</li> select <strong>Refactor</strong> > <strong>Rename</strong>.</li>
<li>Open the {@code AndroidManifest.xml} file and update the package attribute value to
use the package name for your project.</li>
<li>Fix import statements as needed so that your project compiles correctly.
In Android Studio, you can press <strong>Ctrl+Shift+O</strong>
in each file showing errors.</li>
<li>Modify the sample to create your own application. Remember to copy the Base64
public license key for your application from the Developer Console to
your {@code MainActivity.java}.</li>
</ol> </ol>
<h3>Existing Project</h3> <h3>Adding in-app billing to an existing project</h3>
<p>To add the In-app Billing Version 3 library to your existing In-app Billing project:</p> <p>To add the In-app Billing Version 3 library to an existing project, follow these steps:</p>
<ol> <ol>
<li>Copy the {@code IInAppBillingService.aidl} file to your Android project. <li>Copy the {@code IInAppBillingService.aidl} file to your Android project.
<ul> <ul>
<li>In Android Studio: Create a directory named {@code aidl} under {@code src/main}, add a new <li>In Android Studio: Create a directory named {@code aidl} under {@code src/main},
package {@code com.android.vending.billing} in this directory, and import the add a new
package {@code com.android.vending.billing} in this directory, and then import the
{@code IInAppBillingService.aidl} file into this package.</li> {@code IInAppBillingService.aidl} file into this package.</li>
<li>In other dev environments: Create the following directory {@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl} file into this directory.</li> <li>In other dev environments: Create the following directory
{@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl}
file into this directory.</li>
</ul> </ul>
</li> </li>
<li>Build your application. You should see a generated file named {@code IInAppBillingService.java} in the {@code /gen} directory of your project.</li> <li>Build your application. You should see a generated file named
<li>Add the helper classes from the {@code /util} directory of the {@code TrivialDrive} sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly.</li> {@code IInAppBillingService.java}
in the {@code /gen} directory of your project.</li>
<li>Add the helper classes from the {@code /util} directory of the {@code TrivialDrive}
sample to
your project. Remember to change the package name declarations in those files
accordingly so
that your project compiles correctly.</li>
</ol> </ol>
<p>Your project should now contain the In-app Billing Version 3 library.</p> <p>Your project should now contain the In-app Billing Version 3 library.</p>
<h2 id="SetPermission">Set the Billing Permission</h2> <h2 id="SetPermission">Set the Billing Permission</h2>
<p>Your app needs to have permission to communicate request and response messages to the Google Play’s billing service. To give your app the necessary permission, add this line in your {@code AndroidManifest.xml} manifest file:</p> <p>Your app needs to have permission to communicate request and response messages to
the Google Play billing service. To give your app the necessary permission, add the following
line in your {@code AndroidManifest.xml} manifest file:</p>
<pre> <pre>
&lt;uses-permission android:name="com.android.vending.BILLING" /&gt; &lt;uses-permission android:name="com.android.vending.BILLING" /&gt;
</pre> </pre>
<h2 id="Connect">Initiate a Connection with Google Play</h2> <h2 id="Connect">Initiate a Connection with Google Play</h2>
<p>You must bind your Activity to Google Play’s In-app Billing service to send In-app Billing requests to Google Play from your application. The convenience classes provided in the sample handles the binding to the In-app Billing service, so you don’t have to manage the network connection directly.</p> <p>To send In-app
<p>To set up synchronous communication with Google Play, create an {@code IabHelper} instance in your activity's {@code onCreate} method. In the constructor, pass in the {@code Context} for the activity, along with a string containing the public license key that was generated earlier by the Google Play Developer Console. </p> Billing requests to Google Play from your application, you must bind your Activity
<p class="note"><strong>Security Recommendation:</strong> It is highly recommended that you do not hard-code the exact public license key string value as provided by Google Play. Instead, you can construct the whole public license key string at runtime from substrings, or retrieve it from an encrypted store, before passing it to the constructor. This approach makes it more difficult for malicious third-parties to modify the public license key string in your APK file.</p> to the Google Play In-app Billing service. The sample includes convenience classes
that handle the binding to the In-app Billing service, so you don’t have to
manage the network connection directly.</p>
<p>To set up synchronous communication with Google Play, create an {@code IabHelper}
instance in your activity's {@code onCreate} method, as shown in the following example.
In the constructor, pass in the {@code Context} for the activity along with a string
containing the public license key that was generated earlier by the Google Play
Developer Console.
</p>
<p class="caution"><strong>Security Recommendation:</strong> Google highly recommends that
you do not hard-code the exact public license key string value as provided by Google Play.
Instead, construct the whole public license key string at runtime from substrings
or retrieve it from an encrypted store before passing it to the constructor.
This approach makes it more difficult for malicious third parties to modify the public
license key string in your APK file.</p>
<pre> <pre>
IabHelper mHelper; IabHelper mHelper;
@@ -130,13 +194,20 @@ public void onCreate(Bundle savedInstanceState) {
} }
</pre> </pre>
<p>Next, perform the service binding by calling the {@code startSetup} method on the {@code IabHelper} instance that you created. Pass the method an {@code OnIabSetupFinishedListener} instance, which is called once the {@code IabHelper} completes the asynchronous setup operation. As part of the setup process, the {@code IabHelper} also checks if the In-app Billing Version 3 API is supported by Google Play. If the API version is not supported, or if an error occured while establishing the service binding, the listener is notified and passed an {@code IabResult} object with the error message.</p> <p>Next, perform the service binding by calling the {@code startSetup} method on the
{@code IabHelper} instance that you created, as shown in the following example.
Pass the method an {@code OnIabSetupFinishedListener} instance, which is called once
the {@code IabHelper} completes the asynchronous setup operation. As part of the
setup process, the {@code IabHelper} also checks if the In-app Billing Version 3 API
is supported by Google Play. If the API version is not supported, or if an error occurs
while establishing the service binding, the listener is notified and passed an
{@code IabResult} object with the error message.</p>
<pre> <pre>
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) { public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) { if (!result.isSuccess()) {
// Oh noes, there was a problem. // Oh no, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result); Log.d(TAG, "Problem setting up In-app Billing: " + result);
} }
// Hooray, IAB is fully set up! // Hooray, IAB is fully set up!
@@ -144,9 +215,18 @@ mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
}); });
</pre> </pre>
<p>If the setup completed successfully, you can now use the {@code mHelper} reference to communicate with the Google Play service. When your application is launched, it is a good practice to query Google Play to find out what in-app items are owned by a user. This is covered further in the <a href="{@docRoot}training/in-app-billing/purchase-iab-products.html#QueryPurchases">Query Purchased Items</a> section.</p> <p>If the setup completed successfully, you can now use the {@code mHelper} reference
to communicate with the Google Play service. When your application is launched, it is
a good practice to query Google Play to find out what in-app items are owned by a user.
This is covered further in the
<a href="{@docRoot}training/in-app-billing/purchase-iab-products.html#QueryPurchases">
Query Purchased Items</a> section.</p>
<p class="note"><strong>Important:</strong> Remember to unbind from the In-app Billing service when you are done with your activity. If you don’t unbind, the open service connection could cause your device’s performance to degrade. To unbind and free your system resources, call the {@code IabHelper}'s {@code dispose} method when your {@code Activity} is destroyed.</p> <p class="caution"><strong>Important:</strong> Remember to unbind from the In-app Billing service
when you are done with your activity. If you don’t unbind, the open service connection could
degrade device performance. To unbind and free your system resources, call the
{@code IabHelper}'s {@code dispose} method when your {@code Activity} is destroyed,
as shown in the following example.</p>
<pre> <pre>
&#64;Override &#64;Override
@@ -156,8 +236,3 @@ public void onDestroy() {
mHelper = null; mHelper = null;
} }
</pre> </pre>