Translations of this page:

Store object

This object can be used for accessing the 'in app purchases' functionality of iOS applications. Please read the In app purchases guide for detailed description.
While this object can be accessed on all platforms, it only works on iOS. For other platforms all the method calls will fail.

Methods

Store.EnableEvents()

This enables the reception of App Store transaction events. The transaction events will be delivered to the script which last called this method. If such script no longer exists, the devents will be delivered to the Game object.

Store.DisableEvents()

This disables the reception of App Store transaction events.

Store.ValidateProducts(productIdList)

This method sends a list of product IDs to App Store for validation. When the products are validated, a "ProductsValidated" event is triggered in the script which last called this method. After the event is triggered, the application can use the Store object for accessing valid and invalid products (see below).

The 'productIdList' parameter is a string containing list of IDs, separated by semicolon (;).

Store.GetValidProduct(index)

This method returns a description of a valid product at specified index. The 'index' parameter must be in range between 0 and (Store.NumValidProducts - 1).

The method returns an object with the following properties:

  • Id - the unique identifier of the product
  • Name - localized name of the product
  • Description - localized description of the product
  • Price - localized price of the product (for example "$0.99")

Store.GetInvalidProduct(index)

This method returns an ID of an invalid product at specified index. The 'index' parameter must be in range between 0 and (Store.NumInvalidProducts - 1).

Store.GetTransaction(index)

This method returns a description of a transaction at specified index. The 'index' parameter must be in range between 0 and (Store.NumTransactions - 1).

The method returns an object with the following properties:

  • Id - the unique identifier of the transaction
  • ProductId - the ID of the product being purchased by this transaction
  • State - the status of the transaction; it can be one of the following strings:
    • purchased - the transaction was successful and the product was purchased
    • cancelled - the user cancelled the transaction
    • failed - the transaction failed
    • restored - it is a previously handled transaction requested by Store.RestoreTransactions()

Store.Purchase(productId)

This method invokes a purchase of a specified product. The productId must be ID of one of the valid products. This method is asynchronous - it returns immediately and the application is notified of the result by the 'TransactionsUpdated' event.

Store.FinishTransaction(transactionId)

This method finalizes a transaction. Using this method the application notifies App Store that it handled a transaction. The application MUST finalize all transactions using this method; the App Store will keep redelivering any pending transactions until they are finalized.

Store.RestoreTransactions()

This method is used for requesting the redelivery of previous successful purchases. The application must allow the user to restore previous purchases, because the user might have reinstalled the application or they are using a different device.

If there are any restored transactions, the script will receive the 'TransactionsUpdated' event once they are redelivered. Also the script will always receive either the 'TransactionsRestoreFinished' or 'TransactionsRestoreFailed' events.

Store.UnlockProduct(productId)

This method marks a specified product ID as unlocked (purchased). This information is stored in application settings and is therefore available even when the application is quit and restarted.

Note that this information is lost if the user uninstalls and reinstalls the application. The application must provide means of restoring previous purchases using the Store.RestoreTransactions() method.

Store.IsProductUnlocked(productId)

This method returns true if the product with specified ID has been previously purchased.

Properties

Store.Type

Read-only. This property returns 'store'.

Store.Available

Read-only. This property returns true if the in app purchases are available. The user can disable purchases in the device Settings, in that case the application should notify the user instead of letting them continue with purchases.

Store.EventsEnabled

Read-only. This property returns true if the application requested transaction events using the Store.EnableEvents() method.

Store.NumValidProducts

Read-only. This property returns the number of valid products. This property is filled after calling Store.ValidateProducts().

Store.NumInvalidProducts

Read-only. This property returns the number of invalid products. This property is filled after calling Store.ValidateProducts().

Store.NumTransactions

Read-only. This property returns the number of active unprocessed transactions.

Events

ProductsValidated

This event is triggered after the App Store validated product IDs sent using the Store.ValidateProducts() method.

TransactionsUpdated

This event is triggered after the App Store notified the application that some new unprocessed transaction has been addeed to the transaction queue.

TransactionsRestoreFinished

This event is triggered after the Store.RestoreTransaction() has been successfully processed.

TransactionsRestoreFailed

This event is triggered after the Store.RestoreTransaction() has been called, but App Store failed to process the request.

 
wmelite/store.txt · Last modified: 2011/07/30 15:57 by Mnemonic
Recent changes RSS feed Creative Commons License Driven by DokuWiki