3

I'm trying to integrate Plaid transaction webhooks into an api, and seem to have trouble getting any webhooks to fire. I used the plaid quickstart code and added the webhook parameter:

Plaid.create({
    apiVersion: "v2",
    clientName: "Plaid Walkthrough Demo",
    env: "<%= PLAID_ENV %>",
    product: ["transactions", "auth"],
    webhook: "http://localhost:3000/api/plaid/webhook",
    key: "<%= PLAID_PUBLIC_KEY %>",//...

On the receiving end I'm just logging the req.body to see if webhook fired:

  app.post("/api/plaid/webhook", (req, res) => {
  console.log("WEBHOOK FIRED");
  console.log(JSON.stringify(req.body));
});

When I tested the route in Postman, the req.body was logged as expected, but when creating a new PLAID Item it's not working. I'm currently working in Sandbox mode

dmulter
  • 2,608
  • 3
  • 15
  • 24
Michael
  • 61
  • 7

3 Answers3

1

Wrote to Plaid support and the reason it didn't work is because localhost:3000 is not a valid URL. Once i tried it on an actual server it worked.

Michael
  • 61
  • 7
1

As you already found out yourself, localhost:3000 won't work since it's not public (visible to Plaid).

When I want to test webhooks locally, I typically user services like:

https://postb.in

https://webhook.site

1

Like Plaid support mentioned, localhost:8000 isn't a public URL so Plaid can't see it.

However, its easy to give localhost a public URL using expose.sh. Then you can test the webhook locally.

Install expose.sh

For Mac or Linux, go to Expose.sh and copy/paste the installation code shown into a terminal.

For Windows go to Expose.sh, download the binary and put it somewhere in your PATH.

Expose your api to the web

Start your API server. Then run expose <port> where port is the port your API server is running on, like 80 or 8080.

Expose.sh will generate a random public expose.sh URL. You'll see output like

https://s3rh.expose.sh is forwarding to localhost:80
http://s3rh.expose.sh is forwarding to localhost:80

Then you can get Plaid to use the public HTTPS URL, which will forward to localhost.

I've written a full guide here

Disclaimer: I built expose.sh