Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes implementing in-game purchases. They are transactions within a game so that players can acquire virtual items or enhance their gaming experience. These purchases can be cosmetic, offering visual customization options like character skins or outfits, or functional, providing in-game advantages such as weapons or power-ups.
Implement in-game purchases by using the Microsoft Game Development Kit and Microsoft Store
To implement player in-game purchases by using the Microsoft Game Development Kit (GDK) APIs and services, follow these steps.
- Go to the Apps and games dashboard in Partner Center.
- Select your Game product from the list, or use the Search option to search by name or Store ID.
- Select Add-ons from the left navigation pane.
- Select + Create a new, and then select Consumable or Durable.
- Enter an identifier for the item. This will be displayed in the Partner Center UI and referenced in game code.
- Integrate with GDK Commerce Systems: Use the Commerce System in the GDK to interact with the platform's (Xbox/Microsoft Store) purchase system. Use the following functions to retrieve product information from the platform's store.
- XStoreQueryAssociatedProductsAsync: Gets store listing information for the products that can be purchased from within the current game.
- XStoreQueryProductForCurrentGameAsync: Provides store product information for the currently running game, its SKUs and availabilities, and other metadata.
- XStoreShowAssociatedProductsUIAsync: This opens the Microsoft Store app and shows the set of available add-ons that are associated associated with the game.
- Purchase initiation: The player selects the product they want to purchase from the in-game store. This could be a consumable, durable, subscription, or other types of in-game content. The game initiates the purchase process by using functions like the following:
- XStoreShowPurchaseUIAsync: Begins the purchase UI overlay for the specified product.
- XStoreShowProductPageUIAsync:Opens the Microsoft Store app directly to the Product Details Page (PDP) of the provided ProductId.
- Manage entitlements: Use the entitlement APIs (XStoreQueryEntitledProductsAsync and XStoreQueryEntitledProductsResult in the GDK to verify and manage player ownership of purchased items. Use the
XStoreAcquireLicenseAPIs for durable products where licenses can be shared.
See also
The GDK documentation is the best source of up-to-date information. For more details see the following articles and samples.
-
This sample demonstrates the client-based operations that are used in presenting and operating an in-game storefront. This sample also shows how to examine game license information, including how to enable and check for trial status.
-
This sample works with the Microsoft.StoreServices Sample and demonstrates the client-side call pattern to do service-to-service authentication with Store Services.