Test Webhook at localhost in braintree

These are some of the tools that can be used during development of webhooks :

1) PostCatcher,

2) RequestBin,

3) ngrok,

4) PageKite and

5) LocalTunnel

http://telerivet.com/help/api/webhook/testing

https://www.twilio.com/blog/2013/10/test-your-webhooks-locally-with-ngrok.html


Well Another way to test it is by creating a WebAPI and POSTing Data to your POST method via Postman. To do this, just create a WebAPI in Visual Studio. In the API controller, create a POST method.

/// <summary>
/// Web API POST method for Braintree Webhook request
/// The data is passed through HTTP POST request. 
/// A sample data set is present in POSTMAN HTTP Body
/// /api/webhook
/// </summary>
/// <param name="BTRequest">Data from HTTP request body</param>
/// <returns>Webhook notification object</returns>
public WebhookNotification Post([FromBody]Dictionary<String, String> BTRequest)
{

    WebhookNotification webhook = gateway.WebhookNotification.Parse(BTRequest["bt_signature"], BTRequest["bt_payload"]);
    return webhook;
}

In Postman, Post the following data in the Body as raw JSON.

    {
        "bt_signature":"Generated Data",
        "bt_payload":"Very long generated data"
}

The data for the above Json dictionary has been generated through the below code:

     Dictionary<String, String> sampleNotification = gateway.WebhookTesting.SampleNotification(WebhookKind.DISPUTE_OPENED, "my_Test_id");
// Your Webhook kind and your test ID

Just pick the data from sample notification and place it above in the JSON. Run your WebAPI, place debuggers. Add the localhost URL in Postman, select POST, and click on Send. Your POST method should be hit.

Also, don't forget to add your gateway details:

private BraintreeGateway gateway = new BraintreeGateway
        {
            Environment = Braintree.Environment.SANDBOX,
            MerchantId = "Your Merchant Key",
            PublicKey = "Your Public Key",
            PrivateKey = "Your Private Key"
        };

I hope this helps!