Search code examples
asp.net-mvcstripe-paymentswebhooksngrokstripe.net

Testing Stripe webhook over HTTPS keep failing : Timed out


Short version

I'm trying to create a very basic webhook which redirects to a ASP.NET MVC Controller method on localhost. However, my website uses full HTTPS, and it seems my tunneling client (ngrok) fails with HTTPS. Creating a new ASP.NET MVC website and implementing my webhook works, but I keep failing with my HTTPS website.

Long version

Here is what I've done so far :

1/ Create an endpoint on my ASP.NET MVC5 website and run it on localhost. It runs on port 44368, as my full website uses HTTPS.

public class StripeWebhookController : BaseController
{
    [HttpPost]
    [AllowAnonymous]
    public ActionResult Index()
    {
         // ...
    }
}

2/ Install ngrok and configure it as explained in this SO answer

3/ Go to my Stripe test dashboard and copy the URL to be called like that : enter image description here
(I tried to check the other RadioButton, "latest", but doesn't work better. I also tried to replace https by http, not better neither)

When I send a test webhook with the Stripe dashboard, I can see the request in http://localhost:4040/inspect/http : enter image description here

But the breakpoint I've placed on the first line of my StripeWebhook/Index method is never hit. And a popup appears in Stripe with the sended request with this error message : Test webhook error: Timed out.

However, if I create a brand new ASP.NET MVC website with the default template, and follow the exact same steps, it works. This is because my project uses HTTPS, and ngrok fails to redirect over HTTPS method (as far as i understood.)

How can I use ngrok (or any other free tunneling tool) to redirect to a controller method over HTTPS ?


Solution

  • It's hard to say from the information available whether the issue is ngrok related or your code related or something in between.

    With ngrok you do have to rewrite the host, see ngrok with https on localhost returns 502

    We also have a free tunnelling tool called Conveyor which installs as a VS extension. You can just install it from Tools -> Extensions and signup for an account via the UI. It should 'just work' once you have the public URL (which will be https). It's possible that the same issue will arise, but I'm happy to help you figure it out. You might find this video helpful too.

    EDIT By OP : Just to make it more clear, I had to install Conveyor, then clic on "Access over Internet" and sign up on their website. Then, you're given an adress like https://projectName.conveyor.cloud. I just had to create a new endpoint on Stripe with this domain name and add my /StripeWebhook/Index route and it works like a charm