In-App Purchase - Android Integration
Integrate Android in-app purchases using the WebToNative JavaScript API. Enable secure subscriptions and one-time purchases in your app.
Functions to sell and restore Google Play In-App Purchases from your app. The WebToNative In-App Purchase plugin wraps Google Play Billing natively, giving you a single JavaScript API to initiate a purchase (one-time or subscription) and query the purchases a user already owns.
Initiate a Purchase
Starts the Google Play Billing purchase flow for the given product. On completion, the callback receives the purchase receipt, which you then verify with the Google Play Developer API.
window.WTN.inAppPurchase({
productId: "Product Id of IAP",
productType: "INAPP",
isConsumable: true,
accountToken: "11112222-3333-4444-5555-666677778888",
callback: function (data) {
if (data.isSuccess) {
// Send data.receiptData to your server to verify the purchase.
console.log(data.receiptData);
}
},
});import { inAppPurchase } from "webtonative/InAppPurchase";
inAppPurchase({
productId: "Product Id of IAP",
productType: "INAPP",
isConsumable: true,
accountToken: "11112222-3333-4444-5555-666677778888",
callback: (data) => {
if (data.isSuccess) {
// Send data.receiptData to your server to verify the purchase.
console.log(data.receiptData);
}
},
});Parameters:
productId
String
Yes
The product ID exactly as created in the Google Play Console.
productType
String
Yes
"INAPP" for one-time purchases, or "SUBS" for subscriptions.
isConsumable
Boolean
Yes
Whether the product can be purchased again. See the guidance below.
accountToken
String
No
A token that associates the purchase with a user in your system, for server-side reconciliation. See availability note below.
callback
Function
No
Callback function invoked with the response.
accountTokenavailability: TheaccountTokenparameter went live on 09/06/26. It is only honored by Android builds generated on or after 09/06/26 — earlier builds ignore the field. Regenerate your build after this date to use it.
Choosing isConsumable:
Product
productType
isConsumable
Behavior
One-time consumable
"INAPP"
true
User can purchase the product again and again.
One-time non-consumable
"INAPP"
false
User can purchase the product only once.
Subscription
"SUBS"
false
Treated as a non-consumable product.

Callback Response:
type
String
Always "inAppPurchase". Use this to filter the callback.
isSuccess
Boolean
true if the purchase completed successfully, false otherwise.
receiptData
Object
The purchase receipt. Send this to your server for verification.
Example response:
Query Purchases
Returns all purchases the user currently owns — active subscriptions and non-consumed one-time purchases. Use this to restore purchases or re-verify entitlements.
Parameters:
callback
Function
No
Callback function invoked with the response.
Callback Response:
type
String
Always "purchaseList". Use this to filter the callback.
isSuccess
Boolean
true if the query completed successfully, false otherwise.
purchaseData
Array
The user's active subscriptions and non-consumed one-time purchases.
Example response:
Official References
Last updated