Google Play / ANDROID
Subscriptions
Keep Billing client setup, product queries and purchase callbacks in one reusable Android component.
Before you start
- Configured subscription products, base plans and offers in Play Console.
- An app-owned purchase UI that displays the selected offer’s current terms.
- Trusted purchase verification, account binding and entitlement storage, plus suitable test accounts.
Connect the component
Generate the Billing component
Select Subscriptions, inspect the Billing 8 APIs and generate a component in your Android module. This integration is for subscriptions sold by your Android app.
Load current products
Connect the client and query your configured subscription ID. Render current ProductDetails and eligible offer terms in your UI. Do not assume a product or offer is always available.
Connect purchase and restore
Launch the selected offer only from a clear user action. Restore/query existing subscriptions through the same verification path. Handle pending, canceled, failed and suspended states.
Verify, then acknowledge
Send purchase tokens to your trusted backend. Grant entitlements through the verified app/backend flow and acknowledge only after verification. Close the component when its owner is destroyed.
What initialization looks like
These excerpts use the generated component’s public methods. Import your component and merge the calls into the lifecycle and callbacks shown in its generated guide.
val billing = PlayBillingClient(
context = this,
onPurchaseEvent = { result, purchases ->
// Verify purchases with your trusted backend.
}
)
billing.connect(
onReady = {
billing.querySubscription("your_product_id") { result, details ->
// Display current products and eligible offers.
}
},
onFailure = { result -> /* Report the result. */ }
)PlayBillingClient billing = new PlayBillingClient(this,
new PlayBillingClient.PurchaseListener() {
public void onPurchaseEvent(BillingResult result,
List<Purchase> purchases) {
// Verify purchases with your trusted backend.
}
});
billing.connect(() ->
billing.querySubscription("your_product_id", (result, details) -> {
// Display current products and eligible offers.
}),
result -> { /* Report the result. */ });INTEGRATION NOTES
- The component is not a purchase-verification server or a complete entitlement system.
- Acknowledgement alone does not establish that access should be granted.
- This generated Android Billing integration is separate from buying a license for the GooglePlay API IDE plugin.
Keep the official references close.
GooglePlay API maintains the component template. The SDK behavior and service requirements are defined by the provider.