Search Unity

[Closed] Unity IAP for Facebook Payments

Discussion in 'Unity IAP' started by fastgamedev, Jun 12, 2016.

Thread Status:
Not open for further replies.
  1. fastgamedev

    fastgamedev

    Joined:
    Mar 27, 2014
    Posts:
    91
    Hi,

    I am making a WebGL game for Facebook canvas. I want to use Unity IAP to handle Facebook payments. I know that Unity IAP doesn't support Facebook store, but the documentation has a whole section on implementing a new store:

    http://docs.unity3d.com/540/Documentation/Manual/UnityIAPImplementingAStore.html

    So, before I jump in to implement Facebook store for Unity IAP myself, has anyone already done that and is willing to share the code? Pretty please!

    Thank you,
    Arman.
     
  2. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,341

    Hi fastgamedev,

    Did you ever implement this and can you share the code? Pretty Please? :p
     
  3. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Unity IAP supports Facebook Canvas "Payments Lite" when used with Facebook Gameroom (native and WebGL.) That support is currently in beta (see the Gameroom site for details) and will be officially launched with Unity 5.6.
     
  4. fastgamedev

    fastgamedev

    Joined:
    Mar 27, 2014
    Posts:
    91
    @Antony-Blackett I ended up doing payments differently without implementing Facebook store for Unity IAP.

    @JayR Any plans for Unity IAP supporting Facebook payments for facebook.com canvas games?
     
  5. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Unity IAP for Facebook uses Canvas Payments but requires that you select the "serverless" Payments Lite option on the Canvas Payments page. Unity WebGL games using Canvas Hosting with Payments Lite work fine in our browser-based testing (and also run in the Gameroom client.) If you are hosting the game on your own server then Unity IAP should still work from the browser, but will require some additional configuration on the app settings in Facebook.

    Canvas Payments using Webhooks is not currently planned for Unity IAP.
     
  6. fastgamedev

    fastgamedev

    Joined:
    Mar 27, 2014
    Posts:
    91
    JayR likes this.
  7. JurassicApps

    JurassicApps

    Joined:
    Aug 3, 2012
    Posts:
    7
    Hi, using 5.6b10 Mac and installing the Unity IAP directly downloaded from Facebook Gameroom page I first encountered problems with the previous UNITY IAP installation specifically IAPButton scripts, but seeing I wasn't using code less IAP implementation I just commented out those which gave errors. Testing build in Gameroom my IAP's all return successful without any Dialogs appearing using test users?

    So I took it that I don't have to implement FB.Canvas.Pay and using normal Unity IAP code as i do for every other platform would do the job for me?

    Do i have to build and test IAP's using Development Build in Build Settings?
    Is it essential I 'Create Test App' in Facebook dashboard for testing?

    Why don't i see payment dialogs?

    Please any help would be appreciated.
     
  8. JurassicApps

    JurassicApps

    Joined:
    Aug 3, 2012
    Posts:
    7
    Using Development Build within unity Build Settings and Using A Test user Brings up 'Select Payment Method' dialog with IAP details set as 'Always Succeeds'

    Clicking Buy brings up Alert 'Sorry something went wrong and your payment couldn't be completed'

    any idea's to what's wrong?
    Should I not select and build a Development Build for final release and submission?

    These are all questions that of course once you have working once it all seems so logical but i've had to do numerous experiments and sourcing answers through multiple web searches and narrowing down.

    thanks
     
  9. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    You are correct, you do not need to call FB.Canvas.Pay() in your code and your existing Unity IAP code should suffice as long as the product IDs are set correctly. You do not need to use a Development Build and you do not need to create a Facebook Test App.

    Key things to check are that Payments Lite is enabled (looks like Canvas Payments is now Web Payments on the sidebar) and that you have Testers defined (to avoid charges while testing.)

    The fact that you weren't seeing any dialogs suggest that something else was wrong in the setup but would need to see logs to narrow that down. Which platform (Gameroom Windows or WebGL) were you using when the dialog didn't apepar?


    Using a Development Build shouldn't change anything with respect to IAP so it could just be a matter of settings changes propagating through FB to get the Payments Lite enabled on your app. The 'Always Succeeds / Always Fails' option in the dialog means you're on a test user so that part is working correctly.

    The "Sorry something went wrong..." message is what I've seen when you attempt to re-purchase a non-consumable item. The Payments Lite "Products" setup doesn't actually have a concept of consumables vs. non-consumables. Unity IAP will use the Product Type from when you AddProduct() to decide how to manage items coming from Facebook.
     
  10. JurassicApps

    JurassicApps

    Joined:
    Aug 3, 2012
    Posts:
    7
    Thanks for your reply that clears up some things for me, the mind does wander off in crazy directions when things don't work.

    I have 7 in-apps set up in my store and for only 2 of them when i first click on them i get no purchase dialog just a Facebook error 'Couldn't complete purchase. We didn't receive all the information we needed from this app complete your purchase'

    I verified both in-app product ID's by trying to create another and says already used.

    Have you come across this before?

    I have a total of 8 in-apps setup in unity 7 of which are Consumable and the 8th like you say set up as NonComsumable.

    Do i consider everything is fine, just under test conditions it's falling over and just submit for public release?
     
  11. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    I don't recall seeing that error message before -- is the error text appearing in a dialog/popup or in the player log? If you can DM me a copy of the player log there may be something useful there.
     
  12. JurassicApps

    JurassicApps

    Joined:
    Aug 3, 2012
    Posts:
    7
    the error message was a facebook dialog/popup.
     
  13. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    OK, then a log would be useful to get a little extra detail on what the server is reporting. For the Gameroom client the logs appear under Users\Public\Facebook Games\appid\version\appid_Data\output_log.txt

    Also, do you recall if you updated the Facebook SDK version in Player Settings? 5.6b10 would default to using Facebook SDK 7.9.1 but should show 7.9.4 as available in the Build... dialog and Player Settings. You want to be on 7.9.4 (but that shouldn't be causing this error message.)
     
  14. jeric-aragon

    jeric-aragon

    Joined:
    Dec 11, 2015
    Posts:
    3
    Hi, I'm currently trying to make the facebook payment work for Unity 5.6 and I'm getting this error from the console when trying to purchase:

    UnityIAP FB: PurchaseCallback() RawResult {"callback_id":"4","response":{"error_code":1383146,"error_message":"invalid og type. Expected og: product, got website"}}​

    I've been trying to fix it for days and I would be glad to get some help on this issue.

    Thanks!
     
  15. JurassicApps

    JurassicApps

    Joined:
    Aug 3, 2012
    Posts:
    7
    Do you know if Facebook in regards to Payments through Gameroom are having any problems?

    Paypal seems to get caught in endless processing loop after signing into PayPal and clicking confirm. I have to force close and abandon so i guess users are doing the same, Im seeing say 100 users Start Purchase 20 cancel and the rest uncounted for guessing they did what i did and have to force close payment as it doesn't process?

    Now of course only a small fraction of users going through the payment process actually buy thats common sense but my experience of using PayPal through gameroom leads me to think they are still working of things behind the scene as I paid for my own IAP using a debit card and worked so UNITY's IAP must be set up ok thou still having problems with 2 IAP's reporting error pop up in Gameroom saying 'Couldn't complete purchase. We didn't receive all the information we needed from this app complete your purchase', maybe my IAP item identifier Facebook just doesn't like its a mystery that probably if i setup another IAP with a different ID then all will be fine but is a pain.

    They need also to implement that when a user attempts to purchase a IAP and isn't signed into Facebook they prompt the user to do so, first thought is you have to be signed into Facebook to use Gameroom but if you are say signed into another Facebook account in the web browser or not signed in at all seems to cause no response or dialogs appear when attempting to purchase within gameroom just nothing happens and could be improved.
     
  16. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    For this issue is the application set up to use Web Payments / Payments Lite? Can you provide additional log text from prior to the purchase attempt? This sounds like either the app is set up for webhooks-based payments or something is otherwise wrong with your available products or InitiatePurchase()
     
  17. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Hi,

    Unity IAP should be prompting the user to log into Facebook if they've somehow gotten into a state where they're not logged in (shouldn't happen with Gameroom now I think) so if you can reproduce that case we should investigate further. WRT PayPal purchases I have not tested it recently but have successfully used it in the past. Is this happening on both the Windows Gameroom client and WebGL?
     
  18. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    @NickSet Also, is this a "Test App" or your live app?
     
  19. jeric-aragon

    jeric-aragon

    Joined:
    Dec 11, 2015
    Posts:
    3
    I'm using Payments Lite for my IAP. I think I'm initializing it correctly since I'm able to retrieve the data correctly for the items from my Facebook definition.

    These are the logs returned from Facebook:

    UnityIAP FB: already Initialized
    UnityIAP FB: productRequest = /816765165099513/products
    UnityIAP FB: RetrievePurchases()
    UnityIAP FB: PurchaseListCallback RawResult `{
    "data": [
    ]
    }`
    UnityIAP FB: Purchase, Product ID com.monstronauts.potionpunch.handfulofcoins
    UnityIAP FB: PurchaseCallback() RawResult {"callback_id":"2","response":{"error_code":1383146,"error_message":"invalid og type. Expected og: product, got website"}}
    UnityIAP FB: PurchaseCallback Error `invalid og type. Expected og: product, got website`
    UnityIAP FB: PurchaseCallback Cancelled == FALSE
     
  20. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    There are some updates underway from the Facebook team that may address this problem. I know that one of them is already live but I think the other is still under review. I would suggest giving your test another try later today and tomorrow to see if behavior changes.

    The Unity IAP plugin available from the Gameroom site has had some debug removed -- we can provide a debug build if it looks like we need to dig further into the Facebook server responses. Alternatively, if you're comfortable with using Facebook's Graph API Explorer I can give you some requests to try there to confirm product details.
     
  21. JackmanGomel

    JackmanGomel

    Joined:
    Jun 3, 2015
    Posts:
    12
    Integrated IAP. But says that "could Not complete your purchase:" the Game is specified in production. They may earn after the release?
     
    Last edited: Apr 6, 2017
  22. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    239
    Anyone using new Payments lite ? It just doesn't for us at this point.
    Throws following error
    invalid og type. Expected og:product, got website"

    using this method to call Fb pay
    Code (CSharp):
    1. FB.Canvas.PayWithProductId(
    2. productID,
    3. "purchaseiap",
    4. 1,
    5. null, null, null, null, null,
    6. PayCallback // Callback function that receives an IPayResult
    7. );
    Also is it required to consume the product every time in Facebook Payments lite ?
     
    Last edited: Apr 10, 2017
  23. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Hi,

    I think we need a little more detail on your issue to see what's happening. Do you have a log available and are you currently testing with a test user or normal?
     
  24. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Unity IAP uses Payments Lite behind the scenes but you don't need to make a direct call to PayWithProductId (if you are using Unity IAP.) If you have implemented your own purchasing system that uses Payments Lite then I can confirm that it does work if the products are set up correctly. We use:
    Code (CSharp):
    1. FB.Canvas.PayWithProductId(myID, callback: PurchaseCallback);
    All products in Payments Lite are considered "managed" at this time so you should decide whether to consume or not based on your internal product type. Unity IAP handles that for you based on the Product Type you specify when setting it up in your game.
     
  25. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    239
    @JayR
    Yea it was working fine. then there was some issue from the Facebook side which they resolved recently. now everything works fine.
     
  26. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    2,297
    Hi @JayR,

    the Unity IAP Facebook package has been removed from the Gameroom page mentioned in one of the first posts of this thread. I've downloaded Unity 5.6 and the latest Unity IAP package, however the UnityPurchasing Stores.dll does not seem to include a Facebook store class.

    How should we use Facebook's Payments Lite with the current Unity IAP tools? Could you clarify when the Facebook store will be merged into the public Unity IAP package?
     
  27. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    Unity IAP 1.11 includes the Facebook Store as part of the Standard distribution and should be used instead of the beta version hosted on the Gameroom page. If you encounter any issues with 1.11 in your Gameroom projects please start a new thread in this forum.
     
  28. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,858
    Is 1.11 the version that is in the service tab? I'm trying to figure out integration of Facebook Payment lite. Was trying to see if there was an example for the Facebook Payment Lite setup since it's not called the same way as the android/ios stores.
     
  29. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,379
  30. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    4,858
    Did you create your products on Facebook?
     
  31. JayR

    JayR

    Unity Technologies

    Joined:
    Aug 2, 2016
    Posts:
    80
    The most likely source of that error would be a null product request, but we can't really confirm details from the partial code included here. Check your builder.AddProduct usage (you don't need store-specific IDs if they're the same and this appears to be edited from your real code.)

    Is this running in the Gameroom client from a FB-hosted build or are you using the "[DEV] Debug Local Unity Game Build" menu item in Gameroom? Is the account being used to test here authorized to access the application? One other possible source of an exception here would be a problem with the FB authorization token. Are you explicitly calling FB.Init() elsewhere in your code? If so, are you also handling login and with what permissions? Unity IAP will try to take care of that for you as well, but the log here is either from a later test in a session where that's happened or you're doing your own init / login.
     
    Last edited by a moderator: Sep 27, 2017
  32. birlagames

    birlagames

    Joined:
    Feb 16, 2014
    Posts:
    2
    Solved! Thank You @JayR
     
Thread Status:
Not open for further replies.