Purchasing in an UWP App

Pavel Kouřil 11 Reputation points
2019-11-13T11:23:41.63+00:00

Hello,

Basically, I have three questions:

  1. I have a trouble understanding one thing about the "Microsoft Store ID key" retrieved by a StoreContext.GetCustomerCollectionsIdAsync method. It is valid for 90 days and supports renewing which leads me to believe we can cache it in the backend/cloud service; however, I do not see any way to pair it with an actual currently-logged in user in the Microsoft Store?
  2. How to handle e.g. user changing the logged in user in the Microsoft Store whilist using the app? Is there an event we can listen to, and gracefully exit the app?
    1. StoreContext.GetConsumableBalanceRemainingAsync seems to return even balance of an UnmanagedConsumable (so-called developer-managed consumable), however, the documentation says it is usable only for a store-managed Consumable. Is the documentation wrong?

Thanks in advance for any replies, since the documentation about Windows.Services.Store is pretty lacking, and the online resources are too! :)

Universal Windows Platform (UWP)
0 comments No comments
{count} vote

4 answers

Sort by: Most helpful
  1. Roy Li - MSFT 31,551 Reputation points Microsoft Vendor
    2019-11-14T08:15:53.467+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    >> however, I do not see any way to pair it with an actual currently-logged in user in the Microsoft Store?

    If you are using StoreContext in your app, then you don't need to worry about it. The StoreContex is different according to the current user. As the document mentioned: Get started with the StoreContext class, the first step of IAP is to get the StoreContext to correspond to the current user.

    But if you are using Microsoft Store collection API or purchase API to manage your Add-ons, the Microsoft Store ID Key is required as a parameter to as the identity of the user. For example, you could check this collection API: Query for products.

    >>How to handle e.g. user changing the logged in user in the Microsoft Store whilist using the app? Is there an event we can listen to, and gracefully exit the app?

    Currently, I'm sorry to say that there is no such event that will trigger when the login user is changed. But as I mentioned in the first question, you don't need to worry about purchasing an add-on in a wrong account. You will need to log in every time when you want to purchase an add-on.

    You could try to take a look at our IAP sample here: https://github.com/msdnwptest/UWP-Support-Samples/tree/master/In-app-purchase

    >>StoreContext.GetConsumableBalanceRemainingAsync seems to return even balance of an UnmanagedConsumable (so-called developer-managed consumable), however, the documentation says it is usable only for a store-managed Consumable. Is the documentation wrong?

    It should return the Store-managed consumable. The developer-managed consumable is managed by yourself. You need to report the consumable is fulfilled using StoreContext.ReportConsumableFulfillmentAsync

    For more information, please refer to Enable consumable add-on purchases.

    1 person found this answer helpful.
    0 comments No comments

  2. Pavel Kouřil 11 Reputation points
    2019-11-14T09:16:04.427+00:00

    Thank you, @RoyLiWicresoftNorthAmericaLtd-0833, but you have unfortunately not answered the questions.

    Basically, if you combine the "Currently, I'm sorry to say that there is no such event that will trigger when the login user is changed" with no way to pair the generated ID key with a user (for the purposes of the caching the key and renewing it), does it mean we should generate a new Microsoft Store ID Key with every purchase and send it with the in-app request to our backend so that we get the proper user ID key and can query for products for the right user, meaning the key renewing mechanism is actually meaningless?

    As for developer vs store-managed consumables; yes, we know we need to manage them by ourselves.
    The reason why I am asking is that I'm trying to figure out if there is a way to find out in the client app whether or not there is a way to find out about non-consumed developer-managed consumables (e.g., due to some network/etc. errors when the purchase fails mid-request). We'd try the store-managed consumables, but it seems that based on the Query for products documentation, that the collection API won't return a "Consumable" (i.e., a store-managed consumable) productKind, forcing us to use the developer-managed ones?

    1 person found this answer helpful.

  3. Sameh Sobhy Abdelrady 6 Reputation points
    2022-07-07T15:03:06.457+00:00

    I can't asked a question

    1 person found this answer helpful.
    0 comments No comments

  4. Sameh Sobhy Abdelrady 6 Reputation points
    2022-07-07T15:04:21.33+00:00

    How are things with my

    0 comments No comments