Mac Developer Library

Developer

StoreKit Framework Reference SKPayment Class Reference

Options
Deployment Target:

On This Page
Language:

SKPayment

Inheritance


Conforms To


Import Statement


Swift

import StoreKit

Objective-C

@import StoreKit;

Availability


Available in OS X v10.7 and later.

The SKPayment class defines a request to the Apple App Store to process payment for additional functionality offered by your application. A payment encapsulates a string that identifies a particular product and the quantity of those items the user would like to purchase.

  • Returns a new payment for the specified product.

    Declaration

    Swift

    class func paymentWithProduct(_ product: SKProduct!) -> AnyObject!

    Objective-C

    + (id)paymentWithProduct:(SKProduct *)product

    Parameters

    product

    The product the user wishes to purchase.

    Return Value

    A new payment object.

    Discussion

    This factory method uses the productIdentifier property obtained from the product parameter to create and return a new payment with that identifier. The quantity property defaults to 1.

    To create a SKPayment object with a quantity greater than 1, create a SKMutablePayment object, adjust its quantity property and then add it to the payment queue.

    • SKMutablePayment *myPayment = [SKMutablePayment paymentWithProduct: myProduct];
    • myPayment.quantity = 2;
    • [[SKPaymentQueue defaultQueue] addPayment:myPayment];

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • A string used to identify a product that can be purchased from within your application. (read-only)

    Declaration

    Swift

    var productIdentifier: String! { get }

    Objective-C

    @property(copy, readonly) NSString *productIdentifier

    Discussion

    The product identifier is a string previously agreed on between your application and the Apple App Store.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • quantity quantity Property

    The number of items the user wants to purchase. (read-only)

    Declaration

    Swift

    var quantity: Int { get }

    Objective-C

    @property(readonly) NSInteger quantity

    Discussion

    The default value is 1, the minimum value is 1, and the maximum value is 10.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • Reserved for future use. (read-only)

    Declaration

    Swift

    @NSCopying var requestData: NSData! { get }

    Objective-C

    @property(copy, readonly) NSData *requestData

    Discussion

    The default value is nil. If requestData is not nil, your payment request will be rejected.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.7 and later.

  • An opaque identifier for the user’s account on your system. (read-only)

    Declaration

    Swift

    var applicationUsername: String! { get }

    Objective-C

    @property(nonatomic, copy, readonly) NSString *applicationUsername

    Discussion

    This is used to help the store detect irregular activity. For example, in a game, it would be unusual for dozens of different iTunes Store accounts making purchases on behalf of the same in-game character.

    The recommended implementation is to use a one-way hash of the user’s account name to calculate the value for this property.

    Import Statement

    Objective-C

    @import StoreKit;

    Swift

    import StoreKit

    Availability

    Available in OS X v10.9 and later.