Skip to main content

Simulating Purchases with Postman

This advanced tutorial will guide you through simulating a purchase using Postman, allowing you to test your iap.dev integration without going through the Google Play billing flow.

Prerequisites

  • Access to the iap.dev console
  • Postman installed on your computer. (Alt. Curl would work just as well.)
  • The Doggie Treats sample app installed on your device

Steps

1. Get Device Auth Tokens

  1. In the iap.dev console, navigate to your project.
  2. Go to Devices by clicking on the left navigation bar

Devices Button

  1. Create a new device or select an existing one (Different from the one running the native app).
  2. In the device details, click on "Generate Auth Tokens".

Generate Auth Tokens Button

  1. Copy the generated device auth token. (Ignore the refresh token for this)

Device Auth Tokens

2. Prepare the Doggie Treats App

  1. Open the Doggie Treats app on your device.
  2. Ensure you're on the app's home screen and that the Connection Status is "Connected" and the Purchase Status is "Ready"

3. Set Up Postman Request

  1. Open Postman and create a new POST request to:
    https://api.iap.dev/api/client/android/purchases

Postman new post

  1. In the Authorization tab:
    • Select "Bearer Token" from the Type dropdown.
    • Paste the device auth token you copied earlier into the Token field.

Postman auth header

  1. In the Body tab:

    • Select "raw" and choose "JSON" from the dropdown.
    • Enter the following JSON, replacing doggie_treats with the actual product ID from your iap.dev project if different:
    {
    "productType": "inapp",
    "productIds": ["doggie_treats"],
    "applicationId": "my.test.app"
    }

    Postman JSON body

4. Send the Request

Click the "Send" button in Postman to submit the request.

5. Verify the Results

  • In Postman:
    • You should receive a 201 Created response with a JSON payload.

Postman Successful Response

  • In the Doggie Treats app:

    • You should see the confetti animation, indicating that the purchase event was received.
  • In the iap.dev console:

    • Navigate to the Product Purchases section.
    • You should see a new purchase entry in the "Acknowledged" state.(The app automatically acknowledges the purchase)

Troubleshooting

If you don't see the expected results:

  • Double-check that you are using the Auth token and not the refresh token.
  • Ensure the product ID in the request matches a product in your iap.dev project.
  • Verify that the Doggie Treats app is properly configured with your iap.dev project details.

Next Steps

Now that you can simulate purchases, try experimenting with different product types or multiple products in a single request. This method is particularly useful for testing edge cases and purchase scenarios that might be difficult to reproduce through the normal purchase flow.