purchase

open fun purchase(activity: Activity, productId: String): String

Launches the purchase flow for a product, letting the library pick the offer (the configured trial offer if any, otherwise Play's last offer).

See also

to buy one specific offer.


open fun purchase(activity: Activity, productId: String, @Nullable offerToken: String): String

Launches the purchase flow for one specific offer of a product.

Use this when the paywall shows more than one offer for the same product — a full price alongside a launch discount, or several subscription base plans — and must buy exactly the one the user tapped. Pass the token from getOfferToken or getOfferToken.

When offerToken is null this behaves exactly like purchase.

Return

a human-readable result string; "Billing flow started" on success.

Since

4.4.0

Parameters

activity

the launching activity; must not be finishing.

productId

Play product id.

offerToken

offer token to buy, or null to let the library choose.


open fun purchase(activity: Activity, @NonNull offer: OneTimeOfferInfo): String

Launches the purchase flow for the exact one-time offer described by offer.

Return

a human-readable result string; "Billing flow started" on success.

Since

4.4.0

Parameters

activity

the launching activity; must not be finishing.

offer

an offer obtained from getOneTimeOffers.


open fun purchase(activity: Activity)

Deprecated