So, we've implemented IAP with StoreKit2 e2e for both the client and backend and it's working mostly perfectly, however we have an issue which we can't seem to understand Apple's behavior.
So, imagine a purchase that occurred on the 10th of December in the sandbox environment through an install from TestFlight, and this same purchase keeps getting queued in the Transaction.unfinished
list for some reason (today, the 17th of December, a whole week after the initial purchase!).
Here's the flow:
- We iterate the list on app launch
- Send the unfinishedTransaction's
transactionId
to our servers - The server says "hey, we could verify it with Apple but it's not longer active (expired). We can't really work with it so just finish it on your side and don't send it to me again"
- The client finishes!! the transaction
- On the very next app launch it keeps reappearing in the
Transaction.unfinished
queue
Are we doing something wrong, why doesn't it get cleaned? Is this an expected behavior?
Note, this is generally the server's logic for new purchases:
- If we weren't able to contact Apple - we tell the client to not finish the transaction so that we'll be able to re-iterate it on the next app launch or retry
- If the transaction is not expired and valid - we update our records and tell the client to finish the transaction
- If we couldn't update our records - we tell the client to not finish the transaction so that we'll be able to re-iterate it on the next app launch or retry
- If the transaction is not valid for some reason - we tell the user to finish the transaction
The server might see it as a valid transaction if we'll send the originalTransactionId
instead of the 'transactionId(using it to call
getTransactionInfoin
AppStoreServerLibrary`), but is this something we want to do?
This will obviously not fix the problem because the server tells the client to finish the transaction anyways, but it simply doesn't work.
Please, any advice or changes to make to either Client/Server would be greatly appreciated
Best Regards, Ofek