0

I have inherited this old ASP.Net MVC application and now I have to integrate a new Payment Service Provider. This PSP returns the responses to all payment requests via a POST message. The fields of the response are sent as hidden fields. The URL of the webhook must be provided in the request. After reading different SO posts along the same lines, I kinda know, in principle, what I would have to do. The PSP has a test & integration environment so I can send test request from my development environment. The problem I am facing is how to read the response. The URL for the webhook must be public, so me, running my development environment on my localhost, won't help. I can use webhook.site to get the responses, but I would like to get them in my application, so I check that my code behaves correctly and can handle properly the POST message containing all the hidden fields. Did anyone manage to find a possible solution for this problem?

TIA, Ed

Eddie
  • 271
  • 4
  • 18

1 Answers1

1

You mention that you want to test if you code behave correctly, I also see tag asp.net mvc in the post. For this requirement I can suggest you to go with azure. Azure have remote debugging feature which can easily help you test your code.

If you don't want to go with Azure, you can use ngrok software to make your localhost url public. This way you can trigger your code and debug it locally like remote debugging in azure.

There is one more way to test this thing very well. Just log the whole body of webhook (in logs or DB) and later execute it yourself through postman. This might doesn't let your webhook endpoint know the result at same time.

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
  • Thanks Anirudha. I thought of Azure remote debugging, but that may not be logistically possible. How about this ngrok software? I saw it suggested on other posts related to webhooks. Can you tell me more about it? How to use it exactly? – Eddie Aug 12 '22 at 13:48
  • I think I found an article that describes that. If it works, I will accept your answer. https://betterprogramming.pub/ngrok-make-your-localhost-accessible-to-anyone-333b99e44b07 – Eddie Aug 12 '22 at 14:58
  • I accepted your answer but I just realised that it may not work as expected. I need to forward my incoming webhook call to my local running API. This one includes a route in the path, so I would have to start ngrok with the following command: "ngrok http localhost:50550/api/webhook". Sadly this is not supported. Any ideas on how to do it? – Eddie Aug 15 '22 at 16:22
  • @Eddie this might help you https://stackoverflow.com/a/54679176/713789 – Anirudha Gupta Aug 16 '22 at 04:16
  • Hi Anirudha, that is not really my problem. I do not need multiple ngrok instances running on different ports. I have posted a new question that describes my issue here: https://stackoverflow.com/questions/73379139/ngrok-not-able-to-forward-incoming-webhook-post-request-to-my-local-web-api – Eddie Aug 16 '22 at 19:09