誰でもphpでbraintree webhookの動作例を教えてください。以下のコードを使用してリンクを確認しましたが、正常に動作しています:
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);