1

我一直在尝试集成 PAYMENT.SALE.COMPLETED 通知 webhook。我在整个互联网上搜索,它总是失败并出现以下错误代码:“verification_status”:“FAILURE”,状态:

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 是 request-promise(尝试了几个 requests 模块)。

这是我的请求正文(webhookObjJSON 变量)

'{
   "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"
         }
      ]
   }
}'

谢谢您的帮助!

4

1 回答 1

0

您似乎正在尝试在https://developer.paypal.com/docs/api-basics/notifications/webhooks/simulator/验证模拟器生成的模拟 webhook

正如该页面所述,“您无法验证模拟器生成的事件。”

于 2020-06-08T05:25:54.587 回答