客户端自行连苹果服务器验证购买完成返回的receipt


    //write your test code here
    NSError *error = nil;
    NSDictionary *requestContents  = @{@"receipt-data":[receipt base64EncodedStringWithOptions:0]
                                       ,@"password":@"29596c75453d49d4a8a46b7e89fff625"};
    
    NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents options:0 error:&error];
    NSURL *storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"];
#ifdef DEBUG
    storeURL = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];
#endif
    NSMutableURLRequest *storeRequest = [NSMutableURLRequest requestWithURL:storeURL];
    [storeRequest setHTTPMethod:@"POST"];
    [storeRequest setHTTPBody:requestData];
    NSData * data1 =[NSURLConnection sendSynchronousRequest:storeRequest returningResponse:nil error:&error];
    NSDictionary* json1 = [NSJSONSerialization JSONObjectWithData:data1 options:NSJSONReadingMutableLeaves error:&error];
    NSLog(@"%@", json1);


你可能感兴趣的:(receipt,验证收据,苹果服务器)