0.3.10
Android
Should be able to rebuy an item as many times as I need since I'm just testing
Returns
Error: You already own this item.
at createErrorFromErrorData (59522b9c-ca17-4e00-9e00-05cc989b1199:2016)
at 59522b9c-ca17-4e00-9e00-05cc989b1199:1968
at MessageQueue.__invokeCallback (59522b9c-ca17-4e00-9e00-05cc989b1199:2410)
at 59522b9c-ca17-4e00-9e00-05cc989b1199:2155
at MessageQueue.__guardSafe (59522b9c-ca17-4e00-9e00-05cc989b1199:2323)
at MessageQueue.invokeCallbackAndReturnFlushedQueue (59522b9c-ca17-4e00-9e00-05cc989b1199:2154)
at t (RNDebuggerWorker.js:1)
Buy an item more than once using a test account
@ilyakar Is this a consumable product? You should consumeItem to rebuy it. Please read some guides on how IAP works in android.
Hi @dooboolab, it's not a consumable product. Users have it forever. There's a way to restore the product so it's good to let users known in production that they cannot buy the same product again since they already bought it. But for testing purposes, it gets very uncomfortable to have to use a different account each time all the purchases have been bought.
I don't think I had this problem in 0.2.17
@ilyakar Ah.. Sorry I was confused. Actually, if it is non-consumable
product, you can't actually rebuy it. If that was possible in 0.2.17
that must be working awkwardly.. Only consumable products are able to rebuy it. It is same in both platforms (ios and android). If user want to restore the item they have to do it optionally but as in LINK, it won't charge the user again. Therefore, if you are designing in-app products that you want to charge users by rebuying, I think you should create consumable
product.
@ilyakar I've got feedback from my friend developer and he also faced the same problem. Therefore, I came up with solution to use refreshItems
method that only occurs in android
. You can use this in [email protected]
. Try using it after prepare
method. My friend was facing this issue because he couldn't find the token of purchased product to consume. Therefore, this method
is just for your ease if you don't care about the history of the purchases that relies in playstore
. When you have your own backend collecting the purchase history, this will help you to solve the issue. I have to take a look on this one furthermore tough. Also, following the readme
would help you. Thank you for your report!
P.S. I think above method will work on non-consumable
product too. Also this article will help you understand what refeshItems
would solve you.
I think this is already solved since I don't think IAP works with Test Account
And @dooboolab's solution of refreshItems
is the way to go
One noob question @dooboolab as I have only implemented IAP once in an Android App but never tried if it works 😂
Can we buy a product without spending any money like $0❓
Yes @deadcoder0904, that's the whole concept of Android test accounts (https://developer.android.com/google/play/billing/billing_testing.html). Which do work fine with the plugin, but as I have pointed out, you cannot make the same purchase twice.
@ilyakar You're saying that it is still not working. Did you tried calling refreshItems
after buying product? As described in here, it may cause some delay in playstore. However, you can force consuming the product to able to rebuy again. I'm also curious why this works though.. Also watch out if you rely on purchases on google play history and not collecting it in your backend.
Hi @dooboolab, I was just responding to @deadcoder0904 with my previous knowledge. I'm afraid I have not tried your solution and probably won't for some time since it's not an urgent fix. But I will let you know in the future when I have.
@ilyakar becareful using refreshItems
because it will consume all the products user has bought. You can only use it if you don't care about those information stored in playstore because you have your won server. Also, this problem use to occur like I posted 13 days ago from here, if user has refunded the item, user may not rebuy the same item for 24 hours.
I was running into the same issue as @ilyakar, and using the code below I was able to clear the non-consumable purchase and test it again.
async componentDidMount() {
const { itemSkus } = this.props;
try {
const result = await RNIap.initConnection()
console.log('initiated connection?', result)
const consumed = await RNIap.consumeAllItems();
console.log('consumed all items?', consumed)
let products = await RNIap.getProducts(itemSkus);
console.log('loaded products', products)
} catch (err) {
console.warn(err);
}
};
@TylerNoblett This solution isn't working right now.
consumeAllItemsAndroid
instead of consumeAllItems
.The console output is:
setUpDeveloperTools.js:73 TypeError: _reactNativeIap.default.consumeAllItems is not a function
at loadPurchases$ (NewGameScreen.js:167)
at tryCatch (runtime.js:45)
at Generator.invoke [as _invoke] (runtime.js:271)
at Generator.prototype.<computed> [as next] (runtime.js:97)
at tryCatch (runtime.js:45)
at invoke (runtime.js:135)
at runtime.js:145
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:289
On:
"react": "16.9.0",
"react-native": "0.61.3",
"react-native-iap": "^4.3.0",
@tulpn Looks like you've not correctly installed our module since consumeAllItemsAndroid
should be working fine.
@hyochan Didn't work for me.
@roots-ai What version are you using? Also, please refers to the code we've provided in example
too.
Most helpful comment
I was running into the same issue as @ilyakar, and using the code below I was able to clear the non-consumable purchase and test it again.