CurrentAppSimulator.RequestProductPurchaseAsync Method

Creates the async operation that displays the UI that is used to simulate the purchase of a product or feature from the Microsoft Store.

Syntax

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

Parameters

productId
Type: String 

  Specifies the id, as defined by the simulation, of the product or feature to buy.

includeReceipt
Type: bool 

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

Return value

Type: IAsyncOperation<String^ > 

If the includeReceipt parameter is set to true, this string contains XML that represents all receipts for specified productId. If includeReceipt is set to false, this string is empty.

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. For more info, see the code examples in CurrentAppSimulator.

If the purchase transaction succeeds, the license state is updated only in memory. The contents of WindowsStoreProxy.xml are not changed.

This method returns a success value even if:

You should treat a success result as indicating the async process completed without errors. To ensure that the transaction itself was successful, check the LicenseInformation element in the returned receipt.

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

The XML-formatted string that this method returns uses these elements:

Element Name Description Child Elements Attributes
Receipt Contains information about app and in-app purchases AppReceiptProductReceiptSignature Version: The version number of the receipt. CertificateId: The certificate thumbprint used to sign the receipt. ReceiptDate: Date the receipt was signed and downloaded.ReceiptDeviceId: Identifies the device used to request this receipt.
AppReceipt Contains information about an app purchase. None. Id: Identifies the purchase. AppId: The Package Family Name value that the OS uses for the app. LicenseType: Full, if the user purchased the full version of the app. Trial, if the user downloaded a trial version of the app.PurchaseDate: Date when the app was acquired.
ProductReceipt Contains information about in-app purchases. None. Id: Identifies the purchase. AppId: Identifies the app through which the user made the purchase.ProductId: Identifies the product purchased. ProductType: Determines the product type. Currently only supports a value of Durable.PurchaseDate: Date when the purchase occurred.
Signature Contains the signature for the receipt and information on how the receipt was digitally signed. SignedInfoSignatureValue This element is a standard XML-DSIG construct. It contains a SignatureValue element, which contains the signature you can use to validate the receipt.

To verify a receipt’s authenticity, you can check the receipt’s signature using the public certificate. To get this certificate, use the following URL:

https://go.microsoft.com/fwlink/p/?linkid=246509&cid=&lt;CertificateId>

where <CertificateId> is the CertificateId of the receipt.

Requirements

Namespace: Windows.ApplicationModel.Store

Metadata: windows.winmd

See also

Reference

CurrentAppSimulator Class

CurrentAppSimulator Members

Windows.ApplicationModel.Store Namespace