#RichHamilton-webhook

1 messages · Page 1 of 1 (latest)

shell ocean
#

Can you provide an example event ID that is resulting in this error?

primal onyx
#

endpointSecret = "whsec_AS7GBIHZKcOn7jJlS6Fi1FibJ0lj7mVt"

Stripe-Signature = t=1649781708,v1=a24705e4171b7962d83267eaca1cf848c363786aa0716f7aa376e50a434c6843,v0=443da03be93be9bcdd915a563cd0099ffdbca3025b5e6f6528a3b0a22c23e945

#

evt_3KnliHBJoTIUOmnP10ByvB9C

shell ocean
#

and what does your webhook processing code look like?

primal onyx
#

(I am using Umbraco)

#

[HttpPost]
public async Task<IHttpActionResult> IndexAsync([FromBody] dynamic content)
{
var contentService = _services.ContentService;
StripePaymentHelper stripePaymentHelper = new StripePaymentHelper(_services.ContentService);

        var contentString = Convert.ToString(content);
        try
        {
            var stripeSignature = Request.Headers.GetValues("Stripe-Signature").First();

            var stripeEvent = EventUtility.ConstructEvent(contentString,
                stripeSignature, endpointSecret);
           
            if (stripeEvent.Type == Events.PaymentIntentPaymentFailed || stripeEvent.Type == Events.PaymentIntentCanceled)
            {...
shell ocean
#

I'm not the most familiar with .net, but from a quick read of your code my guess would be that you're not working with the raw body of the event. We expect you to make NO modifications to the raw body (you need to keep all the same spaces, new lines, etc) and any change will result in the wrong signature

primal onyx
#

OK

#

That would make sense as I'm reading as JSON and then converting

#

so maybe I just need to read as a raw string

shell ocean
#

Yeah, try working with the raw string and see if that helps

primal onyx
#

Thanks

#

is it sent as text/plain
or text/json ?

shell ocean
#

Sorry I missed this question! It should be application/json

primal onyx
#

If I use string I get NULL returned, it needs a type 😦
public async Task<IHttpActionResult> IndexAsync([FromBody] string content)

shell ocean