steprescott / SCPStoreKitManager

Block based store kit manager for In-App Purchase on iOS 7, 8 & 9 with receipt validation.
MIT License
68 stars 29 forks source link

validateReceiptWithBundleIdentifier: Always Fails #22

Open joshkahane opened 9 years ago

joshkahane commented 9 years ago

The validateReceiptWithBundleIdentifier always fails. I am running in a sandbox environment, tried several sandbox accounts and devices.

Whenever I run the method (just as in your sample but with relevant identifier and version) I get the following error:

Failure reason : The receipt is not for this device or app Description : Could not validate receipt Suggestion : N/A

Any suggestion as to what the problem could be in more detail? Really unsure how to get around this. Great looking pod though, seems it will really help out.

Really appreciate any support, thanks. Josh.

brittonmobile commented 8 years ago

It's probably because the version number you're passing in the validate call does not match the version number in the receipt. Set a breakpoint on the error block call and go back up the stack to where you can print the receipt to the console. The version number must match the value that is currently in your Info.plist file for the key "CFBundleVersion" for the receipt to be considered valid.

Unfortunately, if the value you have in CFBundleVersion does not match the value in CFBundleShortVersionString it will also fail. This can happen if you use CFBundleVersion for the build number and CFBundleShortVersionString for the user-facing version string. In 1.1.2, the class erroneously validates the version number you pass against CFBundleShortVersionString prior to checking the receipt itself when it should be validating against CFBundleVersion as the App Store does. The actual code on master is correct, but no 1.1.3 tag was ever created so CocoaPods is loading a tag prior to it being fixed.

SoundBlaster commented 8 years ago

CFBundleShortVersionString and CFBundleVersion MUST NOT be the same! For example: CFBundleShortVersionString - aka Version - may be 1.0.1 CFBundleVersion - aka Build - may be 101 I checkout code of validator: In method - (void)verifyReceiptAtPath:(NSString *)receiptPath success:(Success)successBlock failure:(Failure)failureBlock in 128 line you check _bundleVersion with CFBundleShortVersionString but in 177 line you check _bundleVersion and [receipt version] that doesn't equal to a CFBundleShortVersionString, but equals to CFBundleVersion — Build, not a Bundle Version! You need to fix this issue.