I have a case where I am getting an invalid transaction receipt from the app store while doing purchases in sandbox. I'm doing server-side receipt validation.
Steps:
1. Go to make a purchase.
2. Get the Apple "Cancel" or "Buy" confirmation dialog; click "Buy".
3. Get the Apple "Thank You" OK dialog; do NOT click OK.
4. Sometimes the "purchased" transaction update message has arrived from the app store at this point, but sometimes it hasn't and the transaction is still in a pending state until the OK dialog is dismissed, but problems can occur if it is not dismissed.
5. While the Thank You dialog is still showing, minimize the app, turn off wifi, and return to the app.
6. The "Thank You" dialog has disappeared. If the transaction was in the pending state in step 4, I now get into the purchased state, but the transaction I get has a receipt that looks as if it has garbage data in it, and when the wifi is turned back on, and the receipt is sent to my server for validation, Apple rejects the receipt as having invalid data.
7. If the transaction was in the purchased state in step 4, the receipt is valid and everything works fine. But repeating the above steps will eventually reproduce the issue.
Once I get a bad receipt, if I leave the transaction open and restart the app, the purchase goes through again, this time with a valid receipt.