---
title: "codeOffer(referenceName:)"
framework: storekit
role: symbol
role_heading: Type Method
path: "storekit/product/purchaseoption/codeoffer(referencename:)"
---

# codeOffer(referenceName:)

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

## Declaration

```swift
static func codeOffer(referenceName: String) -> Product.PurchaseOption
```

## Parameters

- `referenceName`: The reference name of the offer code to apply to the transaction. You need to set up offer codes in your StoreKit configuration file.

## Discussion

Discussion Use this purchase option when you test your app in Xcode using StoreKit Test and call buyProduct(identifier:options:). Set up the offer codes to use in this call in your StoreKit configuration file. For more information, see Setting up StoreKit Testing in Xcode. When you apply this option, the purchase transaction simulates a customer redeeming an offer code and includes the offer code you specify.

## See Also

### Setting options for StoreKit Testing in Xcode

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