Webhook

[Doc] How to test webhook verification

You can test it in two ways. Either one is fine
Approach 1:
Nodejs version: 18
Create a file called test.js & paste this code
(async function verifyWebhookSignature() {
const url = 'https://api-stage.agencyhandy.com/api/v1/webhooks/verify-signature';
const postData = {
webhookId: 'your_webhook_id',
signature: 'your_signature',
secret: 'your_webhook_secret',
payload: {
// Your payload object here
}
};

try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(postData)
});

const data = await response.json();
console.log('Success:', data);
} catch (error) {
console.error('Error:', error);
}
})();

Run the code with this command in the terminal: node test.js

Approach 2:
Or you can test it with postman:
Open webhook folder in postman, Open the request named ‘Verify Signature’. Go to Body and change the values. Make sure the URL says ‘https://api-stage.agencyhandy.com/api/v1/webhooks/verify-signature’
If it’s verified response should be:
{
"verification_status": "SUCCESS"
}
If not:
{
"type": "PermissionError",
"status": 403,
"verification_status": "FAILED"
}

Test cases:
If any propery in postData [CODE EXAMPLE TO REFER THE TERM] is missing. You will get an error
if you provided any wrong value. you will get an error
apply permutation on postData properties and test it out. for example provide only 3, see if you get errors. you should. or provide 3 right value and one wrong value. you should get an error. Test all scenarios this way.
Provide all the right properties and values. you should get success message
Query:
Please provide the postman collection.
Test case and Testing Results:
Check if for all valid data it is working properly by giving success message. PASSED
image.png
Check if for any incorrect data it is showing failed status. PASSED ​
image.png
Check if empty data it is showing 400 and missing status with the property name. PASSED
image.png
Check if wrong value in price for payload showing failed status. PASSED
Check if from the mandatory property if one is missing error is generated. PASSED
image.png
image.png
image.png
image.png
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.