Not getting purchase information of subscription

Dev 0 Reputation points
2025-06-10T14:11:46.0766667+00:00

I'm using the windows_iap package for implementing in-app purchases in my Windows Flutter app. However, whenever I run the app or create an MSIX package and check for purchases, I consistently receive empty results or messages indicating that no purchase was found — even though I've already purchased a subscription plan. If anyone has encountered and resolved this issue or knows how to properly retrieve purchase information, your guidance would be greatly appreciated.

This C++ code attempts to retrieve information. However, the data returned always empty.

We have used access token as serviceTicket and user's email as publisherUserId in below method.

public extern IAsyncOperation<string> GetCustomerPurchaseIdAsync([In] string serviceTicket, [In] string publisherUserId);

We are getting access token using this method:


winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> GetTokenFromAzureOAuthAsync(
        winrt::hstring client_id,
        winrt::hstring client_secret,
        winrt::hstring tenant_id
) {
    co_await winrt::resume_background(); // Switch to MTA before WinRT API usage

    // Prepare form data
    winrt::Windows::Web::Http::HttpFormUrlEncodedContent content({
                                                                         { L"grant_type", L"client_credentials" },
                                                                         { L"client_id", client_id },
                                                                         { L"client_secret", client_secret },
                                                                         { L"resource", L"https://onestore.microsoft.com" }
                                                                 });
    // Prepare HTTP client
    HttpClient httpClient;

    content.Headers().ContentType(
            winrt::Windows::Web::Http::Headers::HttpMediaTypeHeaderValue(L"application/x-www-form-urlencoded")
    );

    // Construct URL
    std::wstring url = L"https://login.microsoftonline.com/" + std::wstring(tenant_id) + L"/oauth2/token";

    winrt::Windows::Foundation::Uri uri(url);

    try {
        // Send POST request
        HttpResponseMessage response = co_await httpClient.PostAsync(uri, content);
        hstring responseString = co_await response.Content().ReadAsStringAsync();

        // Parse JSON
        JsonObject json = JsonObject::Parse(responseString);
        if (json.HasKey(L"access_token")) {
            co_return json.GetNamedString(L"access_token");
        } else {
            co_return L"";
        }
    } catch (...) {
        co_return L"";
    }
}

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 1,630 Reputation points Microsoft External Staff
    2025-11-13T15:41:42.51+00:00

    Thanks for reaching out!

    You’re encountering issues retrieving purchase information for your subscription with the windows_iap package in your Windows Flutter app. Here are some things you might want to check and try out:

    1.Access Token and ServiceTicket: Ensure that the access token you are receiving is valid and has the necessary scopes for accessing purchase information. You seem to be using the correct method to fetch the token, but it’s crucial to confirm that the token is being generated correctly.

    2.User Identity: Make sure that the publisherUserId you're passing (the user's email) is accurately tied to the purchases made. Sometimes, discrepancies in user identity can lead to no data being returned.

    3.Query the Purchase ID: Use the method GetCustomerPurchaseIdAsync with a valid serviceTicket and publisherUserId to query the purchase. If the purchase is found, you should receive the customer purchase ID. If you're consistently getting empty results, double-check that the purchase was properly completed and that you’re querying the right user.

    4.Multiple States of Subscription: Understand the states of the subscription; if it's inactive, canceled, or failed, you may not get the expected results and could require a re-purchase. Here’s a brief on relevant states:

    • Active: Valid subscription.
      • Inactive / Canceled / Failed: Not entitled to benefits.
      • InDunning: Subscription nearing expiration but still valid if within grace period.
        1. Delay in Updates: Sometimes there may be a delay in updating the status of subscriptions, so if you just purchased, give it a few minutes to sync across systems, and then try again.
        **
        6.Check the API Documentation**: Double-check the Microsoft Store APIs documentation for any specific response or error handling mechanisms outlined.

    Let me know if you need any further help with this. I will be happy to assist.

    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.