1

I followed this tutorial and everything works. But Xcode show me that transactionReceipt is deprecated.

Now looking on google, I saw that you can change using this method:

[NSData dataWithContentOfURL:[[NSBundle MainBundle] appStoreReceiptURL]];

But if I make this change, in this way:

/*    NSString *jsonObjectString = [self encodeBase64:(uint8_t *)transaction.transactionReceipt.bytes
                                         length:transaction.transactionReceipt.length]; 
*/

NSData *data = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString *jsonObjectString = [data base64EncodedString];

// Create the POST request payload.
NSString *payload = [NSString stringWithFormat:@"{\"receipt-data\" : \"%@\", \"password\" : \"%@\"}",
                     jsonObjectString, ITC_CONTENT_PROVIDER_SHARED_SECRET];

NSData *payloadData = [payload dataUsingEncoding:NSUTF8StringEncoding];

The validation always fails. Instead, if I leave transactionReceipt all works properly.

What is the problem?

Note: Tested on iPhone 4 with iOS 7.1.

Amar
  • 13,202
  • 7
  • 53
  • 71
Ilario
  • 5,979
  • 2
  • 32
  • 46
  • @iTroyd23 no on device – Ilario Mar 18 '14 at 11:49
  • @Ilario is your device running iOS 7? – sbarow Mar 18 '14 at 11:51
  • 1
    Is it possible that it is your base64 encoding causing it to fail? What is the JSON object that you get? – sbarow Mar 18 '14 at 12:00
  • @sbarow in both cases jsonObjectString is very long and the log is something like: ewoJInNpZ25hd ... etc etc.. What could I change? – Ilario Mar 18 '14 at 12:05
  • @Ilario why not try `NSString *jsonObjectString = [self encodeBase64:(uint8_t *)data.bytes length:data.length];` cause that has obviously worked before, if it fails then you can rule out the base64 issue. – sbarow Mar 18 '14 at 12:09
  • @sbarow I tried it and it is the same, validation fails... so the problem is NSData *data = ... – Ilario Mar 18 '14 at 13:14
  • @Ilario have a look at this http://stackoverflow.com/questions/18903879/transactionreceipt-for-in-app-purchase-is-deprecated-in-ios-7-how-can-i-replacem read the comments and look at this http://stackoverflow.com/questions/19955352/invalid-transaction-receipt-returned-by-appstorereceipturl-nsdata-in-ios-7? answertab=votes#tab-top I think you might be running into the same problem. – sbarow Mar 18 '14 at 13:30
  • And here is an open source solution for you https://github.com/rmaddy/VerifyStoreReceiptiOS :-) – sbarow Mar 18 '14 at 13:31
  • @sbarow thanks for the link, I knew them, but both answers are not able to solve the problem. I guess I'll try to implement open source project – Ilario Mar 18 '14 at 13:37
  • @Ilario have a look at the open source project code, it should give you some clues as to what is going wrong. I feel just changing to `appStoreReceiptURL` isn't all that is needed and might need a different approach there after. – sbarow Mar 18 '14 at 13:39
  • @sbarow perhaps it is so .. the apple documentation is not very clear sincerely.. anyway thanks – Ilario Mar 18 '14 at 13:41
  • So it works with SKReceiptRefreshRequest but not with appStoreReceiptURL? The appStoreReceiptURL file definitely exists? Why are you passing ITC_CONTENT_PROVIDER_SHARED_SECRET? This is not an autorenewing subscription. – Rhythmic Fistman Mar 18 '14 at 20:04
  • @RhythmicFistman as i wrote in question i followed a tutorial... but this tutorial was for iOS 6... have you any suggestion? – Ilario Mar 19 '14 at 12:36
  • @Ilario Follow https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1- for iOS 7 receipt validation – z22 May 30 '14 at 05:31
  • @z22 thanks, but again return ever Invalid transaction - failed transaction – Ilario May 30 '14 at 09:00

0 Answers0