Get Purchase History / Restore Purchases

Get Purchase History

You must be able to restore your users purchases at the click of a button. This is an iOS App Store policy.

Learn more about the data this API call returns

The following is the format of data returned by this block

//iOS
[{
purchaseTime:234234234234,
originalPurchaseTime:23423423423423,
purchaseState: 2,
orderId:"adsfasfdf",
originalOrderId:"232adfa",
acknowledged: true,
productId:"rasdf",
transactionReceipt:"LONG STRING"
}]






//Android
[{
"packageName":"edu.fit.jgibb",
"productID":"new_sub",
"acknowledged":true,
"purchaseToken":"LONG STRING",
"purchaseState":1,
"orderId":"GPA.3388-2344-2345-65433",
"purchaseTIme":23423423423423424
}]

Notes about purchaseState:

0 = PURCHASING - The transaction is being processed.

1 = PURCHASED - The App Store successfully processed payment.

2 = FAILED - The transaction failed.

3 = RESTORED - iOS OnlyThis transaction restores content previously purchased by the user. Read the originalTransaction properties to obtain information about the original purchase. InAppPurchaseState.RESTORED = 3

4 = DEFERRED - iOS OnlyThe transaction has been received, but its final status is pending external action such as the Ask to Buy feature where a child initiates a new purchase and has to wait for the family organizer's approval. Update your UI to show the deferred state, and wait for another callback that indicates the final status.

A quick note on the blocks above. users have asked where the individualPurchaes variable comes from.

Get purchase history step-by-step

First show the hider to block user interaction, then call Get Purchase History

List of Purchase info will output a list of objects that are formatted like this:

[{
purchaseTime:234234234234, //this will be Epoch time in miliseconds
originalPurchaseTime:23423423423423, //this value is formatted as above
purchaseState: 2,
orderId:"adsfasfdf",
originalOrderId:"232adfa",
acknowledged: true,
productId:"YOUR_PRODUCT_IDs_WILL_BE_HERE", 
transactionReceipt:"THIS_IS_A_VERY_LONG_STRING"
}]

[{
purchaseTime:234234234234, //this will be Epoch time in miliseconds
originalPurchaseTime:23423423423423, //this value is formatted as above
purchaseState: 2,
orderId:"adsfasfdf",
originalOrderId:"232adfa",
acknowledged: true,
productId:"YOUR_PRODUCT_IDs_WILL_BE_HERE", 
transactionReceipt:"THIS_IS_A_VERY_LONG_STRING"
}]

more info on Epoch time

Last updated

Change request #1203: