New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
purchaseUpdatedListener called multiple times even after purchase #1172
Comments
Does the event fire the same purchase results? |
Yes, it fires with the successful results/receipt. If there is no current receipt it fires too, but fails on the validation server. |
Could you please check if your component is not rerendered? There were lots of issue when the component rerendered and listeners started several times occationally. Well that should be released tough but we need to reproduce your case. |
Well, it's the "NavigatorContainer" means I am setting different states, updating stuff and so on. But only renders one and then "rerenders" for the update of different states, props... But that's what is for - to unsubscribe to the listeners/to avoid this.
|
Yes I have also mentioned this. Just shared the previous issue I remember. We need the reproduction. Also, cleariing transaction or trying with different testflight account might help. |
Tested in in TestFlight, production and different devices. |
Different account? |
Yes, same result. |
Strange. Could you also try the code snippet in our |
I have the following behaviour.
I am using classes, but I don't see any re-render. I am on "react-native-iap": "4.4.1" and "react-native": "0.63.3". I have tried to upgrade to 5.0.0, but I am getting the same behaviour. |
Hello one question. did you find the solution to this? |
Still same problem. Looks like it´s purchaseUpdatedListener is broken. Please fix this asap. No solution found. |
Having same issue with this. How is it possible that it's not fixed for months? Is this not a critical issue or has someone found a workaround for this? Also if it helps, I think I only encountered this issue when I upgraded my device from iOS 13 to iOS 14. As far as I could recall it was working fine on iOS 13 but I could be mistaken. |
Same issue here. This is my
And then i use this code in the root component
The root component can happen to get unmounted and remounted, the Even in this situation, the purchase purchaseUpdatedListener is still called many times, es |
any solution? |
Have the same issue. |
Same issue for me. It calls the past receipts when the iap initialises the next time. |
I had the same problem and I realized that the same was happening because I was not assembling and disassembling the component correctly, thus making several listeners open at the same time.
Every time a purchase is made and the component is disassembled it is necessary to remove the listener/subscription and add a new one when assembling the component. |
A possible workaround, testing I noticed that it sometimes shows the past receipts(sent to the server) so what I did is immediately store the transactionId of each notification received, so you always check the database first for if this transactionId has been processed and if so then ignore(it's a duplicate) if not then you can proceed. If the notification comes first to the App(rather than the server) then you can put some logic to control this i.e you should only receive 1 after a certain button has been clicked etc. |
Yes, there are some sketchy workarounds, but they are all pretty .... |
There is only one solution, is to use : Revenuecat ;) |
Revenuecat |
same issue |
Have you guys checked |
Please look into below information and see if these helps. "What you're seeing with multiple process purchase calls is actually normal in the case of auto-renewing subscriptions. When you test in the sandbox those subscriptions renew very quickly (how fast depends on sub period) and you can often see several of those appear in the queue after an app restart. Also, if a purchase hasn't been successfully completed (which is likely given those exceptions) then they can remain in the queue and result in multiple calls to your ProcessPurchase on every app restart until the problem is resolved." from https://forum.unity.com/threads/solved-processpurchase-event-get-called-multiple-times.506574. Also, The stackoverflow. |
Any solution I am facing the same issue of calling both purchaseUpdatedListener purchaseErrorListener multiple times (more than 15 times) I am using the latest released version "react-native-iap": "10.0.1" |
Can you please share what kind of events are you getting? Could it be previous transaction that were not finished? |
Yes it gets called imiidatly for multiple times with the same purchase, I want to call My API to store the recipt for the subscription and due to multiple call backend will be confused Any solution to stop I am also finishing transaction after calling my API but before finishing it get called again and again. |
@andresesfm also note that the same is happening for purchaseErrorListener. I am attaching the screenshot of the already having subscription error after pressing the ok button from the popup. |
Please try 10.0.3 that adds clean up on disconnect. Please open a new ticket if this is still an issue. Even if the symptoms are the same, the code has changed too much to trace back. Thank you for understanding |
Okay, I will try with the 10.0.3 and update you here. |
Hello @andresesfm, I used the latest version 10.0.5 but still, the listeners are called 3-4 times. |
Hi @andresesfm I tried with the latest version but still the same is happening for purchaseErrorListener and purchaseUpdatedListener. Anything else I can try? |
@dprajapati1179 the listeners will get every purchase transaction |
@andresesfm Hello i have some questions about transactions and updateListener.I start to use react-native-iap and for testing i used sandbox like everybody i think..when i make purchase for any product everything is good i get receipt, sending to my server to validate, if server send me status okey i finishTransaction (this method always return undefined). And sandbox make multiple payments every 3-5 minutes.I saw that we have 2 statuses of payments(Available and Pending) i console.log to see what happen everytime with them.When statuses are in Available -> updateListener work correctly, but sometimes a lot statuses come to Pending and crash my server.I find out one flow that make my purchases to Pending -> I pay 1 subscription for example, my server validate and i finish transaction..after 15 minutes i goes to paymentscreen and click again to this subscription i receive status that already own this product, click okey and after return again to this page i saw a lot purchases goes to Pending.So i try to understand how that work.Also why after finish any trasanction they again goes to AvailableProducts, and how to understand that i finishTransaction works correctly when return me undefined.And what if for example i finishTransaction only in one screen..and if i make first purchase and leave page, after 30 minutes i log again, sandbox will make auto 5-6 payments, should i make 1 loop before updateListener to finish all new upcomming Pending transactions? |
@ToniNikolaev23 You might get many duplicate transactions on sandbox as you are making many purchases with the same account. This is not typical in production |
Same issue for me also.purchaseUpdatedListener calling when user enter into the screen as well. |
const processNewPurchase = async (purchase) => { What if transactionReceipt is get empty ? |
It means that the purchase didn't go through |
I'm using latest version 12.10.2 and still getting this problem, Please help me out in this |
same here! It seems the more i test, the more the listener gets called |
the same problem? any updates? |
I currently have the same issue on Android. I get at least two listeners, which is quite problematic. On iOS everything seems to be fine for me. I am using "react-native-iap": "^12.10.4" Any ideas how to fix it? |
Any fix for this issue? |
use expo-in-app-purchases Development of expo-in-app-purchases is currently paused to focus on other projects. Alternative libraries include react-native-iap and react-native-purchases from RevenueCat. |
I had the same issue. Purchase listener was running two times. I made the function which will do nothing when listener run more than once. You can set
|
Isn't this expected behavior? You are calling "await finishTransaction(purchase);" in the purchaseUpdatedListener. //Global Scope
let lastTransactionRecipe = null;
purchaseUpdateSubscription = purchaseUpdatedListener(
(purchase) => {
if (purchase.transactionReceipt) {
if(lastTransactionRecipe === purchase.transactionReceipt) return;
//Do recipe validation check
lastTransactionRecipe = purchase.transactionReceipt;
finishTransaction({purchase, isConsumable: false});
}
}
); |
any new update? we have the same problem. |
there is we have only a crutch as a solution -_- |
+1 |
My version: "react-native-iap": "^12.13.0" |
Version of react-native-iap
5.0.1
Version of react-native
0.63.3
Platforms you faced the error (IOS or Android or both?)
IOS
Expected behavior
purchaseUpdatedListener not getting called multiple times
Actual behavior
purchaseUpdatedListener getting called on startup multiple times, sometimes even in between
Tested environment (Emulator? Real Device?)
Real device (iOS 14, 13 in Test Flight and in AppStore)
Steps to reproduce the behavior
(Navigator Component)
The text was updated successfully, but these errors were encountered: