#dineshkumar6419
1 messages · Page 1 of 1 (latest)
hi, any code you can share?
my code was,
switch (stripeEvent.Type)
{
case Events.CustomerSubscriptionUpdated:
{
var stripeSubscription = (Subscription) stripeEvent.Data.Object;
if (stripeSubscription != null && stripeSubscription.Status == "active")// i got error here
{
}
break;
}
what is the event ID evt_xxx for the webhook event? What version of stripe-dotnet do you have installed?
that version of stripe-dotnet can only accept events in API version 2023-10-16 https://github.com/stripe/stripe-dotnet/blob/master/CHANGELOG.md#4300---2023-10-16 but the event is using an old API version, which is why stripeEvent.Data.Object will be null, the library can't parse it
the best fix would be to delete the webhook endpoint and create it again and pick "latest API version" when setting it up
sorry i can't understand, please clear me
i created latest endpont last week only on stripe dashboard.
I'd suggest deleting the webhook endpoint and create it again and pick "latest API version" when setting it up
not the "default API version"
i am not clear, i wiil again check with my team and document then i will ask anyhelp need.
this is latest event from another account please check this , "evt_1OnzvqESdEyRtJkzqmhb95aC"
what error happens in your code?
i got error, Object reference not set to an instance of an object"
same code,
my code was,
switch (stripeEvent.Type)
{
case Events.CustomerSubscriptionUpdated:
{
var stripeSubscription = (Subscription) stripeEvent.Data.Object;
if (stripeSubscription != null && stripeSubscription.Status == "active")// i got error here
{
}
break;
}
what's the full code, how do you create stripeEvent?
does it work if you do stripeEvent.Data.Object as Subscription ?
here not showing to select api version, i logged in developer role
and pass true to the second argument to ParseEvent (it would throw an exception for the problem you had which I described above so it's good to do that so you can detect that happening)
that's because your account's default API version is also the latest version, so it's all good.
so can i create new one again, delete old endpoint?
if you want. Shouldn't be needed(it's needed on the other account that you first shared).
great, so what is your curent problem?
also note you did not reply to this ^^
i will check this stripeEvent.Data.Object as Subscription
can i test this webhook in local machine?
hi! I'm taking over this thread.
you can with the Stripe CLI: https://docs.stripe.com/cli/listen
also i should need to pass second argument is true?
var stripeEvent = EventUtility.ParseEvent(json, false);
I recommend using the code that's in our documentation here: https://docs.stripe.com/webhooks/quickstart?lang=dotnet
And there we use EventUtility.ParseEvent(json);
I shared the link that explains how it works. it's something like this stripe listen -f http://localhost:3000/webhooks/