
I'm trying to use a payment services webhook and verifying the signture. I'm having some trouble with processing payload.
the webhook.verify function in standardwebhooks library requires a string or a Buffer payload (as seen in error in image 2)
When I try it in a local express app. I do this- (see commented code 1) (the express.raw at the top allows me to access the raw payload without express preprocessing it) I log the response to see types if payload and it comes like this [image 1],
notice the payload is type buffer, i convert it to string and pass it to function. This works.
Now when I replicate the same thing in appwrite - (see commented code 2) , the payload is coming in as object and I think that is causing issues with webhook.verify function, getting a response like this [image 2] What I suspect is happening is appwrite preprocesses the payload and converts it from buffer to object.
Here are some questions I have .
- is there a way to stop this preprocessing like I'm doing in express and get a raw buffer payload.
- can I use express in an appwrite cloud function and do it like that.
- any other way I can verify the signature, I suspect this should be something similar to what stripe uses, so if you have verified stripe payload maybe that would apply here as well.
Thanks in advance!

express code code 1
app.post('/webhook', async (req, res) => {
try {
console.log("req", req.body)
console.log(typeof req.body)
const rawBody = req.body.toString('utf8');
const headersList = req.headers;
let webhookHeaders = {
"webhook-id": headersList["webhook-id"] || "",
"webhook-signature": headersList["webhook-signature"] || "",
"webhook-timestamp": headersList["webhook-timestamp"] || "",
};
try{
const verifyres = await webhook.verify(rawBody, webhookHeaders);
console.log("verifyres", verifyres)```

appwrite code code 2
try {
let params = req.body || {};
log(typeof params)
log("params",params )
const rawBody = params.toString('utf8');
log("rawBody",rawBody)
log(typeof rawBody)
const headersList = req.headers;
let webhookHeaders = {
"webhook-id": headersList["webhook-id"] || "",
"webhook-signature": headersList["webhook-signature"] || "",
"webhook-timestamp": headersList["webhook-timestamp"] || "",
};
log("webHookHeaders", webhookHeaders)
log(typeof webhookHeaders)
try{
const verifyres = await webhook.verify(params, webhookHeaders);
log("verifyres", verifyres)```

code pasted in comments bcs post limit reached 😅
Recommended threads
- Anonymous accounts flooding auth users
Dear all, I want to implement anonymous user access for my client-side site, however, I am aware that Appwrite has certain quotas around users (200K). Now, I n...
- error: 'Document with the requested ID a...
just as the title says..
- Stripe Payment Webhook Function
I'm seeing this error in console: ``` Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received ...
