-
public final class BillingModuleBilling module namespace. Delegates to NativeBillingManager when available.
SPEC-070-A A.29 / A.30 — public APIs are typed suspend functions returning concrete data classes (
TransactionInfo,ProductInfo,Entitlement), mirroring iOSAppDNA.Billing(AppDNA+Modules.swift). Java consumers get*Futureoverloads via kotlinx.coroutines.future.future.
-
-
Method Summary
Modifier and Type Method Description final BooleanhasActiveSubscription()Check if user has active subscription. final UnitrefreshEntitlementCache()SPEC-401 Fix 1D — silently refresh cached entitlement state. final CompletableFuture<Unit>refreshEntitlementCacheFuture()Java-friendly overload — returns a CompletableFuture. final List<ProductInfo>getProducts(List<String> productIds)SPEC-070-A A.30 — typed suspend product fetch. final CompletableFuture<List<ProductInfo>>getProductsFuture(List<String> productIds)Java-friendly overload — returns a CompletableFuture. final TransactionInfopurchase(Activity activity, String productId, PurchaseOptions options)SPEC-070-A A.29 / A.30 — initiate a purchase flow. final TransactionInfopurchase(Activity activity, String productId)SPEC-070-A A.29 / A.30 — initiate a purchase flow. final CompletableFuture<TransactionInfo>purchaseFuture(Activity activity, String productId, PurchaseOptions options)Java-friendly overload — returns a CompletableFuture. final CompletableFuture<TransactionInfo>purchaseFuture(Activity activity, String productId)Java-friendly overload — returns a CompletableFuture. final List<String>restorePurchases()SPEC-070-A A.30 — typed suspend restore. final CompletableFuture<List<String>>restorePurchasesAsync()Java-compatible CompletableFutureadapter for restorePurchases.final List<Entitlement>getEntitlements()SPEC-070-A A.30 — typed suspend entitlements fetch. final CompletableFuture<List<Entitlement>>getEntitlementsFuture()Java-friendly overload — returns a CompletableFuture. final UnitonEntitlementsChanged(Function1<List<Entitlement>, Unit> callback)Register a callback for entitlement changes. final UnitsetDelegate(AppDNABillingDelegate delegate)Set a delegate to receive billing lifecycle callbacks (purchases, failures, restores). -
-
Method Detail
-
hasActiveSubscription
final Boolean hasActiveSubscription()
Check if user has active subscription.
-
refreshEntitlementCache
final Unit refreshEntitlementCache()
SPEC-401 Fix 1D — silently refresh cached entitlement state.
Calls into NativeBillingManager.refreshEntitlementCache which re-reads the user's current entitlements via Play Billing
BillingClient.queryPurchasesAsyncand primes the EntitlementCache in place. Designed for two callers:AppDNA.identify — auto-refresh after host signs in a user so the next paywall_trigger entitlement gate (Fix 1A) reflects that user's subscriptions, not the previous anonymous user's empty entitlements.
Hosts that complete auth out-of-band (SSO callbacks, deep links, OAuth web flows) and need to flush stale cache without firing user-visible restore events.
Side effects: ZERO. No analytics events, no delegate callbacks, no UI. Errors are swallowed and logged at warning level — the suspend returns normally so callers can chain without try/catch. Mirrors iOS
BillingModule.refreshEntitlementCache().
-
refreshEntitlementCacheFuture
final CompletableFuture<Unit> refreshEntitlementCacheFuture()
Java-friendly overload — returns a CompletableFuture.
-
getProducts
final List<ProductInfo> getProducts(List<String> productIds)
SPEC-070-A A.30 — typed suspend product fetch.
Returns
ProductInfodata classes from NativeBillingManager.getProducts. Replaces the previous brokenscope.launch; return resultstub which always returned an empty list synchronously.
-
getProductsFuture
final CompletableFuture<List<ProductInfo>> getProductsFuture(List<String> productIds)
Java-friendly overload — returns a CompletableFuture.
-
purchase
@JvmOverloads() final TransactionInfo purchase(Activity activity, String productId, PurchaseOptions options)
SPEC-070-A A.29 / A.30 — initiate a purchase flow.
Activity is now the FIRST parameter (required by Google Play Billing
launchBillingFlow). Mirrors iOSBillingModule.purchase(productId:options:)(AppDNA+Modules.swift:72).Returns a TransactionInfo on success. Throws on failure (cancelled, pending, billing error).
- Parameters:
activity- Activity used to launch the Play billing dialog.productId- The Google Play product ID to purchase.options- Optional purchase parameters (offer token, app account token).
-
purchase
@JvmOverloads() final TransactionInfo purchase(Activity activity, String productId)
SPEC-070-A A.29 / A.30 — initiate a purchase flow.
Activity is now the FIRST parameter (required by Google Play Billing
launchBillingFlow). Mirrors iOSBillingModule.purchase(productId:options:)(AppDNA+Modules.swift:72).Returns a TransactionInfo on success. Throws on failure (cancelled, pending, billing error).
- Parameters:
activity- Activity used to launch the Play billing dialog.productId- The Google Play product ID to purchase.
-
purchaseFuture
@JvmOverloads() final CompletableFuture<TransactionInfo> purchaseFuture(Activity activity, String productId, PurchaseOptions options)
Java-friendly overload — returns a CompletableFuture.
-
purchaseFuture
@JvmOverloads() final CompletableFuture<TransactionInfo> purchaseFuture(Activity activity, String productId)
Java-friendly overload — returns a CompletableFuture.
-
restorePurchases
final List<String> restorePurchases()
SPEC-070-A A.30 — typed suspend restore. Mirrors iOS
AppDNA+Modules.swift:88restorePurchases() async throws -> [String]. Returns the list of restored product IDs so hosts can show a confirmation UI; the underlying Entitlement objects are still surfaced via AppDNABillingDelegate.onRestoreCompleted for hosts that prefer the delegate flow.
-
restorePurchasesAsync
final CompletableFuture<List<String>> restorePurchasesAsync()
Java-compatible
CompletableFutureadapter for restorePurchases.
-
getEntitlements
final List<Entitlement> getEntitlements()
SPEC-070-A A.30 — typed suspend entitlements fetch.
Returns the current cached active entitlements as
Entitlementdata classes. Suspend so future implementations can refresh from the network without a breaking change.
-
getEntitlementsFuture
final CompletableFuture<List<Entitlement>> getEntitlementsFuture()
Java-friendly overload — returns a CompletableFuture.
-
onEntitlementsChanged
final Unit onEntitlementsChanged(Function1<List<Entitlement>, Unit> callback)
Register a callback for entitlement changes.
-
setDelegate
final Unit setDelegate(AppDNABillingDelegate delegate)
Set a delegate to receive billing lifecycle callbacks (purchases, failures, restores).
-
-
-
-