xcode 我从苹果的沙箱服务器测试 ios 中的自动更新订阅时收到 21004 作为状态值的回复?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14976453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm getting 21004 as status value in reply from apple's sandbox server testing auto-renewable subscriptions in ios?
提问by Ravindhiran
I'm testing In app purchase auto-renewable subscription but apple's sandbox server always returns status=21004
我正在测试 In app purchase auto-renewable subscription 但苹果的沙箱服务器总是返回 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?
有人可以帮助我获得正确的收据验证吗?
回答by Andrew
You must replace this text at the top INSERT HERE YOUR ITUNESCONNECT SHARED SECRECT KEY FOR AUTORENEWABLE SUBCRIPTIONS RECEIPT VALIDATION
with the secret key that you get from iTunes Connect. (obviously, don't post the full secret on Stack Overflow, though).
您必须使用INSERT HERE YOUR ITUNESCONNECT SHARED SECRECT KEY FOR AUTORENEWABLE SUBCRIPTIONS RECEIPT VALIDATION
从 iTunes Connect 获得的密钥替换顶部的此文本。(显然,不要在 Stack Overflow 上发布完整的秘密,不过)。
The secret is typically a 32 digit, alpha-numeric string that looks something like this 39fkjc38jd02mg72k9cn29dfkm39fk00
(this one is fake).
秘密通常是一个 32 位的字母数字字符串,看起来像这样39fkjc38jd02mg72k9cn29dfkm39fk00
(这个是假的)。
In (the new) iTunes Connect go to My Apps> (Then click on your app) > In-App Purchases> View or generate a shared secret
在(新的)iTunes Connect 中,转到“我的应用程序”>(然后单击您的应用程序)>“应用程序内购买”>“查看或生成共享密钥”
回答by MANCHIKANTI KRISHNAKISHORE
go to ituenes connet and then your app and then go to ManageInApp purchases and then here see the left bottom there is an option view or generate a sharedsecret here you can generate an shared secret or you can view the previous shared secret
转到ituenes connet,然后转到您的应用程序,然后转到ManageInApp 购买,然后在此处查看左下角有一个选项视图或在此处生成共享秘密您可以在此处生成共享秘密,也可以查看以前的共享秘密