Sample payload and signature

We've provided a sampleNotification method to generate a parsable signature and payload. This allows you to generate a sample notification and POST the contents of the payload and signature to your application to test your webhook handling code.

PHP
Copy
Copied
$sampleNotification = $gateway->webhookTesting()->sampleNotification(
    Braintree_WebhookNotification::SUBSCRIPTION_WENT_PAST_DUE,
    'my_id'
);

$webhookNotification = $gateway->webhookNotification()->parse(
    $sampleNotification['bt_signature'],
    $sampleNotification['bt_payload']
);

$webhookNotification->subscription->id;
# => "my_id"
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

This method expects two arguments: the kind of webhook notification to be generated, and an ID of the object which triggered it.

note

The notification returned will contain a dummy object of the type specified, but this object is not a complete item from your gateway. It will not necessarily have everything you expect from a production webhook.

The webhook kind can be specified as any one of the following:

Braintree Auth

  • Braintree_WebhookNotification::CONNECTED_MERCHANT_STATUS_TRANSITIONED
  • Braintree_WebhookNotification::CONNECTED_MERCHANT_PAY_PAL_STATUS_CHANGED

Disbursement

  • Braintree_WebhookNotification::DISBURSEMENT
  • Braintree_WebhookNotification::DISBURSEMENT_EXCEPTION
  • Braintree_WebhookNotification::TRANSACTION_DISBURSED

Dispute

  • Braintree_WebhookNotification::DISPUTE_OPENED
  • Braintree_WebhookNotification::DISPUTE_LOST
  • Braintree_WebhookNotification::DISPUTE_WON

OAuth

  • Braintree_WebhookNotification::OAUTH_ACCESS_REVOKED

Partner Merchant Account

  • Braintree_WebhookNotification::PARTNER_MERCHANT_CONNECTED
  • Braintree_WebhookNotification::PARTNER_MERCHANT_DECLINED
  • Braintree_WebhookNotification::PARTNER_MERCHANT_DISCONNECTED

Sub-merchant Account

  • Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED
  • Braintree_WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED

Subscription

  • Braintree_WebhookNotification::SUBSCRIPTION_CANCELED
  • Braintree_WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY
  • Braintree_WebhookNotification::SUBSCRIPTION_CHARGED_UNSUCCESSFULLY
  • Braintree_WebhookNotification::SUBSCRIPTION_EXPIRED
  • Braintree_WebhookNotification::SUBSCRIPTION_TRIAL_ENDED
  • Braintree_WebhookNotification::SUBSCRIPTION_WENT_ACTIVE
  • Braintree_WebhookNotification::SUBSCRIPTION_WENT_PAST_DUE

Test

  • Braintree_WebhookNotification::CHECK

Trigger a test notification from Braintree

Once you've created a webhook, you can use the Control Panel to fire a test notification to the webhook's destination URL. This notification's kind is Braintree_WebhookNotification::CHECK.

The Check URL button that fires the webhook is located on the primary webhooks page in the Control Panel, next to each configured webhook. Be careful when using this button in production- if your webhook handling code doesn’t look for the kind of webhooks it receives, this could lead to unexpected behavior.

For example, if your integration assumes it will only receive Subscription Canceled webhooks and you test the URL, it might cause an exception when your code tries to access the non-existent subscription object on the webhook.

Still have questions?

If you can’t find an answer, contact our Support team