Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Solved] Unity IAP and Facebook payment lite

Discussion in 'Unity IAP' started by Brathnann, May 11, 2017.

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

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    UPDATE: Finally found it. Turns out Facebook has a consume call that has to be made.

    Currently using Unity 5.6f3 and Facebook 7.9.4.

    We have set up all products in the product page on Facebook and turned on Payment lite.

    We have a mobile version of our app and were using Facebook canvas payments in a previous app, however on our next app we decided to go with the Facebook payment lite as it sounded easier to setup and deal with.

    I setup the mobile shop to work for the Facebook product ids and then we setup a test user to purchase (without being charged).

    The test user gets the dialog box and we can choose always succeed and the payment works, but when trying to buy it again, it fails with an error. I assume it's just not being properly consumed (even though they are being declared as consumable in the builder.AddProduct call).

    The error when trying to rebuy is "There was a problem processing your payment. Sorry, but we're having trouble processing your payment. You have not been charged for this transaction. Please try again."

    I'm just not sure what I need to consume as the results are a bit different it appears vs mobile. I have a callback for the purchase and it catches it and I can check the IPayResult.

    What do we need to call to ensure the product is consumed from Facebook lite payments?

    Thank you for your help!
     
    Last edited: May 12, 2017
  2. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    What platform(s) are you using here? Unity IAP's Facebook Store is intended for Gameroom clients only and will consume items based on the AddProduct definitions. Based on your other comments here we assume you have implemented your own store interface so your code will indeed need to handle that (Payments Lite treats all products as "managed.")
     
  3. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    We're using this for webgl and Gameroom. It's working on both after I added the call to consume using Facebook.
     
  4. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    You should not need to call consume yourself if you are using this with a Gameroom platform. Your first post mentions that you have set up a callback and are checking the IPayResult -- you also shouldn't be doing that if you are using Unity IAP with the included Facebook Store. Can you give us some details on how you're handling purchasing here?
     
  5. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    I'm not sure what you mean by include Facebook store. Our store is all custom, and the user can select a coin bundle and then hit buy. At this point, it brings up the Facebook dialog box to handle payment (FB.Canvas.PayWithProductId).

    IPayResults helps give us the results of the payment process (cancelled, error, etc).

    Without the consume call (using the FB.API call with the purchaseToken/consume?access_token=accessToken , the purchase wasn't consumed on our test accounts resulting in an error when I tried to buy the product again. Once I added that in, the test accounts were able to purchase the bundles repeatedly.

    So far, it's working correctly now. We have one project using the non-lite version of FB payments and it works great. The new project I converted over the mobile version of our shop that uses Unity IAP since the setup is similar, just the calls were different.
     
  6. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,186
    There is no need to post this in multiple other post. Start your own post instead. Honestly, idk what the issue is. Use proper code tags when posting code and give us more info. When does your error occur? It's a null ref error, so just work towards figuring out what could be null. Also make sure you're using the latest IAP if you aren't already.
     
  7. JayR

    JayR

    Joined:
    Aug 2, 2016
    Posts:
    84
    If you are using Unity IAP 1.11 or later in a Facebook build on a Gameroom platform then Unity's Facebook "store" implementation will be automatically included in the build and purchasing will behave the same as your mobile version -- no code change is required beyond possibly adding store-specific names. In that situation there is no need to call FB.Canvas.PayWithProductId() or consume the purchased items in your code -- just call controller.InitiatePurchase(productId) and your existing callbacks will be used.

    Based on what you've written here we assume you have either implemented your own store for Facebook (using Unity IAP), disabled Unity IAP completely on these platforms or are using an older version of Unity IAP.
     
  8. birlagames

    birlagames

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