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

限于喜欢 提交于 2019-12-21 04:55:31

问题


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?


回答1:


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
        }
    }
}



回答2:


Try MKStoreKit framework https://github.com/MugunthKumar/MKStoreKit It is pretty good, well maintained framework. I have a few apps with in-app purchases. Never had any issues like that.




回答3:


@Tibidabo I wouldn't recommend MKStoreKit because it has a big hole in restore purchased items functionality.



来源:https://stackoverflow.com/questions/11086179/restoring-an-in-app-purchase-with-a-user-who-never-paid-for-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!