#Roopa
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ can you tell me a bit more about the problem that you're running into?
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
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.
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.
This is the code what we are using. But it works fine with one account.
we have problem with other account with same code
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.
But I am wondering how it was working before? we used same code.
and we want to use only one user
Are all events failing, or only the ones for the new endpoint?
all the events are failing.
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?
we are not handling any errors right now. Just doing the app related updates.
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.
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);
๐
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?
yes, we have done all that.
Which line is it specifically erroring on? The ConstructEvent?
I think so
You aren't using the CLI, are you?
To forward to your endpoint? I assume not, but always good to check everything
no but, when the public url did not work, we tried that aswell with different key
And that errored as well?
yes, same error
Okay then what I would recommend next is commenting out your current code in your endpoint and dropping our quickstart code in there (https://stripe.com/docs/webhooks/quickstart?lang=dotnet). Hard code your secret and then see what happens.
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
sure, I will try that and let you know.
๐
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..."
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
So, in that account, recreate your endpoint with https://stripe.com/docs/api/webhook_endpoints/create and set the API version to 2020-08-27
Or, you can update your .NET version
Ok, I will try it later. Thank you very much for your help.