开发者控制台
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Share:

Edit the Blog Post Header component above this, then place your content here, then fill out the Related Articles section below, if possible. You should have at least one related article and ideally, all three.

Feel free to add supplementary content to the sidebar at right, but please retain the Twitter component (it can live at the bottom of your added content). 

This text component can be edited or deleted as necessary.

Related Articles

Related article title here

Related articles only have an image (the squarer version of the banner) and a title. This text can be deleted. Place 1-3 related articles.

Subscribe

How to Test IAP Pre-Launch (with DevTest)

Share:
How to Test Make Money
Blog_Header_Post_Img

Testing in-app purchase (IAP) items in your app is vital. That's why you need a way to make it part of an efficient dev workflow, and start testing it right away as you’re developing your app.

DevTest for IAP makes this possible by letting you test locally against live Amazon services without publishing your app or even submitting a beta version. It lets you test your purchase logic immediately and iterate quickly, so you can show up to beta testing (via Live App Test) with confidence that your IAP stuff works.
 

How is DevTest different from App Tester and Live App Testing?

App Tester just simulates mock responses. DevTest connects to Amazon's actual services, so you're testing the real thing.

Live App Testing requires your app to be published (as a beta) first. DevTest doesn't. You can test your code right after writing it.
 

Let's walk through setting up DevTest with a simple fictional app, so you can start using DevTest in your own projects.

Our Fictional App: "Guess the Number"

"Guess the Number" is a game app where you try to identify a random number between 1 and 100 within five attempts. After each guess, the game indicates whether the secret number is "higher" or "lower" than your guess.

How to test In-App-Purchase pre-launch

This game has three IAP items (one for each type):

  • "Advanced Mode" is a monthly subscription item that unlocks score tracking.
  • "Extra Guess" is a consumable item that gives you an extra guess when you run out. These get consumed when used, so you can buy them multiple times.
  • "Divisibility Hint" is an entitlement item that tells you at the beginning of each game if the number is divisible by 2, 3, or 5. Buy it once, keep it forever.

How to test In-App-Purchase pre-launch
How to test In-App-Purchase pre-launch

Setting Up DevTest for IAP

To ensure the app's subscription tracking, consumable extra guesses, and hints entitlement work correctly, we need to test them against Amazon's live services. DevTest lets us validate these purchase flows immediately without waiting for app approval.
 

Step 1: Generate a certificate

If you don't already have a certificate, generate one locally using the following command:

Copied to clipboard
$ openssl req -x509 -nodes \
    -newkey ec \
    -pkeyopt ec_paramgen_curve:secp384r1 \
    -keyout key.pem -out cert.pem

This creates two files: key.pem (your private key) and cert.pem (your certificate). Keep both of these files safe, as you'll need them for app registration and signing.
 

Step 2: Register your app in the Amazon Developer Console

In the Amazon Developer Console, create your app (if you haven't already). Then, navigate to Amazon Appstore DevTest for IAP.

How to test In-App-Purchase pre-launch

Copy and paste the contents of your cert.pem file into the certificate field. Enter the package name for your application, which can be found in your project's build.gradle file. Click Register.

How to test In-App-Purchase pre-launch

The registration process for your app may take several minutes. Once it is complete, reloading this page will show the following:

How to test In-App-Purchase pre-launch

You can add up to multiple certificates for your app. This allows you to build and sign your APK with different certificates (up to three).
 

Step 3: Add your IAP items

If you have already added IAP items for your app, you can skip this step. Otherwise, navigate to In-App Items to add your subscription, consumables, and entitlements.

How to test In-App-Purchase pre-launch

You must submit each of your IAP items before you can test them.

How to test In-App-Purchase pre-launch

Step 4: Add test accounts

Under Amazon Appstore DevTest for IAP, navigate to Manage Testers.

How to test In-App-Purchase pre-launch

Add test accounts so you (and other testers) can make purchases without getting charged. You can add up to 50 testers who will be able to test purchases on their devices.

How to test In-App-Purchase pre-launch

Step 5: Generate a signed APK

Generate a signed APK, using the same certificate you used for DevTest registration.

Create a keystore from your certificate.

Copied to clipboard
$ openssl pkcs12 -export -out keystore.p12 -inkey key.pem -in cert.pem

If you're using Android Studio, navigate to Generate Signed App bundle or APK.

How to test In-App-Purchase pre-launch

Select APK.

How to test In-App-Purchase pre-launch

Use the keystore file you just created to sign your app. If you are prompted for the key alias, it is likely "1". However, you can verify this by running the following command in your terminal:

Copied to clipboard
$ keytool -v -list -keystore keystore.p12

Enter keystore password:  
Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: 1
…

After your build is complete, you'll have a signed APK which you can sideload onto any test device. Because the app is signed with the certificate used to register your app with DevTest, any calls made to the Appstore SDK API will be routed to Amazon's test servers.

Now you're ready to test purchases.

Running IAP Tests with DevTest

Install your signed APK on your test device. Follow the instructions for using adb to connect to your Fire Tablet or connect to Fire TV.

Using the file that corresponds to your signed APK, run the following command:

Copied to clipboard
$ adb install app-release.apk 

Performing Streamed Install
Success

After installing the app, sync your device with Amazon's servers so the device knows about the IAP items that have been added.
On your testing device, navigate to Settings > Device Options > Sync Device.
 

Debug with logcat

While testing your app with DevTest, use adb logcat to show you what's happening behind the scenes. With your computer connected to your testing device, open a terminal and run the following command, using the package name for your application:

Copied to clipboard
$ adb logcat | grep com.example.guessthenumber

This will show log statements filtered to your app specifically.

Test each purchase type by actually using your app. Monitor your logs along the way to debug any unexpected behaviors. Test edge cases too. For example:

  • What happens when someone cancels a purchase?
  • What if the network cuts out mid-transaction?
  • What about trying to buy the same entitlement twice?

Test all the unexpected scenarios now rather than discovering them in production.

During all of this, your app is talking to Amazon's real servers, so you're getting authentic purchase flows without affecting real customers.
 

Reset IAP purchases

To reset IAP purchases, return to the Manage Testers page in the Amazon Developer Console. Select your testers and then choose from the available reset actions.

How to test In-App-Purchase pre-launch

This way, your testers can go back and test your app from a clean state.

Conclusion and Next Steps

DevTest speeds up your IAP development and debugging process by removing the cycle of submit, wait, test, discover bugs, repeat. With it, you can test your purchase logic quickly—immediately after writing it.

Use DevTest early in your development process. Write your IAP code. Set up DevTest. Test everything locally with quick and easy iterations. Then, move to Live App Testing with confidence in your IAP code. Your beta testers can focus on user experience instead of finding basic integration bugs.

The time savings alone make DevTest worth setting up, but this will also help you catch broken purchase flows before they reach production. For detailed setup steps, refer to Get Started with Appstore DevTest for IAP, then use DevTest in your next Amazon Appstore project today!

Related articles

Sign up for our newsletter

Stay up to date with the latest Amazon Developer news, industry trends and blog posts.