Install and Configure the App Tester
App Tester allows you to unit test the In-App Purchasing (IAP) functionality of your app in sandbox mode before you submit the app for publication.
You download App Tester from the Amazon Appstore onto the same Android device as your app. The App Tester simulates the production environment.
You run IAP-related test cases on your app, and App Tester generates API responses (that you configure using a JSON file).
App Tester prerequisites
Your development and testing environment must meet the following prerequisites to run test cases with App Tester:
- Your development environment allows logging via ADB and logcat
- An Android device that supports SDK version 10 or later
- Your app implements Appstore SDK API method calls
- No SDK Tester on the device. SDK Tester is not compatible with App Tester or with the Appstore SDK.
Note: If your app targets Android OS 5.0 (Lollipop), ensure that you download the App Tester tool version that is later than 3-Dec-2014.
We recommend that you create one or more purchasable items for your app in the Amazon Appstore. This allows you to easily create the required JSON file.
Install App Tester
The App Tester is a free app that runs on Android mobile devices. Download App Tester from the Amazon Appstore:
- Uninstall any versions of the SDK Tester tool that you used to test IAP v1.0.
- Download the App Tester
You can also install the App Tester app directly from the Amazon Appstore to your Android mobile device:
- Uninstall any versions of the SDK Tester tool that you used to test IAP v1.0.
- On your Android mobile device, start the Amazon Appstore app.
- Search for "Amazon App Tester".
- Select the "Amazon App Tester" app. (Do not select the Web App Tester, which is a different app.)
- Tap through the prompts to download and install the app.
Create a JSON data file
App Tester responds to API calls using data stored in a JavaScript Object Notation (JSON) file. The file contains purchase data for the IAP items.
You can automatically create the JSON file through the Developer Console.
- In a web browser, go to your app's page in the Developer Console.
- Add your IAP purchasable items to your app, if you have not already done so.
- Click the link to download your JSON Data File.
- Name the downloaded file "amazon.sdktester.json".
-
Copy the file to the
/sdcard/
folder in your device file system.$ adb push [_Your_JSON_File_Folder_]/amazon.sdktester.json /sdcard/amazon.sdktester.json
/mnt/sdcard/
.In the downloaded JSON file, the general file format is as follows.
{
Item_ID_1:{Item_1_Description},
Item_ID_2:{Item_2_Description},
.
.
.
Item_ID_n:{Item_n_Description}
}
The actual item description definition varies by item type. The order of the items in the JSON file is not significant. Note the comma "," between description definitions.
File format and example: IAP consumable and entitlement items
Consumable and Entitlement IAP Item Descriptions have the same format. The itemType property indicates whether the item is ENTITLED or CONSUMABLE. Every purchasable item is associated with a unique identifier called a SKU.
"your_item_SKU":{
"itemType": "ENTITLED|CONSUMABLE",
"price": price,
"title": "item_title",
"description": "item_description",
"smallIconUrl": "full_url_for_small_icon"
}
The following example shows a consumable and an entitlement item:
{
"com.amazon.sample.iap.consumables.orange":{
"itemType": "CONSUMABLE",
"price": 10.00,
"title": "Orange",
"description": "An orange",
"smallIconUrl": "http://www.amazon.com/orange.jpg"
},
"com.amazon.sample.iap.entitlements.level2":{
"itemType": "ENTITLED",
"price": 10.00,
"title": "Level 2",
"description": "An entitlement to play level 2"
}
}
File format and example: IAP subscription item
Subscription items are different from other types of items you can purchase. Every purchasable item is associated with an identifier called a SKU that identifies it as unique. When a subscription is purchased, there are two SKUs involved. One, the parent SKU, describes what the subscription is for (such as a magazine title). The other SKU is the terms SKU, which describes the terms (price, length) of the subscription. The terms SKU is what actually gets purchased by a customer.
Since the terms SKU is the purchasable item, the JSON IAP item description is for that item. However, the description must also contain a reference to the parent SKU. Therefore, subscription item types include an additional property: subscriptionParent
, as shown in the following example.
"your_terms_SKU":{
"itemType": "SUBSCRIPTION",
"price": price,
"title": item_title,
"description": item_description,
"smallIconUrl": "http://www.amazon.com/kindle.jpg",
"subscriptionParent": "your_parent_SKU"
}
An example of a subscription item description follows below (note the subscription parent SKU).
{
"com.amazon.sample.iap.subscription.mymagazine.silver": {
"description": "Monthly Subscription to My Magazine Silver",
"title": "Silver month",
"itemType": "SUBSCRIPTION",
"price": 50.0,
"subscriptionBase": "com.amazon.subs.base",
"subscriptionParent": "com.amazon.subs.silver",
"term": "Monthly",
"freeTrialPeriod": "Monthly",
"promotions": [
{
"promotionType": "Introductory",
"promotionPlans": [
{
"promotionPrice": 15,
"promotionPricePeriod": "Monthly",
"promotionPriceCycles": 2
},
{
"promotionPrice": 20,
"promotionPricePeriod": "Monthly",
"promotionPriceCycles": 1
}
]
}
]
},
"com.amazon.sample.iap.subscription.mymagazine.gold": {
"description": "Monthly Subscription to My Magazine Gold",
"title": "Gold month",
"itemType": "SUBSCRIPTION",
"price": 80.0,
"term": "Monthly",
"subscriptionBase": "com.amazon.subs.base",
"subscriptionParent": "com.amazon.subs.gold"
}
}
termSku
in its JSON response by appending _term
to the subscription's parent or base SKU. For more information, see Test receipts in RVS Cloud Sandbox.Verify your IAP items
You can review the contents of the JSON file. From the App Tester main menu, tap the IAP Items in JSON File option to display a human-readable list of the item data in the JSON file.
Next steps
Familiarize yourself with the App Tester tool and the test options for IAP.
- To learn how to use App Tester, see App Tester User Guide.
- For ideas on how to test your IAP functionality, see Design and Run Test Cases for IAP.
Last updated: Nov 06, 2024