Facebook canvas payments

Hi,

I’m implementing in-app purchases for Facebook canvas game and I’m running into some problems.

I have Facebook canvas application and it works fine.

I have added Canvas Payments product to Facebook application.
I have added Webhook and tested it by sending a test request to callback url. Test request was successful.
(Our other games use Webhooks but payment is done via Unity SDK’s FB.Canvas.Pay dialog with OG url to product)
I have added products into facebook application.
I have added myself as tester to canvas payments

When I try to use

iap.buy(product_id)

where product_id is an id of a product I have added to Facebook, I get an error saying that “Purchase could not be finished. We didn’t get all information from the application we need to finish the purchase. You have not been charged for this purchase, so please try again. If this error keeps happening, contact the developer” (Translated from finnish to english so it might not be the exact english version of the error)

When I click “OK” in the dialog to close it, I get response as callback

{
  error = product already owned,
  reason = 0,
}

But when I use Facebook graphs API (https://graph.facebook.com/APP_ID/purchases?access_token=ACCESS_TOKEN) to check purchased products for my facebook account, the data response is empty

{
   "data": [
      
   ]
}

.
Am I missing something on this canvas payment setup?

Thank you in advance

Hmm, what if you open Chrome dev tools? Do you see any errors there? Javascript errors or network response errors?

I see no errors. Only thing that comes up when I try to do the purchase is a GET request to

https://apps.facebook.com/v2.6/dialog/pay?action=purchaseitem&product=aimer_s&e2e=%7B%7D&app_id=1845033202437457&sdk=joey&display=async&redirect_uri=https%3A%2F%2Fwww.facebook.com%2Fdialog%2Freturn%2Farbiter%23origin%3Dhttps%253A%252F%252Fiq.dev.playforia.net%252Fapp%252Fbubblesuniverse%252F&state=f83485f8163ea&dpr=1&__asyncDialog=2&__user=664792219&__a=1&__dyn=7AmajEzUGAcgngDxyG8EigmzFEbFbGAdy8Z9LFwxBxCbzES2N6wAxu13wFG2K48jyR88y8ixuAUW49XDG4XzEa8iGt0gKum4WxqUpHqCDxi5-u4bz8lUlwkEG9z9oybx24oqyUf8oC_UjDQ6EvGi64iiamezES68G5ECqnhomx2i5pumq&__af=i0&__req=d&__be=-1&__pc=PHASED%3ADEFAULT&__rev=2801889

which returns “200 OK”

EDIT: Now that I look at the url, it says v2.6 and in our app dashboard the API version is 2.8 with hint

This is the oldest version of the API this app can access. Any call to a version earlier than this or unversioned call by this app will automatically get upgraded to this.

Could that be the problem?

Ah, the product_id should be the full URL to the product HTML with og:product metatags not just the name of the product.

Fyi, I don’t think those api-warning generally are an issue, they constantly upgrade their graph API, so one usually has some leeway there. But for sure, I’ll add a ticket to upgrade our version.

Thank you, that seemed to get rid of that error. But now I’m facing another one.

When I start the purchase it says “There was a problem processing your payment. There is a problem processing your credit card. You have not been charged for this transaction. Try again later” (Again translated from finnish)

and when I close the error dialog, console says

ERROR:IAP: IAP error 6 
{
  error = failed to buy product,
  reason = 0,
}

I tried adding my credit card information to my Facebook account, but the same error occured.

Then again when I can start a transaction with our other game made with Unity, it gives me an option to add/choose my payment method.

1 Like

Hmm, this problem is outside the realm of the Defold engine and is more likely a configuration issue of some kind. Is your user account added as a Facebook Canvas Payments tester? Or is this a live/real purchase you’re trying? Is the other game setup in the same way in the Facebook Developer console as the page for the Defold game?

1 Like

I have added myself as a Canvas Payment tester and I’m trying to do a test purchase.

The Facebook application is a test version and it is not available for all Facebook users, ie. it’s not live.

The other game is setup the same way with the exception that it has no products added into Canvas Payments/Products section.

I need to double check the OG object creation. I haven’t created that myself so it might have some things that needs to be done for it to work properly.

Thanks for you help so far!

1 Like

Ah, I got it working. Apparently I needed to use Dynamic Pricing Callback URL for it to work. Now I can see the product and purchase it.

I wonder though, shouldn’t it use products from Canvas Payment/Products if no Dynamic Pricing Callback URL is given?

3 Likes

Good that you got it working!

Do you have static prices in the og:products meta-data? If you specify product:price:amount and product:price:currency then you shouldn’t need to set the dynamic pricing URL.