Skip to main content
Native Plugins & Integrations2 min read

In-App Purchases and Subscriptions

Sell digital products and subscriptions with App Store and Google Play billing from your website, with the In-App Purchases plugin or RevenueCat.

Overview

Apple and Google require their own billing for digital goods and subscriptions used in an app: premium content, memberships, coins, unlockable features. Card gateways (Stripe, Razorpay, PayPal) are only for physical goods and services.

WebAppStudio offers two plugins. Use one, not both:

PluginChoose it when
In-App PurchasesYou verify purchases on your own server with Apple's and Google's APIs
RevenueCatYou manage subscriptions, entitlements and receipts in RevenueCat

Turn the plugin on in Integrations › Native plugins and build a new version.

In-App Purchases plugin

1. List your products

Create the products in App Store Connect and Google Play Console. Then host a JSON file and put its URL in Products list URL:

json
{
  "ios": { "products": ["com.example.premium_monthly", "com.example.coins_100"] },
  "android": { "inappProducts": ["coins_100"], "subProducts": ["premium_monthly"] },
  "consumables": ["coins_100", "com.example.coins_100"]
}

The app reads it at launch, so you can change products without a new build. consumables marks products that can be bought again.

2. Show products and buy

javascript
// Products arrive when ready; or call: const { products } = await wapp.iap.info();
wapp.on('iap_info_ready', (data) => renderPrices(data.products));

const result = await wapp.iap.purchase({ productID: 'premium_monthly' });
if (result.success) {
  // 3. Verify on your server, then finish the transaction
  await fetch('/iap/verify', { method: 'POST', body: JSON.stringify(result.purchase) });
  await wapp.iap.finish({ transactionId: result.purchase.transactionId });
}

Products have productID, type (inapp or subscription), title, description, price, priceFormatted and currency. Android subscriptions also have subscriptionOfferDetails; pass an offerToken to purchase() to buy a specific offer.

3. Verify and finish

  • iOS: use the App Store Server API (Get Transaction Info).
  • Android: use the Google Play Developer API with the purchaseToken.

Call finish() only after verifying. Google refunds Android purchases that are not acknowledged within 3 days; as a safety net, the app acknowledges any it still finds after 48 hours. The Finish purchases without server verification setting skips your server, for testing only.

Other methods

  • wapp.iap.purchases(): open and active purchases; also fires the iap_purchases event.
  • wapp.iap.restorePurchases()
  • wapp.iap.manageSubscription({ productID }) and wapp.iap.manageAllSubscriptions(): the store's subscription screen.
  • Android upgrades: purchase({ productID, offerToken, previousProductID, previousPurchaseToken, replacementMode }).
  • appAccountToken: your user's UUID, linked to the purchase.

RevenueCat plugin

Put your public API keys (RevenueCat › Project settings › API keys: appl_… and goog_…) in the plugin settings; they apply without a new build.

javascript
await wapp.revenueCat.logIn({ appUserId: currentUser.id });

const offerings = await wapp.revenueCat.getOfferings();
const result = await wapp.revenueCat.purchasePackage({ packageId: '$rc_monthly' });
if (result.success && result.customerInfo.entitlements.pro) unlockPro();

Other methods: getCustomerInfo(), restorePurchases(), logOut() and manageSubscriptions(). RevenueCat checks receipts itself; on your server, rely on RevenueCat's REST API or webhooks before granting access.

Next steps