• Register

Gamieon is a privately owned entertainment software development company located in Tampa, Florida. Since October of 2004, we have aimed to provide quality video game software which emphasizes both intellectual and action-driven challenge to the gaming community. Gamieon depends on the talent of individuals working as a team to develop video games and video game engines with a focus on exceptional game play and surrealism.

Image RSS Feed Latest Screens
Dominoze Construction Kit
Blog RSS Feed Report abuse Latest Blog: Unity Windows Phone 8 In-App Purchase Integration

0 comments by Gamieon on Jul 7th, 2014

The focus of this journal entry is on how I integrated In-App purchase capabilities into my Unity game. I'm not going to discuss strategies for earning money from players, or how I used the IAP assets once they were integrated.

Unity Setup for Zaubersee

I began by purchasing a Windows Phone 8 IAP Unity package by Zaubersee at Assetstore.unity3d.com to get things going. Like with other third-party Windows Phone 8 assets I've used, it didn't work out of the box. I also struggled a bit with my interpretation of the documentation. After creating a new Unity test project, importing the asset, and deploying to my Windows Phone, I got this error in the status window of the demo scene:

Exception from HRESULT: 0x805A0194

I overcame this error by submitting the test project as a beta app to the Windows Phone Dev Center. I believe the asset developer tried to explain this in the documentation, but I thought that submitting a beta version of the app was merely a suggestion.

Here's what I did to build a functional test project:

  • I created a beta version of Hamster Chase on the Windows Phone Dev Center.
  • For the beta version, I made a duplicate of every In-App product that already existed for the main version. I used the same product ID's.
  • I made a new Unity project, imported the In-App purchase asset, and built the project for Windows Phone 8.
  • I opened VS 2013 to the Windows Phone 8 project I built from the previous step, then opened WMAppManifset.xml under the Properties folder.
  • I went to the packaging tab and updated the ProductID and PublisherID values to be those of Hamster Chase Beta.
  • I made a Master build of the app, and submitted it to Windows Phone Dev Center. I made absolutely sure it was a beta, and not an app to be shown in public.
  • About an hour later I got an e-mail from Microsoft with the download link. I went there from my phone, installed the app, and the purchases worked!
  • Cleanup: From my phone, I went to the home screen, then Apps, then Games to find and uninstall the test app.

Taking this idea a step further, I opened the VS 2013 project for the real Hamster Chase, set the product ID to be that of the beta app, and then deployed it in debug mode to the device.

Since the test app worked well, I figured it would work the first time in my game...but it did not. The app crashed after the app was restored upon me dismissing Microsoft's purchase screen.

My guess is that in the onWP8inAppPurchased callback, I wasn't supposed to do stuff with Unity objects like changing TextMesh text values or calling Transform.GetChild(). I proceeded to move all that code into a function called DoStuffAfterPurchaseFinished(), and then I call Invoke("DoStuffAfterPurchaseFinished", 0.2f) within the callback. The crash went away after that.

Unity Setup for Prime31

I was about to move on entirely when I discovered that Prime31 was offering a free Windows Phone 8 In-App package (while the offer lasted) at Prime31.com . I've worked with Prime31's assets before, and I like their brand.

I decided to make a test app with Prime31's IAP package. Using the lessons learned from integrating Prime31's WinPhoneAds package and the Zaubersee package; I was able to quickly get a functional Prime31 In-App demo app.

I then imported the Prime31 package into the official Hamster Chase app, and tested it. To my surprise, I had the same crash I had with the Zaubersee asset when trying to manipulate GameObjects within the purchase completion callback. As before, the Invoke workaround made the crash go away.

Conclusion

In the end I got both the Zaubersee and Prime31 assets to work; but I decided to stick with the Prime31 asset primarily out of brand loyalty and the expectation of continued upkeep.

Check out my homepage and social feeds

And my projects!

Groups
Desura

Desura

Official group with 10,073 members, open to all members

Desura is a community driven digital distribution service for gamers, putting the best games, mods and downloadable content from developers at gamers...

Desura Publishing

Desura Publishing

Official group with 181 members, open to all members

Desura Publishing group is a group dedicated to all questions regarding game & mod publishing on Desura. Official features and updates on publishing progress...

Gamieon

Gamieon

Developer with 4 members, open to all members

Gamieon is a small independently owned company devoted to developing innovative and high quality video games.

Gamieon, Inc.

Gamieon, Inc.

Developer Open to all members

Gamieon, Inc. is a privately owned entertainment software development company located in Tampa, Florida. Since October of 2004, Gamieon provides quality...

Unity devs

Unity devs

Hobbies & Interests group with 1,147 members, open to all members

For all Unity developers and developers-to-be, both beginners and professionals!

Post comment Comments
ArtisanCodesmith
ArtisanCodesmith Sep 24 2012, 7:38am says:

I'm new to IndieDB and ModDB and wish to invite a few people (random people picked from the online list lol) to view my game and start generating a few opinions, do you mind taking a quick look? The game is called Arkanius. Thanks, Artisan Codesmith. :)

+2 votes     reply to comment
AlexVSharp
AlexVSharp Jan 30 2012, 6:07pm says:

Wow, well written. You should include this article in the Unity Dev's group. ;)

+3 votes     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Level
Avatar
Avatar
Offline Since
Jul 22, 2014
Country
United States United States
Gender
Male
Member Watch
Track this member
Accolades
Desura
Statistics
Activity Points
953
Rank
2,087 of 463,065
Watchers
5 members
Time Online
13 hours
Comments
18
Site Visits
2,128
Profile Visitors
59,856 (23 today)
Contact
Homepage
Gamieon.com
Private Message
Send Now
Email
Members Only
ICQ
387263084
Twitter

Latest tweets from @gamieon

#hamsterchase officially held a featured spot on the Windows Phone store! Now back to fixing bugs... T.co

Jul 11 2014, 7:37pm

#hamsterchase is now on the Windows Phone Store! T.co

Jun 29 2014, 12:08pm

Just submitted #hamsterchase to the Windows Phone store...will do some last minute testing before publishing.

Jun 27 2014, 5:08pm

Finally got ads and in-apps working in #hamsterchase for Windows Phone 8. Final testing time!

Jun 23 2014, 9:36pm

Got #hamsterchase to run fast on my Windows phone...but no luck with in-apps, ads and Facebook integration. Everything is a klunky beta!

Jun 17 2014, 8:54pm

Initial deployment of #hamsterchase to my Windows Phone running super slow...not a good sign...

May 31 2014, 9:23pm

Just upgraded to #unity3d 4.5; now investigating releasing #hyperspacepinball onto the Windows 8 Store too!

May 28 2014, 1:49pm

Just now got #hamsterchase working in a #WindowsPhone emulator, too! T.co

May 23 2014, 9:43pm

Just got #hyperspacepinball working on a #WindowsPhone emulator! Stay tuned for updates... T.co

May 16 2014, 5:04pm

Try out the #papercowboys alpha preview! Details and screenshots at T.co

May 6 2014, 4:55pm

shaulhadar
shaulhadar friends since Nov 29, 2011
hermesdavidms
hermesdavidms friends since Jan 2, 2011
swiftseraph
swiftseraph friends since Jun 3, 2011
Original_Speeder
Original_Speeder friends since Jun 4, 2011
Namelessness
Namelessness friends since Apr 26, 2013
NullSoldier
NullSoldier friends since Jun 4, 2011