facebook支付对话框未显示本地货币对话框

facebook支付对话框未显示本地货币对话框,facebook,payment,Facebook,Payment,facebook pay dialog仅显示积分,当我点击buy credits时,它应该转到下一个对话框,询问我支付选项,它只是说您的购买成功。不知道我在做什么尝试了一切但都不起作用 这是我的javascript函数 function buy_tokens(p){ FB.init({appId: "myappid", status: true, cookie: true}); var obj = { method: 'pay', action: 'buy_item'

facebook pay dialog仅显示积分,当我点击buy credits时,它应该转到下一个对话框,询问我支付选项,它只是说您的购买成功。不知道我在做什么尝试了一切但都不起作用

这是我的javascript函数

function buy_tokens(p){

FB.init({appId: "myappid", status: true, cookie: true});

    var obj = {
    method: 'pay',
    action: 'buy_item',
    order_info: {'item_id': 'tokens', 'price':p},
    dev_purchase_params: {'oscif': true}
    };
    //FB.ui(obj, js_callback);
   FB.ui(obj, function(paydata) {
       // response back        
   });

}
这是我的callback.php

<?php

$facebook = new Facebook(array(
'appId'  => APP_ID,
'secret' => SECRET,
'cookie' => true,  
));

$api_key = 'appid';
$secret = 'app secret';

// prepare the return data array
$data = array('content' => array());

//parse signed data
$request = parse_signed_request($_REQUEST['signed_request'], $secret);

if ($request == null) {
// handle an unauthenticated request here
}

$payload = $request['credits'];

// retrieve all params passed in
$func = $_REQUEST['method'];
$order_id = $payload['order_id'];


function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

 // decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);

if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}

// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}

return $data;
}


function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}


if ($func == 'payments_status_update') {
$status = $payload['status'];

// write your logic here, determine the state you wanna move to
if ($status == 'placed') {
$next_state = 'settled';
$data['content']['status'] = $next_state;
}
// compose returning data array_change_key_case
$data['content']['order_id'] = $order_id;
} else if ($func == 'payments_get_items') {
// remove escape characters  
$order_info = stripcslashes($payload['order_info']);
$item_info = json_decode($order_info, true);
//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.

if($item_info['price']=='0.69'){
    $tokens = 150000;
}elseif($item_info['price']=='1.49'){
    $tokens = 350000;
}elseif($item_info['price']=='2.49'){
    $tokens = 600000;
}elseif($item_info['price']=='3.99'){
    $tokens = 1000000;
}

$fb = $facebook->api('/me/?fields=currency'); 
$credit = round($item_info['price']*$fb[currency]        ['currency_exchange_inverse']*$fb[currency]['currency_offset']*$fb[currency] ['currency_exchange']);
//  $symbol = array('GBP'=>'£','EUR'=>'€','USD'=>'$');


if ($item_info['item_id'] != "") {
$item['title'] = $tokens.' Tokens ';
$item['price'] = $credit;
$item['description']= 'You will get '.$tokens.' Tokens';
$item['image_url']='url';
$item['product_url']='url';
}
//for url fields, if not prefixed by http:,
//prefix them
$url_key = array('product_url', 'image_url');  
foreach ($url_key as $key) {
if (substr($item[$key], 0, 7) != 'http://') {
$item[$key] = 'http://'.$item[$key];
}
}
$data['content'] = array($item);
}

// required by api_fetch_response()
$data['method'] = $func;
echo json_encode($data);

?>


dev_purchase_参数:{'oscif':true}仅当您未使用测试帐户进行购买时,该参数才有效。使用未在应用程序设置中列为付款测试仪的facebook帐户进行尝试。

是的,使用任何其他非应用程序管理员/开发人员的帐户进行尝试,您将看到带有paypal和其他付款选项的付款对话框