Android Question In-App Billing v3 - cancel transaction

Discussion in 'Android Questions' started by Shay, Jun 7, 2015.

  1. Shay

    Shay Well-Known Member Licensed User

    I read this:

    My issue:
    I made order, then cancel it from google play, it was 24hr ago
    I do send:
    If BillManager.SubscriptionsSupported = True Then
    End If
    and on:
    Sub BillManager_OwnedProducts (Success As Boolean, purchases As Map)
    If Success Then
    For Each p As Purchase In purchases.Values
    Log(p.ProductId & ", Purchased? " & (p.PurchaseState))
    '0 - purchased, 1 - canceled, 2 - refunded
             If p.PurchaseState = p.STATE_PURCHASED Then
              Trial_Button.Visible = 
              Trial_Button.Visible = 
    End If
    End If
    End Sub
    but I am always getting "0" as purchased

    this is from logcat:
    (MyMap) {standard_user_1year=Purchase(type:subs): standard_user_1year, state = 0}
    standard_user_1year, Purchased? 0

    what is wrong?
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is a known issue with Google IAP. It can take a very long time until the order state is correctly updated.
    Peter Simpson likes this.
  3. Shay

    Shay Well-Known Member Licensed User

    Can it be related to this, which I don't see in the library option to: "getPurchases"

    Local Caching
    Because the Google Play client now caches In-app Billing information locally on the device, you can use the Version 3 API to query for this information more frequently, for example through a getPurchases call. Unlike with previous versions of the API, many Version 3 API calls will be serviced through cache lookups instead of through a network connection to Google Play, which significantly speeds up the API's response time.
  4. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    I'm seeing this issue too in a game where a user can purchase packs of x number of bonuses that can then be consumed one by one. The problem is that if I cancel an order at a user's request & there's a delay in seeing the cancellation in my code in the app, they could use all the bonuses before I can deduct them from their stash. I suppose at least I have some control over this, because users have to ask me to cancel the order (ie: with In-App Billing they can't request an automatic refund like they can with app purchases) - so if a user tries to exploit this issue, I can just refuse to cancel their order. Not ideal though & it would be good to see this library implement all the In-App Billing 3 API functionality.

    - Colin.
  5. Erel

    Erel Administrator Staff Member Licensed User

    The problem is not in the library. You can call GetOwnedProducts to get the current known purchases.

    The problem is that it takes a long time for the data to be updated.
  6. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Thanks Erel - I realize that the delay in the cancellation processing is on Google's end, so I guess we just have to live with it - although seeing how many developers seem to be having issues with it, I'm surprised they haven't done something to fix it.

    I should have written the last part of my post more clearly - what I meant to say was that apart from the cancellation delay issue, it would be great to see all the API functionality implemented. There is a getSkuDetails method in the API that doesn't appear to be implemented in the library. One instance where I can see this would be useful to have would be if I was to have a bunch of IAP items that I want to roll out gradually without having to release an update every time. I could put all the relevant code in my app & have it conditional upon certain product IDs being available, then add those IDs to my IAP list in the Developer Console at a later date. Having the getSkuDetails implemented would allow the app to check what products are available & show them to the user dynamically as they are added in the back-end.

    Anyway, for now I have successfully implemented some In-App Billing in one of my games, so thanks for providing the library in its current form.

    - Colin.