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:
App is built with Microsoft Teams JavaScript client library (TeamsJS).
App is enabled with a transactable SaaS offer.
App is enabled with RSC permissions.
App is invoked with
openPurchaseExperience
API.
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 Microsoft Teams JavaScript client library:
<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:
In the Teams Store, find and select the app.
In the app details dialog, select Buy a subscription or Add for me.
Add for me offers a free trial version of the app and later Upgrade it to a paid version.
In the Choose a subscription plan dialog, choose the plan and select Checkout.
Complete the transaction and select Configure now to set up your subscription.
Next step
See also
Feedback
Submit and view feedback for