Intégration in APP Purchase iOS / Unity

 

Réponse trouvée sur le forum Unity. Thanks to cobaltmind

I was just able to complete my first IAP using Prime31′s StoreKit plugin (woohoo!) and I thought I’d share the steps I took to get it working. This is NOT meant to be an exact HOW-TO but more of a general path to help out anyone who is currently fighting with this. Also note, the iPhone I’m referring to is an iPhone 3GSrunning iOS 5.

1. I read Apple’s IAP documentation (mostly) to figure out what the hell is going on with this. Seems really complicated as a noob.
2. I went through the Provisioning Profile maze and got my iPhone to be recognized in XCode. I highly recommend building a 1 scene game with a single cube or something to ensure your game will run on an iPhone before continuing. Don’t fuss with IAP until you have a prototype running on the phone.
3. I integrated the Prime31 StoreKit into my game (painless). One caveat, I’m a C# developer so this was kids play.
4. I learned that (at least right now) the iTunes Connect developer site is where the magic happens (https://itunesconnect.apple.com):
5. I went to « Manage Users » –> Test User –> Add New User
6. Then I went to « Manage Your Applications » –> « Add a New App » and plugged in a bunch of values and stub images to get iTunes to actually create my game on their server.
7. Once created you need to click on your game and in the « App Information » section click –> « Manage In-App Purchases » –> Create New
8. Back in your code, make SURE you call StoreKitBinding.requestProductData() RIGHT BEFORE you call StoreKitBinding.purchaseProduct() as is stated on the Prime31 website. Otherwise you’ll get the dreaded « Cannot Connect To iTunes Store » error. Totally logical… right? …
9. Delete the app off of the iPhone (just in case.. not sure if this is needed).
10. On the phone: click Settings –> Store –> Tap the « AppleID » at the bottom –> Sign Out –> Sign In as your test user
11. On your Mac: Click « App Store » –> Store –> Sign Out –> Sign in as your test user
12. Now, finally, you can Build & Run in Unity to test your IAP.

Note 1: I’m not doing anything to re-run (not deleting the app, logging in-out). Simply rebuilding and running again.
Note 2: The IAP purchase is NOT appearing in the App Store purchase history (sandbox purchase) BUT when I make the call to purchase again, iTunes Connect is indicating that the purchase was already made and asks if I’d like to download again. This was after a StoreKitBinding.purchaseProduct() call NOT a restoreCompletedTransactions() call.

Hope this helps.