Game Development Reference
In-Depth Information
Once you know a player has a license and is fine to buy it, you can request the pur-
chase, which will inform Windows that it should display the details and the required
screens to let the user purchase the product.
concurrency::task<Platform::String^>
buyTask(CurrentApp::RequestProductPurchaseAsync("PRODUCT_ID",
false));
buyTask.wait();
try
{
auto result = buyTask.get();
auto success =
CurrentApp::LicenseInformation->ProductLicenses->Lookup("PRODUCT_ID")->IsActive;
}
catch (Platform::Exception^ e)
{
// Purchase failed
}
In the RequestProductPurchaseAsync() command you need to provide the
string ID for the product as specified in the store dashboard, as well as a Boolean
representing whether you want to receive a receipt from the purchase for your own
tracking. Once it is done you can check the IsActive flag on the corresponding li-
cense and verify that everything has been processed appropriately.
Once that is done successfully you can grant the user access to whatever your in-
app purchase provides, and continue as normal.
Note
Remember that you don't have to use the Windows Store to implement in-app
purchases. If you prefer to use an alternate payment provider you are allowed to
do this, and Microsoft does not require a cut of the profits in this case.
Search WWH ::




Custom Search