Armelline's In-App Purchase Tutorial Template

ArmellineArmelline Member, PRO Posts: 5,354
edited November 2014 in Community Tutorials

I finally got around to finishing this off.

The new IAP system in GameSalad is powerful but confusing. You can see some musing regarding it that I posted before in this thread, as well as a handy flow-chart type thing.

What I want to share today is what I'm calling a Tutorial Template that walks you through setting up a non-consumable IAP with dynamic button updating. Apple are keen to get people doing this, and it adds an extra bit of polish to your game.

Included too is a way of testing your IAP within the Creator. Frustratingly, GameSalad doesn't give you a way to simulate the return of the Request Purchase Data or Purchase Item behaviours, but this template shows you a really easy way to approximate this behaviour.

This video will show you what I'm talking about:

I chose in this example to only trigger the filling of the PurchaseTable when the user actually requests a purchase. My experience has been that trying to fill it before a purchase is requested can lead to the user getting popups requesting they log in. I have a strong preference to avoid that happening. Depending on the complexity of your shop, though, you might want to make that concession.

You can find the template to download at my website. Click here to jump straight to it, or click here to visit the homepage.

This template is completely free and I hope it helps some people figure this IAP stuff out! Should you wish to donate a dollar or five towards me making more free templates like this, there's a link on my page - but doing so is 100% voluntary.

Enjoy!

Strictly no inclusion of logic from this template is allowed in any commercial template.

«1

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    Awesome stuff man - thanks for sharing! Very kind of you!

  • SocksSocks London, UK.Member Posts: 12,822

    Just brilliant ! I can't say I understand it all yet, but I'm glad someone does.

  • neomanneoman Member, BASIC Posts: 826

    Thank you so much ... I will be checking this out for sure ... Cheers :smiley:

  • game ongame on Sun Valley, California Member, PRO Posts: 79

    Armelline, looks good as always.

  • jorkosjorkos Member, PRO Posts: 353

    THANK YOU!!!!!!!!!!!!

  • ArmellineArmelline Member, PRO Posts: 5,354

    Glad everyone's enjoying it! I'll do an update with consumable purchases when I have the time!

  • ArmellineArmelline Member, PRO Posts: 5,354

    Doing something I normally hate, but bumping this for the weekend visitors!

  • robertkdalerobertkdale USAMember Posts: 912

    Thank you for sharing! :)

    Big Smile Games Play Happy!
    Check out our other GameSalad exclusives.

  • gamestudentgamestudent Member Posts: 504

    Woo Hoo!

  • iKandyiKandy Imagineer of Crazy Shit New York CityMember Posts: 310
    edited March 2015

    Armeline, you mentioned in a GS Workshop that this method doesn't work in an adhoc. Could you clarify this? I've been trying to use your method and have been having a LOT of difficulty. When testing in either adhoc or testflight versions-- if the Apple server detects that the app has been previously purchased (in sandbox,) it throws the entire mechanism out of whack. (asking me to keep inputting my password over and over as well as going through the various purchase windows, over and over. It also keeps generating 1,0 in the callback attribute and purchased, pending and unpurchased in the table.)

  • ArmellineArmelline Member, PRO Posts: 5,354

    @iKandy said:
    Armeline, you mentioned in a GS Workshop that this method doesn't work in an adhoc. Could you clarify this? I've been trying to use your method and have been having a LOT of difficulty. When testing in either adhoc or testflight versions-- if the Apple server detects that the app has been previously purchased (in sandbox,) it throws the entire mechanism out of whack. (asking me to keep inputting my password over and over as well as going through the various purchase windows, over and over. It also keeps generating 1,0 in the callback attribute and purchased, pending and unpurchased in the table.)

    My experience was that when I put games on my phone via Xcode, the IAP didn't work, but when I used Apple's TestFlight, they did. I'm not sure exactly what the restrictions are though.

    It sounds like you may have a problem in your IAP logic, though.

  • jorkosjorkos Member, PRO Posts: 353

    Yes @Armelline using in Testflight is the best way to test iAP

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @Armelline Is this template still available? Wasn't able to download it from your site :/

  • ArmellineArmelline Member, PRO Posts: 5,354

    I broke all the links by mistake. I intend to update my site but haven't had time. Here is is in the meantime:

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @iKandy Did you ever figure out your issue...? I'm literally having the same problem after following the tutorial by @Armelline :neutral:

    This new IAP method is killing me...!

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    @Armelline In my game, I have a "Shop" page setup up as follows:

    • Stars 250 ($0.99)
    • Stars 750 ($1.99)
    • Stars 2,000 ($2.99)

    • Remove Ads ($1.99)

    I also have a "Settings" page setup as follows:

    • Restore Purchases
    • Remove Ads ($1.99)

    I'm having the same issue as @iKandy where I am prompted to input my password over and over, as well making a purchase only to be followed up with several purchase windows for my other IAP's...even though I did not press their buttons.

    Any ideas what is going on?

    Could it be I need to remove the "purchase request data" from all but one actor? I'm confused as to why I try making one purchase but then several purchases windows are fired right after...

  • LovejoyLovejoy Member Posts: 2,078

    @As_Of_Latte said:

    You should only have one request purchase data behavior, thats all it takes to fill the purchase table.

    Fortuna Infortuna Forti Una

  • ArmellineArmelline Member, PRO Posts: 5,354

    @As_Of_Latte said:
    Armelline In my game, I have a "Shop" page setup up as follows:
    Any ideas what is going on?

    Could it be I need to remove the "purchase request data" from all but one actor? I'm confused as to why I try making one purchase but then several purchases windows are fired right after...

    It sounds like you're triggering something repeatedly when you're not. I'm afraid IAP issues are very difficult to troubleshoot by description alone. I'd recommend creating a new thread and posting screenshots of ALL the logic you use for your IAP.

  • lotte205lotte205 Tallinn, EstoniaMember, PRO Posts: 41

    I'm making my first game and it's a little confusing. When I have this logic in my game, then do I have to put Show Banner behaviour in a rule and what kind of rule? For example When any attribute: buying, restoring and item_purchased is false then show ads?

  • ArmellineArmelline Member, PRO Posts: 5,354

    @lotte205 I'm assuming you're mentioning show banner behaviours because you're using the in-app purchase to disable ads in the game?

    If so, you'll use the IAP logic to change a game attribute (or table cell) from true to false/0 to 1 when the purchase is confirmed. e.g. "Change attribute game.Disable Ads to true"

    Then you put your ads in a rule that says something like:

    When game.Disable Ads is false
    Show banner ad

  • lotte205lotte205 Tallinn, EstoniaMember, PRO Posts: 41

    @Armelline Thank you for your quick reply. Unfortunately I really don't understand why the extra attribute "game.DisableAds"? In your template wouldn't it be "When game.ItemPurchased is false, then show banner"? And if you need the attribute game.DisableAds how do I use the IAP logic to change this attribute and where do I even put it? It would've been so much easier if you had the example show banner behaviour in your template :) But I really appreciate your work, the template is great and very detailed.

  • ArmellineArmelline Member, PRO Posts: 5,354

    @lotte205 said:
    Armelline Thank you for your quick reply. Unfortunately I really don't understand why the extra attribute "game.DisableAds"? In your template wouldn't it be "When game.ItemPurchased is false, then show banner"? And if you need the attribute game.DisableAds how do I use the IAP logic to change this attribute and where do I even put it? It would've been so much easier if you had the example show banner behaviour in your template :) But I really appreciate your work, the template is great and very detailed.

    I was just forgetting the name of the attribute. Substitute "game.DisableAds" with "game.ItemPurchased".

  • sebmat86sebmat86 Member Posts: 339

    Man, this is a lifesaver! Im so grateful! Shut up and take my money!

  • ArmellineArmelline Member, PRO Posts: 5,354

    @sebmat86 said:
    Man, this is a lifesaver! Im so grateful! Shut up and take my money!

    Very much appreciated!

  • GreenfroggGamesGreenfroggGames Member Posts: 224

    Might be a stupid question but you're supposed to replace "item" with iap ID right?

  • ArmellineArmelline Member, PRO Posts: 5,354

    @GreenfroggGames said:
    Might be a stupid question but you're supposed to replace "item" with iap ID right?

    Yes - both in the "Buy Item" behaviour and in the PurchaseTable.

  • TomvnTomvn Member Posts: 47

    Armelline .
    I try your code is work great , but put to my game is nothing happen.
    i got a button Buy coins with the Buy Coins attribute. integer , I use that instead Item.purchase attribute in boolean . Could you please make little more help on that?
    Thank you.

  • lotte205lotte205 Tallinn, EstoniaMember, PRO Posts: 41

    @Armelline I would now like to try consumable IAP. Do you have a template for that? If not, what's especially important to notice when adapting the non-consumable template?

  • ArmellineArmelline Member, PRO Posts: 5,354

    @lotte205 said:
    @Armelline I would now like to try consumable IAP. Do you have a template for that? If not, what's especially important to notice when adapting the non-consumable template?

    The only significant difference if you need to add the "Consume item" behaviour once you've confirmed the purchase has gone through. I let my develop account lapse a while ago as I had no specific need for it, but I'll need to re-enable it soon to test some IAP work for a client, so I'll see about adding consumable to the template when I do.

    @Tomvn said:
    Armelline .
    I try your code is work great , but put to my game is nothing happen.
    i got a button Buy coins with the Buy Coins attribute. integer , I use that instead Item.purchase attribute in boolean . Could you please make little more help on that?
    Thank you.

    Sorry @Tomvn I didn't see your message here. I'm afraid I'd need a lot more detail than that. It could be one of a hundred things going wrong.

  • lotte205lotte205 Tallinn, EstoniaMember, PRO Posts: 41

    @Armelline Thank you again :) Hope you have the time to update the template too..

Sign In or Register to comment.