Test Webhook at localhost in braintree

走远了吗. 提交于 2019-12-20 12:50:39

问题


I am working on braintree and I want to send custom email notifications to my customers as I am working with recurring billing, so every month these custom notifications should be send to all users. For this I have to use webhooks to retrieve currently ocuured event and then send email notification according to webhook's response. (I think this is only solution in this case, If anyone know another possible solution please suggest). I want to test webhooks at my localhost first, And I have tried to create a new webhook and specified the localhost path as destination to retrieve webhooks. But this shows a error "Destination is not verified"..........

My path is : "http://127.0.0.1:81/webhook/Accept"


回答1:


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




回答2:


I work at Braintree. If you need more help, please get in touch with our support team.

In order to test webhooks, your app needs to be able to be reached by the Braintree Gateway. A localhost address isn't. Try using your external IP address and make sure the port on the correct computer can be reached from the internet.

Take a look at the Braintree webhook guide for more info on setting up webhooks.




回答3:


You can use PutsReq to simulate the response you want and do your end-to-end test in development.




回答4:


For quick 'n dirty testing: http://requestb.in/

For more formal testing (e.g. continuous integration): https://www.runscope.com/




回答5:


If you have a online server you may forward port from your computer to that server.

ssh -nNT -R 9090:localhost:3000 root@yourvds.com

And then specify webhook as http://yourvds.com:9090/webhook

all requests will be forwarded to you machine, you will be able to see logs




回答6:


I know this is an old question, but according to the docs, you can use this code to test your webhook code:

Dictionary<String, String> sampleNotification = gateway.WebhookTesting.SampleNotification(
    WebhookKind.SUBSCRIPTION_WENT_PAST_DUE, "my_id"
);

WebhookNotification webhookNotification = gateway.WebhookNotification.Parse(
    sampleNotification["bt_signature"],
    sampleNotification["bt_payload"]
);

webhookNotification.Subscription.Id;
// "my_id"


来源:https://stackoverflow.com/questions/21234356/test-webhook-at-localhost-in-braintree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!