Skip to content

Google Play Billing integration — subscription (playstore flavor) #5

Description

@Pivii

Context

For the playstore flavor (Google Play Store distribution), Pro features are unlocked via a monthly subscription through Google Play Billing Library. This targets the mainstream Android audience.

Architecture

User taps "Upgrade to Pro"
  → App launches Google Play purchase flow (native UI)
  → User pays via Play Store (card, Google Pay, etc.)
  → BillingClient confirms purchase
  → App verifies purchase locally
  → isPro = true, stored in DataStore
  → Subscription auto-renews monthly

Key properties

  • No server required: Google handles billing, receipt validation can be local
  • Subscription model: Monthly (pricing TBD, likely ~2-3€/month)
  • Yearly option: Optional discounted annual plan
  • Restore: BillingClient.queryPurchasesAsync() on app start

What to implement

1. PlayStoreUnlocker in app/src/playstore/

class PlayStoreUnlocker(
    private val context: Context,
    private val dataStore: DataStore<Preferences>
) : ProUnlocker {

    private val billingClient = BillingClient.newBuilder(context)
        .setListener(purchasesUpdatedListener)
        .enablePendingPurchases()
        .build()

    override val isPro: StateFlow<Boolean>

    override fun launchPurchase(activity: Activity) {
        // Query product details → launch billing flow
    }

    override suspend fun restorePurchase(): Boolean {
        // queryPurchasesAsync → check for active subscription
    }
}

2. Play Console setup

  • Create Google Play Developer account (25$ one-time)
  • Create app listing for Dictus
  • Configure subscription product ("dictus_pro_monthly", "dictus_pro_yearly")
  • Upload playstore-release APK (or AAB)
  • Set up internal testing track first

3. Subscription products

Product ID Type Price Notes
dictus_pro_monthly Subscription ~2-3€/mo Main offer
dictus_pro_yearly Subscription ~20-25€/yr Optional discount

Pricing TBD — can be adjusted in Play Console without app update.

4. Paywall screen

  • Show Pro features with descriptions
  • Monthly / Yearly toggle
  • "Subscribe" button → native Play purchase flow
  • "Restore purchase" link
  • Terms of service / privacy policy links (required by Google)

Acceptance criteria

  • PlayStoreUnlocker implements ProUnlocker in playstore flavor
  • BillingClient connects and queries products
  • Purchase flow launches and completes
  • Subscription status persisted in DataStore
  • Restore purchase works on fresh install
  • Paywall screen with feature list and pricing

Prerequisites

  • Google Play Developer account created
  • App listing created on Play Console
  • At least one subscription product configured
  • Depends on: #1 (playstore flavor), Gradle product flavors: libre + playstore #2 (ProUnlocker interface)

Notes

  • Google takes 30% commission (15% for first $1M/year under Small Business program)
  • Play Billing Library v6+ required
  • Must handle edge cases: pending purchases, subscription paused, account hold

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions