Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recover missing SKPaymentTransactions?

Tags:

ios

storekit

I have one test account that has exactly two purchases in its transaction history. Both products are Non-Consumable.

I logged in on iPad 1 and bought product A.

Then I logged out of iPad 1 and logged in on iPad 2 and bought product B.

Then I attempted to restore previous transactions using [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; to unlock product A on iPad 2.

When the call comes back, only product B is in the list of restorable transactions.

Additionally, when I attempt to buy product A again on iPad 2 using

SKPayment *payment = [SKPayment paymentWithProduct:productA];
[[SKPaymentQueue defaultQueue] addPayment:payment];

I get a popup saying 'You've already purchased this. Tap OK to download it again for free.'

If I've already purchased product A, why isn't it in the list of products when I try to restore previous purchases? Why do I have to have the user attempt to purchase it again?

EDIT:
I've discovered that it doesn't matter which iPad I use (iPad 1 or iPad 2), only product B shows up in the list of restorable transactions and product A needs to be repurchased.

EDIT:
I extrapolated the product request, restore and purchase work into its own project with the same bundle ID and product IDs as the original.

Now nothing appears in the list of restorable transactions but the same popup appears when I attempt to buy either product.

Another trip down the rabbit hole with broken Apple tools.

EDIT:
The inspiration for this investigation is a rash of user complaints about missing entitlements. This largely started to become an issue when users were switching from their iPad 2s to new iPad 3s. This isn't consistent among all my users, but enough of them have raised a stink about it to make it a priority, and Apple customer support has directed them back to me, but I'm not sure this is a problem I can fix, especially since Apple insists on being the cash register for in-app purchasing.

like image 863
Hyperbole Avatar asked May 16 '12 13:05

Hyperbole


2 Answers

I have it on good authority that this is a bug in Apple's server software somewhere.

like image 121
Hyperbole Avatar answered Nov 07 '22 06:11

Hyperbole


This message 'You've already purchased this. Tap OK to download it again for free.' is usually appear when you add a payment transaction to the default queue and didn't finish the transaction so the StoreKit suppose that the user did purchased the item but it hasn't been downloaded by your application , so make sure that you are delivered the item to the user and finish the transaction ... I'v got a way to retrieve the user purchased items and its work good for me .. try it

- (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];
  }

}

the purchasedItemIDs will contain all the product IDs that the user purchased it.

like image 25
Malek_Jundi Avatar answered Nov 07 '22 06:11

Malek_Jundi