Skip to main content

Windows Dev Center

CurrentAppSimulator.RequestProductPurchaseAsync(String, Boolean) | requestProductPurchaseAsync(String, Boolean) method

[RequestProductPurchaseAsync(productId, includeReceipt) may be altered or unavailable for releases after Windows 8.1. Instead, use RequestProductPurchaseAsync(productId).]

Creates the async operation that displays the UI that is used to simulate the purchase of an in-app product from the Windows Store.

Syntax


Windows.ApplicationModel.Store.CurrentAppSimulator.requestProductPurchaseAsync(productId, includeReceipt).done( /* Your success and error handlers */ );

public static IAsyncOperation<string> RequestProductPurchaseAsync(
  string productId, 
  bool includeReceipt
)

Public Shared Function RequestProductPurchaseAsync(
  productId As String,  
  includeReceipt As Boolean 
) As IAsyncOperation(Of String)

public:
static IAsyncOperation<String^>^ RequestProductPurchaseAsync(
  String^ productId, 
  bool includeReceipt
)

Parameters

productId

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

Specifies the id, as defined by the simulation, of the in-app product to buy.

includeReceipt

Type: Boolean [JavaScript] | System.Boolean [.NET] | Platform::Boolean [C++]

Determines if the method should return the receipts for the specified productId.

Return value

Type: IAsyncOperation<String>

A string providing in-app product purchase details for the provided productId. If includeReceipt is set true, the returned string will include a full receipt xml.

Remarks

Uses the CurrentApp/ListingInformation/Product element in the WindowsStoreProxy.xml file with the ProductId attribute that matches ProductId as the data source for the members of the returned object. If the purchase transaction succeeds, the license state is updated only in memory. The contents of WindowsStoreProxy.xml are not changed.For more info, see the code examples in CurrentAppSimulator.

Use the LicenseInformation.IsActive property to confirm that a product license is active after a "successful" RequestProductPurchaseAsync call.

Note  This method of confirming a successful purchase is only applicable to the RequestProductPurchaseAsync overloads that don't return a PurchaseResults object.
 

You can see an example of how to use this method in our code sample.

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Store
Windows::ApplicationModel::Store [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.ApplicationModel.Store
Windows::ApplicationModel::Store [C++]

Metadata

Windows.winmd

Attributes

[ Deprecated()]

See also

CurrentAppSimulator
RequestProductPurchaseAsync(String)