如何捕获paypal webhook?

How to capture paypal webhook?

我在我的网站上集成了 PayPal 智能按钮,createOrderCapture 都在服务器端处理,当付款完成后,交易可以在商业沙盒帐户上使用,并且webhook 事件已在 Webhooks 事件页面中注册。

webhook POST url 在仪表板中订阅了所有事件并在 localhost 中测试它我使用 webhookrelay.

问题是只有当事件来自 Webhook 模拟器而不是来自 Smart Button 的实际付款时,我才会调用 webhook

因此我的服务器仅接收来自模拟器的 webhook 调用,并且 未从 Smart Button 支付中触发

我处于沙盒模式,所有支付和智能按钮都处于沙盒模式。

这是我的智能按钮代码:

paypal
  .Buttons({
    style: {
      shape: "rect",
      color: "gold",
      layout: "horizontal",
      label: "paypal",
      tagline: false,
      height: 52,
    },
    createOrder: async function () {
      const res = await fetch(
        "https://www.example.it/payment/paypal/order/create/" + orderID,
        {
          method: "post",
          headers: {
            "content-type": "application/json",
          },
          credentials: "include",
        }
      );
      const data = await res.json();
      return data.id;
    },
    onApprove: async function (data) {
      const res = await fetch(
        "https://www.example.it/payment/paypal/" +
          data.orderID +
          "/capture/",
        {
          method: "post",
          headers: {
            "content-type": "application/json",
          },
          credentials: "include",
        }
      );
      const details = await res.json();
      if (localStorage.STBOrder) {
        localStorage.removeItem("STBOrder");
      }
      $("#modalPayments").modal("hide");
      $("#modalSuccess").modal("show");
    },
    onCancel: function (data) {},
  })
  .render("#paypal-button-container");