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.

Common Fields#

FieldTypeDescription
idIDUnique identifier for the offer
displayPriceString!Formatted display price (e.g., "$4.99")
priceFloat!Numeric price value
currencyString!Currency code (ISO 4217, e.g., "USD")
typeDiscountOfferType!Always one-time for DiscountOffer entries. The shared enum's introductory and promotional variants are used by SubscriptionOffer.

Android-Specific Fields#

FieldTypeDescription
offerTokenAndroidStringRequired for purchase. Pass to requestPurchase()
offerTagsAndroid[String!]Tags associated with this offer
fullPriceMicrosAndroidStringOriginal price in micro-units (divide by 1,000,000)
percentageDiscountAndroidIntPercentage discount (e.g., 33 for 33% off)
discountAmountMicrosAndroidStringFixed discount amount in micro-units
formattedDiscountAmountAndroidStringLocalized discount amount including the currency symbol (e.g., "$5.00")
validTimeWindowAndroidValidTimeWindowAndroidTime window for limited-time offers
limitedQuantityInfoAndroidLimitedQuantityInfoAndroidQuantity limits for the offer
preorderDetailsAndroidPreorderDetailsAndroidPre-order details (Billing Library 8.1.0+)
rentalDetailsAndroidRentalDetailsAndroidRental offer details
purchaseOptionIdAndroidStringPurchase 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"
}