Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by Em Lazer-Walker · Feb 12, 2021 at 08:51 PM · In-Game EconomyPlayer Inventory

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) => {
	Debug.Log(JsonUtility.ToJson(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?

Thanks!

Comment

People who like this

0 Show 2
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rick Chen ♦ · Feb 15, 2021 at 08:07 AM 0
Share

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?

avatar image Em Lazer-Walker Rick Chen ♦ · Feb 16, 2021 at 05:22 PM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Rick Chen · Feb 17, 2021 at 09:16 AM

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:

https://github.com/PlayFab/UnicornBattle/blob/master/UnicornBattle/Assets/Scripts/PF_StaticsAndHelpers/PF_PlayerData.cs#L78

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

foreach (var pair in result.VirtualCurrency)

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

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Steam microtransactions bug. 0 Answers

    Restoring Purchases via PlayFab's Receipt Verification Does Not Work - Apple's App Receipt (iOS7+) 1 Answer

    Noticed Odd Inventory behaviour 1 Answer

    The rules don't work 0 Answers

    Catalog Versions in inventory 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges