Testing Billing Errors

  • 27 April 2022
  • 1 reply


I am hoping we can get some guidance on how to test billing errors in the sandbox. Specifically, we are never seeing billingIssueDetectedAt populated.

As an example, we subscribe using a license tester on Android in our React Native app. The subscription goes through successfully, and afterwards, we set our payment source to “always decline” through Google Play. Because it’s a monthly subscription, we wait 5 min, and when the renewal charge is made, we get an email from Google saying the subscription was suspended because of a billing issue. However, there is no change on the customerInfo object when I call getPurchaserInfo().

Fast forward another 5 min, and the subscription is cancelled. This time, if I call getPurchaserInfo(), I immediately see the purchase is no longer active. However, there is still no value for billingIssueDetectedAt, and the expirationDate has not changed either.

I guess my questions are:

  1. should the above have generated a billingIssueDetected at value?
  2. I know the docs mention a lag w/regard to web hooks and billing/expiration, but does this also apply to a real-time customerInfo object returned from getPurchaserInfo()?
  3. Is there a better way to test billing?

Thanks in advance ...

1 reply

Userlevel 4
Badge +8

Hey @Gravy Developer!

This might be related to the on-device cache of PurchaserInfo - the SDK will cache PurchaserInfo for ~5 minutes, so if might just be a timing issue, where the cache isn’t being updated until after the subscription was actually cancelled.

You might be able to test this by calling `invalidatePurchaserInfoCache` before calling `getPurchaserInfo` in sandbox mode so it’s fresh each time. You shouldn’t call this in production though, as it can cause unnecessary delays (and it’s very rare in production for a brief ~5 minute cache to be noticeable to the end user, it’s just noticeable in sandbox since the durations are so short).