About use of SKReceiptRefreshRequest

I lost receipt data with following steps.


  1. Purchased a consumable IAP item In Sandbox environment.
  2. Terminate app before SKPaymentTransaction is finished.
  3. In addition, I delete app and re-install. (This is KEY action)
  4. Launch app and receive an above transaction (not finish yet)
  5. Get receipt using NSBundle#appStoreURL method but No receipt data exist.


I want to get receipt data.

I found some way to get it but I dont know whether that way is correct or not.


  • Solution-1: Request with SKReiectRefreshRequest. After that, I can get receipt data using NSBundle#appStoreURL
  • Solution-2: Request with SKPaymentQueue#restoreTransaction. I know it usualy use to restore non-consumable item's receipt. But it works fine.
  • Solution-3: Purchase other item. Somehow I can get receipt data.


I think Solution-1 is most natural. ( But I think it is for Volume Purchase or auto-renewal item )


Is my use of SKReiectRefreshRequest correct ?

or can you tell me other good solution ?

If you check the receipt in the updatedTransactions method and it is not there then that is a serious bug, please report it!


Here is a work around for that bug - in updatedTransactions check to see if the receipt exists. If it does, fine. If it does not exist then do a SKReiectRefreshRequest. However, this should not be necessary.

PBK

Thank you for your reply


http://devstreaming.apple.com/videos/wwdc/2013/308xex4x6ybggtlw4ztv0sg5btp/308/308.pdf?dl=1


Above presentation , WWDC 2013 Session 308 "Using Receipts to Protect Your Digital Sales", say following.


>> If the receipt doesn’t exist or is invalid

>> Refresh the receipt using Store Kit


I think the receipt doesn't exist in a specified situation. For example a reinstall while purchasing.

I dont know this behavior is a bug or not. But I satisfied that my solution is not wrong.


You described a sequence of events in the sandbox such that the purchase of a consumable item is not completed with the finishTransaction call by the application. You then re-install the application, launch it, and it appears that the addTransactionObserver call results in the notification to the user that there is a pending successful transaction - the consumable purchase to be processed. The interesting part of the process is that on inspection of the application receipt at appStoreURL, that the item is not in the application receipt in the in_app array.


On this issue, it's important to verify that the app waited until the call to the updatedTransactions delegate method before checking the application receipt. The application receipt should be updated before the call to the delegate method. In this case, a consumable item should appear in the in_app array. The consumable item appears in the in_app array until the application completes the purchase process by calling finishTransaction.


In the case that the item is not in the in_app array, the app can present an alert to the effect that there appears to be a problem with the receipt and ask the user whether to refresh the receipt. When the user agrees, then make the SKReceiptRefreshRequest. If the in_app array remains empty, there's a problem, but don't call finishTransaction on a transaction you can't validate actually occurred (at least by it's presence in the in_app array).


You mentioned using the restoreCompletedTransactions method and finding that the method worked - it should have for 2 reasons, restoreCompletedTransactions isn't designed to restore consumable transactions types (as you noted) and it doesn't restore any transactions which are pending (you stated that the finishTransaction method had not been called).


However, a restoreCompletedTransaction call will cause the application receipt to be updated - maybe this is what you meant. In updating the receipt, this will cause the application receipt to be updated and a pending consumable item that is pending, will be present in the in_app array - again, maybe this is what you refer to - this is what the SKReceiptRefreshRequest does.


You also suggested buying another item - this again will trigger the receipt to be updated - which again is something that SKREceitRefreshRequest would do.


rich kubota - rkubota@apple.com

developer technical support CoreOS/Hardware/MFI

rich


Thank you for reply.

I have released new version app using SKReceiptRefreshRequest (Solution-1).

It looks like to work fine.

About use of SKReceiptRefreshRequest
 
 
Q