---
title: "refundTransaction(identifier:)"
framework: storekittest
role: symbol
role_heading: Instance Method
path: "storekittest/sktestsession/refundtransaction(identifier:)"
---

# refundTransaction(identifier:)

Simulates a refund for an in-app purchase that completes outside of the app.

## Declaration

```swift
func refundTransaction(identifier: Int) throws
```

## Parameters

- `identifier`: The transaction doc://com.apple.storekittest/documentation/StoreKitTest/SKTestTransaction/identifier of an in-app purchase to get a refund.

## Discussion

Discussion In the testing environment, the system always approves refund requests, and processes them immediately. You can choose the reason for the refund by using beginRefundRequest(in:) in your app and selecting a reason. (Your app may also use beginRefundRequest(for:in:), beginRefundRequest(in:), or beginRefundRequest(in:).  If your app uses SwiftUI, it may use refundRequestSheet(for:isPresented:onDismiss:).) Otherwise, the refund reason defaults to other. After calling this function, handle the new transaction in updates or in your payment queue. Look for the revocationDate and revocationReason properties, which indicate the refund.

## See Also

### Testing externally performed transactions

- [buyProduct(productIdentifier:)](storekittest/sktestsession/buyproduct(productidentifier:).md)
