Restoring in-app purchases with a user who never paid for it

I am trying to verify the purchase of an application in my application.

When I restore an in-app purchase using a test user who bought an in-app purchase, everything works fine.

But when I try to restore the purchase in the application with a user who did not , I made a purchase in the application before I expected the environment to call the following method:

-paymentQueue:restoreCompletedTransactionsFailedWithError:

but instead, the framework calls:

-paymentQueueRestoreCompletedTransactionsFinished:

how my test user already bought a purchase in the application ....

Is this normal behavior? And if so, how can I verify a user trying to recover without buying an in-app purchase?

+6
source share
3 answers

See the answer here: iOS in-app-purchase recovery returns many transactions

You will have to process it in a transaction observer.

In short, you start the recovery process with:

 [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; 

Then the following transaction observer is called:

 - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { int thisIsTheTotalNumberOfPurchaseToBeRestored = queue.transactions.count; for (SKPaymentTransaction *transaction in queue.transactions) { NSString *thisIsProductIDThatHasAlreadyBeenPurchased = transaction.payment.productIdentifier; if([thisIsProductIDThatHasAlreadyBeenPurchased isEqualToString:product1ID]) { //Enable product1 here } } } 
+7
source

Try the MKStoreKit structure https://github.com/MugunthKumar/MKStoreKit This is a pretty good, well-kept structure. I have several in-app purchases. There have never been such problems.

+1
source

@Tibidabo I would not recommend MKStoreKit, because it has a large hole in the restoration of purchased items.

0
source

Source: https://habr.com/ru/post/918377/


All Articles