0

As Facebook are forcing us to change ways once again, we need to introduce their "local currency" as payment option in our app.

However, I'm finding the documentation hard to understand, and are in desperate need of some example code. If anyone knows of some sample code, it would be greatly appreciated.

halfer
  • 19,824
  • 17
  • 99
  • 186
JPJens
  • 1,185
  • 1
  • 17
  • 39
  • FB has documentation on this new feature here https://developers.facebook.com/docs/howtos/payments/ – Filippos Karapetis Jun 10 '13 at 12:25
  • Thank you. However im aware of this documentation, but from that i am still unable to create a successfull payment promt according to their new "local currency". What i was hoping for was a working example that might illustrate exactly how it works – JPJens Jun 10 '13 at 12:36

2 Answers2

0

I think this error occurs if you are the developer/owner of the app, try a different account

I have only just worked this out myself and have not yet completed the callback, I will edit my answer then. Hope this is useful to someone. First make a graph object

<head prefix=
"og: http://ogp.me/ns# 
fb: http://ogp.me/ns/fb# 
product: http://ogp.me/ns/product#">
<meta property="og:type"                   content="og:product" />
<meta property="og:title"                  content="Friend Smash Coin" />
<meta property="og:plural_title"           content="Friend Smash Coins" />
<meta property="og:image"                  content="http://www.friendsmash.com/images/coin_600.png" />
<meta property="og:description"            content="Friend Smash Coins to purchase upgrades and items!" />
<meta property="og:url"                    content="https://www.yourdomain.com/test.html" />
<meta property="product:price:amount"      content="0.30"/>
<meta property="product:price:currency"    content="USD"/>
<meta property="product:price:amount"      content="0.20"/>
<meta property="product:price:currency"    content="GBP"/>
</head>

Save this as an html file and upload it to your server, lets say yourdomain.com/test.html

Visit this page https://developers.facebook.com/tools/debug and enter yournew url here (yourdomain.com/test.html)

change the product url below to your domain (yourdomain.com/test.html)

<h2>Purchase a product:</h2>
<button id="pay">Buy Product</button>
<div class="returndata" id="output"></div>


<div id="fb-root"></div>
<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'APPID',
      status     : true,
      cookie     : true,
      xfbml      : true
    });

    function buy() {
      var obj = {
        method: 'pay',
        action: 'purchaseitem',
        product: 'http://yourdomain.com/test.html'
      };

      FB.ui(obj, function(data) {
          console.log(data);
        });
    }

    document.getElementById('pay').onclick = function() {buy()};
  };

  // Load the SDK Asynchronously
  (function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) { return; }
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    ref.parentNode.insertBefore(js, ref);
  }(document));
</script>
Michael L Watson
  • 964
  • 13
  • 23
  • Thank you for the answer. Unfortunately i'm stuck debugging, as facebook only returns: Error Parsing URL: Error parsing input URL, no data was scraped. – JPJens Jun 14 '13 at 12:56
  • is this when parsing the url with the debugger? are you sure the path is correct and the data is formatted correctly? What is the url? – Michael L Watson Jun 14 '13 at 16:48