Skip to main content
Question

Slow Test Card Causes Issues with User Logout or Uninstall After Purchase

  • November 6, 2024
  • 1 reply
  • 64 views

Forum|alt.badge.img

Hi folks,

I'm experiencing some issues with handling pending purchases in our app. Let me first outline the scenario:

We have a consumable product that users can purchase repeatedly. Each time a user makes a purchase, we store tokens in Firestore collection associated with their Firebase Auth userId. We've also integrated RevenueCat with Firestore to log purchase events and we are using the same AppUserID in revenue cat as the Firebase Auth userId to keep data in sync.

The issue arises when I test purchases using the “Slow test card (approved after a few minutes)” option. With this, the purchase initially goes into a "pending" state. I know that reopening the app later will register the purchase under the correct AppUserID in both the RevenueCat dashboard and our Firestore collection tracking RevenueCat events.

I've read articles suggesting solutions, such as setting up a listener or periodically calling getCustomerInfo() to monitor for updates. The goal would be to automate this so that if a purchase enters the pending state, our backend listens for purchase events tied to that specific AppUserID and can update the user’s tokens accordingly. Does this seem like a viable solution, or are there any improvements I should consider?

The main issue occurs when a user initiates a purchase with the “Slow test card” and then logs out or uninstalls the app. If they later sign back in after the purchase completes, or even if they sign back in before the purchase completes, the RevenueCat dashboard registers the purchase, but it’s associated with an anonymous AppUserID. The event collection on firestore also shows AppUserID = anonymous in Firestore collection, meaning we lose track of the user-specific data.

I've searched for solutions to this, but haven't found anything that directly addresses this scenario. Any advice on how to handle this would be greatly appreciated!

Thank you in advance!

SDK Version: 8.9.0

This post has been closed for comments

1 reply

jeffrey_bunn
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 277 replies
  • November 8, 2024

Hi @muhammad-amaan-f71839 - thanks for sharing such detailed context about this issue.

For the first scenario, I’d suggest setting up the customerInfo listener. This listens for purchases made on the current device, which is exactly what happens in this situation. When the purchase fulfills, the listener will push a new customerInfo object, which you can then use display the “upgraded” version of your app to the customer.

For the second scenario - do you allow users to use your app without logging into an account? For example, calling configure without providing a user ID will create an anonymous ID. If, instead, you waited to call configure until you have a user ID (i.e., they logged into their account), the purchase would be associated with the correct user.

Another way to handle this (without changing how you currently call configure) is, assuming you have our default “Transfer to new App User ID” restore behavior enabled, to call syncPurchases after a user logs in. This would then merge the (newly created) anonymous user with the identified app user, so the purchase would end up with the identifier app user. 

Happy to help if you have additional questions. Thanks!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings