#Roopa

1 messages ยท Page 1 of 1 (latest)

errant starBOT
lunar blaze
#

Hi there ๐Ÿ‘‹ can you tell me a bit more about the problem that you're running into?

minor vale
#

We have problem in webhook event when listening invoice updated event.

#

we have two stripe accounts with one account it works perfectly, but with other one it creates the subscription but webhooks fails

lunar blaze
#

Can you elaborate on what you mean when you say the webhook fails? Is an error being encountered?

#

If you're doing signature verification on your webhook events, then you'll need to add logic to support two separate webhook signing secrets as each webhook endpoint has a unique signing secret.

minor vale
#

we are getting this error

lunar blaze
#

That is an error that is being returned by your event handler code. You'll need to review your code to determine why it is responding with that error.

minor vale
#

This is the code what we are using. But it works fine with one account.

#

we have problem with other account with same code

lunar blaze
#

Yeah, that code is using the webhook endpoints signing secret to verify the authenticity of the events that are being received. Since each webhook endpoint has a unique signing secret (endpointSecret in your code) you will need to update that code to be able to handle multiple signing secrets.

#

You can either try to construct the event with the signing secret for each webhook endpoint that is pointing to that URL, or you could add query params to your endpoint URLs so you can determine which endpoint the events belong to and which secret needs to be used for them.

minor vale
#

But I am wondering how it was working before? we used same code.

#

and we want to use only one user

lunar blaze
#

Are all events failing, or only the ones for the new endpoint?

minor vale
#

all the events are failing.

lunar blaze
#

Hm, I'm not sure then, have you found the portion of your code that is responsible for deciding to respond to us with the 400 error?

minor vale
#

we are not handling any errors right now. Just doing the app related updates.

lunar blaze
#

Something in your code is causing it to respond to our requests with a 400 rather than a 2XX status indicating that the request was successfully received.

I would suggest adding logging to each step of the code for your endpoint, and then run a test event through it. You can then use the logged information to determine the exact flow that the event took through your code, and where it stopped.

minor vale
#

we have logs, and it is failing in one of below line of code
var stripeEvent = EventUtility.ParseEvent(json);
var signatureHeader = HttpContext.Current.Request.Headers["Stripe-Signature"];
stripeEvent = EventUtility.ConstructEvent(json, signatureHeader, endpoint);

vast egret
#

๐Ÿ‘‹

#

Stepping in as toby needs to step away

#

Do you see any error on your server?

#

And have you logged out the Signature you are using and ensured it is the correct one for this endpoint/account?

minor vale
#

yes, we have done all that.

vast egret
#

Which line is it specifically erroring on? The ConstructEvent?

minor vale
#

I think so

vast egret
#

You aren't using the CLI, are you?

#

To forward to your endpoint? I assume not, but always good to check everything

minor vale
#

no but, when the public url did not work, we tried that aswell with different key

vast egret
#

And that errored as well?

minor vale
#

yes, same error

vast egret
#

This will help rule out a config error or something else.

#

And make sure the endpoint is indeed healthy and that it is some nuance with your current code

minor vale
#

sure, I will try that and let you know.

vast egret
#

๐Ÿ‘

minor vale
#

I am getting exception at this line
var stripeEvent = EventUtility.ParseEvent(json);

#

"Message = "Received event with API version 2022-08-01, but Stripe.net 39.126.0 expects API version 2020-08-27. We recommend that you create a WebhookEndpoint with this API version. Otherwise, you can disable this exception by passing `throwOnApiVersionMismatch: false..."

vast egret
#

Ah okay

#

So that helps

#

And now this all makes sense.

#

The .NET Stripe SDK versions are pinned to API versions

#

We just had a new API version release recently

#

So your newer account is likely on the newer one by default

#

Or, you can update your .NET version

minor vale
#

Ok, I will try it later. Thank you very much for your help.