0

I've been testing code for in-app purchases, and I can't get the transaction state to set to restored in the updatedTransactions SKPaymentTransactionObserver delegate method when it's called. When does that method call with that transaction state?

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

    for transaction in transactions {
        switch transaction.transactionState {
        // Call the appropriate custom method for the transaction state.
        case SKPaymentTransactionState.purchasing:
            showTransactionAsInProgress(transaction, deferred: false)
        case SKPaymentTransactionState.deferred:
            showTransactionAsInProgress(transaction, deferred: true)
        case SKPaymentTransactionState.failed:
            failedTransaction(transaction)
        case SKPaymentTransactionState.purchased:
            completeTransaction(transaction)
        case SKPaymentTransactionState.restored:
            restoreTransaction(transaction)
        }
    }

}
daniel
  • 1,446
  • 3
  • 29
  • 65

1 Answers1

2

You get a restored transaction if you call restoreCompletedTransactions on SKPaymentQueue and the user has restorable in-app purchases. See the reference documentation for complete details.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • The documentation says that I can mark the product in App Store as restorable. I don't see that setting anywhere. Is that something that I can only do after I have passed the review by Apple for the product, or is that implicitly set when I select the product as non-consumable? I uninstalled my app and ran my project. The !!! paymentQueueRestoreCompletedTransactionsFinished method was not called by payment queue like the documentation seemed to have said. – daniel Sep 29 '18 at 05:56
  • IAPs that aren't consumable are restorable – Paulw11 Sep 29 '18 at 07:49