---
title: Product.PurchaseOption
framework: storekit
role: symbol
role_heading: Structure
path: storekit/product/purchaseoption
---

# Product.PurchaseOption

Optional settings for a product purchase that add account information, purchase details, and offers, or that specify behaviors.

## Declaration

```swift
struct PurchaseOption
```

## Mentioned in

Generating JWS to sign App Store requests

## Overview

Overview Associate purchase options with an in-app purchase when you call the methods to initiate a purchase, such as purchase(options:) or purchase(confirmIn:options:). Use the testing-specific options with StoreKit Test or in the sandbox testing environment. Purchase options enable you to provide additional information for the purchase, such as an app account token, promotional offer, win back offer, and quantity. You can also use purchase options to indicate how the transaction behaves if the storefront changes, and to indicate whether the transaction is eligible for an introductory offer. important: Purchases fail if a purchase option is invalid, and can result in the purchase method throwing a StoreKitError or Product.PurchaseError. Use purchase options during testing In the sandbox testing environment, use simulatesAskToBuyInSandbox(_:) to test Ask To Buy scenarios. In the Xcode testing environment with StoreKit Test, use the following testing-specific purchase options when you call buyProduct(identifier:options:): Use codeOffer(referenceName:) and promotionalOffer(id:) to simulate customers redeeming the offers. Use purchaseDate(_:renewalBehavior:) to control the transaction date and subscription renewal behavior.

## Topics

### Setting the purchase options

- [appAccountToken(_:)](storekit/product/purchaseoption/appaccounttoken(_:).md)
- [winBackOffer(_:)](storekit/product/purchaseoption/winbackoffer(_:).md)
- [promotionalOffer(offerID:keyID:nonce:signature:timestamp:)](storekit/product/purchaseoption/promotionaloffer(offerid:keyid:nonce:signature:timestamp:).md)
- [promotionalOffer(offerID:signature:)](storekit/product/purchaseoption/promotionaloffer(offerid:signature:).md)
- [quantity(_:)](storekit/product/purchaseoption/quantity(_:).md)

### Specifying the behavior for storefront changes

- [onStorefrontChange(shouldContinuePurchase:)](storekit/product/purchaseoption/onstorefrontchange(shouldcontinuepurchase:).md)

### Specifying eligibility for an introductory offer

- [introductoryOfferEligibility(compactJWS:)](storekit/product/purchaseoption/introductoryoffereligibility(compactjws:).md)

### Setting options for StoreKit Testing in Xcode

- [purchaseDate(_:renewalBehavior:)](storekit/product/purchaseoption/purchasedate(_:renewalbehavior:).md)
- [Product.PurchaseOption.SubscriptionRenewalBehavior](storekit/product/purchaseoption/subscriptionrenewalbehavior.md)
- [codeOffer(referenceName:)](storekit/product/purchaseoption/codeoffer(referencename:).md)
- [promotionalOffer(id:)](storekit/product/purchaseoption/promotionaloffer(id:).md)

### Setting options for sandbox testing

- [simulatesAskToBuyInSandbox(_:)](storekit/product/purchaseoption/simulatesasktobuyinsandbox(_:).md)

### Setting custom purchase options

- [custom(key:value:)](storekit/product/purchaseoption/custom(key:value:)-80cvh.md)
- [custom(key:value:)](storekit/product/purchaseoption/custom(key:value:)-3g3nc.md)
- [custom(key:value:)](storekit/product/purchaseoption/custom(key:value:)-8tjim.md)
- [custom(key:value:)](storekit/product/purchaseoption/custom(key:value:)-7rju9.md)

### Type Methods

- [promotionalOffer(_:compactJWS:)](storekit/product/purchaseoption/promotionaloffer(_:compactjws:).md)
- [billingPlanType(_:)](storekit/product/purchaseoption/billingplantype(_:).md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Purchasing a product

- [purchase(options:)](storekit/product/purchase(options:).md)
- [purchase(confirmIn:options:)](storekit/product/purchase(confirmin:options:)-6dj6y.md)
- [purchase(confirmIn:options:)](storekit/product/purchase(confirmin:options:)-3bivf.md)
- [purchase(confirmIn:options:)](storekit/product/purchase(confirmin:options:)-8eai6.md)
- [Product.PurchaseResult](storekit/product/purchaseresult.md)
- [Product.PurchaseError](storekit/product/purchaseerror.md)
