Google App Engine で Facebook クレジットを使用する例はありますか?
このブログ投稿を見つけましたが、完全ではありません http://blog.suinova.com/2011/01/integrating-facebook-credits-api-into.html
App Engine で動作するサンプル runwithfriends の例を取得し、クレジットで拡張しようとしましたが、今のところうまくいきません。
FB開発者フォーラムも検索しましたが、何も得られませんでした。
あなたが私に指摘できるリソースはありますか?
何が機能していないか:
1) 「Facebook で支払う」ボタンをクリックすると、エラー コードなしで「アプリケーション エラー」が表示されます。
・javascriptコンソール
を確認・fbアプリの設定
を確認・ローカルサーバーと本番サーバーで試した
2)署名されたリクエストを解析できなかったため、callback.pyは完全ではありません(pyで学習できるコードがありません)
3) 私が基本的に行ったことは、Suinova Designs (上のリンク) のコードを既存の Run With Friends アプリのコードに追加することでした。期待通りにはなりませんでした。
これまでの私のコード:
//payment_page.html
<html>
<table>
<tr><th>Name</th><th>Price</th><th> </th></tr>
<tr><td>Something to buy</td><td>10 FC</td><td><a href="" onclick="return buyit();">
<img src="http://www.facebook.com/connect/button.php?app_id=215638625132268&feature=payments&type=light_l" />
</a></td></tr>
</table>
// javascript
function buyit(){
FB.ui({
method:'pay',
purchase_type:'item',
order_info:{
item_id:'myitem',
title:'Something to buy',
price:2,
description:'Whatever',
image_url:'http://www.facebook.com/images/gifts/21.png',
product_url:'http://www.facebook.com/images/gifts/21.png'}
},
function(resp){
if(resp.order_id) window.top.location='http://apps.facebook.com/runwithfriends trial'; else alert(resp.error_message);
});
return false;
}
//callback.py
class FacebookPaymentRequest(webapp.RequestHandler):
def post(self):
signed_request = parse_signed_request(self.request.get('signed_request'),conf.FACEBOOK_APP_SECRET)
payload = signed_request['credits'] #credits:{buyer:int,order_id:int,order_info:{},receiver:int}
order_id = payload['order_id']
method = web.request.get('method')
return_data = {'method':method}
if method == 'payments_get_items':
order_info = payload['order_info'] #order_info:{item_id:'',title:'',description:'',price:0,image_url:'',product_url:''}
item = simplejson.loads(order_info) #needs to convert JSON string to dict
#check item,price,etc and reply
return_data['content'] = [item]
elif method == 'payments_status_update':
status = payload['status']
return_data['content'] = {'status':'settled','order_id':order_id}
if status == 'placed':
#just return settled status to Facebook, this may be called twice
order_details = simplejson.loads(payload['order_details'])
#check and log here
elif status == 'settled':
order_details = simplejson.loads(payload['order_details'])
#order_details:{order_id:0,buyer:0,app:0,receiver:0,amount:0,update_time:0,time_placed:0,data:'',items:[{}],status:'placed'}
buyer = order_details['buyer']
item = order_details['items'][0]
#now save this transaction into our database
else:
#may be refunded, canceled, log the activity here
return_data['content']['status'] = status
self.response.out.write(simplejson.dumps(return_data))