Solved

[Flutter & Android] after refund, still get active entitlement

  • 12 November 2021
  • 5 replies
  • 421 views

Badge +2

Hi,

I am developing an app for Android using Flutter and I am trying your awesome service!!
All is working fine by now, but the refund operation. I explaining what I did till now:
I have purchased successfully a non-cosumable (life time) with my testing account. This is working fine also when restarting the app without internet active also after hours, meaning the cache does the job.

Then I refunded the account in Google Play console and waited till it was successfuly refunded.

Starting the app the entitlement is still active. At start I check this using:

PurchaserInfo purchaserInfo = await Purchases.getPurchaserInfo();
purchaserInfo.entitlements.all['myLifeTimeEntitlement']?.isActive <== this is true

Basically I have the same issue described in this post:
https://community.revenuecat.com/topic/show?tid=326&fid=7

I read somewhere that the SDK cache is refreshed about every 5 minutes. Thinking about this, I found:

await Purchases.invalidatePurchaserInfoCache();

which is not recommended. Anyway seems not to work and I didn't find anything similar to try.
So I tried to uninstall and reinstall the app. And this worked! The entitlement.isActive was set to false.

I think I missed something, any help is greatly appreciated!
Thanks for your time

icon

Best answer by ryan 22 November 2021, 22:24

View original

5 replies

Badge +2

Some more info:

the log after calling invalidatePurchaserInfoCache() is:

D/[Purchases] - DEBUG: ℹ️ Invalidating PurchaserInfo cache.
D/[Purchases] - DEBUG: ℹ️ No cached PurchaserInfo, fetching from network.
D/[Purchases] - DEBUG: 😻 PurchaserInfo updated from network.
D/[Purchases] - DEBUG: ℹ️ API request started: GET /subscribers/%24RCAnonymousID%3A03a90e4607c44dd3b03b1719a15d47a3
D/[Purchases] - DEBUG: ℹ️ API request completed with status: GET /subscribers/%24RCAnonymousID%3A03a90e4607c44dd3b03b1719a15d47a3 304

 

I also tried to call Purchases.reset() and this is working. The cache is cleared and the purchaser info are fetched correctly hence the entitlement after the refund has isActive=false as expected.

But the reset() method is deprecated in favor of logout(). The latter gives this error:

E/[Purchases] - ERROR: 😿‼️ Called logOut but the current user is anonymous

Userlevel 3
Badge +7

Hey @Marco B. :wave:

When refunding a subscription with Android we don’t recommend refunding from the Google Play Console since RevenueCat cannot track refunds initiated through the Google Play console. You can either refund from the dashboard or via our REST API endpoint. Here are more information in our docs here: https://docs.revenuecat.com/docs/managing-subscriptions#play-store.    

Badge +2

Thank you @jazmine,

I’ll take care of your suggestion. I never made a refund myself, but happens that the user made it following the “refund” link given in the email Google send to purchasers.

I’ve found that doing Purchases.reset() and call restoreTransactions() the isActive value is corrected after the user made the refund. But I don’t know if this is the correct way since reset() is deprecated.

Thanks for any clarification!

Userlevel 5
Badge +9

Hey @Marco B.!

I’ve found that doing Purchases.reset() and call restoreTransactions() the isActive value is corrected after the user made the refund. But I don’t know if this is the correct way since reset() is deprecated.

Calling .reset() will change the underlying App User ID, essentially creating a new anonymous user. Then .restoreTransactions() will re-sync the underlying purchase tokens on the device with their account.

It’s not recommended to call .reset() or .restoreTransactions() programatically. Usually these should be triggered through some customer interaction when they logout, or tap a “Restore Purchases” button.

Detecting non-subscription refunds initiated through Google Play is currently a gap in the system without a clean workaround. I know some developers have built some on-device systems to check for this, but the server-side subscription status from RevenueCat unfortunately can’t react to refunds through Google Play. For subscriptions, this isn’t as big of an issue since the entitlement is revoked at the end of the subscription period. 

 

 

 

Badge +5

Hey @Marco B.!

I’ve found that doing Purchases.reset() and call restoreTransactions() the isActive value is corrected after the user made the refund. But I don’t know if this is the correct way since reset() is deprecated.

Calling .reset() will change the underlying App User ID, essentially creating a new anonymous user. Then .restoreTransactions() will re-sync the underlying purchase tokens on the device with their account.

It’s not recommended to call .reset() or .restoreTransactions() programatically. Usually these should be triggered through some customer interaction when they logout, or tap a “Restore Purchases” button.

Detecting non-subscription refunds initiated through Google Play is currently a gap in the system without a clean workaround. I know some developers have built some on-device systems to check for this, but the server-side subscription status from RevenueCat unfortunately can’t react to refunds through Google Play. For subscriptions, this isn’t as big of an issue since the entitlement is revoked at the end of the subscription period. 

 

 

 

Hey! What is the on-device systems to check for this ? I need it for Google Play Pass program. If in app purchase is refunded by user it shouldn’t be treated as active. 

Reply