OneTimeOfferInfo

data class OneTimeOfferInfo(val productId: String, val offerId: String?, val purchaseOptionId: String?, val offerToken: String, val offerTags: List<String>, val formattedPrice: String, val priceMicros: Long, val currencyCode: String, val fullPriceMicros: Long?, val discountPercentage: Int?, val discountAmountMicros: Long?, val formattedDiscountAmount: String?, val discountCurrencyCode: String?, val rentalPeriod: String?, val rentalExpirationPeriod: String?, val preorderReleaseTimeMillis: Long, val preorderPresaleEndTimeMillis: Long, val maximumQuantity: Int, val remainingQuantity: Int, val validFromMillis: Long, val validUntilMillis: Long, val raw: ProductDetails.OneTimePurchaseOfferDetails)

Typed view over a one-time product offer (ProductDetails.OneTimePurchaseOfferDetails), surfacing the Play Billing 9 features — discounts, rentals, pre-orders and limited quantity — as flat fields for easy UI binding.

Play Billing 9 lets a single one-time product carry multiple offers (a full price plus, say, a 30%-off launch discount). Older code paths that call ProductDetails.getOneTimePurchaseOfferDetails only ever see one of them; use AppPurchase.getOneTimeOffers to enumerate all of them and AppPurchase.purchase with an explicit offer token to buy a specific one.

Obtain instances via AppPurchase.getOneTimeOffers or AppPurchase.getOneTimeOffer — do not construct directly.

Since

4.4.0

Constructors

Link copied to clipboard
constructor(productId: String, offerId: String?, purchaseOptionId: String?, offerToken: String, offerTags: List<String>, formattedPrice: String, priceMicros: Long, currencyCode: String, fullPriceMicros: Long?, discountPercentage: Int?, discountAmountMicros: Long?, formattedDiscountAmount: String?, discountCurrencyCode: String?, rentalPeriod: String?, rentalExpirationPeriod: String?, preorderReleaseTimeMillis: Long, preorderPresaleEndTimeMillis: Long, maximumQuantity: Int, remainingQuantity: Int, validFromMillis: Long, validUntilMillis: Long, raw: ProductDetails.OneTimePurchaseOfferDetails)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

ISO-4217 currency code (e.g. "USD").

Link copied to clipboard

Absolute discount amount in micros, or null when Play reports a percentage instead.

Link copied to clipboard

ISO-4217 currency of the absolute discount amount, or null.

Link copied to clipboard

Percentage discount configured in Play Console, or null when not a discount offer.

Link copied to clipboard

Whole-percent discount against fullPriceMicros. Prefers the percentage Play reports; otherwise derives it from the full and actual prices. Returns 0 when this offer is not a discount.

Link copied to clipboard

Locale-formatted absolute discount amount, or null.

Link copied to clipboard

Locale-formatted price the user pays (e.g. "$6.99").

Link copied to clipboard

Undiscounted list price in micros when this offer is a discount, or null when the offer has no strike-through price.

Link copied to clipboard

true when this offer is priced below the product's list price.

Link copied to clipboard

true when Play caps how many of this offer can be sold.

Link copied to clipboard

true when this offer is a pre-order that has not been released yet.

Link copied to clipboard

true when this offer is a rental rather than a permanent purchase.

Link copied to clipboard

true when a limited-quantity offer has sold out.

Link copied to clipboard

Maximum quantity available for a limited-quantity offer, or 0 when unlimited.

Link copied to clipboard

Offer id from Play Console; null for the product's default offer.

Link copied to clipboard

Free-form tags configured for the offer in Play Console.

Link copied to clipboard

Opaque token passed to com.android.billingclient.api.BillingFlowParams when launching purchase.

Link copied to clipboard

Pre-order presale cut-off in epoch millis, or 0 when this is not a pre-order.

Link copied to clipboard

Pre-order release time in epoch millis, or 0 when this is not a pre-order.

Link copied to clipboard

Price the user pays, in micros (price × 1,000,000).

Link copied to clipboard

Play product id this offer belongs to.

Link copied to clipboard

Purchase option id from Play Console, or null when not configured.

Link copied to clipboard
val raw: ProductDetails.OneTimePurchaseOfferDetails

Raw offer details, for fields not surfaced here.

Link copied to clipboard

Quantity still available for a limited-quantity offer, or 0 when unlimited.

Link copied to clipboard

ISO-8601 rental expiration period — how long the user has to start — or null.

Link copied to clipboard
Link copied to clipboard

ISO-8601 rental period — how long access lasts after first playback — or null.

Link copied to clipboard

rentalPeriod parsed into components, or null when this is not a rental.

Link copied to clipboard

Start of the offer's validity window in epoch millis, or 0 when unbounded.

Link copied to clipboard

End of the offer's validity window in epoch millis, or 0 when unbounded.

Functions

Link copied to clipboard
fun hasTag(tag: String): Boolean

true when this offer carries the given Play Console offer tag, matched case-insensitively.

Link copied to clipboard
fun isValidAt(nowMillis: Long = System.currentTimeMillis()): Boolean

true when nowMillis falls inside this offer's validity window. Unbounded ends are treated as always-valid.