SnipCart redirect to my custom thank you page URL on my MVC C# site

Solution 1:

It seems that you are using v3, however, the events that you are listening to are for v2. You would need to listen to this event https://docs.snipcart.com/v3/sdk/events#cartconfirmed for v3.

You could listen to the cart.confirmed event and redirect the customer to the page of your choice using native browser API (location.href).

Solution 2:

You have 2 problems here. One is using Snipcart object, and second is redirecting to custom page.

Using Snipcart object

In order to use Snipcart object, you should use window global object. So you would access Snipcart like this:

window.Snipcart.events.on('cart.confirmed', async (cartConfirmResponse) => {
  // Your logic
})

Redirecting to custom page

In example above, we subscribed to cart.confirmed event. That will fire whenever a purchase is finished. Snipcart will by default open it's own Order Summary page. So you can just add a logic that will instead close the cart and redirect to some other page. You can do it like this:

window.Snipcart.events.on('cart.confirmed', async (cartConfirmResponse) => {
  await window.Snipcart.api.theme.cart.close();
  window.location.replace("http://example.com/custom_page");
})