Would you have any example of how to use PlayFabEconomyAPI.PurchaseInventoryItems for a user to purchase an item from Catalog v2? Show full example
After setting up the catalog items and currency items according to the Economy V2 documentations, you could call the PurchaseInventoryItem Api to allow logged-in players to purchase items. The following is a code example for calling the PurchaseInventoryItem API.
void PurchaseInventoryItem()
{
PlayFabEconomyAPI.PurchaseInventoryItems(new PurchaseInventoryItemsRequest
{
Item = new InventoryItemReference { Id = "1ee5ef6c-a739-440a-a913-bfa02dc11025" }, //this Id is the Item you want to purchase
Amount = 1,
PriceAmounts=new List<PurchasePriceAmount> { new PurchasePriceAmount { ItemId= "c025c484-1152-46ad-bbbf-242964850cd0",Amount=10 } } //this ItemId is the Currency Item Id for purchasing
}, re =>
{
Debug.Log(re.TransactionIds[0].ToString() + " purchase success");
}, er =>
{
Debug.Log(er.GenerateErrorReport());
});
}
69 People are following this question.