We want to store when a google play purchase is refunded to a user for data analysis.
According to documentation, there are 3 ways for a user to request a refund for a subscription on google play: https://support.google.com/googleplay/answer/2479637?hl=en
If the user requests the refund to the developer (us), we can keep track of it on our servers and manage it on our end, no problem. However, users can also ask google for a refund directly. Problem is that we can't find documentation on this kind of refunds.
Looking at the API documentation for subscriptions, it doesn't provide whether a purchase was refunded or not: https://developers.google.com/android-publisher/api-ref/purchases/subscriptions
Also tried looking into the realtime developer notifications system. Looks like it doesn't have an event for refunds. https://developer.android.com/google/play/billing/realtime_developer_notifications#json_specification
Any idea what happens if google refunds a purchase on their end?
In my experience with the realtime events thus far, after a subscription is refunded two realtime-events get sent. First, a SUBSCRIPTION_CANCELED event is sent, followed by a SUBSCRIPTION_REVOKED event.
On my server, I treat the SUBSCRIPTION_CANCELED as a normal cancel, then if that event is followed by a SUBSCRIPTION_REVOKED event for the same subscription, I mark it as refunded.
Details can be found for these two specific events, as you also mentioned, at this link: https://developer.android.com/google/play/billing/realtime_developer_notifications.html#json_specification