Webhook

Akshada
New Member
1 0 0
My webhook is getting deleted every after next daythough I am sending 200 to shopify from aws lambda by following wayPlease let me know any modification in code.

exports.handler = (eventcontextcallback=> {
    let response;
    const shopify_hmac_hash = event.headers ?
        event.headers['X-Shopify-Hmac-Sha256'] || event.headers['x-shopify-hmac-sha256']
        : "";
    const content_hmac_hash = crypto.createHmac("sha256"'KEY')
        .update(Buffer.from(event.body"utf8"))
        .digest("base64");
    if (content_hmac_hash !== shopify_hmac_hash) {
        console.log('Integrity of request compromised, aborting');
        response = {
            statusCode: 500,
            body: JSON.stringify("Bad request"),         
        };
        return response;
    }
    if (event.body !== null && event.body !== undefined) {
        let body = JSON.parse(event.body)      
        //////////////
        /// Business logic ////
        ///////////////     
        console.log('Valid webhook')
        response = {
            statusCode: 200,
            body: JSON.stringify('OK'),
        };
        console.log("response"response);
        //response.statusCode(200).send('ok')
        return response;
    }
    response = {
        statusCode: 200,
        body: JSON.stringify('OK'),
    };
    console.log("previous respnse"response);
    return response;
}
0 Likes