apple/app-store-server-library-java

I only have one transactionId, but I’m not sure whether it’s a sandbox or a production environment. How to get the subscription plan?

Closed this issue · 2 comments

Hello, I have a scenario that I would like to consult. I have a transactionId, but I am not sure whether it is a sandbox or a production environment. I don’t know which environment to get its subscription plan. Do you have any solutions here?

Generally we always recommend passing an environment around with a transaction id to help prevent this issue! But these cases definitely happen, and a good way to approach this is to call the Get Transaction Info endpoint (https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info) in production, and if you receive a 404 TransactionIdNotFoundError, call the same endpoint in Sandbox and see if a non-404 response is returned.

Generally we always recommend passing an environment around with a transaction id to help prevent this issue! But these cases definitely happen, and a good way to approach this is to call the Get Transaction Info endpoint (https://developer.apple.com/documentation/appstoreserverapi/get_transaction_info) in production, and if you receive a 404 TransactionIdNotFoundError, call the same endpoint in Sandbox and see if a non-404 response is returned.

My side now requests the online environment first. If an exception occurs TRANSACTION_ID_NOT_FOUND(4040010L), I will call the sandbox environment again to obtain the subscription information, The way you said it is the same as mine.
image