4
votes

Problem: I call [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; And it return to my observer paymentQueueRestoreCompletedTransactionsFinished: SKPaymentQueue with empty transactions array. But I have purchased non-consumable in-apps.

I'm testing how my app could restore purchases from different states.

Simple steps to reproduce:

  1. Add payment and complete purchase. The queue returns SKPaymentTransactionStatePurchased transaction, so the app enables feature and finalize transaction in queue.
  2. Remove information about purchase, so I can re-purchase. (imagine, that a user reinstalled the app, or start using the app on another device)
  3. Try to purchase in-app again. receive "You've already purchased this. Tap OK to download it again for free.". Press OK, and the queue returns SKPaymentTransactionStatePurchased transaction, so the app enables feature and finalizes the transaction in queue.
  4. Remove information about purchase again.
  5. Try to purchase in-app once again. Receive "You've already purchased this In-App Purchase but it hasn't been downloaded.". There is only one OK button, and even before you could press it, you'll receive transaction with state SKPaymentTransactionStateFailed. The app finalizes the transaction, but it won't enable feature when transaction is failed.
  6. Finally try to restore completed transactions with [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];. And it return to observer paymentQueueRestoreCompletedTransactionsFinished: SKPaymentQueue with empty transactions array.

I feel that something is broken in Apple Sandbox servers, so I can't restore transactions correctly. Or am I doing something wrong?

1
Have you tried with real device and deleted the old app first? - lk_vc
sure, I'm testing on real device. And I reinstalled the app, and I created new test account for purchases testing. - Evgen Bodunov
have you figured out how to solve this? thanks. - Duck

1 Answers

2
votes

Since you have done the purchase in step 3, it is not necessary to restore that purchase IMHO.

Step 2 and 4 is not the same as user reinstall the app because the app is up and running so SKPayment may do something to reduce server load. You'd better try with delete the app, and install, then use restoreCompletedTransactions immediately to restore the purchases.


My old answer:

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue is called AFTER all restorable transactions have been processed by the payment queue. It just tells you the restoration process is done.

For each restorable purchase, - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions will be called, and you need to deal with each transaction in transactions that transaction.transactionState being SKPaymentTransactionStateRestored.