#ebenezer-owusu_azure-webhook-data-issue

1 messages ยท Page 1 of 1 (latest)

terse basinBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1342536979761336380

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

reef tundra
rain vault
#

I mean request headers

#

context.log("๐Ÿ”น Request Headers:", JSON.stringify(request.headers, null, 2));

#

comes empty

terse basinBOT
rain vault
#

Hello

proven horizon
#

Hello!

rain vault
#

context.log("๐Ÿ”น Request Headers:", JSON.stringify(request.headers, null, 2));

#

request.headers comes to the webhook empty

#

Hence error here - const sig = request.headers['stripe-signature'];

proven horizon
#

What platform are you running your webhook endpoint on?

rain vault
#

Azure functions

#

hello, Am using Azure function (Serverless function)

#

hello

proven horizon
#

Ok cool, I gotcha. I'm not familiar with that one. Have you tried looking at the contents of the whole request object to see what's there?

rain vault
#

here is the request

Request: HttpRequest {
query: URLSearchParams {},
params: {
id: 'evt_3QuyzY2BmsN6YOna0XndJChz',
object: 'event',
api_version: '2020-08-27',
created: '1740154943',
livemode: 'False',
pending_webhooks: '2',
type: 'charge.succeeded'
}
}

#

I did context.log("๐Ÿ”น Request:", request);

proven horizon
#

Are you testing in live mode?

rain vault
#

No, it wasn't working in live mode thats why I decided to debug and test in TEST MODE

proven horizon
#

Ahh ok gotcha.

rain vault
#

Yeah

proven horizon
#

Are you parsing them in that particular way? Also apparently Azure is silly. ยฏ_(ใƒ„)_/ยฏ

#

You're also going to need to access the raw request body or you won't be able to verify the signature.

rain vault
#

Naaa, am not passing them in any partiular way. Do I need to access the raw body in a particular way?

#

I guess this will work

  • const headers = Object.fromEntries(request.headers.entries());
proven horizon
#

It looks like you might do that like this with Azure (using .text()) https://stackoverflow.com/a/78559789/379538

If you can get the signature and the raw body to use with it, you'll be good to go; if not, you'll have to raech out to Azure to find out more.

rain vault
#

Hello so how does this

  • const sig = request.headers['stripe-signature'];

march to this
const headers = Object.fromEntries(request.headers.entries());

Am trying to access stripe-signature

proven horizon
#

What does headers contain after you do that?

rain vault
#

I don't get your question

proven horizon
#

JSON.stringify(headers, null ,3) looks like what when you log it?

#

(despite being python)

rain vault
#

Yeah, Am talking about the stripe-signature in the header. Sine am trying

const headers = Object.fromEntries(request.headers.entries());

proven horizon
#

Yes. And what does the variable headers contain after you do that?

terse basinBOT
#

ebenezer-owusu_azure-webhook-data-issue

rain vault
#

I see this

Header Content {
"accept": "/; q=0.5, application/xml",
"accept-encoding": "gzip",
"cache-control": "no-cache",
"content-length": "3580",
"content-type": "application/json; charset=utf-8",
"host": "localhost:7071",
"stripe-signature": "t=1740158497,v1=ec2087fc80c86d446716a06452537d640347ee31eeaf422bc661a28c6281f2ff,v0=2e8c2727eafb831944bad36e3baf5425bb77c3922e83aca25969cb022dd0c2c2",
"user-agent": "Stripe/1.0 (+https://stripe.com/docs/webhooks)"
}

proven horizon
#

Cool, so you've got the signature now.

rain vault
#

Yeah fabulous

proven horizon
#

Now make sure you're using the raw body to compare it with, and you should be good to go.

rain vault
#

I guess this help to get the raw body

const rawBody = await request.text();
const bodyBuffer = Buffer.from(rawBody, 'utf8');

proven horizon
#

Try just using the contents of request.text() first. Otherwise you could use request.buffer().

rain vault
#

ok

#

A minute pls

rain vault
#

Seems am getting another Azure issues. It not able to read the payload in a fast pace

proven horizon
#

What does that mean?

rain vault
#

Is it possible to Trunate Event before logging?

#

Is an azure issue pls

proven horizon
#

Everything beyond what we've done already is an Azure issue, ya - once Azure can give you the right body content, you can verify it. I unfortunately don't know ~anything about Azure Functions other than what I could google so I've hit the limit of how much I can help here.

rain vault
#

Thanks

proven horizon
#

You're welcome - and good luck! ๐Ÿ™‚