Receiving transaction(same transaction id) state success after cancel.

In-app purchase on my app is called observer method by SKPaymentTransactionObserver.

When user touch purchase button, add payment on purchase queue.

Then observer call my observer method call with transaction state SKPaymentTransactionStateFailed.

(at this time, receiveing state, finish transaction on observer method)

After few second observer call my method call with same transaction with trasaction state SKPaymentTransactionStatePurchased.

I don't know why cause like this.


I wish somebody know this problem.

Please let me know How can I solve this problem.

and let me know why this problem has happend.

You did not indicate whether this behavior is in the sandbox environment or in the production environment.


In the production environment if a user's iTunes account does not have the correct credit card information then they will be directed to update their credit card information. After they update their information they can continue with the IAP or cancel it. If they cancel it then only one failed gransaction comes through. If they chose to continue with the IAP then two transactions will be sent - a fail and then a purchase. Perhaps this is what you are seeing.

Your App can handle this simply by finishing the failed transaction and waiting for the next transaction. I don't close down my IAP system for a few seconds after receiving a failed (or deferred) transaction state to be able to receive a possible second transaction. And I also offer the user the chance to "Get approved purchases" if the user believes there is a purchase in the queue - that causes an addTransactionObserver and a few second interval for any purchases in the queue to come through before closing the transaction observer. Apple recommends always having a transaction observer in place - I respectfully disagree with that advice.

Hi,PBK,

Are the two transaction’s ID same when

receiving transaction(same transaction id) state success after cancel?

I want to make the procedure more strictly.

Thank you very much.

You asked:


>are the two transaction's ID same when receiving transaction(same transaction id) state success after cancel?


That makes no sense to me. The transaction ID for a transaction (transaction.transactionIdentifier) will be different each time there is a call to the updatedTransaction method. The transaction_id in each receipt for IAPs in the receipts in_app field will reflect the transaction.transactionIdentifier of the transaction in which the product was purchased or restored. There will be no receipt field for a failed transaction in the receipt.

Receiving transaction(same transaction id) state success after cancel.
 
 
Q