xcode - I'm getting 21004 as status value in reply from apple's sandbox server testing auto-renewable subscriptions in ios? -
i'm testing in app purchase auto-renewable subscription apple's sandbox server returns status=21004
#define shared_secret @"insert here itunesconnect shared secrect key autorenewable subcriptions receipt validation" -(void)checkreceipt { // verifies receipt 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 sandbox receipt validation; replace "sandbox" "buy" in production or 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 help me proper receipt verification?
you must replace text @ top insert here itunesconnect shared secrect key autorenewable subcriptions receipt validation
secret key itunes connect. (obviously, don't post total secret on stack overflow, though).
the secret typically 32 digit, alpha-numeric string looks 39fkjc38jd02mg72k9cn29dfkm39fk00
(this 1 fake).
in (the new) itunes connect go my apps > (then click on app) > in-app purchases > view or generate shared secret
xcode in-app-purchase
No comments:
Post a Comment