Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Getting In-app Purchases to work
  • I think I am on the right track.
     I have tested AdMob ads and they work great without having the ability to Pay-to-remove the ads(simply setting a Rules Component to trigger Ads at a specific time).
    So to have an option for customers to pay to remove Ads this is what I have in the works . . .

    I already set-up an In-app Product called Remove Ads in the Google Developer Console.


    In my game I set up a Global property called:  PaidRemoveAds and left it set at 0.

    Then I have a level (a Game Settings page) with two buttons.
    1. Remove Ads button
    2. Restore Purchase button                 


    1.On the Remove Ads button I have set to trigger,

    Action Type:   Purchase Product
    Product Type:   Non-Consumable
    Product Id:   remove_ads.iap.nonconsumable
    Public Key (Android):   restore_remove_ads.iap.nonconsumable
    Debug Mode: checked

    On Completion:
    Trigger:
    ChangeGlobalPaidRemoveAds
    Change Property #Globals.Data.PaidRemoveAds = Type Integer 1


    2.On theRestore Purchase Button I have set to trigger:

    Action Type:   Restore Purchases
    Public Key (Android):   restore_remove_ads.iap.nonconsumable
    Debug Mode: checked

    On Load:
    Trigger:
    RestoreRemoveAds
    Change Property #Globals.Data.PaidRemoveAds = Type Integer 1


    Then all I’d have to do back on the game screen, off stage, is set up a generic spatial to control the ads to show up when the game transitions to show the Game Over Screen for example:

    Set up a Rules component to check for a property
    When:
    #GlobalGameState.GameStateMachine.currentState = GAME_OVER
    And
    #Globals.Data.PaidRemoveAds = 0

    Trigger:
    Admob Ad



    So what is happening is my ads show at a set time when the Global property for the ads remains as 0.
    Then when a customer pays, the Global property for the ads is set to 1, and they won’t show.


    The big question is, Am I even close?
    Can this be tested in debug mode or at all?


     image



    image
    image
  • 23 Comments sorted by
  • @BenFromOregon, yes this sounds right. On first glance I can see that you are using the wrong value for the Public Key. That should be the really long License Key from the Android developer portal. You should be able to test in debug mode once you correct that. 

    Remember that you have to be logged into your Android device with a different account (email) than the one associated with your Android developer account. The IAP will not work. So if the main account email on your android device is the same email associated with your android developer account, log out of your phone and log back in with another account (email).
  • @Lavon  Ok Great! and thank you for the advice it all makes sense to me. I have a separate email account for the Android device I am testing with.
    I will test this out in the next couple of days.
  • @BenFromOregon,  You also might want to work in a storage save for when the use purchases the 'remove ads'. That way when the game loads it could check that storage save file to see if they already purchased the 'remove ads' option.
  • @Carlton That sounds like a great idea, thanks!
    When I get this set up and tested I will post it here.
  • @Lavon Hi Lavon I haven't heard if any other user has been able to test the Android In-app Purchase in GBs
    and have yet to get it to take me through the purchase flow written about on the Google Developer website related to Testing In-app Billing.

    So far, anyway I try it my "Remove Ads" button just scales back up upon release or freezes the screen until the button is held down again.


    Does an in-app purchase Public Key need to be in "quotes"? I have tried both.


    Going through a checklist here:
    • I already set-up an In-app Product called Remove Ads in the Google Developer Console and set it to Activate.
    • Have a separate account on an Android device to test with and logged in.
    *When deploying to device for testing, I have tried both production and debug under publish settings,(publish settings debug just makes game lag on device, so I test in Production mode, Ads show up either way)



     In my game I set up a Global property called:  PaidRemoveAds and left it set at 0.



    Then I have a level (a Game Settings page) with two buttons.
    1. Remove Ads button
    2. Restore Purchase button                 


    1.On the Remove Ads button when the touch is released I have set to trigger,

    TRIGGER 1.(In-app Purchase) RemoveAds
    image
    TRIGGER 2.(Local Store) StorePaidRemoveAds

    image



    2.On the Restore Purchase Button when the touch is released I have set to trigger:


    TRIGGER 1.(Local Store)LoadPaidRemoveAds

    image

    TRIGGER 2.(In-app Purchase)Restore
    image

    Back on the game screen, off stage, is set up a generic spatial to control the ads to show up when the game transitions to show the Game Over screen for example:

    Set up a Rules component to check for a property
    When:
    #GlobalGameState.GameStateMachine.currentState = GAME_OVER
    And
    #Globals.Data.PaidRemoveAds = 0

    Trigger:
    Admob Ad

  • @BenFromOregon your game logic seems fine. You don't need to put quotes around the Public Key because the input field is not an expression input. Only expressions need quotes around strings. So in your IAP action where you put the product id you need quotes around that string because that is an expression field. That may be why the game is freezing because that causes a runtime error. 

    Also the debug and production settings in the Publish window is just for performance. Debug mode shows the console and log messages which does decrease performance on mobile. Production is what you want to use when ready to release or evaluating performance. 

     Make sure that your device has internet access when testing the in-app purchase action. Try putting something in the On Failed action slot also to see if the IAP is failing?
  • I am definitely logged in with the testing device as I purchased from Google Play store to test that.
    On the Failed action I had it trigger to play a particular sound, which does play, so IAP is failing.

    Is there a way I can see what is failing behind the scenes?

    I double checked/re-entered the Public Key.
  • @BenFromOregon did you add quotes around the product id string yet?
  • @Lavon Yes, it looks like
    "remove_ads.iap.nonconsumable"


    UPDATE:

    on the GooglePlay Dev Console, under all applications, then my application, there is a checklist including:
    APK
    STORE LISTING
    PRICING & DISTRIBUTION
    In-app Products
    Services & API's

    I've yet to fill out the STORE LISTING section with all the screen shots and game descriptions leaving STORE LISTING a dull grey unchecked color whereas the APK and PRICING & DISTRIBUTION have a green check mark.

    Maybe they require everything for the application to be filled out now. . .? or maybe need to set up Beta testing?
  • @BenFromOregon, that is not required. What does your screen look like on the In-App Products page? Is your product id marked as Active?



    Also check under Settings -> Account details -> License Testing make sure to add any emails that you will be using to test on your device to this section.



    Also make sure your Google Wallet is active and you have accepted any financial agreements required by google.


    image
    LicenseTestingEmailAdresses.jpg
    2962 x 1772 - 246K

  • @Lavon it must be in the Google Wallet, it is set to active currently, but inside the Google Wallet Settings there is LEGAL PROFILE and PAYMENT SETTINGS which have a few days to get approved? so I'll see if that makes a difference in a few days. Seeing the google wallet marked as Active, I hadn't set the Tax information and Bank Account.


    My product ID is Active
    image
    The email account to my testing device is set up(different account than Google Dev account)
    image
  • @BenFromOregon ok and in the meantime I'm going to look into updating the IAP plugin and re-testing to make sure it is still working with the latest changes from Google.
  • @Lavon I'll report what I find here after the accounts are approved and I have re-tested.
  • @BenFromOregon Google has in fact changed the way In-App Purchases become eligible for testing using a published product id. This is the message from their site:

    Previously, you could publish a "draft" version of your app for testing. This functionality is no longer supported. Instead, there are two ways you can test how a pre-release app functions on the Google Play store:

    • You can publish an app to the alpha or beta distribution channels. This makes the app available on the Google Play store, but only to the testers you put on a "whitelist".
    • In a few cases, you can test Google Play functionality with an unpublished app. For example, you can test an unpublished app's in-app billing support by using static responses, special reserved product IDs that always return a specific result (like "purchased" or "refunded").

    Now to test IAP on your device without going through the publish process there are a few "static" product ids that are recognized by Google's servers as test products and will return a specific response. They are:

    • android.test.purchased
    • android.test.canceled
    • android.test.item_unavailable
    • android.test.refunded
    You can use any of those product ids initially to test that your IAP flow works in your game. You will need to make sure you are using the correct Public License Key from your developer console.

    Now if you want to test your custom product ids which you will use in your final game you will need to actually publish an "Alpha" build of your game, with the License Key in it, via the google developer console. So you DO need to fill out all the required fields in order to publish your .APK file. You also need to make sure you have a physical address attached to your account because that is now a new requirement to comply with consumer protection laws.

    By uploading the build file from GBs to the alpha tab of your application it will not make the app available to the public but only to those users (emails) you have specified in the License testing section.


    image

    Once your alpha build is uploaded fill out all the store listing requirements. You will need to upload icons, sample screen shots, etc. You can use all dummy images for now because it won't be seen by the public. Once everything is fill out correctly you should see a  "Ready to publish" button.


    image

    Once you publish the alpha build of your game and your product ids are active and all the previous requirements are met you will need to wait a couple hours maybe until it all registers with Google's servers and then you should be able to test the real product ids on your device. Previously this was easier but now Google makes developers jump through a lot of hoops just to test IAP.
    TestInAppPurchase_AlphaBuild.jpg
    1024 x 426 - 72K
    IAP_ReadyToPublish.jpg
    1200 x 493 - 69K
  • @BenFromOregon you also asked how you can see the responses from Google. 

    If you export a debug version of your game from GBs the debug console becomes available. There is a performance hit but it is just for debugging purposes so that is fine. 

    In order to open that console on the device to see any log messages create a button object and put a Rules component on it to listen for a touch event. Every time that touch event is received trigger a Simulate Input action and simulate the firing of the "~" TILDE key which is the hot key for the console. Every time that key is fired the console will just toggle open and closed. Thats how you can see the actual response logs regarding IAP. Once again this only works with a debug build type set in the Publish window project settings. Also make sure debug mode is turned on in your IAP action.
  • @Lavon that's funny I thought it should be easier also when I saw the Alpha testing etc. This all sounds good and makes sense! I'll get a solid chance to get on this Saturday (juggling harvest season 'round here at the moment) I appreciate your simplified clarification of Google's Dev Console documentation on IAP and the trick to read the console will be VERY useful. BIG thanks

  • @Lavon Certainly a lot of hoops! I was able to set-up the alpha testing and Install an alpha build of my game to a device.
    The IAP (remove ads in my case) took me through the IAP flow with the next two images:
    image
    image

    The Ads remained in the game so I realized I needed to refigure some logic, which I did.
    Back in the Google Dev Console I Unpublished my alpha build and went to Upload a New APK (after I had re-figured some of the logic in GBs and saved the project and un-installed the game from the testing device)


    Upon Uploading a New APK to Alpha I recieve the following image in the reddish color:

    image

    Do I address this in GBs under Publish Settings/Platform and change the Bundle Version to say 1.1  ?
    and will have to do this everytime I refigure the logic in GBs to then test an alpha build to see if the IAP works correctly?



    *SIDE NOTE for anyone reading this: to get an alpha build onto a device, you will see a 'Manage list of Testers' on the Google Developer Console under the Alpha Testing tab. So before you can manage this, you first need to set-up(if you haven't one yet) a Google Group and then invite your testing devices' email address, next they(you) accept via email, and then when you add the Google Groups' email address to the 'Manage list of Testers' , that device will then be able to have access to the Alpha Build of your game in the Google Play store.  Or there is also the option of setting up a Google+ Community I believe.

  • @BenFromOregon, No, you only need to upload your .apk file from GBs once to the alpha section of your Google play console with your License key included in the build. You don't need to upload a new one each time you want to check the IAP process on your device. Just re-deploy to your device through GBs as long as you are not testing a new app with a new License Key.

    You do however have to update the version number in the publish settings if you upload a new alpha build so that Google recognizes it as a new version otherwise it will give you that error.
  • @Lavon, sorry, the reason I ask is I had uninstalled my game via the Google Play store, then made the changes in GBs and saved the project. Then when I re-installed the alpha version via Goole Play it is clearly the previous version I had before.
    Are you saying I can re-deploy and test the edited alpha version by clicking Deploy in the Publish Settings in GBs, NOT the in Publish button in the Publish Settings in GBs, I don't have to go back to the Google Play store page that says "You are a tester" and click the link "download from the play store"?
  • @BenFromOregon correct. Just re-deploy to your device for testing functionality in a new build. Only re-upload to Google once you are ready to release or you change something like the bundle Id or License Key.
  • @Lavon Just a heads up as what I have noticed so far. 
    I have a new build of my game with the same bundle id and License Key for the In-app Purchase as before. And I can deploy it to a device of mine via GBs. 
    The mystery is how to make the new build available to other testers from a Google Group(set up under 'Manage Testers' on Google Dev Console)
    Deploying from GBs doesn't have an effect for the link in the Google Play store the testers have access to. If a tester Installs the alpha build from the Google Play link, they definitely get the previous version of the game, not the new one.
    The goal is to have the testers be able to have access to a new alpha build to test the In-App purchase (in this case to see if the Ads disappear).
    I will keep investigating.  
  • @BenFromOregon If you want to provide a new build to your alpha testers just increase the version number in the Publish Settings, generate a new build, and upload it to the Google Play dashboard.

    Keep in mind that the version number is just an indicator of a new build version and when you publish your final game you can always put it back to 1.0 for the first version that will be live on the play store.
  • @Lavon That clears it all up now, Thank You !

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tagged