To ensure that In-app Billing is functioning correctly in your application, you should test the application before you publish it on Google Play. Early testing also helps to ensure that the user flow for purchasing in-app items is not confusing or slow, and that users can see their newly purchased items in a timely way.
Test with Static ResponsesTest your In-app Billing application with static responses by using Google Play’s reserved product IDs.By using reserved product IDs instead of actual product IDs, you can test the purchase flow without specifying an actual payment method or transferring money. To learn more about the reserved product IDs, see Testing In-app Billing.
Test with Your Own Product IDs
Because Google Play does not allow you to use your developer account to directly purchase in-app products that you have created yourself, you'll need to create test acccounts under your developer account profile. To create a test account, simply enter a valid Google email address. Users with these test accounts will then be able to make in-app-billing purchases from uploaded, unpublished applications that you manage.
To test your In-app Billing Version 3 application using your own product IDs:
- In the Play Console, add one or more tester accounts to the developer account that you are using to publish your application.
- Login to the Play Console with your developer account.
- Click Settings > Account details, then in the License Testing section, add the Google email addresses for your tester accounts.
- Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see Building Your Application for Release.
- Make sure that you have uploaded the signed APK for your application to the Play Console, and associated one or more in-app products with your application. You don't need to publish the application on Google Play to test it.
Warning: It may take up to 2-3 hours after uploading the APK for Google Play to recognize your updated APK version. If you try to test your application before your uploaded APK is recognized by Google Play, your application will receive a ‘purchase cancelled’ response with an error message “This version of the application is not enabled for In-app Billing.”
- Install the APK file to your physical test device by using the
adbtool. To learn how to install the application, see Running on a Device. Make sure that your test device is running on Android 2.2 (API level 8) or higher and is installed with Google Play client Version 3.9.16 or higher.
- Login to the test device by using a tester account. Test your In-app Billing application by purchasing a few items, and fix any issues that you encounter. To learn more about how you can perform large-scale testing of your In-app Billing app, see Test Purchases (In-app Billing Sandbox).