DiscountOffer
DiscountOffer#
DiscountOffer is the standardized representation of a Google Play one-time product purchase option or offer. OpenIAP populates ProductAndroid.discountOffers from ProductDetails.getOneTimePurchaseOfferDetailsList() on Google Play Billing Library 8.0+.
Each entry maps to ProductDetails.OneTimePurchaseOfferDetails and has the wire type one-time. Subscription introductory and promotional offers use SubscriptionOffer instead. iOS does not populate DiscountOffer.
Native references: Google · Multiple purchase options and offers for one-time products · ProductDetails.OneTimePurchaseOfferDetails
Common Fields#
| Field | Type | Description |
|---|---|---|
id | ID | Unique identifier for the offer |
displayPrice | String! | Formatted display price (e.g., "$4.99") |
price | Float! | Numeric price value |
currency | String! | Currency code (ISO 4217, e.g., "USD") |
type | DiscountOfferType! | Always one-time for DiscountOffer entries. The shared enum's introductory and promotional variants are used by SubscriptionOffer. |
Android-Specific Fields#
| Field | Type | Description |
|---|---|---|
offerTokenAndroid | String | Required for purchase. Pass to requestPurchase() |
offerTagsAndroid | [String!] | Tags associated with this offer |
fullPriceMicrosAndroid | String | Original price in micro-units (divide by 1,000,000) |
percentageDiscountAndroid | Int | Percentage discount (e.g., 33 for 33% off) |
discountAmountMicrosAndroid | String | Fixed discount amount in micro-units |
formattedDiscountAmountAndroid | String | Localized discount amount including the currency symbol (e.g., "$5.00") |
validTimeWindowAndroid | ValidTimeWindowAndroid | Time window for limited-time offers |
limitedQuantityInfoAndroid | LimitedQuantityInfoAndroid | Quantity limits for the offer |
preorderDetailsAndroid | PreorderDetailsAndroid | Pre-order details (Billing Library 8.1.0+) |
rentalDetailsAndroid | RentalDetailsAndroid | Rental offer details |
purchaseOptionIdAndroid | String | Purchase option ID for identifying which purchase option was selected (8.0+) |
Type Definition#
swift
struct DiscountOffer: Codable {
// Common fields
let id: String?
let displayPrice: String
let price: Double
let currency: String
let type: DiscountOfferType
// Android-specific fields
let offerTokenAndroid: String?
let offerTagsAndroid: [String]?
let fullPriceMicrosAndroid: String?
let percentageDiscountAndroid: Int?
let discountAmountMicrosAndroid: String?
let formattedDiscountAmountAndroid: String?
let validTimeWindowAndroid: ValidTimeWindowAndroid?
let limitedQuantityInfoAndroid: LimitedQuantityInfoAndroid?
let preorderDetailsAndroid: PreorderDetailsAndroid?
let rentalDetailsAndroid: RentalDetailsAndroid?
let purchaseOptionIdAndroid: String?
}
enum DiscountOfferType: String, Codable {
case introductory = "introductory"
case promotional = "promotional"
case oneTime = "one-time"
}