Mac Developer Library

Developer

StoreKit Framework Reference SKPaymentTransaction Class Reference

Options
Deployment Target:

On This Page
Language:

SKPaymentTransaction

Inheritance


Conforms To


Import Statement


Swift

import StoreKit

Objective-C

@import StoreKit;

Availability


Available in OS X v10.7 and later.

The SKPaymentTransaction class defines objects residing in the payment queue. A payment transaction is created whenever a payment is added to the payment queue. Transactions are delivered to your application when the App Store has finished processing the payment. Completed transactions provide a receipt and transaction identifier that your application can use to save a permanent record of the processed payment.

  • error error Property

    An object describing the error that occurred while processing the transaction. (read-only)

    Declaration

    Swift

    var error: NSError! { get }

    Objective-C

    @property(readonly) NSError *error

    Discussion

    The error property is undefined except when transactionState is set to SKPaymentTransactionStateFailed. Your application can read the error property to determine why the transaction failed. For a list of error constants, see SKErrorDomain in StoreKit Constants Reference.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • payment payment Property

    The payment for the transaction. (read-only)

    Declaration

    Swift

    var payment: SKPayment! { get }

    Objective-C

    @property(readonly) SKPayment *payment

    Discussion

    Each payment transaction is created in response to a payment that your application added to the payment queue.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • The current state of the transaction. (read-only)

    Declaration

    Swift

    var transactionState: SKPaymentTransactionState { get }

    Objective-C

    @property(readonly) SKPaymentTransactionState transactionState

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • A string that uniquely identifies a successful payment transaction. (read-only)

    Declaration

    Swift

    var transactionIdentifier: String! { get }

    Objective-C

    @property(readonly) NSString *transactionIdentifier

    Discussion

    The contents of this property are undefined except when transactionState is set to SKPaymentTransactionStatePurchased or SKPaymentTransactionStateRestored. The transactionIdentifier is a string that uniquely identifies the processed payment. Your application may wish to record this string as part of an audit trail for App Store purchases. See In-App Purchase Programming Guide for more information.

    The value of this property corresponds to the Transaction Identifier property in the receipt.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • The date the transaction was added to the App Store’s payment queue. (read-only)

    Declaration

    Swift

    var transactionDate: NSDate! { get }

    Objective-C

    @property(readonly) NSDate *transactionDate

    Discussion

    The contents of this property are undefined except when transactionState is set to SKPaymentTransactionStatePurchased or SKPaymentTransactionStateRestored.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • downloads downloads Property

    An array of download objects representing the downloadable content associated with the transaction. (read-only)

    Declaration

    Swift

    var downloads: [AnyObject]! { get }

    Objective-C

    @property(readonly) NSArray *downloads

    Discussion

    The contents of this property are undefined except when transactionState is set to SKPaymentTransactionStatePurchased. The SKDownload objects stored in this property must be used to download the transaction’s content before the transaction is finished. After the transaction is finished, the download objects are no longer queueable.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.8 and later.

  • The transaction that was restored by the App Store. (read-only)

    Declaration

    Swift

    var originalTransaction: SKPaymentTransaction! { get }

    Objective-C

    @property(readonly) SKPaymentTransaction *originalTransaction

    Discussion

    The contents of this property are undefined except when transactionState is set to SKPaymentTransactionStateRestored. When a transaction is restored, the current transaction holds a new transaction identifier, receipt, and so on. Your application will read this property to retrieve the restored transaction.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • The state of a transaction.

    Declaration

    Swift

    typealias SKPaymentTransactionState = Int

    Objective-C

    enum { SKPaymentTransactionStatePurchasing, SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestored, SKPaymentTransactionStateDeferred, }; typedef NSInteger SKPaymentTransactionState;

    Constants

    • SKPaymentTransactionStatePurchasing

      SKPaymentTransactionStatePurchasing

      The transaction is being processed by the App Store.

      Available in OS X v10.7 and later.

    • SKPaymentTransactionStatePurchased

      SKPaymentTransactionStatePurchased

      The App Store successfully processed payment. Your application should provide the content the user purchased.

      Available in OS X v10.7 and later.

    • SKPaymentTransactionStateFailed

      SKPaymentTransactionStateFailed

      The transaction failed. Check the error property to determine what happened.

      Available in OS X v10.7 and later.

    • SKPaymentTransactionStateRestored

      SKPaymentTransactionStateRestored

      This transaction restores content previously purchased by the user. Read the originalTransaction property to obtain information about the original purchase.

      Available in OS X v10.7 and later.

    • SKPaymentTransactionStateDeferred

      SKPaymentTransactionStateDeferred

      The transaction is in the queue, but its final status is pending external action such as Ask to Buy. Update your UI to show the deferred state, and wait for another callback that indicates the final status.

      Available in OS X v10.10 and later.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.