2013-08-17 70 views
1

任何一個可以請提供我php.I布倫特裏網絡掛接的工作示例使用了下面的代碼中提到,以驗證我的鏈接,它是工作的罰款:布倫特裏網絡掛接工作例

require_once 'braintree-php-2.22.0/lib/Braintree.php'; 

Braintree_Configuration::environment('sandbox'); 
Braintree_Configuration::merchantId('jmvhd879pf68kfk8'); 
Braintree_Configuration::publicKey('cfywtwxy8bxmwtkn'); 
Braintree_Configuration::privateKey('ad3f3b6e9c8b8186c1204a0f533899da'); 

$bt_challenge_param = $_GET['bt_challenge']; 
echo $response = Braintree_WebhookNotification::verify($bt_challenge_param); 

但是當我寫它不寫入文件在同一頁面上下面提到的代碼(沒有與文本文件的路徑沒有問題),甚至支付成功後:

require_once 'braintree-php-2.22.0/lib/Braintree.php'; 

Braintree_Configuration::environment('sandbox'); 
Braintree_Configuration::merchantId('jmvhd879pf68kfk8'); 
Braintree_Configuration::publicKey('cfywtwxy8bxmwtkn'); 
Braintree_Configuration::privateKey('ad3f3b6e9c8b8186c1204a0f533899da'); 

/*$bt_challenge_param = $_GET['bt_challenge']; 
echo $response = Braintree_WebhookNotification::verify($bt_challenge_param);*/ 
$notification = Braintree_WebhookNotification::parse(
$_POST['bt_signature'], 
$_POST['bt_payload'] 
); 
$notification->kind == Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED; 
$date = date('Y-m-d h:i:s'); 
$file = fopen("log.txt","w"); 
fwrite($file,$date."\r\n"); 
fwrite($file,$notification->merchantAccount->status."\r\n"); 
fwrite($file,$notification->merchantAccount->id."\r\n"); 
fwrite($file,$notification->merchantAccount->masterMerchantAccount->id."\r\n"); 
fwrite($file,$notification->merchantAccount->masterMerchantAccount->status."\r\n"); 
fwrite($file,"\r\n\r\n\r\n\r\n\r\n\r\n"); 
fclose($file); 
+0

你得到任何異常? – agf

回答

2

我在布倫特裏工作。如果你需要更多的信息,你可以輕鬆獲得堆棧溢出,請聯繫我們的support team。我們有一個webhook guide for each of our client libraries, including PHP

簡述:

if(
    isset($_POST["bt_signature"]) && 
    isset($_POST["bt_payload"]) 
) { 
    $webhookNotification = Braintree_WebhookNotification::parse(
     $_POST["bt_signature"], $_POST["bt_payload"] 
    ); 

    $message = 
     "[Webhook Received " 
     . $webhookNotification->timestamp->format('Y-m-d H:i:s') . "] " 
     . "Kind: " . $webhookNotification->kind . " | " 
     . "Subscription: " . $webhookNotification->subscription->id . "\n"; 

    file_put_contents("/tmp/webhook.log", $message, FILE_APPEND); 
}