Em Lazer-Walker avatar image
Em Lazer-Walker asked

Unable to fetch player virtual currency?

I have a very simple Unity project that logs in a player with a CustomID and then tries to fetch virtual currency balance. I also have a virtual currency ("CC") set up with an initial deposit of 100.

When logging in a user, I'm running the following code (simplified for brevity):

 var request = new LoginWithCustomIDRequest { 
 	CustomId = CustomId, 
	CreateAccount = true,
 	InfoRequestParameters = new GetPlayerCombinedInfoRequestParams {
 		GetUserVirtualCurrency = true

PlayFabClientAPI.LoginWithCustomID(request, (result) => {
}, (error) { /* handled properly in real code */ });

The login result object being logged to the console does not contain the virtual currency balance, despite it being specified in the request. Similarly, making a GetUserInventory API call also does not return my virtual currency balance (although if I manually assign that user an inventory item, that item does show up in the response). If I look up that user in the PlayFab dashboard, they do in fact have a CC balance of 100 in the "Virtual Currency" tab for their account.

After I turned on client access to add/subtract virtual currency values, I have been able to successfully make AddUserVirtualCurrency calls that do in fact modify the user's CC balance. The responses to those requests reflect the correct balance given all of the previous AddUserVirtualCurrency calls I have made. e.g. for a user I've made three calls to add 5 CC to their account, the response to the third call correctly listed the new balance as 115 CC. Despite that, continued GetUserInventory calls (and login calls with the correct parameter set) continue to not return VC balance data.

Is there any reason my login and GetUserInventory calls wouldn't be returning my virtual currency balance, despite explicitly asking for it and that player having a VC balance?


In-Game EconomyPlayer Inventory
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rick Chen avatar image Rick Chen ♦ commented ·

I have done some tests on my title and successfully got the virtual currency. I cannot reproduce the issue on my test title. Could you please provide your title ID for us to diagnose?

0 Likes 0 ·
Em Lazer-Walker avatar image Em Lazer-Walker Rick Chen ♦ commented ·

The title ID I’m experiencing this on is 381AF. Thanks!

0 Likes 0 ·

1 Answer

Rick Chen avatar image
Rick Chen answered

I have checked the Entity Global Title Policy on your title, it was not the policy’s issue.

In your origin post I noticed that you are trying to print the result using Debug.Log(JsonUtility.ToJson(result)); in Unity, which does not print the virtual currency. But this does not mean that the VC is unable to fetch. You could try the request on Postman and see if it returns the VC. There’s an example of the demo in Unity:

These 2 lines show you how to handle the VC in Unity:

foreach (var pair in result.VirtualCurrency)

virtualCurrency.Add(pair.Key, pair.Value);

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.