0
votes

I've integrated PayPal Smart Buttons in my website, both createOrder and Capture are processed on the server side, when a payment has been completed the transation is available on business sandbox account and the webhook event is registered in Webhooks Events page.

The webhook POST url is subscribed in dashboard to all event and to test it in localhost i use webhookrelay.

The issue is that i get the webhook called only when the event comes from the Webhook Simulator and not from an actual payment from Smart Button.

So my server receives webhook calls only from the simulator and is NOT triggered from a Smart Button payment.

I'm in sandbox mode and all payments and Smart Buttons are in sandbox mode.

Here is my Smart Button code:

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");
1

1 Answers

1
votes