Cordova InAppBilling can only buy once

I am using Cordova and this plugin and I am currently testing In-App_ purchases on Google Play.

Here's the plugin url:

LINK HERE

It works great when I use:

function buy(){
    // make the purchase
   inappbilling.buy(successHandler, errorHandler,"myProduct");
}

      

BUT, this only allows me to buy the product once ... After the first purchase, if I try again, I get the error:

"ERROR: Error purchasing: labResult: Unable to buy item. (response 7:Error)

      

So now I am trying:

function consumePurchase(){

   inappbilling.consumePurchase(successHandler, errorHandler, "myProduct");

}

      

But this also gives me an error:

"ERROR: myProduct is not owned so it cannot be consumed"

      

Hope I can get it so I can buy the same product multiple times?

+3


source to share


1 answer


This is a somewhat wild assumption as you can't see the details of your products, but your products don't seem to be consumed. For consumable and non-consumable products, see here (under the heading Non-Consumable and Consumable In-app Products) where it says:

Unused products

Typically, you will not implement consumption for in-app products that can only be purchased once in your application and provide ongoing benefits. Once purchased, these items will be permanently associated with a Google user account. An example product not consumed in the app is a premium upgrade or tier pack.

Consumable Products

On the contrary, you can implement the consumption of items that can be made available for purchase multiple times. Typically, these items provide some temporary effects. For example, a custom character can get life points or get additional gold coins in the inventory. The distribution of the benefits or effects of a purchased item in your app is called in-app product provisioning. You are responsible for monitoring and tracking how the products in the application are delivered to users.

Reasoning

Why does it seem like your foods are currently not being consumed? When you try to buy a second product , it gives you error code 7 , This error code



BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED: Failure to purchase since item is already owned

      

which only happens for non-consumable items that, by definition, can only be purchased once.

While these non-consumable foods cannot be purchased more than once, they also cannot be used as the name suggests. This leads to your second error message that you cannot consume the product.

How to fix

Simple: Change the items you want to consume to consumables, not consumables. If you cannot find how to do this, please let me know. All I can tell you (since I haven't even read about In-app billing) is that it has to be done in the Google Play developer console as stated here :

You can specify these types of products for your In-app Billing apps driven by apps and subscriptions. Google Play processes and tracks app ownership and app subscriptions based on user account.

+3


source







All Articles