<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onInAppPurchaseCompletion(perform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP010_StoreKit_aB0E25onInAppPurchaseCompletion7performQry0dE07ProductV_s6ResultOyAI0iM0Os5Error_pGtYacSg_tF"
  },
  "title" : "onInAppPurchaseCompletion(perform:)"
}
-->

# onInAppPurchaseCompletion(perform:)

Add an action to perform when a purchase initiated from a StoreKit view within this view completes.

```
nonisolated func onInAppPurchaseCompletion(perform action: ((Product, Result<Product.PurchaseResult, any Error>) async -> ())?) -> some View
```

## Parameters

`action`

The action to perform, with the product value and the purchase result
provided as parameters.

## Discussion

By default, transactions from successful in-app store view purchases will be emitted from
`Transaction.updates`. If the purchase fails with an error, an alert will be displayed. You can
revert a view back to this behavior by providing `nil` for action.

Only one action will be performed for each purchase. Descendant views can override the action by
using another [`onInAppPurchaseCompletion(perform:)`](/documentation/SwiftUI/View/onInAppPurchaseCompletion(perform:)) modifier.

---

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)