Skip to content

AmazonAppDev/amazon-iap-kotlin

Android build

Amazon IAP Kotlin Example

This project is a simple demonstration of the Amazon IAP API on a Amazon Fire Tablet.

πŸ’» Building the IAP demo

  1. Clone the demo app repository: git clone https://github.com/AmazonAppDev/amazon-iap-kotlin.git
  2. Connect your Fire tablet device following these instructions.

πŸ§ͺ How to test with In-App Items

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.json on 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 update MainActivity.kt to 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 with adb 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:

sample app showing the three IAP items loaded from the sandbox

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.

πŸ‘©β€πŸ’» Building your app

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.

Get support

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:

Stay updated

Get the most up to date Amazon Appstore developer news, product releases, tutorials, and more:

Authors

About

This project demonstrates how to integrate the Amazon In-App Purchasing (IAP) API into a Kotlin Android app for Amazon Fire tablets, including testing with the Amazon App Tester in sandbox mode. πŸ’°πŸ›’πŸ“±

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors