0

Facebook クレジットをアプリケーションに実装しようとしています。現在、2 つのアイテムを販売したいと考えています。1 つはユーザーの健康を回復するポーションで、もう 1 つはユーザーの体力を回復するポーションです。

これまでのところ、支払いを促すために次の 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';

これまでのところ、すべてが正常に機能しています。ユーザーに製品を発行するためのコードを配置する場所に行き詰まっています。調査したところ、製品を発行するためのコードを実装する必要があるようです。

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

しかし、ユーザーが実際にどの製品を購入したかを判断するには、どの変数を使用する必要がありますか... ユーザーが正しいアイテムを確実に受け取るようにするためです。

前もって感謝します、

ジャック。

4

0 に答える 0