0

I saw this tutorial on stripe.com they unfortunatelly the have only asp.net core sample code for webhook but I need asp.net webform sample code:

using System;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Stripe;

namespace workspace.Controllers
{
    [Route("api/[controller]")]
    public class StripeWebHook : Controller
    {
        [HttpPost]
        public async Task<IActionResult> Index()
        {
            var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();

            try
            {
                var stripeEvent = EventUtility.ParseEvent(json);

                // Handle the event
                if (stripeEvent.Type == Events.PaymentIntentSucceeded)
                {
                    var paymentIntent = stripeEvent.Data.Object as PaymentIntent;
                    // Then define and call a method to handle the successful payment intent.
                    // handlePaymentIntentSucceeded(paymentIntent);
                }
                else if (stripeEvent.Type == Events.PaymentMethodAttached)
                {
                    var paymentMethod = stripeEvent.Data.Object as PaymentMethod;
                    // Then define and call a method to handle the successful attachment of a PaymentMethod.
                    // handlePaymentMethodAttached(paymentMethod);
                }
                // ... handle other event types
                else
                {
                    // Unexpected event type
                    Console.WriteLine("Unhandled event type: {0}", stripeEvent.Type);
                }
                return Ok();
            }
            catch (StripeException e)
            {
                return BadRequest();
            }
        }
    }
}


Instead of using Microsoft.AspNetCore.Mvc what should I replace it with in asp.net webforms? what other classes should I use to rewrite sample code of stripe? Please help me if you can..

Dragos
  • 1
  • 2
  • Web Forms isn't build around the idea of processing just an HTTP request. But you can fairly easy adapt this logic into a [generic handler](https://stackoverflow.com/questions/2332579/what-is-a-generic-handler-in-asp-net-and-its-use), which is a lower level concept in ASP.NET. – mason Jun 12 '23 at 12:33

0 Answers0