Skip to content

Most visited

Recently visited

navigation

Administering In-app Billing

In-app billing frees you from processing financial transactions, but you still need to perform a few administrative tasks. These tasks include the following:

To register a test account, you must have a Google Play publisher account. If you already have a publisher account on Google Play, you can use your existing account. You do not need to register for a new account to support in-app billing. If you don't have a publisher account, you can register as a Google Play developer and set up a publisher account through the Google Play Developer Console.

If you want to create a product list and issue refunds to your users, you must have a Google payments merchant account. If you don't have a merchant account, you can register for one through the Developer Console.

Creating a Product List

The Google Play Developer Console provides a product list for each of your published apps. You can sell an item using Google Play's in-app billing feature only if the item is listed on an app's product list. Each app has its own product list; you cannot sell items that appear on another app's product list.

You can access an app's product list by opening the In-app Products page for an app that is listed in your developer account. The link to the In-app Products page appears only if you have a Google payments merchant account and the app's manifest includes the com.android.vending.BILLING permission. For more information about this permission, see Updating Your App's Manifest.

A product list specifies items you are selling in an app: in-app products, subscriptions, or a combination of both. For each item, the product list contains information such as product ID, product description, and price. You can create a product list for any published app, including apps published to the alpha and beta channels.

The product list stores only metadata about the items you are selling in your app. It does not store any digital content. You are responsible for storing and delivering the digital content that you sell in your apps.

Note: Previously, you could test an app by uploading an unpublished draft version. This functionality is no longer supported; instead, you must publish it to the alpha or beta distribution channel. For more information, see Draft Apps are No Longer Supported.

In addition, an app package can have only one product list. If you create a product list for an app, and you use the multiple APK feature to distribute more than one APK for that app, the product list applies to all APK versions that are associated with the app listing. You cannot create individual product lists for each APK if you are using the multiple APK feature.

You can add items to a product list two ways: you can add items one at a time on the In-app Products page, or you can add a batch of items by importing the items from a comma-separated values (CSV) file. Adding items one at a time is useful if your app has only a few in-app items or you are adding only a few items to a product list for testing purposes. The CSV file method is useful if your app has a large number of in-app items.

Note: Batch upload of product lists containing subscriptions is not supported. Also, when updating existing items in a batch upload, you cannot include changes to in-app products that are linked to a pricing template.

Adding items one at a time to a product list

To add an item to a product list using the Developer Console UI, follow these steps:

  1. Log in to your publisher account.
  2. In the All applications panel, click on the app name, then open the In-app Products page.
  3. Click Add new product. After you provide the product type and ID for the item you are selling, click Continue.

    Product Type

    The product type can be "Managed product" or "Subscription." You cannot change an item's product type after you create the item. For more information, see Choosing a Product Type.

    Note: For subscription items, you cannot change the item's price once you have published the item.

    Product ID

    Product IDs are unique across an app's namespace. A product ID must start with a lowercase letter or a number and must be composed of only lowercase letters (a-z), numbers (0-9), underscores (_), and periods (.). The product ID android.test is reserved, as are all product IDs that start with android.test.

    Note: Be sure to plan your product ID namespace carefully. You cannot modify an item's product ID after the item is created, and you cannot reuse a product ID within an app.

  4. Enter additional information about the item, then click Save.

    Publishing State

    An item's publishing state can be Active or Inactive. To be visible to a user during checkout, an item's publishing state must be set to Active, and the item's app must be published on Google Play.

    Note: If you're using a test account, users can see active items within unpublished apps, as well. For more information, see Testing In-app Billing.

    Languages and Translations

    By default, in-app products inherit their default language from the parent app.

    You can provide localized titles and descriptions for your in-app products by selecting Add Translations. If you want Google Play to translate your title and description for you, based on the title and description in the default language, just choose the languages that you want to offer. You can also provide custom translations in specific languages.

    Title
    The title is a short descriptor for the item. An example of a title is: "Sleeping potion." Every item must have a title. The title is visible to users during checkout. For optimum appearance, titles should be no longer than 25 characters; however, titles can be up to 55 characters in length.
    Description
    The description is a long descriptor for the item. An example of a description is: "Instantly puts creatures to sleep. Does not work on angry elves." Every item must have a description. Descriptions can be up to 80 characters in length.
    Price

    Provide a price in your home currency, or link the price to an existing pricing template. Based on the price you enter or the prices from the pricing template, the system autofills country-specific prices for different currencies. These generated prices use current exchange rates and locally relevant pricing patterns (see figure 1).

    You can also change prices for other currencies manually, but you can do this only if a currency is used in one of the target countries for your app. You can specify target countries for your app on the Pricing & Distribution page in the Google Play Developer Console.

An item that costs 1.99 in USD usually costs a different
  amount in AUD, EUR, or BOB. Some countries also add tax to the price.
Figure 1. Specifying additional currencies for an in-app product.

Adding a batch of items to a product list

To add a batch of items to a product list using a CSV file, you first need to create your CSV file. The data values that you specify in the CSV file represent the options that you set when adding in-app products to a product list using the Google Play Developer Console UI. For more information about using this UI, see Adding items one at a time to a product list.

Note: Batch upload of in-app product lists containing subscriptions is not supported. Also, when updating existing items in a batch upload, you cannot include changes to in-app products that are linked to a pricing template.

To import the in-app products that are specified in your CSV file, do the following:

  1. Log in to your publisher account.
  2. In the All applications panel, select the app name, then open the In-app Products page.
  3. On the In-app Products page, click Import/Export > Import in-app products from CSV file to open the Import In-app Products dialog.

  4. If you want to overwrite existing in-app products in your product list during the import process, select the Overwrite existing products checkbox.

    This option overwrites values of existing items only if the value of the Product ID in the CSV file matches the in-app product ID for an existing in-app product in the product list. The overwriting process doesn't delete in-app products that exist in a product list but aren't included in the CSV file

    Note: If you choose not to overwrite existing items, the Product ID given to each item in the CSV file must be different from any of the Product ID values assigned to existing in-app products.

  5. Select Browse files, then choose the CSV file that contains the items you want to import. The CSV file must be stored locally.

You can also export an existing product list to a CSV file by clicking Import/Export > Export in-app products to CSV file on the In-app Products page. This is useful if you have used the UI to add in-app products to your app but you want to start managing the product list through a CSV file instead.

Formatting batches of items

The CSV file uses commas (,) and semicolons (;) to separate data values. Commas are used to separate primary data values, and semicolons are used to separate subvalues. Each item must appear entirely on a single line within the CSV file.

When creating a CSV file that represents a list of items, you must specify the CSV syntax on the first row, followed by the items themselves on subsequent rows, as shown in the following example:

Product ID,Published State,Purchase Type,Auto Translate,Locale; Title; Description,Auto Fill Prices,Price,Pricing Template ID
basic_sleeping_potion,published,managed_by_android,false,en_US; Basic Sleeping Potion; Puts small creatures to sleep.; es_ES; Poción básica de dormir; Causa las criaturas pequeñas ir a dormir.,false,,4637138456024710495
standard_sleeping_potion,published,managed_by_android,false,en_US; Standard Sleeping Potion; Puts all creatures to sleep for 2 minutes.,true, 1990000,
invisibility_potion,published,managed_by_android,false,en_US; Invisibility Potion; Invisible to all enemies for 5 minutes.,false, US; 1990000; BR; 6990000; RU; 129000000; IN; 130000000; ID; 27000000000; MX; 37000000;

This example contains details for three items, each of which represents an in-app product:

Each row in a CSV file can contain the following values, though at least one of these values is undefined in each row:

Product ID

Setting this value in the CSV file has the same effect as entering a Product ID when creating a new in-app product.

If you specify a Product ID assigned to an in-app product that already exists in a product list, and you've checked the Overwrite existing products checkbox in the Import In-app Products dialog, the data for the existing in-app product is overwritten with the values that you specify in the CSV file.

Publish State

This value must be set to published or unpublished.

Setting this value to published has the same effect as navigating to an item's Managed Product Details page and choosing Active in the drop-down list next to the in-app product's title and product ID. Setting the value to unpublished has the same effect as choosing Inactive in the same drop-down list.

Purchase Type

This value must be set to managed_by_android because batch upload of product lists containing subscriptions is not supported.

Setting this value to managed_by_android has the same effect as selecting Managed product in the Add New Product dialog when creating an in-app product.

Auto Translate

This value must be set to false because auto-translation of in-app product details isn't supported.

If you want to provide translations of an in-app product's title and description, you need to specify these translations explicitly within the Locale value.

Locale, Title, and Description

If you include only one locale for an item, you must specify your app's default locale and the item's default title and description:

app_default_locale; item_default_title; item_default_description;

Setting these values has the same effect as performing the following sequence of actions:

  1. Choosing a default language when you add a new app to your publisher account.
  2. Navigating to an in-app product's Managed Product Details page.
  3. Specifying the in-app product's default title and description.

When setting the Locale value, you can use any of the language codes that appear within the Add Your Own Translations dialog. You can access this dialog by navigating to an in-app product's Managed Product Details page and clicking Add translations or Manage translations.

Note: When specifying the Title and Description values, use backslashes to escape the semicolon (\;) and backslash (\\) characters.

If you want to include translated versions of the item's title and description, you must list the default locale, title, and description, followed by the locales, titles, and descriptions for each translation. In the following example, the in-app product uses en_US (United States English) as the default locale and es_ES (Spain Spanish) as a translation:

en_US; Invisibility Cloak; Makes you invisible.; es_ES; Capote Invisible; Se vuelven invisible.

Note: An app contains a single default language, but each in-app product maintains its own list of translations. Therefore, although the first locale in each item's Locale value must be the same throughout the CSV file, the other locales can differ from one item to another.

Providing values for multiple translations has the same effect as performing the following sequence of actions:

  1. Navigating to an in-app product's Managed Product Details page.
  2. Clicking Add translations.
  3. Selecting the languages for the translations and clicking Add.
  4. Choosing one of the languages you added in the previous step.
  5. Specifying a new title and description, which serve as translations into the selected language.
  6. Repeating steps 4 and 5 to add translations into all other non-default languages.
Auto Fill Prices, Country, and Price

You can set Auto Fill Prices to true or false. If an in-app product uses a pricing template, you should set Auto Fill Prices to false, and you shouldn't set a value for the Price.

Note: When you specify an item's price in a CSV file, you provide a price in micro-units, where 1,000,000 micro-units is equivalent to 1 unit of real currency.

The following sections describe how the value of Auto Fill Prices affects the syntax and meaning of the Country and Price values.

Using auto-filled prices

If you set Auto Fill Prices to true, you specify only the item's default price; you don't include a Country value. Setting Auto Fill Prices to true has the same effect as performing the following sequence of actions:

  1. Navigating to an in-app product's Managed Product Details page.
  2. Selecting Edit in the Price section.
  3. Entering a default, tax-exclusive price. Auto-filled prices include tax.
  4. Clicking the checkbox next to COUNTRY in the Edit Local Prices dialog that appears.
  5. Selecting Refresh exchange rates.
  6. Selecting Apply.

For example, under the following conditions:

  • Your app's default locale is en_US.
  • An in-app product's default, tax-exclusive price is $1.99.
  • You want the prices for other countries auto-filled.

...you'd set the values of Auto Fill Prices and Price at the end of a row in the CSV file as follows:

true,1990000,
Not using auto-filled prices

If you set Auto Fill Prices to false instead, you specify a series of Country and Price values for all countries where you distribute your app, including the country corresponding to your app's default locale. Each Country value is the two-letter uppercase ISO country code that represents a country where your app is distributed.

Note: You must provide a country code and price for each country that your app is targeting. To view and edit the list of countries that your app targets, open your app's Pricing & Distribution page.

Each Price value represents the cost of the item in micro-units of the currency used in that country. Setting Auto Fill Prices to false has the same effect as performing the following sequence of actions:

  1. Navigating to an in-app product's Managed Product Details page.
  2. Selecting Edit in the Price section.
  3. Explicitly setting tax-inclusive prices for different countries in the Edit Local Prices dialog that appears.
  4. Selecting Apply.

For example, if you're offering your app for the following prices (all taxes included) in other countries:

  • R$6.99 in Brazil.
  • 129 ₽ in Russia.
  • ₹130 in India.
  • Rp 27,000 in Indonesia.
  • $37 in Mexico.

...you'd set the values of Auto Fill Prices, Country, and Price at the end of a row in the CSV file as follows:

false, BR; 6990000; RU; 129000000; IN; 130000000; ID; 27000000000; MX; 37000000;
Pricing Template ID

If an item is linked to a pricing template, you should set Auto Fill Prices to false, and you shouldn't set a value for the Price column. If the item isn't linked to a pricing template, you shouldn't set a value for the Pricing Template ID; instead, you should set Auto Fill Prices, Country, and Price based on how you want to set the in-app product's prices.

Setting this value has the same effect as navigating to an in-app product's Managed Product Details page and linking the product's price to the pricing template that has the same pricing template ID as the one specified in the CSV file. This pricing template ID appears underneath a pricing template's name on the Pricing template page.

If you import a CSV file, and you've checked the Overwrite existing products checkbox in the Import In-app Products dialog, you can update the links between in-app products and pricing templates. To link the product to a specific pricing template, set the Pricing Template ID value to that pricing template's ID. To unlink an in-app product from all pricing templates, don't set a value for its Pricing Template ID.

You can link up to 100 app prices or in-app product prices to a particular pricing template. Therefore, don't specify the same Pricing Template ID value in more than 100 rows of a CSV file.

Pricing Templates

If you sell multiple apps at the same price, or if you sell multiple in-app products at the same price across one or more apps, you can add pricing templates. These templates make it easier to manage shared prices.

Adding a pricing template

When creating a pricing template, you provide new pricing information that you can apply to paid apps and in-app products. You can link the prices of up to 100 apps and in-app products to a single pricing template.

To add a pricing template, do the following:

  1. Log in to your publisher account.
  2. In the Settings panel, open the Pricing template page.
  3. If you are adding your first pricing template, the Add a Pricing Template banner appears. Select Add template to create a new template. The new template's Pricing tab appears.

    Otherwise, you see a list of your pricing templates. Select New pricing template. The new template's Pricing tab appears.

  4. Provide details about the template. These details include the name, the price, and whether to include tax as part of your country-specific prices.

    Based on the price and tax option you provide, the Developer Console generates prices for international currencies using current exchange rates and country-specific pricing patterns.

  5. Select Create template to finish adding the template.

You can create links between pricing templates and sets of paid apps and in-app products that share the same price. After completing this linking process, any changes you make to the pricing template are applied to the prices of items that you've linked to the template. To complete the linking process, use either the pricing template's Linked Items tab or the Price section within a paid app or in-app product's pricing page.

Note: Since a subscription within your app has a constant price, you cannot link a subscription with a pricing template. You can, however, import the prices from a pricing template and apply them to a new subscription.

Linking a pricing template to in-app products and paid apps

To link a pricing template to an in-app product, do the following:

  1. Log in to your publisher account.
  2. In the Settings panel, open the Pricing template page. This page shows the list of pricing templates you have created for your account.
  3. Choose an existing pricing template that you want to link to an in-app product, then select the template's Linked Items tab. This tab shows options to link your pricing template to in-app products and paid apps (see figure 2).
  4. In the Link In-App Products section of the tab, enter or choose the name of an app. This app should contain the in-app product that you want to link to your pricing template.
  5. Based on the app that you selected, you see a list of in-app products that are active and are not yet linked to a pricing template. Choose the in-app product that you want to link to the pricing template by selecting the Link button that appears in the same row as the in-app product.
  6. The price of the in-app product is now linked to your pricing template. Any changes you make to the prices within your pricing template affect the prices of the linked in-app product.

To link a pricing template to the price of a paid app, you follow a similar process. On the pricing template's Linked Items tab, choose a paid app in the Link Paid Apps section.

The Sleeping Potion in-app product is linked to the Basic Inventory item,
  but the Invisibility Potion is not.
Figure 2. On a pricing template's Linked Items tab, you can change which in-app products and paid apps are linked to the pricing template.

Linking an in-app product or paid app to a pricing template

To link an in-app product to a pricing template, do the following:

  1. Log in to your publisher account.
  2. In the All applications panel, select the app name, then open the In-app Products page.
  3. Choose the in-app product that you want to link to a pricing template. The item's details page appears.
  4. In the Pricing section, choose the pricing template that you want to link to the price of this in-app product.
  5. The price of the in-app product is now linked to the pricing template you selected. Any changes you make to the prices within your pricing template affect the prices of this in-app product.

To link the price of a paid app to a pricing template, you follow a similar process on the app's Pricing & Distribution page.

Deleting an item that is linked to a pricing template

As your app evolves, you may find it useful to remove older versions of in-app products or unpublish paid apps, some of which may be linked to pricing templates. To delete an in-app product or unpublish a paid app that is linked to a pricing template, complete the following steps. You don't need to unlink the in-app product or paid app from the pricing template beforehand.

Deleting an in-app product that is linked to a template

To delete an in-app product that is linked to a template, do the following:

  1. Log in to your publisher account.
  2. Select the app that contains the in-app product you want to delete.
  3. Open the app's In-app Products page.
  4. Choose the in-app product that you want to delete.
  5. Select the button that indicates whether the in-app product is active or inactive (enclosed in a box within figure 3). The drop-down menu includes a Delete option.
  6. Select Delete, then choose Yes in the confirmation dialog that appears.
Figure 3. Deleting an in-app product that is linked to a pricing template.

Unpublishing a paid app that is linked to a template

Figure 4. Unpublishing an app that has already been published and is linked to a pricing template.

To unpublish a paid app that is already published and is linked to a template, do the following:

  1. Log in to your publisher account.
  2. Select the app that you want to unpublish.
  3. Select Unpublish app (enclosed in a box within figure 4), then choose Unpublish in the confirmation dialog that appears.

Deleting a pricing template

If you no longer need a pricing template, you can delete it by completing the following steps:

  1. Log in to your publisher account.
  2. In the Settings panel, open the Pricing template page, which shows the list of pricing templates you have created for your account.
  3. Select the pricing template that you wish to delete.
  4. On the pricing template's Linked Items tab, unlink all in-app products that are linked to the template.
  5. Select Delete template.

Choosing a Product Type

An item's product type controls how Google Play manages the purchase of the item. The supported product types include "managed product" and "subscription." Since support for different product types can vary among versions of the In-app Billing API, make sure that you choose a product type that's valid for the version of the In-app Billing API that your app uses.

For details, refer to the documentation for the In-app Billing API.

Handling Refunds

In-app billing does not allow users to send a refund request to Google Play. Refunds for in-app purchases must be directed to you (the app developer). You can then process the refund through your Google payments merchant account. When you do this, Google Play receives a refund notification from Google payments, and Google Play sends a refund message to your app. For more information, see Handling IN_APP_NOTIFY messages and In-app Billing Pricing.

Important: You cannot use the API to issue refunds or cancel In-app Billing transactions. You must do this manually through your Google payments merchant account. However, you can use the API to retrieve order information.

Working with Order Numbers

When a user purchases an in-app item, Google assigns the transaction a unique and permanent order number. Google Play provides that order number to you at the conclusion of the purchase flow, as the value of the orderId field of the PURCHASE_STATE_CHANGED intent.

Note: When a user completes a test purchase, the orderId field remains blank. To track test transactions, use the purchaseToken field instead. For more information about working with test purchases, see Testing In-app Billing.

In your app, you can use the order number as a general-purpose identifier for the in-app purchase transaction. After the purchase, you can use the order number as a means of tracking the transaction in reconciliation reports and for customer support.

The order number itself is a string consisting of numbers only, with a format assigned and managed by Google.

For transactions dated 5 December 2012 or later, Google payments assigns a Merchant Order Number (rather than a Google Order Number) and reports the Merchant Order Number as the value of orderID. Here's an example:

"orderId" : "GPA.1234-5678-9012-34567"

For transactions dated previous to 5 December 2012, Google checkout assigned a Google Order Number and reported that number as the value of orderID. Here's an example of an orderID holding a Google Order Number:

"orderId" : "556515565155651"

Setting Up Test Accounts

The Google Play Developer Console lets you set up one or more test accounts. A test account is a regular Google account that you register on the Developer Console as a test account. Test accounts are authorized to make in-app purchases from apps that you have uploaded to the Google Play Developer Console but have not yet published.

You can use any Google account as a test account. Test accounts are useful if you want to let multiple people test In-app Billing on apps without giving them access to your publisher account's sign-in credentials. If you want to own and control the test accounts, you can create the accounts yourself and distribute the credentials to your developers or testers.

Test accounts have three limitations:

To add test accounts to your publisher account, follow these steps:

  1. Log in to your publisher account.
  2. Click the Settings icon.
  3. Locate the License Testing panel.
  4. Add the email addresses for the test accounts you want to register, separating each account with a comma.
  5. Click Save to save your profile changes.

Getting an app's license key

The Google Play Developer Console provides a public licensing key for each app.

To locate the key for an app, follow these steps:

  1. Open the All applications panel.
  2. Click on the app name, then open the Services & APIs page.
  3. Scroll down to the section of the page labeled Your License Key for This Application, as shown in figure 5.

Previously, the Developer Console provided a single public key per developer account. To transition apps to the new per-app public key, the Developer Console sets the app-specific key as the former developer key. This ensures compatibility for apps that depend on the (former) developer key.

Figure 5. You can find the license key for each app on the Services & APIs page.

Where to Get Support

If you have questions or encounter problems while implementing In-app Billing, contact the support resources listed in the following table (see table 2). By directing your queries to the correct forum, you can get the support you need more quickly.

Table 2. Developer support resources for Google Play In-app Billing.

Support Type Resource Range of Topics
Development and testing issues Google Groups: android-developers In-app billing integration questions, user experience ideas, handling of responses, obfuscating code, IPC, test environment setup.
Stack Overflow: http://stackoverflow.com/questions/tagged/ android
Billing issue tracker Billing project issue tracker Bug and issue reports related specifically to In-app Billing sample code.

For general information about how to post to the groups listed above, see Developer Forums document in the Resources tab.

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.