Validate Purchase

I need to validate the purchase by a server.
I get from the store a receipt like “<7b0a0922 7369676e 61747572 6522203d 20224167 322b5776 6e6c6149 4b41316d 68346a4f 684f6b7a 6c686a34 76686250 546f7a52 534f6965 4e423333 3342792b 41756e4b 63753361 33387345 6756525a 4d4c726c 33703035 466f7776 74787132 47414a30 656d6177 546e3349 4a52346e 37313565 594b7a6f 65474548 754a6e76 43364e41 69616a53 43767467 34343239 4d505a73 33774152 394b2b58 2b4c7853 2b565966 774f3574 77395842 73785579 53355248 2f596b70 75574a77 61344141 4144567a 43434131 4d776767 49376f41 4d434151 49434347 55556b55 335a5741 53314d41 304743…”

when i post this to https://sandbox.itunes.apple.com/verifyReceipt i got an error like this:

{“status”:21002, “exception”:“java.lang.IllegalArgumentException”}

at the web i found the information, that i need to base64 encode the string - but that didn’t helped me.

for me it look like, you need to reencode the string in objective c.

http://stackoverflow.com/questions/1298998/verify-receipt-for-in-app-purchase

Is there anyone out there who can help me? [import]uid: 42680 topic_id: 8225 reply_id: 308225[/import]

I got a solution! You can get the sourcecode here:

http://www.sebastian-heinisch.de/in-app-validation/2011-03-25/ [import]uid: 42680 topic_id: 8225 reply_id: 29458[/import]

Thank you very much Sebastian.
It’s been 2 days that I try to get a status =0 back from apple when verifying receipts (without any luck) until I found your post…you’re life saver! [import]uid: 23043 topic_id: 8225 reply_id: 50730[/import]

Hi Is there a lua implementation for this…
i have been trying a lot to no avail. Keep getting the 21002 error

I converted the hex to ascii. Got a json object like this
[lua]{
“signature” = “blah blah”;
“purchase-info” = “blah blah”;
“environment” = “Sandbox”;
“pod” = “100”;
“signing-status” = “0”;
}[/lua]

and i base 64 encoded it using
[lua]ascii = mime.b64(ascii)[/lua]
and gave a “POST” request to Apple
[lua] local values =
{
receipt_data = ascii,
password = “some-password”
}

postData = json.encode(values)
postData = postData:gsub(“receipt_data”,“receipt-data”)
network.request(“https://sandbox.itunes.apple.com/verifyReceipt","POST”,networkListener,postData)[/lua]

What am I doing wrong here???
Please Help. [import]uid: 64174 topic_id: 8225 reply_id: 100001[/import]

I’m having the same issue here. I’m using mime.b64 as well and end up with the same error. Can anyone make a short tutorial or code snippet to share with the rest of us?
[import]uid: 54776 topic_id: 8225 reply_id: 104987[/import]

@Richard

Hey, I actually got this working…

Will share the code in Code exchange when I get back home(in a few hours) [import]uid: 64174 topic_id: 8225 reply_id: 105033[/import]

Thanks! I’d appreciate it. :slight_smile: [import]uid: 54776 topic_id: 8225 reply_id: 105062[/import]

Ok here’s the link

http://developer.anscamobile.com/code/validation-auto-renewable-app-purchases [import]uid: 64174 topic_id: 8225 reply_id: 105071[/import]