I am working on In app Purchase validate on OSX app and get some problem~
My request code like this:
NSData* data = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString* base64Str = [data base64EncodedString];
NSDictionary* dict = [NSDictionary dictionaryWithObject:base64Str forKey:@"receipt-data"];
SBJSON *jsonParser = [[[SBJSON alloc] init] autorelease];
NSString* jsonStr = [jsonParser stringWithObject:dict error:nil];
postUrl = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];
_verifyRequest = [[NSMutableURLRequest alloc] init];
[_verifyRequest setTimeoutInterval:_sTimeoutInterval];
[_verifyRequest setURL:postUrl];
[_verifyRequest setHTTPBody:[jsonStr dataUsingEncoding:NSUTF8StringEncoding]];
[_verifyRequest setHTTPMethod:ASCommon_HttpMethodPost];
_verifyConnection = [[NSURLConnection alloc] initWithRequest:_verifyRequest delegate:self];
[_verifyConnection start];
I get the result like this
{
exception = "java.lang.IllegalArgumentException";
status = 21002;
}
And I log the jsonStr variable seems have no problem:
{"receipt-data":"..........................................................."}
Apple doc here said "Retrieve the receipt data. ...... On OS X, this is the entire contents of the receipt file inside the application bundle. Encode the receipt data using base64 encoding."
Do I misunderstand the receipt data is entire of contents of file? Or something wrong with my code?