Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obj-C, Storekit restoreCompletedTransactions returns zero transactions?

I'm having some problems restoring completed transactions.

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

I've added the observer mentioned in several examples, I've tried adding paymentQueueRestoreCompletedTransactionsFinished and already have updatedTransactions. paymentQueueRestoreCompletedTransactionsFinished says I have zero transactions.

I can buy a product and if I try to buy again, it stops me and says I've already bought the product, using this code.

SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];

I thought maybe I had a problem with my bundle identifier, but that seems fine and the buy wouldn't work if it wasn't.

I have been trying this on the device as well as the simulator, but this has the same result. Also, it doesn't make a difference If I'm using UK or US store.

I'm really grasping at straws to find out why this doesn't work for me ?

like image 474
Jules Avatar asked Apr 12 '12 08:04

Jules


2 Answers

try to do it like this and check the array count is it return zero also ?

- (void) checkPurchasedItems
{
   [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}//You Call This Function

//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
  purchasedItemIDs = [[NSMutableArray alloc] init];

  NSLog(@"received restored transactions: %i", queue.transactions.count);
  for (SKPaymentTransaction *transaction in queue.transactions)
  {
      NSString *productID = transaction.payment.productIdentifier;
      [purchasedItemIDs addObject:productID];
  }
}
like image 116
Malek_Jundi Avatar answered Oct 21 '22 02:10

Malek_Jundi


According to the docs:

When you create a new product to be sold in your store, you choose whether that product can be restored or not.

So the question is, is your product configured to allow restores?

like image 38
brindy Avatar answered Oct 21 '22 03:10

brindy