Webhooks
APIM 4 · 3:08
A webhook version of the API accepts a payment provider's confirmations and stores each one in a channel before it answers ok. An integration then receives them from that channel.
What it covers
- Declaring the channel
paymentswithweikio channel create, then applying version 2.0 as a webhook - The payment provider as a caller with its own key
- A posted confirmation, stored as a webhook receipt before the ok
- Listing the receipts with
weikio events listin thehookfamily - The admin UI's Events page, which lists the receipt and opens it with its body
- An integration in
financethat receives the events of thepaymentschannel
Commands in this video
Terminal
$ weikio channel create finance/payments
$ weikio apply -f ./finance/apis/webhooks.yaml
$ weikio subscription create finance/payment-provider --env production --api invoices --type apikey -y
$ curl http://api.example.com/invoices/2.0/payments -H "X-Api-Key: $API_KEY" -H "Content-Type: application/json" -d '{"payment":"settled","order":42}'
$ weikio events list --env production --family hook --api invoicesTranscript
- 0:02Your payment provider pushes a confirmation every time a payment settles.
- 0:06This video takes one in:
- 0:08a webhook version stores the body in a channel and answers ok.
- 0:17The gateway serves invoices in production, on api.example.com.
- 0:22Partner-x calls invoices 1.0 with its key, its limit counts the calls.
- 0:29Another caller pushes, instead of asking:
- 0:31the payment provider sends a confirmation when a payment settles.
- 0:36It does not want an answer. It wants its message taken in.
- 0:45First, the project declares the channel payments, with one command before the apply.
- 0:50A version can take a call in. This one is applied like any other document.
- 0:56Its type is webhook, its channel is payments.
- 0:59And it publishes to production, beside the proxy version.
- 1:03One apply stores it, and the gateway serves both versions under the same prefix.
- 1:08Version one dot zero forwards calls to the upstream.
- 1:11Version two dot zero stores them.
- 1:18A webhook call is admitted under a subscription, like any other call.
- 1:23So the payment provider is a caller with its own key.
- 1:26The key is minted and printed once.
- 1:32The provider posts a confirmation, with its key.
- 1:36The gateway stores the body in the channel.
- 1:38It answers ok, once the message is stored.
- 1:45The body the gateway just stored has a name.
- 1:48It is the webhook receipt, the message it keeps for one call it took in.
- 1:53Receipts live in a named stream of messages inside the hub that integrations read.
- 1:59That stream is a channel, and this one is payments.
- 2:05Reading what came in is one command.
- 2:07Its family is hook, for the receipts a webhook version stored.
- 2:12This one lists the receipts of the invoices API.
- 2:16Each row is one receipt, with its stream and its size.
- 2:25The version's page names its type and its channel.
- 2:28The Events page lists the receipt this version took in.
- 2:32This list is the same stored stream the command read.
- 2:36A receipt opens with its body.
- 2:42Where they go: an integration in finance reads the payments channel.
- 2:47It takes the receipts from there.
- 2:49The channel is the stream it reads from.
- 2:56Here is the picture.
- 2:57The webhook version stores every call it takes in, as a receipt in its channel.
- 3:03An integration reads the channel, and the provider gets its ok.