question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recommendations for folks who use webhooks

See original GitHub issue

Description

We’ve had a recent API use-case request to be able to monitor the status of a generated invoice to see when it is paid (@john-magill shared this flow in #1239).

We currently have a graphql subscription for this that we use in the galoy-pay repo (see here), which requires being able to use websockets wherever the solution is being deployed.

There are some cases though where setting up a ws/wss connection is tricky, for example with serverless NextJS apps.

Are we aware of any potential solutions to this specific need?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dolcalmicommented, Apr 19, 2022
  • as far as I remember we use WS as transport protocol for subscriptions, even if you check our test client use ws https://github.com/GaloyMoney/galoy/blob/main/test/helpers/apollo-client.ts#L55
  • Not sure if I am understanding correctly but they dont need an api key… or will we add/remove validation filters for that cases?
  • Having a subscription (ws connection) for each invoice is not a good idea because they can have hundreds of clients.
  • setting up a ws/wss connection is tricky, for example with serverless NextJS apps. -> serverless is not a correct approach if they plan to use persistent connections (like ws)

Solution probably webhooks would be a good solution for this case. The easiest way to implement it would be:

  • User request an invoice (on behalf) with metadata (including a ‘callback’ field)
  • When trigger has an update for the invoice we check if its metadata includes a callback and we post the response to that endpoint
  • User receives the POST request (this can be a serverless implementation)
  • With the hash, the user query the transaction status (we cant trust in a post request) and validate the final status

the advantage with this approach is that we can implement it in the same metadata PR and we only have to do a small change in trigger invoice handler (fire and forget POST without additional/external services and/or pods).

0reactions
nicolasburteycommented, Apr 26, 2022

also needed: non subscription api, for developers using serverless api that can’t use subscriptions

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are webhooks? - Zapier
Webhooks are one of the best ways to connect apps that wouldn't otherwise work with Zapier. Have a Mac or iPhone app that...
Read more >
Webhooks done right - Medium
There are some guidelines and best practices explained in this blog to make the webhook implementation scalable, secure and hassle free. When it ......
Read more >
Best Practice to Secure your WebHooks | by Fienny Angelina
Best Practice to Secure your WebHooks · Verification Token · Request Signing & WebHooks Signatures · Mutual TLS (Transport Layer Security) · Thin ......
Read more >
The Plain-English Guide to Webhooks - Level Up Coding
The first step in using webhooks is given the webhook provider a URL where you deliver your requests to. This can be done...
Read more >
Webhooks - Help Center - Typeform
Where do you want your typeform's data to be sent? Use webhooks to get every response sent straight to a compatible web app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found