我正在尝试在我的应用程序中实现 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 文件......
从我读过的内容来看,我应该有诸如“从产品= 1药水的商店中选择*”之类的东西,并从他们那里提取有关产品的信息?这是正确的吗,因为当我尝试这样做时,我刚刚收到错误消息“此交易存在问题,您没有被收取费用”。
因此我目前正在使用:
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;
}
但是我必须使用什么变量来确定用户实际购买的产品......以确保他们收到正确的商品。
提前致谢,
杰克。