configure(); when a user accepts an offer that leads to a purchase, Encore invokes it with the product to buy and awaits your verdict.
Definition
PurchaseRequest
What your controller receives when Encore needs a purchase.Implementations
activity you receive, and acknowledges the purchase before returning Purchased. Follow Google’s Play Billing integration guide for those steps; the contract below is everything Encore requires of you.
The contract
- One invocation returns one verdict, or throws. A returned value lands on the result record as the
publisheraxis (PublisherOutcome.Purchased/Cancelled/Pending) and onEncore.outcomes; a throw lands asPublisherOutcome.Failed. - The controller is invoked on
Dispatchers.Main.immediate. Usually this happens inside the sheet’s lifetime, so your billing UI overlays the sheet and the sheet resolves after you return. One exception: a purchase-first variant invokes your controller over your own Activity before any Encore UI exists, and returningCancelledthere means no sheet is shown and the result isNotPresented(IapFirstDeclined). - The
activityparameter is valid only for the duration of the call. Do not retain it; do notfinish()it. - A thrown exception carries your error type into analytics (
controller_threw: <Type>); cancelling your own coroutine carries only the genericcontroller_threw: CancellationException. Bound your own pre-flight steps (connecting a billing client, catalog lookups) with short timeouts; only the user-facing purchase dialog deserves long waits. - A controller that never resolves is abandoned as failed after 5 minutes. A purchase that completes late within a bounded window is still recorded and linked; beyond that, the Play server notification backstops the money facts.
Related
- configure(), which accepts the controller and defines what happens when none is registered
- PresentationResult, where the verdict lands as the
publisheraxis - Configure the SDK for the registration walkthrough
- Updating to 2.x if you are migrating an existing integration