"Couldn't get funds" issue



  • Hi

    I've purchased SimpleAPI and I'm working through the setup now. I have to say it feels like quite a steep learning curve for me as I've never worked with IAP's before.

    I've got as far as importing PlayFab SDK, your plugin, setting up PlayFab with itself (Full suite) and your plugin and setting up paypal in playfab and granting permission in paypal. I'm now trying to integrate the purchase options.

    The first problem I'm running into is the "Couldn't get funds, currency: 'coins' not found." error message. I've got a simple script to log in which seems to work (I'm integrating into VerticalTabs ) and I thought it might be because it's logging in after reporting this message so I disabled the ShopManager enabling it once the login was successful. Still the same error.

    I'm not sure if I'm making the whole things too complicated. You've got quite a complex setup for multiple purchases with the different scenes such as VerticalTabs but my setup really only needs three buttons, purchase 1 month, 3 months,1 year.

    If I ignore the "Couldn't get funds" error and try and purchase the thing I get "billing is not available" and the "Unity IAP is not initialized correctly! Please check your billing settings.".

    Should I be trying to get the purchasing system working with these scenes or should I be connecting your plugin to the buttons I've got setup?

    Any help with this would be very apricated.

    Philippa



  • Thanks for posting here.

    I have to say it feels like quite a steep learning curve

    Indeed, PayPal & Steam setup are the most complicated, since there are numerous little things that could go wrong.

    The first problem I'm running into is the "Couldn't get funds, currency: 'coins' not found." error message.

    It is likely that you removed the "coins" currency in the IAP Settings editor, but still have a UpdateFunds script floating around in the shop scene. If you are not using virtual currency, you would remove that too.

    I've got a simple script to log in which seems to work

    Logging into PlayFab is done via our PlayfabManager prefab, which should be placed in one of the first scenes along with the IAPManager and SteamManager prefabs. You should not login manually as there is several player data requested from PlayFab when using our PlayfabManager. When logging in manually, probably you do not have access to all data required.

    "billing is not available" and the "Unity IAP is not initialized correctly! Please check your billing settings.".

    This could already be solved when using our PlayfabManager prefab for logging in. If you are starting the app from within Steam, we automatically do a login on PlayFab with your Steam ID.

    Should I be trying to get the purchasing system working with these scenes or should I be connecting your plugin to the buttons I've got setup?

    As Steam and PayPal are already complicated enough to get working correctly, I would recommend using our example scenes as is, and try to get the connection running. Then break it apart and integrate it in your own way.



  • @Baroni said in "Couldn't get funds" issue:

    UpdateFunds

    Thanks,
    both your suggestions worked.

    I'm currently logging on with the email and password for testing within the Unity editor and I'll work out the Steam login once I'm uploading a test to Steam.

    The "billing is not available" was solved when using PlayfabManager. It now loads up paypal, the only issue here is that I don't know how to do developer mode to test purchases. I'll try and work that out and get back to you if I hit a brick wall :)

    Thanks very much for your help. It's really appreciated.

    Philippa



  • Unfortunately there are no Sandbox purchases with PlayFab & PayPal:

    https://community.playfab.com/questions/5228/having-issues-with-playfab-and-paypal-only-in-the.html
    https://community.playfab.com/idea/38663/support-paypal-sandbox.html

    What I'm doing to test a PayPal purchase is creating a $0.01 product in Simple IAP System and purchasing that. This way, at least we only lose 1 Cent per test.

    Good to hear the rest is working!



  • Thanks, I had started working into the sandbox thing so that stopped me wasting a load of time :)

    Sorry to keep throwing you questions. I think I'm almost there but I have a couple of other issues (maybe not issues, just me not understanding).

    Purchases not being registered as purchased.
    So I've managed to get the purchase system working and in playfab it shows up as successful and when also in the example scene it switches to purchased. The problem is that if I close down and open up again it no longer shows as purchased.

    I think what I might be doing wrong here is only going through the purchase system and not actually adding anything to the playfab player account. Is that right? When using the DBManager.isPurchased("FestoonPro") FestoonPro is the purchase id it comes up as false.

    Playfab and purchases that expires.
    So the answer to the above might be solved by the answer to this. My previous message was regarding having an expiry time for the purchase. 1 month, 3 months and 1 year. So I'm guessing that once purchased in the switch (id) section of IAPListener I need to set the purchase with the expiry?

    I hope that I'm starting to understand this. I feel like this might be the last bit of the puzzle and then I'll stop bothering you :)



  • 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