当前位置: 动力学知识库 > 问答 > 编程问答 >

iphone - Apple in app Purchase verify receipt

问题描述:

I am doing the server side with an iPhone dev for this.

right now the receipt-data he is sending me is a block of hex, looks something like:

<7b0a0922 7369676e 61747572 6522203d 20224167 684b5845 6a343245 6e4a5679 48447273 655a696d 55584662 71596158 52435668 ... 72d7374 61747573 22203d20 2230223b 0a7d>

So i base64 encode this and send it off to apple in a json body like so:

{'receipt-data': data_from_above_inb64}

I am not convinced that he is sending me the right block of data for the receipt, because no matter what hoops I jump through or different arrangements I try, I get nothing but java errors from apple.

Is he sending me the right thing? If not what do I ask him for? Apple says i need the transactionReceipt from their response. But obviously what I am doing now is not working.

thanks

EDIT: the ever helpful response: '{"status":21002, "exception":"java.lang.NullPointerException"}'

EDIT2: I also get this from time to time: '{"status":21002, "exception":"java.lang.ClassCastException: com.webobjects.foundation.NSMutableData cannot be cast to com.webobjects.foundation.NSDictionary"}'

EDIT3: Answer found, iPhone client needs to initialize the raw hex data as a string, something like: NSString *receiptStr = [[NSString alloc] initWithData:transaction.transactionReceipt encoding:NSUTF8StringEncoding];

the receipt string should look more like:

{"signature" = "AiM6Ny4IH...OSzQ==";

"purchase-info" = "ewo..Q==";

"pod" = "100";

"signing-status" = "0";}

rather than a string of hex like i was getting before

网友答案:

He should already be sending you the Base64 encoded data, so just pass it along with the 'receipt-data' key. You don't have to re-encode it.

网友答案:

re: EDIT2 I also get this from time to time: '{"status":21002.........

worth reading my post re 21002 response on here

In App Purchase Verify certificate problem

note: If anything this might be the better place for the post, is it moveable by anyone?

网友答案:

For me it was that I was using single quotes due to copy/paste from another example, but it needed to be double quotes.

Not { 'receipt-data' : 'data' } but { "receipt-data" : "data" }

分享给朋友:
您可能感兴趣的文章:
随机阅读: