I'm using ASP.Net MVC in a virtual machine, Stripe for credit card processing and installed ngrok.com to create a url so I could send webhooks from Stripe to my localhost.
I've installed ngrok.exe and I'm running it and have been provided a url to use
I added a new controller called StripeWebHook and added a new Index method to receive webhooks from Stripe.
namespace YogaBandy2017.Controllers
{
[Route("api/[controller]")]
public class StripeWebHookController : Controller
{
[HttpPost]
[AllowAnonymous]
public void Index()
{
StripeConfiguration.SetApiKey("sk_test_WYKc0e2jXBCU...");
var json = new StreamReader(HttpContext.Request.InputStream).ReadToEnd();
//var stripeEvent = StripeEventUtility.ParseEvent(json);
string secret = "whsec_blSjcGhK1UHRbyGwXa...";
var stripeEvent = StripeEventUtility.ConstructEvent(json,
Request.Headers["Stripe-Signature"], secret);
// Do something with stripeEvent
}
}
}
Then in my Stripe account webhook setting page I added the url for a new webhook on connect accounts
Then I tried sending a test webhook to the url from Stripe and I see the post coming in into the ngrok command line (shown in pic above) and I also see it coming in localhost:4040, which is a test page for ngrok shown here, BUT I can't get into the method 'Index' and hit any breakpoints and the Stripe page shows an error shown below
Here is what the Stripe page shows after I send the test webhook. It show no response and timed out.
Update - I was emailed by ngrok "The trouble is the HTTPS. ngrok terminates HTTPS traffic and then forwards the unencrypted http traffic through to your local application. You want to do one of two things:
1) make your application expose an HTTP port as well and forward traffic to that 2) use ngrok's TLS tunnels (which hand of TLS traffic to you for termination). with this option you have all the complexities of doing cert management, cert mismatches, etc, just fyi. i'd recommend #1 if possible"
Question - anyone know how to open up a http port in a ASP.Net MVC app using https?