question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Concern regarding `getAvailablePurchases()`

See original GitHub issue

Version of react-native-iap

4.4.3

Version of react-native

0.61.6

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

First of all, thanks for all the efforts you put to make and maintain this library, really appreciate it.

getAvailablePurchases() should not return subscription that’s canceled (not renewed)

Actual behavior

in the test environment (using test account with test card), when i make subscriptions on my app and cancel the subscription before the expiracytime (5 minutes after purchase in the test account), my subscription won’t be listed in the result of getAvailablePurchases() when expiracytime is exceeded. Which is a desired behavior. However, if i let my subscription to renew (by not canceling before renew period), and then cancel it after that, getAvailablePurchases() would still list my subscription, even after expiracytime is exceeded. My question is, why does it still list subscription I no longer subscribed to?

Also, I want to know the details regarding getAvailablePurchases(), does it make a call to google billing to retrieve available purchases? or does it keep the purchase list locally?

test setting: https://developer.android.com/google/play/billing/billing_testing#testing-subscriptions

Tested environment (Emulator? Real Device?)

real device

Steps to reproduce the behavior

subscribe to a subscription, let it get renewed, then cancel. The subscription would still be listed as available purchases

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:11

github_iconTop GitHub Comments

3reactions
vkachancommented, May 7, 2020

@darriuk I just tested cancelling subscription and confirm that autoRenewingAndroid property is set to false. But! Only if user cancels subscription explicitly. In case of cancelling subscription due to declined payment the subscription stays active forever. This is really big issue with subscriptions and there is no workaround. I had an idea to compare transactionDate and if this date is behind subscription term, then do cancel service on my side. But it seems like transactionDate is always first date of payment for subscription.

2reactions
darriukcommented, May 10, 2020

@vkachan as far as I recall the transactionDate is indeed always for the first subscription payment.

One update from me: I ran getAvailablePurchases again approx 22 hours after cancelling subscription and it is finally returning an empty array. It looks like Google’s billing server is just taking ages to update the response.

I’m going to try a declined subscription payment today and see how long it takes to be removed from the getAvailablePurchases response.

UPDATE I tested declined subscription payment and getAvailablePurchases took approx 32 hours to return an empty array. So the purchase does get removed eventually, it just takes a good while to happen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-iap - npm
This is a react-native link library project for in-app purchase for ... to iterate over the purchases returned by getAvailablePurchases() .
Read more >
How to use the react-native-iap.getAvailablePurchases ...
getAvailablePurchases examples, based on popular ways it is used in public projects. ... 'ios') return InvalidResult() const purchases = await RNIAP.
Read more >
iOS 14: requestSubscription() issues #1120
I do getAvailablePurchases() earlier in the flow - on app load, the screen right before my ... I'll try that, but production is...
Read more >
No updates when Google in-app purchase flow continues ...
... can't see that we ever receive updates on PurchasesUpdatedListener. Calling RNiap.getAvailablePurchases() (equivalent to BillingClient.
Read more >
modules - React Native IAP - dooboolab
For debugging you may want to consume all items, you have then to iterate over the purchases returned by getAvailablePurchases() .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found