It turns out that iTunes Production Support is aware of this problem. While I can't explain the cause of the problem, when an applicationReceipt generated in the sanbox environment is validated against the production Validation server, status result 21002 will be returned. iTunes Production Support is investigating a fix to this issue. This "unexpected" result only occurs with processing sandbox applicationReceipts with the production validation server.
I'm told that at some point, the validation of sandbox applicationReceipts against the production validation servers will result in the expected result - 21007. I have not been provided a date as to when this correction will occur. I've informed those that I report to that this is a big deal and affects all developers of applications with in app purchases who implement receipt validation.
One workaround for this situation is to see that the 21002 result is being returned when validating the applicationReceipt against the production server, and to treat this status result the same as 21007. Then the receipt validation process should attempt to validate the receipt with the sandbox Receipt Validation server. If status 21002 is returned from the sandbox server, then there is likely an actual base64 coding issue with the receipt.
One note - while this is clearly a "bug" with the receipt validation process, the issue is somewhat eased if the server receipt validation process were implemented as described in the Receipt Validation Program Guide
<https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Introduction.html>
In the section regarding receipt validation with the App Store, the recommendation is to implement a trusted server which the app communicates with to pass along the base64 encoded receipt. The trusted server then forwards the receipt first to the production receipt validation server. If the validation attempt returns status 21007, the base64 encoded receipt is forwarded to the sandbox validation server. With this design, it would be a temporary change to check the status from the production validation server for the 21002 status and to retry the validation process with the sandbox server. When this issue gets fixed, the trusted server process can then be restored to the original validation code path. With such a receipt validation design, the issue is moved to the trusted server to be addressed rather than within the application code.
One final note, it is expected that once the application passes App Review, the application processing the production applicationReceipt against the iTunes production Receipt Validation server, should have the receipt validated as expected.
rich kubota - rkubota@apple.com
developer technical support CoreOS/Hardware/MFI