Search code examples
iosstorekit

Should I call finishTransation on failed transactions during in app purchases?


I am writing an in-app purchase capability for ma iOS app. I'm selling some simple consumables (no downloads). I based my code on this tutorial/topic How do you add an in-app purchase to an iOS application? However I noticed it conflicts with official apple docs.

In this code when a Transaction fails for whatever reason, this code [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; is called. However on apple pages https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentQueue_Class/Reference/Reference.html#//apple_ref/occ/instm/SKPaymentQueue/finishTransaction: it is written: "Your application should call finishTransaction: only after it has successfully processed the transaction and unlocked the functionality purchased by the user."

So which approach is correct? Should I call finish on failed transactions?


Solution

  • According to the Apple's In-App Purchase Programming Guide

    Your app needs to finish every transaction, regardles of whether the transaction succeeded or failed.

    So regardless of the transaction result, you always finish the transaction to remove it from the payment queue and then handle the state (successful or failed) in your code in order to provide the user with the appropriate information