- Home /
How to implement Mac App Store in-app purchase and receipt verfication?
I'm trying to build a Mac desktop version of our iPad app, but I'm running into issues implementing in-app purchase and receipt verification. Is this possible with Unity and has anybody done it? To clarify, I'm not just trying to submit my app to the Mac App Store, but I need IAP and receipt verification.
I've built a plugin for Unity to handle the IAP and receipts (in Xcode), but because the app is not being built and run from Xcode, it does not appear to be entering sandbox mode. The only information on this that I can find in the docs is "Test During the Development Process":
http://developer.apple.com/library/mac/#releasenotes/General/ValidateAppStoreReceipt/_index.html
It suggest that the app should exit with code 173 when the receipt file isn't found and that the sandbox receipt will automatically be downloaded. It should be in the app in "Contents/_MASReceipt/receipt". I'm doing exactly this with my bundle using exit(173). The app exits, but no receipt is downloaded.
Since I've been unable to get my app to connect to the sandbox, I thought I'd try using a sample receipt, but the little instruction I've found doesn't work. In any case, I think I need a real receipt to work with.
Also, in case anybody asks I have done the usual required steps for submitting the app to the Mac App Store, updating the Info.plist, icons and running codesign and productbuild.
TL;DR - How do you retrieve the app receipt for a Unity mac desktop app during development?
these days, the best technology by far is http://receigen.etiemble.com
Answer by Steven-Walker · Oct 05, 2011 at 08:03 PM
After quite a bit of work I've found a solution. For anyone else trying to do this, here are the general steps...
1) Build a default Xcode Cocoa app and implement all your in-app purchase and receipt verification code. The app doesn't need to do anything when run, just test that transactions and verification are working in sandbox mode.
2) Build a bundle as a plugin for Unity with the same code from your test app. Add the bundle to Assets/Plugins with your binding code, then build the app (Mac OS X Intel Only).
3) Open the package contents of the app and update the Info.plist, and other files as needed. Follow the usual steps for app store submission up to the codesign step. http://forum.unity3d.com/threads/71340-Submit-Unity-games-to-the-Mac-App-Store!
4) Open the contents of your Xcode app build (from step 1) and copy the _MASReceipt folder over to the contents of your Unity build. This is necessary because insofar as I've seen, running the app built from Unity doesn't trigger the sandbox mode and thus does not receive a receipt. As long as your Unity app has the right bundle ID and code signature, it validates the receipt correctly.
All of this is pretty time consuming, since you have to repeat steps 3 and 4 every time you do a new build. So it's best to save this as the last development phase.
I also found this post... though since I implemented my own I haven't tried it: http://forum.unity3d.com/threads/76764-Mac-App-Store-Receipt-Validation-Plugin-Enjoy-%29
It turns out I may have been wrong about this. For some reason the app has started pulling the receipt by itself, even when I rebuild it from Unity. I might have overlooked a setting in the Info.plist initially.
Your answer
Follow this Question
Related Questions
Stuck: Can't publish game in app Store (unity games don't meet platform requirements?) 2 Answers
Mac App Sandbox Adding Capabilities 0 Answers
In-app purchase "Invalid product" on Mac Store build 0 Answers
Submit to Mac App Store? Unitys guide is outdated 0 Answers
Can't run unity 2.6.1 on mac os x 10.6.3 2 Answers