クレジットbuy()
ルーチンが呼び出されると、Facebook はこのエラーを表示There Was a Problem Processing Your Payment.
し、支払いダイアログは表示されません。
以下を確認しましたが、問題が見つかりません。
- クレジット設定でコールバック URL を設定します: http://sharp-journey-4179.herokuapp.com/callback.jsp
- 自分をクレジット テスターに設定します。
- Facebook Object Debugger ツールからコールバック ルーチンにアクセスできることを確認しました。
- payment_get_items POST に対して定型応答を単純に返すように、callback.jsp を絞り込みました。
- Heroku ルーターはステータス 200 の POST を受信しますが、callback.jsp の console.log 出力は Heroku ログで受信されません。
- payment_get_items への応答は次のとおりです。
"{\"content\":[{\"title\":\"My app \",\"description\":\"This is my app .\",\"price\":2,\"product_url \":\"http://www.facebook.com/images/gifts/21.png\",\"image_url\":\"http://www.facebook.com/images/gifts/21.png \"}],\"メソッド\":\"payments_get_items\"}"
Facebook クレジットのドキュメントには、購入リクエストに応じてアプリケーション サーバー リクエストが発行されることが記載されています。POST を処理してコールバック ルーチンに渡すには、サーブレットを実装する必要がありますか? Facebook は Callback ルーチンの名前をどのように使用していcallback.jsp
ますか? サーブレットに Callback という名前を付ける必要がありますか?
これは私のクライアントbuy()
ルーチンの抜粋です:
// The dialog only opens if you've implemented the
// Credits Callback payments_get_items.
function buy() {
var obj = {
method: 'pay',
action: 'buy_item',
// You can pass any string, but your payments_get_items must
// be able to process and respond to this data.
order_info: {'item_id': '1a1'},
dev_purchase_params: {'oscif': true}
};
FB.ui(obj, js_callback);
}
これは私の callback.jsp コードです:
<script type="text/javascript">
var secret = 'xxxxxxxxxxxxxxxxxxxxx';
console.log("In fnf callback.jsp");
//$request_type = $_POST['method'];
// Setup response.
var return_data = '';
var item = {
title: 'My App',
description: 'This is my app.',
price: 2,
product_url: 'http:\/\/www.facebook.com\/images\/gifts\/21.png',
image_url: 'http:\/\/www.facebook.com\/images\/gifts\/21.png'
};
var content_array = new Array;
content_array[0] = item;
// Construct response.
var response = {
content: content_array,
method: 'payments_get_items'
};
// Response must be JSON encoded.
return_data = JSON.stringify(response);
// Send response.
alert(return_data);
</script>