This project is a simple demonstration of the Amazon IAP API on a Amazon Fire Tablet.
- Clone the demo app repository:
git clone https://github.com/AmazonAppDev/amazon-iap-kotlin.git - Connect your Fire tablet device following these instructions.
Step 1: Install the Amazon App Tester from the Amazon Appstore on your Fire tablet, then open it once so it's ready to receive your IAP config.
Step 2: Push the example amazon.sdktester.json file to your device using the command:
adb push <_Your_JSON_File_Folder_>/amazon.sdktester.json /sdcard/amazon.sdktester.json
This JSON file is usually generated when you create IAP items in the developer portal. For this demo we use the example JSON included in this repo, which defines three IAP items (techsubscription as the parent SKU, with techmonthly and techquarterly as child terms) matching the SKUs the app requests in MainActivity.kt.
The file must be named exactly
amazon.sdktester.jsonon the device, and the SKUs inside must match the SKUs the app queries. When you generate your own JSON from the developer portal, define IAP items with the same SKU names, or updateMainActivity.ktto match yours.
Step 3: Set your app in sandbox mode using the following command:
adb shell setprop debug.amazon.sandboxmode debug
Sandbox mode constrains calls that would normally go to the Appstore client to route to the Amazon App Tester app instead. Use this mode only for testing locally.
β οΈ This property is not persistent across device reboots β re-run the command after every reboot. Before building a release, clear it withadb shell setprop debug.amazon.sandboxmode "".
Step 4: Open the Amazon App Tester app. You should now see the IAP items from your JSON file.
You can now run the demo app:
Note: When you run the demo app, it uses the App Tester, which allows you to test the In-App Purchasing (IAP) functionality of your app in sandbox mode.
You can use this demo as a starting point to build a Kotlin app with an integration to the Amazon IAP API. To learn more about the API you can check out the documentation or the YouTube series I created.
If you found a bug or want to suggest a new [feature/use case/sample], please file an issue.
If you have questions, comments, or need help with code, we're here to help:
- on X at @AmazonAppDev
- on Stack Overflow at the amazon-appstore tag
Get the most up to date Amazon Appstore developer news, product releases, tutorials, and more:
-
π£ Follow @AmazonAppDev and our team on Twitter
-
πΊ Subscribe to our Youtube channel
-
π§ Sign up for the Developer Newsletter
