Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restoring an in app purchase with a user who never paid for it

I'm trying to test the in app purchase in my app.

When i restore the in app purchase with a test user who bought the in app purchase it all works fine.

But when i try to restore an in app purchase with a user who didn't make the in app purchase before i expected the framework to call the following method:

-paymentQueue:restoreCompletedTransactionsFailedWithError:

but instead the framework calls:

-paymentQueueRestoreCompletedTransactionsFinished:

like my test user already bought the in app purchase....

Is this the normal behavior? And if so, how do i test a user trying to restore without ever purchasing the in app purchase?

like image 439
Tieme Avatar asked Jun 18 '12 15:06

Tieme


People also ask

Can in-app purchases be restored?

To restore your purchases:Open the drawer from the upper left corner of the screen and select Support. Select Purchases and Paid App from the menu. Tap on the menu option, located in the upper right-hand corner of the screen. Tap on Recover Paid App.

What does restoring in-app purchases do?

Restoring purchases is a mechanism by which your user can restore their in-app purchases, reactivating any content that had previously been purchased from the same store account (Apple, Google, or Amazon).


1 Answers

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

You'll have to handle it in transaction observer.

In short, you start restore process with:

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

Then 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
        }
    }
}
like image 128
Mesbah Avatar answered Nov 03 '22 15:11

Mesbah