Facebook canvas payment

1.9k Views Asked by At

I am implementing Facebook canvas payment in my app . But I couldn't found what should I mention in its callback url. I didn't found any document regarding this also. Below in my picture I have pointed out the position which I am not sure what to write .So if anyone can help me then it will be my greatest pleasure.

enter image description here

1

There are 1 best solutions below

0
On

Dynamic Pricing Callback URL is used to get the price of an item you're trying to sell with dynamic payments. For example, if you create an OG object for your item and you don't set up the price and currency as meta tags on that object, Facebook will call that endpoint to get the item's price. This is not required if you set the price in the OG Object:

<html>

<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
  <meta property="og:type" content="og:product" />
  <meta property="og:locale" content="en_US" />
  <meta property="og:title" content="Coin" />
  <meta property="og:plural_title" content="Coins" />
  <meta property="og:image" content="http://ancient-savannah-6416.herokuapp.com/images/coin64.png" />
  <meta property="og:url" content="http://ancient-savannah-6416.herokuapp.com/opengraph/coin.html" />
  <meta property="og:description" content="Test Coins!" />
  <meta property="product:price:amount" content="0.10"/>
  <meta property="product:price:currency" content="USD"/>
  <meta property="product:price:amount" content="0.12"/>
  <meta property="product:price:currency" content="CAD"/>
  <meta property="product:price:amount" content="0.08"/>
  <meta property="product:price:currency" content="EUR"/>
  <meta property="product:price:amount" content="0.06"/>
  <meta property="product:price:currency" content="GBP"/>
  <meta property="product:price:amount" content="1.2"/>
  <meta property="product:price:currency" content="MXN"/>
  <meta property="product:price:amount" content="0.50"/>
  <meta property="product:price:currency" content="BRL"/>
  <meta property="product:price:amount" content="0.64"/>
  <meta property="product:price:currency" content="SEK"/>
</head>

</html>

You can read more about that here:

https://developers.facebook.com/docs/howtos/payments/definingproducts#pricing_dynamic

The Realtime Subscription Callback URL is used so that Facebook can notify you about new payments, disputes, chargebacks, etc. This is required as some payment methods are asynchronous and you won't be able to fulfill the payment until the payment changes its status to completed. You can read more here:

https://developers.facebook.com/docs/payments/realtimeupdates/

Here's a sample implementation:

<?php

$verify_token = "nv,mczjhiofewnakfld831nm";

$method = $_SERVER['REQUEST_METHOD'];

if ($method == 'GET' && $_GET['hub_verify_token'] === $verify_token) {
  echo $_GET['hub_challenge'];
  exit();
}
else if( $method == 'GET') {
  echo "<h1>REAL TIME UPDATES</h1>";
}

if ($method == 'POST') {
  $time_now = date("Y-m-d H:i:s"); 
  $updates = json_decode(file_get_contents("php://input"), true);

  log($time_now . " " . json_encode($updates) ."\n\n\n", 3, "rtudata.txt");
  log($time_now . " " . json_encode($_REQUEST) ."\n", 3, "rtudata.txt");
  log($time_now . " " . json_encode($_SERVER) ."\n", 3, "rtudata.txt");
}

?>