---
title: "buyProduct(productIdentifier:)"
framework: storekittest
role: symbol
role_heading: Instance Method
path: "storekittest/sktestsession/buyproduct(productidentifier:)"
---

# buyProduct(productIdentifier:)

Simulates buying an in-app purchase or subscription outside the app.

## Declaration

```swift
func buyProduct(productIdentifier: String) throws
```

## Parameters

- `productIdentifier`: Product identifier of the in-app purchase.

## Discussion

Discussion After calling this function, handle the new transaction in your payment queue.

## See Also

### Testing externally performed transactions

- [refundTransaction(identifier:)](storekittest/sktestsession/refundtransaction(identifier:).md)
