how to cancel an in-app test purchase on android?

前端 未结 9 511
眼角桃花
眼角桃花 2020-12-14 14:43

Until june 20th 2016 i was able to cancel test purchases done in my app. Doing multiple in-app purchases (not consumable) from the same test account made it easy to develop

9条回答
  •  悲&欢浪女
    2020-12-14 15:18

    I found a solution which isn't very convenient, but works. It seems like you can consume uncomsumable products and that way you can buy them again. I'm working with phonegap so I only have example code for the cordova-plugin-purchase plugin:

    store.when("your.product.id").updated(product => {
        if(product.owned) {
            var transaction = product.transaction;
            product.transaction = null;
            store.inappbilling.consumePurchase(
                function() { // success
                    alert("consume success");
                },
                function(err, code) { // error
                    alert("consume error " + err)
                },
                product.id,
                transaction.id
            );
        }
    });
    

    The updated callback gets called when you call store.refresh() or buy the product. So depending on your use case you'd want to implement an additional method of checking when to consume the product.

    I have no experience with the native Android in-app payments, but obviously you will be able to consume the products there as well.

    Edit: Sorry, I just read that you didn't want to include additional code in your project. I don't think that's possible at the moment, but would like to keep my answer here because it might help other people trying to test in-app payments.

提交回复
热议问题