내 통화를 내 앱에 통합하는 동안 콜백 사용 방법을 이해하고 있습니다.facebook 현지 통화 콜백 찾기
기본적으로 내가 찾고있는 것은 데이터베이스 업데이트를 담당하는 코드의 일부입니다. 지불이 확정되는 곳. 여기
코드입니다 : 구매가 만들어 지거나 해당 페이지에 페이스 북 것이다 POST을 취소 먼저 앱 설정에서 URL을 호출을 다시 설정해야합니다$app_secret = '';
// Validate request is from Facebook and parse contents for use.
$request = parse_signed_request($_POST['signed_request'], $app_secret);
// Get request type.
$request_type = $_POST['method'];
// Setup response.
$response = '';
if ($request == null) {
// handle an unauthenticated request here
}
if ($request_type == 'payments_get_item_price') {
// Retrieving the user's info
$user_currency = $request['payment']['user_currency'];
$user_country = $request['user']['country'];
// Here we verify the product by passing back the URL of the OG product
$item['product'] = $request['payment']['product'];
// This is the quantity passed from the JS call to render the pay dialog.
// This parameter is optional and defaults to 1.
$quantity = $request['payment']['quantity'];
// Based on the user's currency and country, we set the price.
// We use fixed values here for testing.
switch($user_currency) {
case 'EUR':
$item['amount'] = 2.99;
$item['currency'] = 'EUR';
break;
case 'GBP':
$item['amount'] = 2.49;
$item['currency'] = 'GBP';
break;
case 'BRL':
$item['amount'] = 6.99;
$item['currency'] = 'BRL';
break;
// Here we default to USD. If a user's preferred currency is different than one
// that you specify, we will convert from the developer provided currency
// and amount to a new amount in the user's currency. You can choose whatever
// default currency works best for you.
default:
$item['amount'] = 3.99;
$item['currency'] = 'USD';
break;
}
// Optionally, you may also choose to override the quantity_min/quantity_max values
// which were passed in when invoking the Pay Dialog.
$item['quantity_min'] = 1;
$item['quantity_max'] = 100;
// Optionally, it's also possible to override the OG product object's title,
// plural_title and description.
$item['title'] = 'Override Title';
$item['plural_title'] = 'Override Title Plural';
$item['description'] = 'Override Description';
// Finally we add the item information to the response 'content'
$response['content'] = $item;
}
// Return the identical method
$response['method'] = $request_type;
// Send data back
echo json_encode($response);
// You can find the following functions and more details
// on https://developers.facebook.com/docs/authentication/canvas
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 signature
$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, '-_', '+/'));
}
현지 통화로 된 고정 지불에서 콜백 URL은 더 이상 페이스 북에서 전화를 걸지 않으므로 동적 가격 정책에서만 콜백 URL을 사용하기 때문에 사실이 아닙니다. –
결제에 대한 향후 변경 사항을 반영하여 답변을 업데이트하겠습니다. 그러나 앱 설정에서 변경 사항을 계속 사용 중지 할 수 있습니다. –