Supported on: Android SDK
1.0.33+Configuration
The Android SDK defaults to Google Play Billing, but the billing backend is selectable via thebillingProvider configuration option (default BillingProvider.StoreKit2, which maps to Google Play Billing on Android). You enable billing by calling AppDNA.configure(...) from your Application.onCreate() and ensuring the Play Billing dependency is on your classpath (the SDK pulls it in transitively).
BillingProvider is a sealed class with these cases:
BillingProvider.StoreKit2— the platform store (Google Play Billing on Android).BillingProvider.RevenueCat— carries no key; the host configuresPurchasesitself and forwards results.BillingProvider.Adapty(apiKey)— starts the Adapty bridge with the given publishable key.BillingProvider.None— no billing; purchases and entitlement reads fail fast rather than silently no-op.
RevenueCat and Adapty bridges exist on Android too (
integrations/RevenueCatBridge.kt, integrations/AdaptyBridge.kt). Select one with billingProvider. When left at the default, all billing flows route through the native NativeBillingManager against Google Play.Module Access
Access the billing module through theAppDNA.billing property:
Get Products
Retrieve product details for one or more product IDs (suspend function — call from a coroutine, or use theFuture overload from Java):
AppDNA.billing.getProductsFuture(productIds): CompletableFuture<List<ProductInfo>>.
ProductInfo
Purchase a Subscription
Initiate a purchase flow for a specific product.purchase is a suspend function that returns a TransactionInfo on success and requires the current Activity to host the Play Billing flow:
AppDNABillingDelegate (see below).
Promotional offers
Pass aPurchaseOptions to select a specific subscription offer token:
Server-side receipt verification is performed automatically by the SDK. You do not need to send purchase tokens to your own server for validation.
Restore Purchases
Restore previously purchased subscriptions and one-time products (e.g., after a device change or reinstall). Suspend function — returnsList<String> of restored product IDs:
Restoring purchases queries Google Play for all active subscriptions and updates entitlements accordingly. This is useful after a reinstall or device change.
Entitlements
Retrieve the current user’s entitlements (suspend function):Entitlement
Check Active Subscription
Quickly check if the user has any active subscription:Listen for Entitlement Changes
Register a listener to be notified when entitlements change (e.g., subscription renewal, expiration, or new purchase):AppDNABillingDelegate
All 5 methods on this delegate fire from the active billing bridge (Google PlayNativeBillingManager). Register via AppDNA.billingDelegate = yourHandler.
onPurchaseCompletedandonPurchaseFailedfire for every purchase regardless of entry point — paywall-driven OR directAppDNA.billing.purchase(...)calls.onRestoreCompletedfires after every successful restore.onEntitlementsChangedfires whenever entitlements change (also broadcast via the localEntitlementCache).onBillingUnavailablefires once when the billing connection gives up after exhausting all reconnect attempts (Play Services missing or permanently broken). Hide paywalls / disable purchase UI when this fires.
AppDNAPaywallDelegate: when a purchase comes from a paywall, both AppDNAPaywallDelegate.onPaywallPurchaseCompleted AND AppDNABillingDelegate.onPurchaseCompleted fire. Each represents a different layer (paywall lifecycle vs platform billing). Pick one as your source of truth for your analytics — they will not double-count if you only listen on one.
For more granular control, implement the AppDNABillingDelegate interface:
Example Implementation
Data Types
TransactionInfo
PurchaseResult
ThePurchaseResult sealed class represents all possible outcomes of a purchase:
Auto-Tracked Events
The billing module automatically tracks the following events:These events include the product identifier and relevant metadata. They are tracked regardless of whether you implement
AppDNABillingDelegate.The SDK automatically acknowledges purchases within 3 days as required by Google Play. If a purchase is not acknowledged within this window, Google Play will automatically refund it. The
NativeBillingManager also handles ITEM_ALREADY_OWNED errors by automatically triggering a restore flow.Full Example
Next Steps
- Configure Onboarding flows to guide new users
- Present Paywalls with integrated purchase handling
- Learn about Offline Support for billing resilience

