I've been trying to integrate a PAYMENT.SALE.COMPLETED notification webhook.I searched all over the internet and its always fails with this error code: "verification_status":"FAILURE", status:
const verifyWebHook = (header, body, token, webhookId) => {return new Promise((resolve, reject) => { const VERIFY_URL = 'https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature'; const webhookObjJSON = '{'+'"auth_algo": "'+ header['paypal-auth-algo'] +'"'+',"cert_url": "'+ header['paypal-cert-url'] +'"'+',"transmission_id": "'+ header['paypal-transmission-id'] +'"'+',"transmission_sig": "'+ header['paypal-transmission-sig'] +'"'+',"transmission_time": "'+ header['paypal-transmission-time'] +'"'+',"webhook_id": "'+ webhookId +'"'+',"webhook_event": '+ JSON.stringify(body) +'}', validationReqOptions = { method: 'POST', uri: VERIFY_URL, headers: {'Authorization': token,'content-type': 'application/json' }, body: webhookObjJSON, } rp(validationReqOptions) .then((res) => { return resolve(res) }) .catch((err) => { return reject(err); }); })} rp is request-promise (tried with couple requests modules).
This is my request body (webhookObjJSON variable)
'{"auth_algo":"SHA256withRSA","cert_url":"https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-5edc0ebc","transmission_id":"9f1826f0-a941-11ea-b1e4-55afeaff811c","transmission_sig":"KxQVusuDV2ZtsjALJ/QXdo9L4voX3VmIWGMrAPbzi1phBIr4FEQz5nG6ANIkHKdOhgifO81UA2Y3ljHKQoe/8T8fozRwox+CSXAwxFVKZC63am0YjkzNDWB3DMxVQKnec8q2Yeha26gfssIG/x+lGnr+fmWAl+3OtxpS7rP7T7fckj53J+5aro1NNf+eHkqjZvAGponHJiPx8pZKXcF2aAXGzkcLB+V7FYjbOoW4QgksoyEMVZ9hqxseA/CWda9t43y+VER3xdtFqH+Z6Oyt5KZfRQ4rdAYqlU3iIgJl1RR/IiPi/YlglBqtY4HFBN9i7507uRF67cbh2hcgqIxZuQ==","transmission_time":"2020-06-08T04:36:29Z","webhook_id":"80021663DE681814L","webhook_event":{"id":"WH-2WR32451HC0233532-67976317FL4543714","event_version":"1.0","create_time":"2014-10-23T17:23:52Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"A successful sale payment was made for $ 0.48 USD","resource":{"id":"80021663DE681814L","create_time":"2014-10-23T17:22:56Z","update_time":"2014-10-23T17:23:04Z","amount":{"total":"0.48","currency":"USD" },"payment_mode":"ECHECK","state":"completed","protection_eligibility":"ELIGIBLE","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","clearing_time":"2014-10-30T07:00:00Z","parent_payment":"PAY-1PA12106FU478450MKRETS4A","links":[ {"href":"https://api.paypal.com/v1/payments/sale/80021663DE681814L","rel":"self","method":"GET" }, {"href":"https://api.paypal.com/v1/payments/sale/80021663DE681814L/refund","rel":"refund","method":"POST" }, {"href":"https://api.paypal.com/v1/payments/payment/PAY-1PA12106FU478450MKRETS4A","rel":"parent_payment","method":"GET" } ] },"links":[ {"href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-2WR32451HC0233532-67976317FL4543714","rel":"self","method":"GET" }, {"href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-2WR32451HC0233532-67976317FL4543714/resend","rel":"resend","method":"POST" } ] }}'Thank you for your help!