In App Purchase - when trying to buy consumable product again - this in-app purchase has already been bought
Asked Answered
A

2

21

I have consumable In-App-Purchase product in my iTunes connect, and when I'm trying to buy it twice (on my iPhone), it tells me that I already bought it. But this is the whole point of consumables, that users can buy them over and over. Any suggestions?

Armistice answered 14/11, 2014 at 19:11 Comment(5)
I'm having a similar issue. Did you fix it?Sholes
@ravisendhav The accepted answer worked for meArmistice
but it's not working for me. Please see my code below.Sholes
Did you see this messages in console log: print("Received Payment Transaction Response from Apple");Fireworks
how can we clear pending transactions?Homeo
W
31

This happens if you haven't marked the transaction for the original purchase as finished, which you should do in your - (void)paymentQueue:(SKPaymentQueue*)queue updatedTransactions:(NSArray*)transactions method after you've successfully processed the purchase.

The method you need to call is [[SKPaymentQueue defaultQueue] finishTransaction:transaction].

Weeden answered 14/11, 2014 at 19:17 Comment(1)
Thank you, that really helped. In order to clear previously unfinished transactions one has to run this code once: let queue = SKPaymentQueue.default(); queue.transactions.forEach { queue.finishTransaction($0) } Lucy
S
-2
public func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    for transaction in transactions {
        switch (transaction.transactionState) {
        case .purchased:
            complete(transaction: transaction)
            break
        case .failed:
            fail(transaction: transaction)
            break
        case .restored:
            restore(transaction: transaction)
            break
        case .deferred:
            break
        case .purchasing:
            break
        }
    }
}
Sholes answered 11/7, 2017 at 14:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.