Solved

Understanding firebase intergration events

  • 2 November 2023
  • 4 replies
  • 97 views

Badge +5

I have installed the firebase extension and setup both the customers and events collections. 
Using the sandbox testing guide, I have made a purchase that seems to renew every 5 minutes until it stops after 6 renewals or so. The first event is INITIAL_PURCHASE then a few RENEWALs, but at the end I get 2 events at the same time one for EXPIRATION and one for CANCELLATION both with  reason BILLING_ERROR.

What is the difference between these 2 and why would they come same time?
I was just expecting one. 

Is this tied to how the test user is setup?

Mainly, which event tells me to remove the extra paid features for the user?
According to the docs, sounds like EXPIRATION is the only one to remove user functionality and not CANCELLATION? Would CANCELLATION ever come alone with nothing after?

icon

Best answer by Michael Fogel 6 November 2023, 19:46

View original

4 replies

Badge +5

FWIW the grace period is set to 3 days in Play Console so I was expecting some time to pass between CANCELLATION  and EXPIRATION.

Thank you

Userlevel 3
Badge +6

Hey @vic-a563d7 !

 

This is expected in the case of billing issues. If a subscriber with an active subscription encounters a billing issue, RevenueCat will immediately dispatch a BILLING_ISSUE event and a CANCELLATION event with a cancel_reason of BILLING_ERROR.

 

If you do not have grace periods enabled, you’ll immediately receive an EXPIRATION webhook and the subscriber’s entitlements will be revoked. If you do have grace periods enabled, the subscriber will retain entitlements as the app store retries the subscriber’s billing method. At the end of the grace period, if billing has not been successful, an EXPIRATION event will be sent and entitlements will be revoked. If billing succeeds at any point during the grace period, you’ll receive a RENEWAL event and entitlements won’t be revoked. (This RENEWAL event may show up before the billing issue in the Customer History timeline. Be sure to check the timestamps on the event pages.) It’s important to note that the BILLING_ISSUECANCELLATION, and EXPIRATION (if no grace period is involved) webhooks are dispatched in order at the same time, so it is unlikely but possible to receive these events in a different order than described here due to network irregularities.

 

While similar, there is a difference between cancellation and expiration events. Cancellation events happen when a subscription or non-renewing purchase has been cancelled or refunded. See cancellation reasons for more details. Expiration events in most cases come after the cancellation event and the cancellation can be seen as a trigger for these expiration events to occur. 

 

Mainly, which event tells me to remove the extra paid features for the user?
According to the docs, sounds like EXPIRATION is the only one to remove user functionality and not CANCELLATION? Would CANCELLATION ever come alone with nothing after?

Cancellation events could come without an expiration immediately in a couple of cases but to keep things simpler on your end I would recommend waiting for the expiration event to make sure that you revoke the features and that can be the designation that a user is truly expired.

 

Let me know if that helps! 

Badge +5

yes this helps thank  you @Michael Fogel !

Badge +3

Hi @Michael Fogel @Jens ,
As mentioned in the above comment and also in this doc (https://www.revenuecat.com/docs/event-flows) in the billing issue flow section that if a billing issue is encountered, then the following events happen:-

1. If grace period is enabled, then billing issue and cancellation event is dispatched simultaneously and when the grace period ends, then expiration event is dispatched immediately.
2. If grace period is not enabled, then billing issue, cancellation and expiration is dispatched immediately.

I have been testing the events in the sandbox environment for two products I created in play console in which I enabled grace period in one of them and disabled in the other one and I bought the subscription successfully and then I chose the test card always decline option before renewal to test the billing issue events. I observe that billing issue and cancellation event is dispatched in both scenarios but the expiration event is dispatched exactly after 10 mins if I don’t enable grace period and is dispatched exactly after 15 mins if I enabled the grace period. My whole concern is that I don’t get any events when the grace period ends. As per docs, an expiration event should have been dispatched immediately when the grace period ends if any but I don’t see it happening in the sandbox environment.

I have attached the screenshot(when grace period is not enabled) and all the screenshot shows the timestamp of the events at the top right corner. The expiration event is sent 10 minutes later after the billing and cancellation event is sent. This 10 minutes is equivalent to 30 days of account being put to hold in real transactions. I have a use case where I need to update the custom claim of the user when the grace period ends but I don’t receive any events for it. Ideally as per docs, expiration event should have been received but it’s not happening. Please look into the issue and let us know if this issue is specific to the sandbox environment only or if this will happen when real transactions are done.


Regards,

Abhishek
 

Reply