In-app purchases

Microsoft Teams provides APIs that you can use to implement the in-app purchases to upgrade from free to paid Teams apps. In-app purchase allows you to convert users from free to paid plans directly from within your app.

Implement in-app purchases

To offer an in-app purchase experience to the users of your app, ensure the following:

In-app purchase experience can be enabled either by updating manifest.json file or by enabling Show in-app purchase offers from Permissions section of your Developer Portal.

Update manifest

To enable in-app purchase experience, update your Teams app manifest.json file by adding the RSC permissions. It allows your app users to upgrade to a paid version of your app and start using new functionalities. The update for app manifest is as follows:


"authorization": {
    "permissions": {
        "resourceSpecific": [
            {
                "name": "InAppPurchase.Allow.User",
                "type": "Delegated"
            }
        ]
    }
}

Purchase Experience API

To trigger in-app purchase for the app, invoke the openPurchaseExperience API from your web app.

Following code snippet is an example of calling the API from the Teams app built using Teams JavaScript client SDK:

<div> 
<div class="sectionTitle">openPurchaseExperience</div>
<button onclick="openPurchaseExperience()">openPurchaseExperience</button>
</div>
</body>
<script>
   function openPurchaseExperience()
      microsoftTeams.initialize();
      let callbackcalled = false;
      microsoftTeams.monetization.openPurchaseExperience((e) => {
            console.log("callback is being called");
            console.log(e);
            if (!!e && typeof e !== "string") {
                  alert(JSON.stringify(e));
              }
              return;
            });
      console.log("after callback: ",callbackcalled);
    }
</script>

End-user in-app purchasing experience

The following example shows the users to purchase subscription plans for a fictional Teams app called Contoso Tasks for Teams:

  1. In the Teams Store, find and select the app.

  2. In the app details dialog, select Buy a subscription or Add for me.

    Buying the subscription for the selected app.

  3. Add for me offers a free trial version of the app and later Upgrade it to a paid version.

    Upgrading to the subscription for the selected app.

  4. In the Choose a subscription plan dialog, choose the plan and select Checkout.

    Selecting the appropriate subscription plan.

  5. Complete the transaction and select Configure now to set up your subscription.

    Setting up the subscription.

    Landing page of the subscription.

Next step

See also