shekhar23/claude-zero-to-hero-android-kmp/android-in-app-purchases
Claude Code and agent skill by shekhar23/claude-zero-to-hero-android-kmp
- community
Checking that the SKILL.md file is still in the repository.
In-app purchase patterns for Android using Play Billing Library 6+ - BillingClient connection lifecycle, one-time products and subscriptions, purchase flow with PurchasesUpdatedListener, server-side verification, acknowledging and consuming purchases, pending purchase handling, and exposing entitlement state via a repository-backed Flow. Use this skill whenever implementing consumable items, one-time purchases, subscription flows, or purchase restoration. Trigger on phrases like "in-app purchase", "IAP", "Play Billing", "subscription", "BillingClient", "purchase flow", "entitlement", "consumable", or "one-time product".
Install
npx vskill@latest install shekhar23/claude-zero-to-hero-android-kmp/android-in-app-purchasesSKILL.md
Android In-App Purchases
Core Principles
- The BillingClient connection is a long-lived resource — manage it carefully and reconnect on disconnect.
- Never grant entitlement based on client-side purchase data alone. Always verify server-side.
- Acknowledge every non-consumable purchase within three days or Google will reverse it.
- Consume purchases only for consumable items (coins, credits, etc.) that can be re-purchased.
- Expose purchase/entitlement state as a
Flowfrom a repository; the domain and presentation layers consume it without touching the Billing API directly.
Dependencies
BillingClient Setup and Connection
The BillingClient should live in the data layer, scoped to the application lifetime:
Register BillingDataSource as a singleton in your DI module. Call disconnect() only when the app is shutting down.
Querying Available Products
Query products before showing a paywall:
Cache ProductDetails results in memory for the session lifetime. Do not query on every recomposition.
Launching the Purchase Flow
The purchase flow must be launched from an Activity:
For subscriptions, always pass an offerToken obtained from ProductDetails.subscriptionOfferDetails.
Do not launch billing flows from a ViewModel directly. The Activity reference must stay in the UI layer.
Repository Layer
Wrap the billing data source behind a clean domain interface:
The domain and presentation layers depend only on PurchaseRepository — never on BillingClient directly.
Acknowledging Purchases
Every non-consumable purchase must be acknowledged within 3 days, or Play will refund it automatically:
Acknowledge only after the server has verified and recorded the purchase.
Consuming Purchases
Consume only items the user can re-purchase (coins, one-time consumables):
Consuming a purchase removes it from the user's purchase history and makes the product available for re-purchase. Never consume subscriptions or permanent unlocks.
Server-Side Verification
Client-side purchase data can be spoofed. The server must verify every purchase before granting entitlement:
The server uses the Google Play Developer API to validate the token. The client should never trust its own Purchase object as ground truth.
Handling Pending Purchases
Purchases can be in a PENDING state (cash payments, carrier billing). Never grant entitlement for pending purchases:
Restoring Purchases
Always re-query active purchases on app startup and after a successful connection:
Call this from your Application.onCreate or when the billing client reconnects.
Exposing Entitlement State as a Flow
Use a StateFlow in the repository to make entitlement state observable:
The ViewModel observes observeEntitlements() and maps it to gated UI state:
Graceful Offline Handling
When ensureConnected() returns false, show a non-blocking error rather than crashing:
Cache the last known entitlement locally (e.g., in DataStore) so the user retains access when offline. See android-datastore-preferences for local persistence patterns.
Anti-Patterns
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-in-app-purchases/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 5
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shekhar23/claude-zero-to-hero-android-kmp/android-in-app-purchases)