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"";
    }
}

C++
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.
3,960 questions
0 comments No comments
{count} votes

Your answer

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