This feature is used usually for situations when you need to restore purchased products for users.
1. FetchInventory
Use StovePC.FetchInventory to call inventory; inventory contain items that have been purchased. You can ship your product by using the purchased product list in the inventory.
Normally, games call the StovePC.ConfirmPurchase function to check the product purchase status and immediately ship the product, but if the information is lost due to an unexpected error or game reinstallation (or etc.), you can use inventory information for restoration.
StovePCResult result = StovePC. FetchInventory();
if(result == StovePCResult.NoError)
{
// handle success
}
C++
복사
If the StovePC.FetchInventory function is successfully processed, the OnFetchInventory callback is called.
The StovePCInventoryItem structure passed to the callback contains meta information about the purchased product.
•
StovePCInventoryItem.TransactionMasterNo: Transaction Master Number (Unique)
•
StovePCInventoryItem.TransactionDetailNo: Transaction Specific Detail Number
•
StovePCInventoryItem.ProductId: ProductID
•
StovePCInventoryItem.GameItemId: In-game item ID mapped to product ID
•
StovePCInventoryItem.ProductName: Product Name
•
StovePCInventoryItem.Quantity: Quantity of Individual Product
•
StovePCInventoryItem.ThumbnailUrl : Representative Product Image
private void OnFetchInventory(StovePCInventoryItem[] inventoryItems)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("OnFetchInventory");
sb.AppendFormat(" - inventoryItems.Length : {0}" + Environment.NewLine, inventoryItems.Length);
for (int i = 0; i < inventoryItems.Length; i++)
{
sb.AppendFormat(" - inventoryItems[{0}].TransactionMasterNo : {1}" + Environment.NewLine, i, inventoryItems[i].TransactionMasterNo.ToString());
sb.AppendFormat(" - inventoryItems[{0}].TransactionDetailNo : {1}" + Environment.NewLine, i, inventoryItems[i].TransactionDetailNo.ToString());
sb.AppendFormat(" - inventoryItems[{0}].ProductId : {1}" + Environment.NewLine, i, inventoryItems[i].ProductId.ToString());
sb.AppendFormat(" - inventoryItems[{0}].GameItemId : {1}" + Environment.NewLine, i, inventoryItems[i].GameItemId);
sb.AppendFormat(" - inventoryItems[{0}].ProductName : {1}" + Environment.NewLine, i, inventoryItems[i].ProductName);
sb.AppendFormat(" - inventoryItems[{0}].Quantity : {1}" + Environment.NewLine, i, inventoryItems[i].Quantity.ToString());
sb.AppendFormat(" - inventoryItems[{0}].ThumbnailUrl : {1}", i, inventoryItems[i].ThumbnailUrl);
if (i < inventoryItems.Length - 1)
sb. AppendFormat(Environment. NewLine);
}
Debug.Log(sb.ToString());
}
Plain Text
복사
If an error occurs while running the StovePC.FetchInventory function, the OnError callback is called.
External errors can be checked through the ExternalError field of the StovePCError structure.
ExternalError | Description |
500 | Internal Server Error |
999999 | undefined error |