"Couldn't get funds" issue



  • Purchases not being registered as purchased.

    This is a bit confusing as you state different outcomes:

    • in playfab it shows up as successful and when also in the example scene it switches to purchased.

    • only going through the purchase system and not actually adding anything to the playfab player account

    So, what do you really see on the user's inventory on PlayFab? If you e.g. have a product that is consumed immediately - this would be the cause. Your products should be set to consumable on PlayFab's backend, by time, with the amount set to "days" in your case. If you export them from SIS, they are set to 5 seconds by default (which needs to be changed as mentioned).

    On purchase, the product is added to the user's inventory and you should see it listed there (added or expired/consumed).

    So I'm guessing that once purchased in the switch (id) section of IAPListener I need to set the purchase with the expiry?

    No. You set the expiration in PlayFab as mentioned above. In Simple IAP System, you do not have to do anything, especially not any DBManager operations in the IAPListener which is for display purposes only. It does that all automatically for you already.



  • When I say in playfab it shows that it's successful what I referring to is that when you select the player in playfab it shows under purchases that a successful purchase has been made.

    I was setting at at non-consumable, I've changed it to consumable and edited the playfab item to expire through time (something reasonable) and it's now showing up in the inventory :) Thanks that seems to be working as expected.

    The only thing left to do now is query playfab to determine what the user has bought and when it expires so they don't just keep buying the same thing again and again. Basically the option to buy more time shouldn't be available unless they have no time (nothing in their inventory). I'm guessing (although my guesses have been pretty poor so far) that this is where IAPSystem's other functions come in use. I shall look into that tomorrow.

    Thanks very much for your help, I'm learning a lot :)



  • I was setting at at non-consumable, I've changed it to consumable [...] and it's now showing up in the inventory

    Then I'm confused even more, because non-consumable items do not expire, so they should definitely be in the user's inventory (and DBManager.isPurchased should return true) on app launch after logging in with PlayFab.

    The only thing left to do now is query playfab to determine what the user has bought and when it expires so they don't just keep buying the same thing again and again.

    Ah, understood! That information is already provided inside the PlayfabManager script, although you have to change it to a public variable: loginResult
    This is the login date and inventory returned from PlayFab. You can then access the List<ItemInstance> via

    PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory
    

    Each ItemInstance has a PurchaseDate and Expiration property. So for your 1-month product you could either check e.g. the current timestamp > PurchaseDate + 30 days, or whether current timestamp > Expiration. If the user is within the subscription, call DBManager.SetPurchase("1-month-product") to make it unavailable for another purchase in the shop.

    It's a bit more complicated than necessary, unfortunately, as PlayFab does still not support subscriptions in their inventory system by default.



  • @Baroni

    I've made loginResult public and my code looks like this

        UserEmail = "phileday@yahoo.co.uk";
        UserPassword = "****************";
        PlayfabManager.LoginWithEmail(UserEmail, UserPassword);
        Debug.Log(PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory);
    

    The console shows this

    Got PlayFabID: E04E1A8F7C33941 (existing account)
    UnityEngine.Debug:Log(Object)
    
    FestoonPro ist vom Object: SIS.IAPObject
    UnityEngine.Debug:Log(Object)
    
    PlayFab (online mode) is enabled: IAP data will not be saved on devices.
    UnityEngine.Debug:Log(Object)
    
    UnityIAP Version: 2.0.0
    UnityEngine.Purchasing.StandardPurchasingModule:Instance()
    
    Null
    UnityEngine.Debug:Log(Object)
    

    So the Debug.Log(PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory); is returning null even though the "FestoonPro ist vom Object: SIS.IAPObject" shows that it is there.

    Any ideas?

    P.S. You've already helped me a great deal so I've posted a review reflecting this :)



  • Thanks for the positive review, much appreciated! Each review counts :)

    Debug.Log(PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory); is returning null

    Very weird. I justed tested this in the example scenes and added the Debug.Log in UILogin.cs, line 141 after the LoginWithEmail call. The output I am getting has the desired value:

    System.Collections.Generic.List`1[PlayFab.ClientModels.ItemInstance]

    Two points that could be important:

    • does your user on PlayFab actually have an item in its inventory? Because if it's a new user or nothing has been bought before, there is actually nothing returned (Null) for the inventory. You can also add more Debug.Logs in PlayfabManager's OnLoggedIn method, where the UserInventory is retrieved.
    • Login calls are asynchronous, so if you access the data right after the request, sometimes it might not have completed yet. You would get a NullReferenceException already though, for accessing the loginResult.InfoResultPayload. Just to be absolutely sure and safe, make use of PlayfabManager's loginSucceededEvent and access the data only when or after it is fired (or in subsequent scenes, after the login scene).


  • Hi

    I'm still having problems but what I've done is create a new project with only your plugin, my small script and all setup. I've removed all the scenes apart from Vertical which is where the scene is. Here's a link:
    //REMOVED

    The player has an item in it's inventory which will expire in October.

    I thought it might be calling it before it's logged in so I've added the Debug.Log(PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory); line into the script with keypress of "t" so you can test it at any time.

    Here is the script info in case it's more obvious in there.

    using PlayFab;
    using PlayFab.ClientModels;
    using System.Collections.Generic;
    using SIS;
    using UnityEngine;
    using UnityEngine.SceneManagement;
    
    public class PlayFabLogin : MonoBehaviour
    {
        private string UserEmail;
        private string UserPassword;
    
        public void Start()
        {
            UserEmail = "philippad@festoonsoftware.com";
            UserPassword = "gffr567gbbfdAAA";
            PlayfabManager.LoginWithEmail(UserEmail, UserPassword);
            Debug.Log("GetThis_"+PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory.Count);
    
        }
    
        void Update()
        {
            if (Input.GetKeyDown("t"))
            {
                Debug.Log(PlayfabManager.GetInstance().loginResult.InfoResultPayload.UserInventory.Count);
            }
        }
    }
    

    Hopefully that should make it relatively easy to see where I'm going wrong :)



  • Even though this is a semi private forum, please do not share source files of our assets here. Uploading them to Dropbox etc. is against the Unity Asset Store EULA (as non purchasers can find it).

    Besides, downloading projects (also with only our asset) is outside our Support Policy.

    As I said above, I am unable to reproduce this in the example scenes. I can only give assistance on where to look, but I'm clueless in this case. If the inventory is Null, this would basically mean that you would never own any products in game, even when you've bought some before. It sounds like there is missing something from the PlayFab setup.



  • No problem, thanks for removing the link.

    So relating to code I shared above. Does that look like it should work then? Effectively if I'm using that script and it isn't working I'm doing something wrong somewhere else?

    Actually the login for playfab is a temporary setup, random password so feel free to login to that to see if there is anything in the inventory.

    UserEmail = "philippad@festoonsoftware.com";
    UserPassword = "gffr567gbbfdAAA";

    and a little more information. The above code show this up in the console

    GetThis_0
    UnityEngine.Debug:Log(Object)
    
    Got PlayFabID: B4085BC7CFEAD453 (existing account)
    UnityEngine.Debug:Log(Object)
    
    FestoonPro ist vom Object: SIS.IAPObject
    UnityEngine.Debug:Log(Object)
    
    PlayFab (online mode) is enabled: IAP data will not be saved on devices.
    UnityEngine.Debug:Log(Object)
    
    UnityIAP Version: 2.0.0
    UnityEngine.Purchasing.StandardPurchasingModule:Instance()
    

    and when you hit "t" you get:
    NullReferenceException: Object reference not set to an instance of an object



  • I downloaded your project, since I need your PlayFab Title ID to login, and downloading was faster than asking :)

    Although your exact same code worked fine in my own project (in hindsight, I wonder why), I was able to reproduce the issue. In line 484 of PlayfabManager.cs, change it to:

    instance.loginResult = result;
    

    In the original code, loginResult is actually set to 'null' on a successful login, because of another feature we haven't fully rolled out yet. This is why you weren't able to access it at all. After doing the above change, pressing 't' returns '1' in the Console.

    Thanks for following up!



  • Thank you so much. That appears to be working now.

    I think I'll be able to go from here :) If I have any problems I'll let you know but hopefully, fingers crossed that should be enough to get everything working.


Log in to reply