Search code examples
c#google-apigoogle-playgoogle-api-dotnet-clientin-app

Purchases.Voidedpurchases.List returns empty response


I'm making request to google Android Publisher api to check purchases that has been voided in my application. The problem is that response is always empty (with code 200). I have some refunded purchases from within 30 days. I tried to make this request using C# android publisher nuget package and manually using postman. The result is successful but empty.

        string           contents   = await File.ReadAllTextAsync("D:/Projects/android-publisher-api-key.json");
        GoogleCredential credential = GoogleCredential.FromJson(contents);

        string[] scopes = { AndroidPublisherService.Scope.Androidpublisher };

        credential = credential.CreateScoped(scopes);

        BaseClientService.Initializer initializer = new BaseClientService.Initializer
        {
            HttpClientInitializer = credential,
            ApplicationName       = "Test App"
        };

        AndroidPublisherService androidPublisherService = new AndroidPublisherService(initializer);

        var request  = androidPublisherService.Purchases.Voidedpurchases.List("com.MyCompany.MyTestApp");
        var response = await request.ExecuteAsync(); // In this response all fields are null

Using postman I send request to (with bearerToken): https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.MyCompany.MyTestApp/purchases/voidedpurchases

Response is success 200 but body contains only {}. It should at least have the structure listed in documentation.


Solution

  • I solved the problem. If you encountered problem like this and you are refunding purchases via google play console then in refund form you must check the Remove entitlement checkbox. Otherwise the voided purchase will not be included as response.