Class: SKPaymentQueue
Overview
The SKPaymentQueue class provides a queue of payment transactions to be processed by the App Store. The payment queue communicates with the App Store and presents a user interface so that the user can authorize payment. The contents of the queue are persistent between launches of your app.
Instance Attribute Summary (collapse)
-
- transactions
readonly
Returns an array of pending transactions.
Class Method Summary (collapse)
-
+ canMakePayments
Returns whether the user is allowed to make payments.
-
+ defaultQueue
Returns the singleton payment queue instance.
Instance Method Summary (collapse)
-
- addPayment:
Adds a payment request to the queue.
-
- addTransactionObserver:
Adds an observer to the payment queue.
-
- cancelDownloads:
Removes a set of downloads from the download list.
-
- finishTransaction:
Completes a pending transaction.
-
- pauseDownloads:
Pauses a set of downloads.
-
- removeTransactionObserver:
Removes an observer from the payment queue.
-
- restoreCompletedTransactions
Asks the payment queue to restore previously completed purchases.
-
- resumeDownloads:
Resumes a set of downloads.
-
- startDownloads:
Adds a set of downloads to the download list.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Array) transactions (readonly)
Returns an array of pending transactions. (read-only) The value of this property is undefined when there are no observers attached to the payment queue.
Class Method Details
+ (Boolean) canMakePayments
Returns whether the user is allowed to make payments. An iPhone can be restricted from accessing the Apple App Store. For example, parents can restrict their children’s ability to purchase additional content. Your application should confirm that the user is allowed to authorize payments before adding a payment to the queue. Your application may also want to alter its behavior or appearance when the user is not allowed to authorize payments.
+ (SKPaymentQueue) defaultQueue
Returns the singleton payment queue instance. Applications do not create a payment queue. Instead, they retrieve the singleton queue by calling this class method.
Instance Method Details
- (Object) addPayment(payment)
Adds a payment request to the queue. An application should always have at least one observer of the payment queue before adding payment requests.The payment request must have a product identifier registered with the Apple App Store and a quantity greater than 0. If either property is invalid, addPayment: throws an exception.When a payment request is added to the queue, the payment queue processes that request with the Apple App Store and arranges for payment from the user. When that transaction is complete or if a failure occurs, the payment queue sends the SKPaymentTransaction object that encapsulates the request to all transaction observers.
- (Object) addTransactionObserver(observer)
Adds an observer to the payment queue. Your application should add an observer to the payment queue during application initialization. If there are no observers attached to the queue, the payment queue does not synchronize its list of pending transactions with the Apple App Store, because there is no observer to respond to updated transactions. If an application quits when transactions are still being processed, those transactions are not lost. The next time the application launches, the payment queue will resume processing the transactions. Your application should always expect to be notified of completed transactions.If more than one transaction observer is attached to the payment queue, no guarantees are made as to the order they will be called in. It is safe for multiple observers to call finishTransaction:, but not recommended. It is recommended that you use a single observer to process and finish the transaction.
- (Object) cancelDownloads(downloads)
Removes a set of downloads from the download list.
- (Object) finishTransaction(transaction)
Completes a pending transaction. Your application should call this method from a transaction observer that received a notification from the payment queue. Calling finishTransaction: on a transaction removes it from the queue. Your application should call finishTransaction: only after it has successfully processed the transaction and unlocked the functionality purchased by the user.Calling finishTransaction: on a transaction that is in the SKPaymentTransactionStatePurchasing state throws an exception.
- (Object) pauseDownloads(downloads)
Pauses a set of downloads.
- (Object) removeTransactionObserver(observer)
Removes an observer from the payment queue. If there are no observers attached to the queue, the payment queue does not synchronize its list of pending transactions with the Apple App Store, because there is no observer to respond to updated transactions.
- (Object) restoreCompletedTransactions
Asks the payment queue to restore previously completed purchases. Your application calls this method to restore transactions that were previously finished so that you can process them again. For example, your application would use this to allow a user to unlock previously purchased content onto a new device.When you create a new product to be sold in your store, you choose whether that product can be restored or not. See the In-App Purchase Programming Guide for more information.The payment queue will deliver a new transaction for each previously completed transaction that can be restored. Each transaction includes a copy of the original transaction.After the transactions are delivered, the payment queue calls the observer’s paymentQueueRestoreCompletedTransactionsFinished: method. If an error occurred while restoring transactions, the observer will be notified through its paymentQueue:restoreCompletedTransactionsFailedWithError: method.
- (Object) resumeDownloads(downloads)
Resumes a set of downloads.
- (Object) startDownloads(downloads)
Adds a set of downloads to the download list. In order for a download object to be queued, it must be associated with a transaction that has been successfully purchased, but not yet finished.