<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StoreKit",
  "identifier" : "/documentation/StoreKit/Product/PurchaseOption",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "StoreKit"
    ],
    "preciseIdentifier" : "s:8StoreKit7ProductV14PurchaseOptionV"
  },
  "title" : "Product.PurchaseOption"
}
-->

# Product.PurchaseOption

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

```
struct PurchaseOption
```

## Overview

Associate purchase options with an in-app purchase when you call the methods to initiate a purchase, such as [`purchase(options:)`](/documentation/StoreKit/Product/purchase(options:)) or [`purchase(confirmIn:options:)`](/documentation/StoreKit/Product/purchase(confirmIn:options:)-6dj6y). Use the testing-specific options with <doc://com.apple.documentation/documentation/StoreKitTest> 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 ``doc://com.apple.storekit/documentation/StoreKit/StoreKitError`` or ``doc://com.apple.storekit/documentation/StoreKit/Product/PurchaseError``.

### Use purchase options during testing

In the sandbox testing environment, use [`simulatesAskToBuyInSandbox(_:)`](/documentation/StoreKit/Product/PurchaseOption/simulatesAskToBuyInSandbox(_:)) to test Ask To Buy scenarios.

In the Xcode testing environment with <doc://com.apple.documentation/documentation/StoreKitTest>, use the following testing-specific purchase options when you call <doc://com.apple.documentation/documentation/StoreKitTest/SKTestSession/buyProduct(identifier:options:)>:

- Use [`codeOffer(referenceName:)`](/documentation/StoreKit/Product/PurchaseOption/codeOffer(referenceName:)) and [`promotionalOffer(id:)`](/documentation/StoreKit/Product/PurchaseOption/promotionalOffer(id:)) to simulate customers redeeming the offers.
- Use [`purchaseDate(_:renewalBehavior:)`](/documentation/StoreKit/Product/PurchaseOption/purchaseDate(_:renewalBehavior:)) to control the transaction date and subscription renewal behavior.

## Topics

### Setting the purchase options

[`appAccountToken(_:)`](/documentation/StoreKit/Product/PurchaseOption/appAccountToken(_:))

Sets a UUID to associate the purchase with an account in your system.

[`winBackOffer(_:)`](/documentation/StoreKit/Product/PurchaseOption/winBackOffer(_:))

Sets a win-back offer to apply to the purchase.

[`promotionalOffer(offerID:keyID:nonce:signature:timestamp:)`](/documentation/StoreKit/Product/PurchaseOption/promotionalOffer(offerID:keyID:nonce:signature:timestamp:))

Applies a promotional offer for an auto-renewable subscription.

[`promotionalOffer(offerID:signature:)`](/documentation/StoreKit/Product/PurchaseOption/promotionalOffer(offerID:signature:))

[`quantity(_:)`](/documentation/StoreKit/Product/PurchaseOption/quantity(_:))

Indicates the quantity of items the customer is purchasing.

### Specifying the behavior for storefront changes

[`onStorefrontChange(shouldContinuePurchase:)`](/documentation/StoreKit/Product/PurchaseOption/onStorefrontChange(shouldContinuePurchase:))

Indicates whether a transaction needs to continue if the App Store storefront changes on the device during the transaction.

### Specifying eligibility for an introductory offer

[`introductoryOfferEligibility(compactJWS:)`](/documentation/StoreKit/Product/PurchaseOption/introductoryOfferEligibility(compactJWS:))

Set the eligibility of an introductory offer for a purchase.

### Setting options for StoreKit Testing in Xcode

[`purchaseDate(_:renewalBehavior:)`](/documentation/StoreKit/Product/PurchaseOption/purchaseDate(_:renewalBehavior:))

Sets the purchase date for the transaction in the testing environment, and indicates the renewal behavior for an auto-renewable subscription.

[`Product.PurchaseOption.SubscriptionRenewalBehavior`](/documentation/StoreKit/Product/PurchaseOption/SubscriptionRenewalBehavior)

Renewal options for auto-renewable subscriptions that you purchase in the testing environment.

[`codeOffer(referenceName:)`](/documentation/StoreKit/Product/PurchaseOption/codeOffer(referenceName:))

Sets an offer code for the transaction in the testing environment.

[`promotionalOffer(id:)`](/documentation/StoreKit/Product/PurchaseOption/promotionalOffer(id:))

Sets a promotional offer for the transaction in the testing environment.

### Setting options for sandbox testing

[`simulatesAskToBuyInSandbox(_:)`](/documentation/StoreKit/Product/PurchaseOption/simulatesAskToBuyInSandbox(_:))

Simulates an Ask to Buy scenario when testing your app in the sandbox environment.

### Setting custom purchase options

[`custom(key:value:)`](/documentation/StoreKit/Product/PurchaseOption/custom(key:value:)-80cvh)

Adds data for a custom key to a purchase.

[`custom(key:value:)`](/documentation/StoreKit/Product/PurchaseOption/custom(key:value:)-3g3nc)

Adds a string for a custom key to a purchase.

[`custom(key:value:)`](/documentation/StoreKit/Product/PurchaseOption/custom(key:value:)-8tjim)

Adds a Boolean value for a custom key to a purchase.

[`custom(key:value:)`](/documentation/StoreKit/Product/PurchaseOption/custom(key:value:)-7rju9)

Adds a number for a custom key to a purchase.

### Type Methods

[`promotionalOffer(_:compactJWS:)`](/documentation/StoreKit/Product/PurchaseOption/promotionalOffer(_:compactJWS:))

Apply a promotional offer to a purchase.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)