---
title: Transaction
framework: storekit
role: symbol
role_heading: Structure
path: storekit/transaction
---

# Transaction

Information that represents the customer’s purchase of a product in your app.

## Declaration

```swift
struct Transaction
```

## Mentioned in

Supporting offer codes in your app Supporting subscription offer codes in your app Supporting monthly subscriptions with a 12-month commitment Supporting win-back offers in your app Managing the life cycle of monthly subscriptions with a 12-month commitment Testing purchases made outside your app Testing refund requests Testing win-back offers in the sandbox environment Choosing a receipt validation technique Choosing a StoreKit API for In-App Purchases Implementing offer codes in your app Validating receipts with the App Store

## Overview

Overview A transaction represents a successful In-App Purchase. The App Store generates a transaction each time a customer purchases an In-App Purchase product or renews a subscription. For each transaction that represents a current purchase, your app unlocks the purchased content or service and finishes the transaction. Use the Transaction type to perform these transaction-related tasks: Get the customer’s transaction history, latest transactions, and current entitlements to unlock content and services. Access transaction properties. Finish a transaction after your app delivers the purchased content or service. Access the raw JSON Web Signature (JWS) string and supporting values to verify the transaction information. Listen for new transactions while the app is running. Begin a refund request from within your app. Access transaction history and current entitlements Your app doesn’t create transaction objects. Instead, StoreKit automatically makes up-to-date transactions available to your app, including when someone launches the app for the first time. note: Session 110404: Implement proactive in-app purchase restore You access transactions in several ways: Get transaction history anytime by accessing the static all sequence, or get just the most recent transaction for a product with the latestTransaction property of Product. Receive notifications for new transactions while your app is running when customers complete a purchase outside of the app, including on another device, through the transaction listener, updates. Access the latest transaction for a subscription group through the subscription status API, using transaction. After a successful In-App Purchase, StoreKit returns the transaction through Product.PurchaseResult.success(_:). The most important use of transaction information is for determining which In-App Purchases the customer has paid access to, so your app can unlock the content or service. The currentEntitlements API provides the information you need to unlock all of the customer’s paid content in your app. Use currentEntitlements to get a list of transactions for all the products the customer is currently entitled to, including non-consumable In-App Purchases and currently active subscriptions. Verify transactions The App Store cryptographically signs transaction information in JWS format. StoreKit automatically validates and returns the signed information, wrapped in a VerificationResult. When the VerificationResult wraps a Transaction value, it provides the raw JWS string in the jwsRepresentation property. If you get a transaction through VerificationResult.verified(_:), the information passed validation. If you get it through VerificationResult.unverified(_:_:), the information didn’t pass StoreKit’s automatic validation. Your app can immediately access the transaction information in the Transaction properties. To perform your own validation on the device, use the verification result’s jwsRepresentation string, and use the provided convenience properties headerData, payloadData, and signatureData. For added control and security, send the jwsRepresentation to your server to verify. Consider using the App Store Server Library to implement your verification. The library provides the functions verifyAndDecodeTransaction and verifyAndDecodeRenewalInfo in each language the library supports. For more information, see Simplifying your implementation by using the App Store Server Library. tip: The jwsRepresentation is the same as the JWSTransaction that the App Store Server API returns and to the JWSTransaction that you receive in App Store Server Notifications V2. You can validate them on your server in the same way. If StoreKit returns a transaction as verified, the transaction is valid for the device. For information about performing your own verification for a device, see deviceVerification. For more information about JWS, see the IETF RFC 7515 specification. Access purchases made with the original API All In-App Purchases that customers make are equally available to your app in this Transaction API, and in receipts using the Original API for In-App Purchase, as follows: New purchases that customers make with the original API are available immediately using the Transaction API. Purchases that customers make with the purchase(options:) method are available in the original API when your app refreshes the receipt. For more information, see SKReceiptRefreshRequest.

## Topics

### Transaction properties

- [Transaction properties](storekit/transaction-properties.md)
- [appTransactionID](storekit/transaction/apptransactionid.md)

### Monitoring transaction-related changes

- [updates](storekit/transaction/updates.md)
- [Transaction.Transactions](storekit/transaction/transactions.md)

### Getting transaction history

- [latest(for:)](storekit/transaction/latest(for:).md)
- [all](storekit/transaction/all.md)
- [unfinished](storekit/transaction/unfinished.md)
- [SKIncludeConsumableInAppPurchaseHistory](bundleresources/information-property-list/skincludeconsumableinapppurchasehistory.md)

### Getting current entitlements

- [currentEntitlements](storekit/transaction/currententitlements.md)

### Getting transactions for a product

- [all(for:)](storekit/transaction/all(for:).md)

### Finishing the transaction

- [finish()](storekit/transaction/finish().md)
- [unfinished](storekit/transaction/unfinished.md)

### Verifying transactions

- [deviceVerification](storekit/transaction/deviceverification.md)
- [deviceVerificationNonce](storekit/transaction/deviceverificationnonce.md)
- [signedDate](storekit/transaction/signeddate.md)

### Getting transaction info in JSON format

- [jsonRepresentation](storekit/transaction/jsonrepresentation.md)

### Requesting refunds

- [Testing refund requests](storekit/testing-refund-requests.md)
- [beginRefundRequest(in:)](storekit/transaction/beginrefundrequest(in:)-9k0pj.md)
- [beginRefundRequest(in:)](storekit/transaction/beginrefundrequest(in:)-63bvd.md)
- [beginRefundRequest(for:in:)](storekit/transaction/beginrefundrequest(for:in:)-65tph.md)
- [beginRefundRequest(for:in:)](storekit/transaction/beginrefundrequest(for:in:)-9mscy.md)
- [Transaction.RefundRequestError](storekit/transaction/refundrequesterror.md)
- [Transaction.RefundRequestStatus](storekit/transaction/refundrequeststatus.md)

### Advanced Commerce transaction data

- [advancedCommerceInfo](storekit/transaction/advancedcommerceinfo-swift.property.md)
- [Transaction.AdvancedCommerceInfo](storekit/transaction/advancedcommerceinfo-swift.struct.md)

### Getting offer types

- [Transaction.OfferType](storekit/transaction/offertype-swift.struct.md)

### Deprecated

- [currentEntitlement(for:)](storekit/transaction/currententitlement(for:).md)
- [currentEntitlements(for:)](storekit/transaction/currententitlements(for:).md)
- [offerPeriodStringRepresentation](storekit/transaction/offerperiodstringrepresentation.md)

### Structures

- [Transaction.CommitmentInfo](storekit/transaction/commitmentinfo-swift.struct.md)
- [Transaction.RevocationType](storekit/transaction/revocationtype-swift.struct.md)

### Instance Properties

- [billingPlanType](storekit/transaction/billingplantype.md)
- [bundleOriginalTransactionID](storekit/transaction/bundleoriginaltransactionid.md)
- [bundleProductID](storekit/transaction/bundleproductid.md)
- [bundleSubscriptionGroupID](storekit/transaction/bundlesubscriptiongroupid.md)
- [bundleTransactionID](storekit/transaction/bundletransactionid.md)
- [commitmentInfo](storekit/transaction/commitmentinfo-swift.property.md)
- [previousOriginalTransactionID](storekit/transaction/previousoriginaltransactionid.md)
- [revocationPercentage](storekit/transaction/revocationpercentage.md)
- [revocationType](storekit/transaction/revocationtype-swift.property.md)
- [revocationTypeStringRepresentation](storekit/transaction/revocationtypestringrepresentation.md)

## Relationships

### Conforms To

- [Copyable](swift/copyable.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [Hashable](swift/hashable.md)
- [Identifiable](swift/identifiable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Transaction history and entitlements

- [updates](storekit/transaction/updates.md)
- [all](storekit/transaction/all.md)
- [currentEntitlements](storekit/transaction/currententitlements.md)
