PlayFab (using PayPal)



  • Hi,

    So I'm at the stage of getting these messages from IAP (Window standalone build):

    IAPListener reports: HandleSuccessfulPurchase: token_2
    purchase({0}): token_2

    so I guess the connection between playfab and IAP is happening, but right now I don't see further steps on the tutorials, how the payment is happening and what is the next steps?

    Also, another question. I have my own authentication system server where people register/login, can this be integrated? I see there is a Login with device ID in the UserLogin scene, can I somehow use this?

    Thank you



  • Hello,

    • did you follow our PlayFab and PayPal guides on the forum?
    • did you enable PlayFab (Full Suite or Validation) and PayPal (Window > Simple IAP System > Plugin Setup)?

    Since a payment is completed automatically only when Unity IAP is set to test mode (in the Unity editor), I guess you did not choose "Playfab Paypal" in the Plugin Setup for the Standalone platform. If you would like to test payments, you would initiate a purchase in the editor and then head over to the PlayFab dashboard, where you can see the user logged in, purchase attempt and status. Each step should tell you what is missing - e.g. if you can't see a user login attempt, your account login does not work.

    Also, another question. I have my own authentication system server where people register/login, can this be integrated? I see there is a Login with device ID in the UserLogin scene, can I somehow use this?

    Not really. LoginWithDevice creates a new unique user account based on the device MAC address & IP. It does allow connecting to an external server.

    You can use your own authentication prior to the PlayFab login. The user needs to be logged in with Playfab though, as otherwise payments via their servers will not work. If your authentication returns a unique userID, you could use that on the LoginWithCustomID call to PlayFab. This way the userID would match on your system and PlayFab.

    You would want to add a custom LoginWithCustomID method to our PlayfabManager, as we do not support this by default. In the request to PlayFab, use the existing InfoRequestParameters and OnLoggedIn / OnPlayFabError callbacks.



  • yeap that was quite easy to implement since I already have a UID for each user, perfect.

    One question, I noticed that if the login happens in the same scene that the shopmanager is, it doesnt refresh so the UI is empty without any items, is there a way to force a refresh there? since I send the login automatically after the user is in the main games scene (for soem reasons, that needs to verify a blockchain item which happens only when the player is in game and inventory is available)



  • yeap that was quite easy to implement since I already have a UID for each user, perfect.

    Great!

    One question, I noticed that if the login happens in the same scene that the shopmanager is, it doesnt refresh so the UI is empty without any items

    Usually, the IAPManager & PlayfabManager prefabs & login should be in a scene prior to the shop - a "loading" screen. This is best practice since you can then act on the login result accordingly (stay in login scene or load intro/next scene). PlayFab sends the user's inventory in the OnLoggedIn callback, so the item data does not exist until that point.

    is there a way to force a refresh there?

    Yes: RefreshAll ().



  • Excellent, almost there.

    1. Since I ll use this nice plugin mostly as a paypal gateway since I have setup my shop, what I need to do is after the player pays successfully via paypal, to run my own code (add stuff to player's inventory etc.), where is the best place to do that? I saw the IAP listener in the manual but seems is more to handle more advanced inventory keeping etc.

    2. Other than the paypal gateway, at a later stage I'm planning to implement a subscription, but I read in the manual " Since a receipt can only be validated once, this option is not suited for validating active or expired subscriptions, due to the fact that they will be rejected as duplicate." What are the limitations here and how I can handle subscriptions with Simple IAP and PlayFab?

    thank you



    1. If you take a look at the IAPListener code, in the HandleSuccessfulPurchase method - it does not do anything, actually. It just shows a popup for feedback to the user. In the background, the purchased item is granted automatically and written to the device locally by the DBManager. If you wish to do local things (e.g. award other bundled products), the IAPListener is the correct spot though. If you have your own or external inventory system, you would look into PlayFab's PlayStream (events fired of certain in-game events and run on their servers) or their CloudScript, which is a safe space to run custom code hidden from the clients.

    2. PlayFab cannot validate transactions twice. This is an issue mostly with the App Stores on mobile devices and lies within Unity IAP. I reported it as a bug with Unity years ago, but they do not care. On standalone platforms this does not affect you, however it comes with the limitation that your users need to re-purchase your "subscription" product each week/month/year manually. On the PlayFab side you would set up the product with an expiration time of one billing cycle.

    An alternative is to have PayPal's purchase workflow on your own website: this would require user's logging in, paying for subscriptions, hooking into PayPal's purchase flow and extend the user's product lifetime on their PlayFab inventory. Each time the subscriptions cycle is renewed by PayPal, this event would need to fire again. I'm not that experienced with PayPal's Rest API, so can't be of much help on that end unfortunately.



  • @Baroni I see the potential going for PlayFab inventory for these purchased items pulled up by my server instead of adding them from the PlayFab stream etc. So, I have another question and if I'm getting out of scope just let me know.

    I have the client side which now works fine player purchases, pays with paypal, the items added on playfab inventory and life is good, I am thinking of having another instance of PlayFab SDK and Simple IAP (is it needed?) in my server build, to handle getting inventory from playfab and adding it that way to my in-game custom inventory and consume in it when the player uses it as well, this sounds safe since only my server will interact with the players playfab inventory etc. Do I think this correctly or it will not work? Is something like that in Simple IAP ready so I can use on server side? (I see a List<ItemInstance> inventory = result.InfoResultPayload.UserInventory; which I guess is what I'm looking for ?) If I don't need the Simple IAP on my server (since no purchases will triggered from server side it will be only for inventory management), can I get inventory only using the playfab SDK?

    BTW, if all that is possible with server side? Since user logs in from there and gets the UID which logins on playfab, maybe initiating everything server side including purchases is safer? and have the user only having UI on client? Is that offers more security or not needed?

    thanks :)

    edit: Unrelated with this, is there a way to have quantity on purchased items? or should I create bundles?



  • PlayFab SDK and Simple IAP (is it needed?) in my server build, to handle getting inventory from playfab and adding it that way to my in-game custom inventory and consume in it when the player uses it as well

    I'm not quite sure what is your reason behind that, as it sounds to me as if you're just duplicating functionality which is already there within PlayFab. You're trying to establish a server-server connection with PlayFab for a secure environment for inventory management, when the PlayFab servers are already secure and allow for custom code (CloudScript) hidden from clients, if you need to run more workflows in the backend.

    Is something like that in Simple IAP ready so I can use on server side?

    Simple IAP System is a client app, it is used for getting, displaying and initiating purchases and inventory. All of these methods can be found in the PlayFab SDK using REST calls so there is no need to run a Unity instance with SIS on a server. Besides, it won't work anyway.

    Since user logs in from there and gets the UID which logins on playfab, maybe initiating everything server side including purchases is safer? and have the user only having UI on client? Is that offers more security or not needed?

    As written above, Simple IAP System does not differ from that. It does not interact with the PlayFab inventory directly. It follows the strict client-server paradigm and does not hook into any update methods directly. I have seen developers do that when they did not own Simple IAP System. Each client call is a 'request' to the server, which is then responsible for granting or denying that request. E.g. a client does not add virtual currency by itself. Having an additional server in the middle would just mean an additional bottleneck, as then the client request is sent to a server which sends a request to PlayFab, and the response comes all the way back. It would not be more secure, just more complex.

    Unrelated with this, is there a way to have quantity on purchased items? or should I create bundles?

    Depends on what type of products you mean: virtual products support quantities already and you can define them right in the IAPSettings editor. For example, buying "bullets" for virtual currency could add 200 bullets to the user's inventory about to be consumed at some later point. For real money products we did not support quantity, since this would require a checkout cart, making the process and workflow more difficult to use. Because of that, only one real money product can be bought at a time. If you wish one product to grant more other products, it is correct that you would use a bundle.



  • Hello again @baroni, everything work as intended except that if I have an item at $14.99, and someone is from a country with KR instead of dollars, it show kr. 14.99 (which is 3$), when he goes to pay he has to pay 14.99$, is just missleading on the UI. Any idea why this happening? This is for real money purchases ofc



  • Could you post screenshots from both frontends, where it shows the wrong and correct amount? Since you mentioned "it shows" "on the UI" I'm not quite sure where you mean exactly :)



  • sure:

    https://ibb.co/n15bqvh

    https://ibb.co/Wtk8J7H

    so the payment its in USD (as it should), but in the shops UI, it shows the country currency, for example a player sent me one with KR. 14.99, which is like 3 USD, in paypal he had to pay 14.99USD as it should, but in the UI is the issue. In the phot is my country's currency which is EUR



  • I guess PlayFab returns the local currency symbol as currency conversion is not handled by Simple IAP System.

    If you would like to always display the amount in Dollars, a quick fix would be to disable "Fetch" in the IAP Settings editor for the product.



  • @Baroni I guess that would also overwrite the description/names etc. will contact playfab then, thank you



  • One more question, if I disable fetch, will any functionality of the item change (if I have it consumable, or consume by time etc in playfab), or only how the name/description/price is viewed in the UI?



  • @Salaz said in PlayFab (using PayPal):

    @Baroni will contact playfab then, thank you

    If you do, please post a link here so I can track it too.

    Disabling "Fetch" only has a visual effect on the text fields in the IAP Settings (name, description, price). These are usually used for localization.



  • I have posted a question but it is under moderation still. Here is something I found that might help:

    https://community.playfab.com/questions/38580/playfab-dollar-currency-x-google-store-currency-or.html


Log in to reply