Game Development Reference
In-Depth Information
Once the player is ready to buy, you just need to call the RequestAppPurchaseA-
sync() method to carry out the purchase and Windows will take care of the rest.
This is shown in the code snippet that follows:
concurrency::task<Platform::String^>
purchaseTask(CurrentApp::RequestAppPurchaseAsync(false));
purchaseTask.wait();
try
{
auto receipt = purchaseTask.get();
}
catch (Platform::Exception^ e)
{
// An error occurred
}
If desired, you can also request a receipt, which you can use with your own systems
as required using the Boolean parameter on the RequestAppPurchaseAsync()
method. Whether you request a receipt or not, you should still call the get() method
on the task so that any errors can be raised as exceptions and you can report suc-
cess appropriately. If you pass false to RequestAppPurchaseAsync() , you will
not receive a receipt, but the get() method won't crash either.
Later in this chapter, we'll take a look at how to use a simulator to test this code out
before you submit to the store.
Search WWH ::




Custom Search