Sample payload and signature

We've provided a sample_notification 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.

Ruby
Click to copy
Copied
sample_notification = Braintree::WebhookTesting.sample_notification(
  Braintree::WebhookNotification::Kind::SubscriptionWentPastDue,
  "my_id"
)

webhook_notification = Braintree::WebhookNotification.parse(
  sample_notification[:bt_signature],
  sample_notification[:bt_payload]
)

webhook_notification.subscription.id
# => "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:

Disbursement

  • Braintree::WebhookNotification::Kind::Disbursement
  • Braintree::WebhookNotification::Kind::DisbursementException
  • Braintree::WebhookNotification::Kind::TransactionDisbursed

Dispute

  • Braintree::WebhookNotification::Kind::DisputeLost
  • Braintree::WebhookNotification::Kind::DisputeOpened
  • Braintree::WebhookNotification::Kind::DisputeWon

Partner Merchant Account

  • Braintree::WebhookNotification::Kind::PartnerMerchantConnected
  • Braintree::WebhookNotification::Kind::PartnerMerchantDeclined
  • Braintree::WebhookNotification::Kind::PartnerMerchantDisconnected

Sub-merchant Account

  • Braintree::WebhookNotification::Kind::SubMerchantAccountApproved
  • Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined

Subscription

  • Braintree::WebhookNotification::Kind::SubscriptionCanceled
  • Braintree::WebhookNotification::Kind::SubscriptionChargedSuccessfully
  • Braintree::WebhookNotification::Kind::SubscriptionChargedUnsuccessfully
  • Braintree::WebhookNotification::Kind::SubscriptionExpired
  • Braintree::WebhookNotification::Kind::SubscriptionTrialEnded
  • Braintree::WebhookNotification::Kind::SubscriptionWentActive
  • Braintree::WebhookNotification::Kind::SubscriptionWentPastDue

Test

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