PaymentQueue: (SKPaymentQueue *) queue updatedTransactions: (NSArray *) of the transaction is not called upon recovery of CompleteTransactions

Hi, I need to implement the restore function in Inapp-Purchase, the "Restore" button is made for this, which calls the method

-(void)restorePurchasedProductsWithProductId:(NSString*)prodID { _productIdsArray = [[NSMutableArray alloc] init]; productID = [prodID retain]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; } 

This gives me a popup for entering the apple id password. And after that, nothing happens.

I read somewhere that it causes

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions 

So i liked this

 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { NSLog(@"paymentQueue"); for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchased: [self completeTransaction:transaction]; break; case SKPaymentTransactionStateFailed: [self failedTransaction:transaction]; break; case SKPaymentTransactionStateRestored: NSLog(@"restored"); [self restoreTransaction:transaction]; break; default: break; } } } 

But the problem is that the above method does not call this

 - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue 

and

 -(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error 

I also included the necessary protocols,

Can any body help me why these delegation methods do not trigger the recovery process. I am trying using a test account.

+7
source share
2 answers

You need to make sure that the class that implements paymentQueueRestoreCompletedTransactionsFinished: and paymentQueue: restoreCompletedTransactionsFailedWithError: is registered as an observer for your payment queue.

If you wrote this code in a UIViewController , try adding it to your viewDidLoad :

 [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; 

and in viewDidDisappear :

 [[SKPaymentQueue defaultQueue] removeTransactionObserver:self]; 
+11
source

I also run into a problem like:

After research and modification, I realized that:

 [[SKPaymentQueue defaultQueue] finishTransaction:transaction] 

the method is not executed immediately.

I usually check transaction.transactionReceipt and send it to my server, and after all I send a callback to complete the transaction. Finally, I realized that the problem was not the immediate completion of the transaction. When I change my code, my application works.

The interesting part was when I test the sandbox environment, everything works fine. However, the AppStore application does not work. When I made this modification, my problem was resolved.

+1
source

All Articles