I'm trying to verify a receipt with the App Store server in the sandbox environment.
I've checked all values are correct but keep receiving:
{
"environment": "Sandbox",
"status": 21003
}
My code:
def verify_receipt(receipt_data: str, sandbox: bool = True) -> dict:
"""
Verify an App Store receipt with Apple's verification service
Args:
receipt_data: The base64 encoded receipt data
sandbox: Whether to use sandbox environment (default True)
Returns:
dict: The verification response from Apple
"""
# URLs for verification
SANDBOX_URL = ";
PRODUCTION_URL = ";
# Shared secret from App Store Connect
SHARED_SECRET = "xxx......"
# Prepare the verification URL
verify_url = SANDBOX_URL if sandbox else PRODUCTION_URL
# Prepare the request payload
payload = {
'receipt-data': receipt_data,
'password': SHARED_SECRET,
'exclude-old-transactions': True
}
response = requests.post(verify_url, json=payload)
result = response.json()