For the complete documentation index, see llms.txt. This page is also available as Markdown.

In App Purchase - Android Integration

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.

You'll need to import the javascript file in your website before starting from this link.

If you have not set up In-App Purchase in your Google Developer account yet, see In-App Purchase Android Setup for how to configure IAP in Android.


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);
    }
  },
});

Parameters:

Key
Type
Required
Description

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.

accountToken availability: The accountToken parameter 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:

Key
Type
Description

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:

Key
Type
Required
Description

callback

Function

No

Callback function invoked with the response.

Callback Response:

Key
Type
Description

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