实施Facebook Credits - Callback.php

时间:2012-01-22 13:24:07

标签: php facebook facebook-apps facebook-credits

我正在尝试将Facebook积分应用到我的应用程序中,我想在此刻卖出两件物品,一件是用于恢复用户健康的药水,另一件是用于恢复用户体力的药水。

到目前为止,我已使用以下Javascript来提示付款:

function placeOrder() {

        // Assign an internal ID that points to a database record
        var order_info = '1potion';

        // calling the API ...
        var obj = {
          method: 'pay',
          order_info: order_info,
          purchase_type: 'item',
          dev_purchase_params: {'oscif': true}
        };

        FB.ui(obj, callback);
      }

      var callback = function(data) {
        if (data['order_id']) {
          return true;
        } else {
          //handle errors here
          return false;
        }
      };     
      </script>

到目前为止一直很好....现在讨论callback.php文件......

根据我的阅读,我应该有一些东西,例如“select * from store where product = 1potion”,并从他们的产品中获取信息?这是正确的,因为当我尝试这个时,我收到了错误消息“此交易存在问题,您没有被收费”。

因此我目前正在使用:

 if ($item_info == "1potion") {

      // Per the credits api documentation, you should pass in an item 
      // reference and then query your internal DB for the proper 
      // information. Then set the item information here to be 
      // returned to facebook then shown to the user for confirmation.
      $item['title'] = 'Will Potion';
      $item['price'] = 15;
      $item['description'] = 'This is a potion which can be used to fully restore your will stat!';
      $item['image_url'] = 'http://www.midcitymafia.com/images/potion.jpg';
      $item['product_url'] = 'http://www.midcitymafia.com/images/potion.jpg';

到目前为止,一切工作仍然正常,我只是停留在哪里,我将代码发布给用户产品,我已经研究过,似乎我需要实现代码来发布产品:< / p>

if ($status == 'placed') {
  $next_state = 'settled';
  $data['content']['status'] = $next_state;
          }

但我需要使用哪个变量来确定用户实际购买的产品......确保他们收到正确的商品。

提前致谢,

杰克。

0 个答案:

没有答案