Difficulty generating valid transactionIDs for IAP

Greetings community!

  • A) I am trying to implement Apple In-App-Purchases for a new iOS app/game.
  • B) I have a client-server application, and the purchase validation and entitlement grant needs to happen on our game-server. As best as I can tell, I want to use Get Transaction History to validate the purchase on the game server.

I'm testing a sandbox app/APIs using TestFlight. My generated transactionID's are sequential integers starting at 0, but some documentation suggests it should be a UUID. So far, the integer transactionID/originalTransactionID have not yielded a valid response from GetTransactionHistory.

The errors I get are:

  • {"errorCode":4000008,"errorMessage":"Invalid original transaction id."}
  • {"errorCode":4040005,"errorMessage":"Original transaction id not found."}

I'm mostly stumped at this point, as I can't find any documentation describing what I may have missed, and there are no other forum posts or search results for those error codes.

So my questions:

  1. Will GetTransactionHistory ever this work with sequential integer transactionIDs?
  2. I've deployed the signed app through TestFlight, and I'm still getting sequential integer transactionIDs. Is that expected? What am I doing wrong?
Post not yet marked as solved Up vote post of pgilmoregv Down vote post of pgilmoregv
1.3k views

Replies

Transaction ids are provided to the device upon a successful purchase. See https://developer.apple.com/documentation/storekit/transaction. You can send the signed transactions to your server and validate the JWS signature directly. If you are interested in getting the full user's history as well, you can then call the Get Transaction History endpoint with the original transaction id contained in the transaction.

Make sure you aren't testing with Xcode itself, but are using the Sandbox or TestFlight environment. Local Xcode testing will not create data that the App Store Server API will recognize.

The UUID you are likely referring to is the appAccountToken https://developer.apple.com/documentation/storekit/transaction/3749684-appaccounttoken.

  • A little yes, and a little no. I have managed to get better transactionIDs: 2000000328415040 and 2000000328446334. But the history results were not useful: "{"revision":"0","bundleId":"com.mycompany.mytestapp","environment":"Sandbox","hasMore":false,"signedTransactions":[]}"

    The documentation says signedTransactions should contain the transaction I just completed, but it's empty. And other invalid TransactionIDs like: 2000000200000000, 2000000299999999 show the same result.

  • Fulfilled consumables are not returned by the Get Transaction History endpoint. "Consumable in-app purchases if the transaction is refunded or revoked, or if the app hasn’t finished processing the transaction. The results don’t include consumable in-app purchases that the app marks as finished. For more information about finishing transactions, see finish() and finishTransaction(_:)." https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history

  • One of the reasons to self-validate the JWS on your server, since fulfilled consumables cannot be double-checked against the Get Transaction History endpoint.