简体   繁体   中英

iOS: restored transactions continue to arrive in sandbox

I'm on the itunes sandbox environment testing in app purchase. I use a test user created in itunes connect and the purchasing code is working fine. Now I'm testing the restore transaction. This is the code for the restore:

    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

After executing this code once, every time I restart the application and I register the TransactionObserver with the code:

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];

I am asked for the password of the last user used to test the restore. Its transactions are returned to me each time. For this reason it is not possible to test the application in the "not purchased" state. I've already tried to log out that user and login as a non test user but it does not change, I always am requested to insert the password of that test user.

I finally found the problem: when the observer received the restored transaction in the method

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

i was processing it and calling

[[SKPaymentQueue defaultQueue] finishTransaction:transaction.originalTransaction];

The problem is i needed to also call

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

on the container transaction itself. Missing that, the sandbox was sending me the same transaction over and over, because i never confirmed receiving it!

First of all, you are in sandbox environment which can be used just by test users. So try again with creating new test user. (You can create a test user with non-existing email address, it is ok to test ;) )

I think you save your states of purchase to NSUserDefaults, so to test with new user and reach the situation of not purchased, you should delete the application and run it again.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM