Hello,
I am trying to validate consumable purchase server side (python) and here is my code :
url = "https://buy.itunes.apple.com/verifyReceipt"
request_body = {"receipt-data": token}
headers = {'Content-Type': 'application/json'}
response = requests.post(url=url, headers=headers, data=request_body)
data = response.json()
if "status" in data:
if data["status"] != 0:
print(f"Response from Apple verification : {data['status']}")
The status code i am getting is : 21002 which means that the receipt is malformed or something.
The token
var contains the base64 encoded value and is a String
here.
What i am missing here please ?
PS : i am also using the sandbox URL as a fallback, and this is giving the same status
code.
Thanks in advance
The answer was so simple i am sorry, i should pass a String object to the POST request. Instead, i was passing a Dict in python which doesn't make sense.
The code should be : request_body = json.dumps({"receipt-data": token})
Thanks for your time, you can close my case as well !