Skip to content
Baggers edited this page Nov 7, 2016 · 8 revisions

Property

canMakePayments

Returns: bool

Returns true if the user can make purchases or false otherwise.

This will be false in cases such as parental restrictions on the device.

Functions

requestProducts([productID0, productID1, .. etc])

Returns: Promise<RequestProductResult> object

Takes a single array of strings. Those strings must be products IDs as defined on iTunesConnect.

The function will return a promise which will resolved to a RequestProductResult. That object contains the details of the products that can be bought and a list of all the ones that cannot.

See the Retrieving Product Information section of the User Guide for more details.

addPayment(productID)

Returns: Promise<SKPaymentTransactionInfo>

addPayment(productID, applicationUserName)

Returns: Promise<SKPaymentTransactionInfo>

This will attempt a purchase of the product named by the productID.

The optional applicationUserName argument is used when you want to assist Apple's fraud detection systems. See the Detecting Irregular Activity section of the User Guide for more details

restoreTransactions()

Returns: Promise<Array<SKPaymentTransactionInfo>>

restoreTransactions(applicationUserName)

Returns: Promise<Array<SKPaymentTransactionInfo>>

This sends a request to the App Store to restore all of your app’s completed transactions. The App Store generates a new transaction for each transaction that was previously completed.

See the Restoring Purchased Products section of the User Guide for more details

The optional applicationUserName argument is used when you want to assist Apple's fraud detection systems. See the Detecting Irregular Activity section of the User Guide for more details

refreshReciept()

Returns: Promise<string>

Refreshing the receipt asks the App Store for the latest copy of the receipt. Refreshing a receipt does not create any new transactions. Although you should avoid refreshing multiple times in a row, this action would have same result as refreshing it just once.

The string will be success on success and can be safely ignored

See the Restoring Purchased Products section of the User Guide for more details

getReceiptTransactions()

Returns: Array<ReceiptTransactionInfo>

Use this to get all the information the app has on what has been purchased.

This does not require any interaction from the user.

Data Layouts

These are actually just plain old objects with fields, but we give them names here for convenience.

enum - TransactionState

One of the following strings:

  • "Purchasing"
  • "Purchased"
  • "Failed"
  • "Restored"
  • "Deferred"

Data - SKPaymentInfo

  • productIdentifier: string
  • quantity: int
  • applicationUsername: string

Data - SKPaymentTransactionInfo

An object with the following fields

  • payment: A SKPaymentInfo object
  • transactionState: a TransactionState string
  • transactionIdentifier: string
  • transactionDateUTC: string UTC time in ISO-8601 format
  • error: null or a string

Data - ReceiptTransactionInfo

An object with the following fields

  • quantity: int
  • productIdentifier: string
  • transactionIdentifier: string
  • originalTransactionIdentifier: `string
  • purchaseDate: string UTC time in ISO-8601 format
  • originalPurchaseDate: string UTC time in ISO-8601 format
  • subscriptionExpirationDate: string UTC time in ISO-8601 format
  • cancellationDate: string UTC time in ISO-8601 format
  • webOrderLineItemID: int

Data - SKProductInformation

An object with the following fields

  • price: string
  • priceLocale: string
  • localizedDescription: string
  • productIdentifier: string
  • localizedTitle: string

Data - RequestProductResult

An object with the following fields:

  • valid: an array of SKProductInformation. These are the successfully validated products
  • invalid: an array of strings. These are the ids of the invalid products