StoreContext.RequestPurchaseAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
RequestPurchaseAsync(String, StorePurchaseProperties) |
Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Microsoft Store, including the product name to display to the user during the purchase. Important This method must be called on the UI thread. |
RequestPurchaseAsync(String) |
Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store. Important This method must be called on the UI thread. |
RequestPurchaseAsync(String, StorePurchaseProperties)
Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Microsoft Store, including the product name to display to the user during the purchase.
Important
This method must be called on the UI thread.
public:
virtual IAsyncOperation<StorePurchaseResult ^> ^ RequestPurchaseAsync(Platform::String ^ storeId, StorePurchaseProperties ^ storePurchaseProperties) = RequestPurchaseAsync;
/// [Windows.Foundation.Metadata.Overload("RequestPurchaseWithPurchasePropertiesAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(winrt::hstring const& storeId, StorePurchaseProperties const& storePurchaseProperties);
[Windows.Foundation.Metadata.Overload("RequestPurchaseWithPurchasePropertiesAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(string storeId, StorePurchaseProperties storePurchaseProperties);
function requestPurchaseAsync(storeId, storePurchaseProperties)
Public Function RequestPurchaseAsync (storeId As String, storePurchaseProperties As StorePurchaseProperties) As IAsyncOperation(Of StorePurchaseResult)
Parameters
- storeId
-
String
Platform::String
winrt::hstring
The Store ID of the app or the add-on that you want to purchase for the current user.
- storePurchaseProperties
- StorePurchaseProperties
An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase.
Returns
An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase.
- Attributes
Exceptions
If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the <xref href="Windows.Services.Store.StoreContext?text=StoreContext" /> object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.
Remarks
The Store ID for an app or add-on is available in Partner Center, and it is returned by the StoreId property of the StoreProduct that represents the app or add-on.
See also
Applies to
RequestPurchaseAsync(String)
Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Microsoft Store.
Important
This method must be called on the UI thread.
public:
virtual IAsyncOperation<StorePurchaseResult ^> ^ RequestPurchaseAsync(Platform::String ^ storeId) = RequestPurchaseAsync;
/// [Windows.Foundation.Metadata.Overload("RequestPurchaseAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(winrt::hstring const& storeId);
[Windows.Foundation.Metadata.Overload("RequestPurchaseAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<StorePurchaseResult> RequestPurchaseAsync(string storeId);
function requestPurchaseAsync(storeId)
Public Function RequestPurchaseAsync (storeId As String) As IAsyncOperation(Of StorePurchaseResult)
Parameters
- storeId
-
String
Platform::String
winrt::hstring
The Store ID of the app or the add-on that you want to purchase for the current user.
Returns
An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase.
- Attributes
Exceptions
If the ErrorCode property of the exception has the value 0x80070578 (ERROR_INVALID_WINDOW_HANDLE), this indicates that the method was not called on the UI thread. If you are calling this method in a desktop application that uses the Desktop Bridge, this can also indicate that you did not configure the <xref href="Windows.Services.Store.StoreContext?text=StoreContext" /> object to specify which application window is the owner window for modal dialogs shown by this method. For more information, see this article.
Remarks
For more information about using this method, including a code example, see Enable in-app purchases of apps and add-ons.
The Store ID for an app or add-on is available in Partner Center, and it is returned by the StoreId property of the StoreProduct that represents the app or add-on.