Android In-app purchase: how to consume?

前端 未结 2 1325
一生所求
一生所求 2021-01-05 16:41

I\'ve implemented Google In-App Billing V3 in my app and i did my first test purchase. Now, as seen that i want it consumable, but if i click the \"Purchase\" button again i

相关标签:
2条回答
  • 2021-01-05 16:54

    As stated in the official documentetion: https://developer.android.com/google/play/billing/billing_reference.html

    The response intent to the purchase includes several fields, one of them being:

    INAPP_PURCHASE_DATA A String in JSON format that contains details about the purchase order. See table 4 for a description of the JSON fields.

    Inside that JSON, you have several fields, also explained in that page, the one you are looking for is:

    purchaseToken A token that uniquely identifies a purchase for a given item and user pair.

    All these is quite easy to follow from the official sample application, which I recommend you to download and try out, also to check the code.

    0 讨论(0)
  • 2021-01-05 17:09

    Ok, i solved. Instead of using:

    int response = mService.consumePurchase(3, getPackageName(), token); 
    

    follow this thread:

    mService.consumePurchase(3, packageName, purchaseToken) always returns RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API

    0 讨论(0)
提交回复
热议问题