Skip to main content

PURCHASE

Purchase flow

Purchasing flow is a multistage process, which involves payment collection, purchase validation and consumption.

Starting purchasing flow​

Use one of the snippets below to launch a purchasing flow depending on whether you use Unity InApp Purchasing or not:

storeClient.PurchaseProduct(productId, (product, error) =>
{
if (error != null)
{
// handle error
return;
}

var receipt = product.ToReceipt();

// handle the purchased product here (e.g. validate or consume)..
});
warning

Although validation is NOT a mandatory step, yet it's highly recommended to minimize the chance of fraud and any other malevolent intents.

For instructions on how to validate your purchases, see Purchase Validation guide.

Consuming purchased goods​

The very final step in the chain of purchasing flow stages is to award the purchased goods to the user and mark these goods as "awarded". The process also known as purchase consumption.

Use the code below to do just that:

storeClient.ConsumeProduct(item.sku, item.quantity, item.transactionId, error => {
if (error != null)
{
return;
}

// handle purchased item
});
important

It's highly recommended to perform at least some form of validation before consuming the purchased goods.