Here is my testing script that sends an example of testing post data to the localhost web host url:
<?php require_once __DIR__ . '/vendor/autoload.php'; // your sandbox data \Braintree\Configuration::environment('env...'); \Braintree\Configuration::merchantId('id'); \Braintree\Configuration::publicKey('your key'); \Braintree\Configuration::privateKey('your key'); $kind = isset($argv[1]) ? $argv[1] : \Braintree\WebhookNotification::CHECK; $id = isset($argv[2]) ? $argv[2] : null; $sampleNotification = \Braintree\WebhookTesting::sampleNotification($kind, $id); $signature = $sampleNotification['bt_signature']; $payload = $sampleNotification['bt_payload']; // Submit a payload and signature to handler $ch = curl_init('http://localhost/braintree.hook.php'); // Your URL curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ['bt_signature' => $signature, 'bt_payload' => $payload] ); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); echo curl_exec($ch);
You can send two parameters to this script, the first kind and the second id . This will allow you to change the appearance of events - check the documentation . Follow the example how to generate a subscription_canceled event:
php webhook.tests.php subscription_canceled 123456 > output.txt
source share