Hi,
We are trying to verify transaction IDs using the App Store Server Library for Python. We have been able to successfully send a test notification, but then when trying to get transaction information for a specific transaction ID we are receiving the InvalidAppIdentifierError (error code: 4000002). We have verified that the bundle_id
is correct and matches what we see in App Store Connect, and the bundle_id
seems to be valid and work when we sent a test notification. We have also tried setting the bundle_id
to be equal to our <TEAM ID>.<BUNDLE_ID>
, which is the format for the application-identifier
in our TestFlight Build Metadata, but we still receive the same error when doing so.
We would greatly appreciate any help or advice on how to resolve this, and please let me know if any more information is needed to help us.
import os
from appstoreserverlibrary.api_client import AppStoreServerAPIClient, APIException
from appstoreserverlibrary.models.Environment import Environment
from appstoreserverlibrary.signed_data_verifier import VerificationException, SignedDataVerifier
from typing import List
private_key_path = "REDACTED"
with open(private_key_path, 'rb') as file:
private_key = file.read()
key_id = "REDACTED"
issuer_id = "REDACTED"
bundle_id = "REDACTED"
environment = Environment.SANDBOX
client = AppStoreServerAPIClient(private_key, key_id, issuer_id, bundle_id, environment)
def load_root_certs(root_certificate_dir: str) -> List[bytes]:
root_certificates = []
for file_name in os.listdir(root_certificate_dir):
if not file_name.endswith('.cer'):
continue
root_cert = file_name
with open(os.path.join(root_certificate_dir, root_cert), 'rb') as file:
root_certificates.append(file.read())
return root_certificates
root_certificates = load_root_certs("REDACTED")
enable_online_checks = True
signed_data_verifier = SignedDataVerifier(root_certificates, enable_online_checks, environment, bundle_id)
try:
response = client.get_transaction_info(transaction_id_ios)
signed_transaction_info = response.signedTransactionInfo or ""
print(signed_transaction_info)
payload = signed_data_verifier.verify_and_decode_notification(signed_transaction_info)
print(payload)
except (APIException, VerificationException) as e:
print(e)```