Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to add Android InApp purchases - Page 3 — Gideros Forum

How to add Android InApp purchases

13»

Comments

  • Hi all, (long time reader, first time poster..)

    If you have an app that allows you to purchase coins. eg. you have made 10 purchases of 20 coins.

    when you RestoreTransactions(), do you get 200 ? or do you get 10 records of 20 coins ?

    Given that the product will be the same for each purchase.

  • hgvyas123hgvyas123 Guru
    edited June 2013
    @ArtLeeApps

    there are three types of iaps i dont know the exact names but might be they are managable, unmanagable and subsciption based one of the type can be purchased only on once and can not be purchased second type in whatever condition and other one can be purchased as much time as much user likes but it can not be restored so in terms of coins you have to go with second option which can not be restored unless you store all the data of user in ur own server however users are already aware by this and if you dont want to setup ur own server it is perfectly fine and most of the games are also not setting their server

    :)

    Likes: fxone

    +1 -1 (+1 / -0 )Share on Facebook
  • @hgvyas123

    Ah ok. that makes sense.

    I had setup a file for "stars" in my game using datasaver, as stars.earnt and stars.purchased so i could record what they earn through achievement and what they purchased.

    I was just worried, if they re-install the app somewhere that i would have to restore what they had paid for. But if that is not an issue, then i will just store it locally as above.

    Many Thanks :)

    Likes: hgvyas123

    +1 -1 (+1 / -0 )Share on Facebook
  • jdbcjdbc Member
    edited July 2013
    @ArtLeeApps

    there are three types of iaps i dont know the exact names but might be they are managable, unmanagable and subsciption based one of the type can be purchased only on once and can not be purchased second type in whatever condition and other one can be purchased as much time as much user likes but it can not be restored so in terms of coins you have to go with second option which can not be restored unless you store all the data of user in ur own server however users are already aware by this and if you dont want to setup ur own server it is perfectly fine and most of the games are also not setting their server

    :)
    After some reading of http://developer.android.com/google/play/billing/api.html#consumetypes, it seems that Android Billing API v3 only supports Managed In-app Products and subscriptions.

    Does someone know what version of Billing API is supported by Gideros?

    In case of supported API v3, it means all products will be managed and how can I send a consumption request to Google Play (for example I purchased 5 coins and during gameplay 2 are used, but 3 are available for using)

    I assume if Gideros only supports Billing API v2, every Android app must manage its own comsumible in-app products (saving in local disk)
  • Anyone ?,

    Ok i have this working, i can buy items using my girlfriends test phone :)

    But, now i can run my app in the Gideros Studio Player, as its looking for Googlebilling.

    how do you fix that, or does this mean from here on, if i do anything to my app, ihave to export it and run it in eclipse ?


  • ArtLeeAppsArtLeeApps Member
    edited July 2013
    ok, ive turned into my own helpdesk.

    ive used this method to get around it.
    To handle the Notification and GoogleBilling.

    In Main:
     
    deviceInfo = application:getDeviceInfo()
     
    if deviceInfo == "Android" then
    	isAndroid = true
    elseif deviceInfo == "IOS" or deviceInfo == "MAS OS" then
    	isIOS = true
    end
     
    -- the graphics class
    require "box2d"
    if isAndroid == true or isIOS == true then
    	require "notification"
    end
    In the Inapp code:
    if isAndroid == true then
    	require "googlebilling"
    end
    and
     
    if isAndroid == true then
    	googlebilling:setPublicKey("My long Key")
    	googlebilling:addEventListener(Event.REQUEST_PURCHASE_COMPLETE, onRequestPurchaseComplete)
    	googlebilling:addEventListener(Event.PURCHASE_STATE_CHANGE, onPurchaseStateChange)
    end

    Is this the way to go ?

    Now i can run this in the Player and my Phone.
  • @ar2rsawseen, excellent. I must be actually understanding some of this language now ... finally :-B
  • ArtLeeAppsArtLeeApps Member
    edited July 2013
    Hi @ar2rsawseen,

    1) I can now make a purchase in my app. it shows google. and i have a payment record in the development console, and it even deducted the payment from my test users account (not a problem but dont know why.).

    The problem is, im not getting anything back to say its processed.
    Even when i put Alert dialogs.
    i have worked out its the Intents/Events. But i dont know what is the standard codes being sent from GOOGLE. Im using the script in this thread to handle the events, but it uses different event codes to my standard exported manifest file.

    eg.
    Manifest File snippet:
                   < action android:name="com.android.vending.billing.IN_APP_NOTIFY" / >
                    < action android:name="com.android.vending.billing.RESPONSE_CODE" / >
                    < action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" / >

    Lua Code From this Thread:
     
    googlebilling:setPublicKey("yourverylongpublickey")
    googlebilling:addEventListener(Event.REQUEST_PURCHASE_COMPLETE, onRequestPurchaseComplete)
    googlebilling:addEventListener(Event.PURCHASE_STATE_CHANGE, onPurchaseStateChange)
    Summary: i need to know what the Intent codes are from GOOGlE so i can listen for them in the manifest.... and in Lua...



  • ar2rsawseenar2rsawseen Maintainer
    All that should be added to manifest is:
    <service android:name="com.giderosmobile.android.plugins.googlebilling.BillingService" />
     
    <receiver android:name="com.giderosmobile.android.plugins.googlebilling.BillingReceiver">
         <intent-filter>
             <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
             <action android:name="com.android.vending.billing.RESPONSE_CODE" />
             <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
          </intent-filter>
    </receiver>
    Most common problem to this is that googlebilling is a global object, but you define a local function as event listener, thus you make purchase somewhere outside the scope and it does not launch it :)
  • @ar2rsawseen

    I dont understand why the Lua code has "PURCHASE_STATE_CHANGED" and the Manifest has "PURCHASE_STATE_CHANGE" (without the "D" at the end)... is that intentional or am i just going loopy ?

  • emreemre Member
    Hii,
    Is there similar sample code for StoreKit in the forum?
    Thanks
  • Hi @ar2rsawseen ,

    sorry for my dumbness on this one, but..

    i dont understand if the Manifest is listening for < action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" / >

    But the Lua code is Listening for and event of :
    googlebilling:addEventListener(Event.PURCHASE_STATE_CHANGE, onPurchaseStateChange)

    Why are they different codes?
    or are they totally not related to each other?
    the way im reading this, is the Manifest needs to listen for a service, then the Lua code Listens for the event...

    Sorry again
  • ar2rsawseenar2rsawseen Maintainer
    @ArtLeeApps well you may say they are unrelated.
    Basically the code in manifest does not exactly go straight to Lua. It calls a subclass of Google Billing, which calls the main Billing Class, which calls a native function in C++ which enqueues event, which gets received by binding class and dispatched to Lua.
    the name Event.PURCHASE_STATE_CHANGE (without D was used for consistency with other Gidros events), like it's not Event.COMPLETED, it's Event.COMPLETE

    Likes: hgvyas123

    +1 -1 (+1 / -0 )Share on Facebook
  • @ar2rsawseen Got it.

    A Noob mistake.
    i copied the IAP Gideros code to its own file (so it was neat). so the calls to start the listeners never happened. I have now put the function in main, and started the listeners there also, so if the game is running, its got ears on.
    i have now successfully made a purchase and its added my stars to the game etc. :)
    thanks again.
  • Is this a Google Bug ?

    During testing, i had made a managed purchase (remove_ads). that worked fine.
    Then i went to my google console and refunded the transaction(as my partners account is still being deducted money even though she is on the test user list.. but thats not the issue..)

    I then uninstalled the game, and reinstalled it.
    The game has ads again (as expected)
    BUT, then i go to purchase remove_ads again, and it says i cant as i already have purchased this.

    Wouldnt google reset that purchase if i refunded the money ?
    * i did buy this when i was still trying to get the purchasing to work, so that may have something to do with it.

    any thoughts ?
  • larflarf Member
    edited October 2013
    @atilim or @ar2rsawseen so is there no way to find out what products have been already purchased by the user? in case a user buys something in the app then removes and re-installs the app. Or does this just not work for gideros player?

    This is what i'm doing.

    local function onRestoreTransactionsComplete(event)
    print("RESTORE_TRANSACTIONS_COMPLETE EVENT")
    for key,value in pairs(event) do print(key,value) end
    end

    googlebilling:setApiVersion(2)
    googlebilling:setPublicKey("my_key")
    googlebilling:requestPurchase("android.test.purchased")
    googlebilling:restoreTransactions()

    and i get

    __target table: 0x5f7df958
    __type restoreTransactionsComplete
    __userdata userdata: 0x5f7ce728
    responseCode ok

    no info about what purchases the user has...

  • Nevermind. I just realized that calling googlebilling:restoreTransactions() gets google to resend the Event.PURCHASE_STATE_CHANGE events
Sign In or Register to comment.