In-App Purchase (IAP)

In-app purchase (IAP) refers to the ability for users to purchase digital goods or services within an app.

What is In-App purchase?

In-app purchase (IAP) refers to the ability for users to purchase digital goods or services within an app. This can include things like virtual currency, additional features or content, or subscriptions to services.

In-app purchases are typically made through the app store (such as Apple's App Store or Google Play), and the app developer receives a percentage of the revenue. This allows developers to offer their apps for free or at a lower cost, while still being able to generate revenue through in-app purchases.

There are several types of in-app purchases, including:

  • 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.

How to setup In App Purchase?

1.) Go to Add-ons --> Extensions --> In-App Purchase & enable it.

2.) Enter Response Submission URL: This is webhook URL where we will submit success or error response of the purchases user will be doing in your app. Your URL must accept POST request and we will be submitting following information with the POST request.

{
      "twinr_product_id": "TWINR_PRODUCT_ID",
      "store_product_id": "STORE_PRODUCT_ID",
      "platform": "android or ios",
      "purchase_token": "PURCHASE_RECEIPT",
      "success":  true //true or false,
      "user_info": "USERNAME",
}

3.) Create IAP products on Android and iOS stores. Follow these documents for Android & iOS.

pageiOS In-App Purchase (IAP)pageAndroid In-App Purchase (IAP)

4.) Click on +Add button to create your IAP product on Twinr.

  • Select product type as per your requirements. It must match the type with the product created on your AppStore and PlayStore accounts.

  • Android Product ID: Enter product ID from your PlayStore product information page.

  • iOS Product ID: Enter product ID from your AppStore product information page.

5.) Once your product will be created, you will see one auto-generated Twinr ID to that product. You will require that product ID to start the purchase flow in your app.

6.) Now you have everything ready to setup IAP links on your website. There are two ways to set it up.

  • Custom URL

  • JS Function

Below you can find the information for both of them in depth.

Custom URL is very easy to setup. We have designed one custom scheme URL to make this work easy for you.

Here is how the URL is formatted. inapppurchase://twinr.dev?product_id=TWINR_ID

In this URL you need to replace TWINR_ID with respected Twinr ID of your product. You can use this URL anywhere in your app to start purchase flow of that product.

For exaple, you can create Hamburger Menu in your app and use this URL there to start a purchase flow. You need to create this kind of URL for each of your product and use it when you want to start purchasing.

You can use this URL in your website as well, when that URL will be executed in the app, Twinr will automatically identify it and will start the purchase of that product respectively.

7.) You cannot test IAP in the preview app. To test it, Create a build of your app from App Build and request new builds. Use TestFlight app for iOS and APK file Android testing. Make sure you have added yourself as a testers to test on Android & iOS. Follow step 3 if you didn't invite yourself as a tester.

Last updated