# Android In-App Purchase (IAP)

## <mark style="color:green;">How to setup In App Purchase?</mark>

### Create In-App Purchase Products

There are 4 types of in-app purchases.

* **Consumable:** These are items that can be used up or expire over time and can be bought multiple times (e.g. in-game currency, items, or other virtual goods).
* **Non-Consumable:** These are permanent items that can only be purchased once (e.g. unlocking a full version of an app or purchasing a permanent game character).
* **Auto-renewable subscriptions:** This type of in-app purchase allows a user to subscribe to a service or content within an app on a recurring basis.
* **Non-renewable subscriptions:** This type of in-app purchase allows a user to subscribe to a service or content within an app for a specific duration of time.

{% tabs %}
{% tab title="Consumable & Non-Consumable" %}
Android doesn't differentiate between consumable & non-consumable products. You need to manage from your side if user can purchase one product single time or multiple times.

**1.)** Go to Google Play Developer Console -> Select Your App -> Monetize -> In-app product.

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FVk9tH2VgVhJXXql5pcyG%2Fiap-gp-consumable.png?alt=media&#x26;token=481341cf-a068-4641-8235-40211b40b994" alt=""><figcaption></figcaption></figure>

**2.)** Click on **Create Product** button to create a product. Enter all the info and create a product.

**3.)** Once you create it, Activate button will gets displayed with all the information you filled-up. Click on **Activate** to activate the product. This is required to test IAP.

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FGlxjEq2Zv5jgwAfV5YOe%2Fiap-ps-activate.png?alt=media&#x26;token=be63b477-aa72-4bc1-aae9-f3da71f278c4" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Subscriptions" %}
Google provides very easy way to create Auto-Renewable and Non-Renewable subscriptions. Follow below steps.

**1.)** Go to Google Play Developer Console -> Select Your App -> Monetize -> Subscriptions

![](https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FbbnpkPz3lGhRw8GEAXAH%2Fiap-ps-sub.png?alt=media\&token=d1fdc00e-8615-4aa9-8a41-1eb236278e4a)

**2.)** Click on **Create Subscription** button to create a product. Enter all the info and create a product.

![](https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FN5wK6gnuRdCNMUCTX7cC%2Fiap-ps-create-sub.png?alt=media\&token=ddce09c8-7ece-4ecd-911d-d9e6681e9591)

**3.)** Once you create it, it will ask you to complete below tasks.

![](https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FPcx6OUnHiOXd4BKlkpJ4%2FScreenshot%202023-01-25%20at%2010.20.43%20PM.png?alt=media\&token=d95b5fcf-5002-4c4e-9515-6dbce9ed9392)

* **Add subscription benefits:** In this section you will need to enter all the subscription benefits, description and other info.
* **Add a base plan:** First of all select your plan type.&#x20;
  * **Auto-renewing:**  Select this option if you want to create auto-renewable subscription.
  * **Pre-paid:** Select this option if you want to create non-renewable subscriptions
* **Add offers:** Use this option if you want to enable offer for your subscription such as free trial. This steps is optional.
* **Activate:** At last you need to activate your subscription to make it available for testing and prod users when you go live.
  {% endtab %}
  {% endtabs %}

### Create Licence User Accounts to Test IAP

**1.)** Go to PlayStore Console -> Setup -> Licence Testing

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2F2rf3JfcNitcnw2B3ZCLh%2Fiap-ps-sandbox.png?alt=media&#x26;token=b2f487bb-afb8-4742-af02-31493a25a40b" alt=""><figcaption></figcaption></figure>

**2.)** Enter comma separated email addresses under **Add licence testers** field and hit Enter.

**3.)** Select **RESPOND\_NORMALLY** under **Licence response** dropdown.

**4.)** Now, you need to prepare an APK and upload it under internal tester. To do that, go to PlayStore Console -> Select Your App -> Testing -> Internal testing.

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FDkEtGpSog2EnSwNUGEnf%2Fiap-ps-internal-testing.png?alt=media&#x26;token=6f027943-7da0-4357-a4c1-03c951057fc7" alt=""><figcaption></figcaption></figure>

**5.)** Click **Create a new release** button and upload your APK in there. Publish that release for review.

**6.)** Next step is to join the testers program. To do so, click on Testers tab and then copy **Join on the web** URL. Open this URL in your browser and join the testers program.

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2FXdxTWGoaBKMYkzlUDUe1%2Fiap-ps-testers.png?alt=media&#x26;token=6ca2fb78-59b0-4593-a616-168b81f1667f" alt=""><figcaption></figcaption></figure>

**7.)** Now, you are ready to test IAP in your application. Install APK file in your mobile and test everything.
