Android Question In App Billing (Querying for Purchased Items)

Discussion in 'Android Questions' started by tucano2000, Jan 25, 2015.

  1. tucano2000

    tucano2000 Active Member Licensed User

    Is there an equivalent method to the code below into B4A using InAppBilling3 library to retrieve information about purchases made by the user from your app ?

    Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp"null);

    int response = ownedItems.getInt(
    if (response == 0) {
    String> ownedSkus =
    String>  purchaseDataList =
    String>  signatureList =
    String continuationToken =
    for (int i = 0; i < purchaseDataList.size(); ++i) {
    String purchaseData = purchaseDataList.get(i);
    String signature = signatureList.get(i);
    String sku = ownedSkus.get(i);
    do something with this purchase information
          // e.g. display the updated 
    list of products owned by user

       // if continuationToken != null, call getPurchases again
       // and pass in the token to retrieve more items
  2. Erel

    Erel Administrator Staff Member Licensed User

    See Manager.GetOwnedProducts.
    Peter Simpson likes this.
  3. tucano2000

    tucano2000 Active Member Licensed User

    I used Manager.GetOwnedProducts, but this only returns Products (Purchases) if I buy something in the same session that I have opened the application.

    See what I did in my code.

    Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
    "manager", key)
          manager.DebugLogging = 

    End If
    End Sub

    Sub Manager_BillingSupported (Supported As Boolean, Message As String)
    Log(Supported & ", " & Message)
    Log("Subscriptions supported: " & manager.SubscriptionsSupported)
    If Supported Then
    End If
    End Sub

    Sub manager_OwnedProducts (Success As Boolean, purchases As Map)
    Log("manager_OwnedProducts Success = " & Success)
    Log("purchases size = " & purchases.Size)
    If Success  Then
    For Each k As String In purchases.Keys
    End If
    End Sub
    The above code returns zero . It is as if I had not bought anything or signed anything. What am I doing wrong ?

    I need to check if a subscription has expired every time you open the application.

    In the documentation of google says:

    Last edited: Jan 26, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

    GetOwnedProducts should return all the owned products (not including consumed products). The "session" doesn't matter.
  5. tucano2000

    tucano2000 Active Member Licensed User

    Ok Erel, then how I can check to check if the subscription has expired using InAppBilling3 ? Is possible ? There is another method ?
    Last edited: Jan 26, 2015
  6. ivan.tellez

    ivan.tellez Active Member Licensed User

    GetOwnedProducts is for managed purchases, a subscription will not be listed calling GetOwnedProducts.
  7. tucano2000

    tucano2000 Active Member Licensed User

    How do I make managing subscriptions ?
  8. Erel

    Erel Administrator Staff Member Licensed User

    GetOwnedProducts should return subscriptions as well.
  9. tucano2000

    tucano2000 Active Member Licensed User

    Finally I'm getting use InAppBilling3 library to retrieve information of purchased products or subscriptions. Now how do I get the Server Response Codes when the user tries to buy a product and no success ?

    _PurchaseCompleted event only returns state success true or false. I need the other server response as well:

    BILLING_RESPONSE_RESULT_USER_CANCELED 1 User pressed back or canceled the dialog
    BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE 3 Billing API version is not supported for the type requested
    BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE 4 Requested product is not available for purchase
    5 BILLING_RESPONSE_RESULT_DEVELOPER_ERROR Invalid arguments provided to the API. This error can que Also Indicate the application was not signed or enquiry.c Correctly set-up for In-app Billing in Google Play, or does not have the Necessary permissions in its manifest
    BILLING_RESPONSE_RESULT_ERROR 6 Fatal error during the API action
    BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED 7 Failure to purchase since item is already owned
    BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED 8 Failure to consume since item is not owned
    Last edited: Mar 6, 2015
    Humberto likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice