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.

Java
HashMap<String, String> sampleNotification = gateway.webhookTesting().sampleNotification(
  WebhookNotification.Kind.SUBSCRIPTION_WENT_PAST_DUE, "my_id"
);

WebhookNotification webhookNotification = gateway.webhookNotification().parse(
  sampleNotification.get("bt_signature"),
  sampleNotification.get("bt_payload")
);

webhookNotification.getSubscription().getId();
// "my_id"

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

  • WebhookNotification.Kind.CONNECTED_MERCHANT_STATUS_TRANSITIONED
  • WebhookNotification.Kind.CONNECTED_MERCHANT_PAY_PAL_STATUS_CHANGED

Disbursement

  • WebhookNotification.Kind.DISBURSEMENT
  • WebhookNotification.Kind.DISBURSEMENT_EXCEPTION
  • WebhookNotification.Kind.TRANSACTION_DISBURSED

Dispute

  • WebhookNotification.Kind.DISPUTE_OPENED
  • WebhookNotification.Kind.DISPUTE_LOST
  • WebhookNotification.Kind.DISPUTE_WON
  • WebhookNotification.Kind.DISPUTE_ACCEPTED
  • WebhookNotification.Kind.DISPUTE_EXPIRED
  • WebhookNotification.Kind.DISPUTE_DISPUTED

OAuth

  • WebhookNotification.Kind.OAUTH_ACCESS_REVOKED

Sub-merchant Account

  • WebhookNotification.Kind.SUB_MERCHANT_ACCOUNT_APPROVED
  • WebhookNotification.Kind.SUB_MERCHANT_ACCOUNT_DECLINED

Subscription

  • WebhookNotification.Kind.SUBSCRIPTION_CANCELED
  • WebhookNotification.Kind.SUBSCRIPTION_CHARGED_SUCCESSFULLY
  • WebhookNotification.Kind.SUBSCRIPTION_CHARGED_UNSUCCESSFULLY
  • WebhookNotification.Kind.SUBSCRIPTION_EXPIRED
  • WebhookNotification.Kind.SUBSCRIPTION_TRIAL_ENDED
  • WebhookNotification.Kind.SUBSCRIPTION_WENT_ACTIVE
  • WebhookNotification.Kind.SUBSCRIPTION_WENT_PAST_DUE

Check

  • WebhookNotification.Kind.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 WebhookNotification.Kind.CHECK.

To test a webook notification:

  1. Log into the Control Panel
  2. Click on the gear icon in the top right corner
  3. Click API from the drop-down menu
  4. Click on the Webhooks tab
  5. Click the Check URL link located to the right of the URL you'd like to check

Be careful when using this check 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.