Question

Other ways to get the Google Product object after purchase?

  • 1 March 2022
  • 3 replies
  • 47 views

Badge +1

Hi there!

I am using this function to purchase products or subscriptions: purchaseProductWith(activity, skuDetails, onError, onSuccess) and I have the following use case: I am trying to purchase a subscription, then immediately after the payment is made, I lose my internet connection. In purchaseProductWith I receive onError → NetworkError, which is ok. Google also sends me an email with the receipt. Then once the internet connection is stable, I am not receiving the Product object from purchaseProductWith → onSuccess, in fact, this method is no longer triggered. If I try to buy again the same subscription it says that I am already subscribed, which is also correct, I already payed for the subscription. The problem is that since we don’t receive back the Product object from purchaseProductWith, we have nothing to send to our server, the server needs this object to validate it with google and to grant the user the necessary permissions to unlock features. We have a lot of clients who have faced this situation and they are not very happy. I tried to find a way to get the Product object but without success. Is this the intended behaviour for purchaseProductWith? Is there another way to get the Product object? Any help is much appreciated. 

P.S: I am using purchases for Android version 4.6.1.


3 replies

Userlevel 5
Badge +10

Hey @Adriana Pele 

Since you’re using RevenueCat, we actually validate the purchase on our end with Google’s endpoint before the subscription is posted to the RevenueCat customer profile. If you have webhooks setup, RevenueCat will dispatch an event to your servers letting you know a purchase has been made. Is there a reason why your team prefers to do this on your end? What information are you looking for from the Product object? 

Badge +1

Hi Tina, 

Thank you for your reply. Unfortunately, webhooks are available only under the paid plans. To validate the product with Google’s endpoint we need the entire product object.

Userlevel 5
Badge +10

Hi @Adriana Pele 

Another option is to set up a listener for CustomerInfo (previously called PurchaserInfo, you can go to an older version of the docs if you wish to see details for PurchaserInfo). For reference: https://docs.revenuecat.com/docs/getting-started#optional-listening-for-customerinfo-updates From the object, you can get a list of purchased product identifiers and also the EntitlementInfo object. Then once you know the product the customer purchased, we have a StoreProduct class to pull any necessary details you need to call Google’s endpoint. Github for reference. 

Reply