KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm testing In app purchase auto-renewable subscription but apple's sandbox server always returns status=21004 #define SHARED_SECRET @"INSERT HERE YOUR ITUNESCONNECT SHARED SECRECT KEY FOR AUTORENEWABLE SUBCRIPTIONS RECEIPT VALIDATION" -(void)checkReceipt { // verifies receipt with Apple NSError *jsonError = nil; NSString *receiptBase64 = [NSString base64StringFromData:receiptData length:[receiptData length]]; NSLog(@"Receipt Base64: %@",receiptBase64); NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[NSDictionary dictionaryWithObjectsAndKeys: receiptBase64,@"receipt-data", SHARED_SECRET,@"password", nil] options:NSJSONWritingPrettyPrinted error:&jsonError ]; NSLog(@"%@",jsonData); NSError * error=nil; NSDictionary * parsedData = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error]; NSLog(@"%@",parsedData); NSLog(@"JSON: %@",[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]); // URL for sandbox receipt validation; replace "sandbox" with "buy" in production or you will receive // error codes 21006 or 21007 NSURL *requestURL = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"]; NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:requestURL]; [req setHTTPMethod:@"POST"]; [req setHTTPBody:jsonData]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:req delegate:self]; if(conn) { receivedData = [[NSMutableData alloc] init]; } else { completionBlock(NO,@"Cannot create connection"); } } Can someone help me to get proper receipt verification?
Tags (comma-separated)
Save Edits
Cancel