Skip to main content
Question

Can I force sync between PaymentQueue and RevenueCat for consumable in app purchases in React Native?

  • March 10, 2022
  • 1 reply
  • 137 views

Forum|alt.badge.img+1
  • New Member
  • 3 replies

Hello,

 

I have a React Native iOS project where I am incorporating RevenueCat Consumable in app purchases.  We noticed that there is an edge case with the purchasePackage flow described in the documentation here: https://docs.revenuecat.com/docs/making-purchases

        try {
            console.log(`Making purchase`);
            await Purchases.purchasePackage(productPackage);
            console.log(`Purchase successful`);
        } catch (error) {
            if (error.userCancelled) {
                // do nothing
            } else {
                // do error logic
            }
        }

If there is an internet disruption or the app crashes during the execution of that purchasePackage promise (after the payment is authorized in the payment sheet but before the promise resolves), the payment can get in a weird state where it seems to be recorded but not recognized by RevenueCat. We do not get a web hook until either the user tries to purchase the product again or the user successfully purchases another product. In the case that the user tries to purchase the product again, it seems to recognize the previous authorization as it does not show the native iOS payment sheet and just synchronizes the previous purchase.

I realize this is an edge case, but is there a way to force RevenueCat to sync with the underlying payment queue to avoid this behavior. Or is there a recommended way to handle this behavior? Is it typical to force the user to try to purchase again?

 

Thank you!

1 reply

Forum|alt.badge.img+1
  • Author
  • New Member
  • 3 replies
  • March 10, 2022

To add to this, I see there is a Purchases.syncPurchases() function. It has a warning in the type header “This function should only be called if you're not calling makePurchase.”

 

This is referenced in the docs with the context of ObserverMode on android. Would this be the right way to go or would there be unintended consequences?


Reply


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