SKPayment Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/StoreKit.framework
Availability
Available in OS X v10.7 and later.
Companion guide
Declared in
SKPayment.h

Overview

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.

Tasks

Creating Instances

Getting Attributes

Properties

applicationUsername

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

@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.

Availability
  • Available in OS X v10.9 and later.
Declared In
SKPayment.h

productIdentifier

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

@property(nonatomic, copy, readonly) NSString *productIdentifier
Discussion

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

Availability
  • Available in OS X v10.7 and later.
Declared In
SKPayment.h

quantity

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

@property(nonatomic, readonly) NSInteger quantity
Discussion

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

Availability
  • Available in OS X v10.7 and later.
Declared In
SKPayment.h

requestData

Reserved for future use. (read-only)

@property(nonatomic, copy, readonly) NSData *requestData
Discussion

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

Availability
  • Available in OS X v10.7 and later.
Declared In
SKPayment.h

Class Methods

paymentWithProduct:

Returns a new payment for the specified product.

+ (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];
Availability
  • Available in OS X v10.7 and later.
Declared In
SKPayment.h