Webhooks
APIM 4 · 3:09
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.
This part of the video couldn't be loaded.
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:02A payment provider pushes a confirmation each time a payment settles. This video receives one through a webhook.
- 0:13The installation is where the earlier APIM videos left it,
- 0:16with API invoices served in production.
- 0:20partner-x calls version 1.0 with its key, under a rate limit.
- 0:25The payment provider pushes its confirmation without being asked.
- 0:29It needs its message taken in, with no response.
- 0:37The channel must exist first,
- 0:39so weikio channel create finance/payments runs before the apply.
- 0:45weikio apply with webhooks.yaml stores both documents and updates the route tables.
- 0:51The document gives version 2.0 the type webhook and the channel payments.
- 0:57It also deploys version 2.0 to production,
- 1:00so the gateway serves both versions under the same prefix.
- 1:04Version 1.0 forwards calls to orders-api,
- 1:09while version 2.0 stores its body in the channel.
- 1:16Webhook calls get in under a subscription like any call,
- 1:20so weikio subscription create makes one for payment-provider.
- 1:25payment-provider gets a key only it has.
- 1:28The key prints once.
- 1:32curl acts as the provider, posting its confirmation with the key.
- 1:38The body goes into the channel.
- 1:40ok comes after the body is stored.
- 1:46What the gateway stores for each call is a webhook receipt.
- 1:50A channel keeps its messages in Weik.io for integrations to read.
- 1:55The receipts of this version are in the channel payments.
- 2:01weikio events list reads the receipts stored for the API invoices in production.
- 2:08The family hook holds the events a webhook version stored.
- 2:12Each row is a receipt from the API invoices.
- 2:19The version page gives the type and the channel: webhook, payments.
- 2:25On the Events page, the receipt appears in finance/payments.
- 2:30The Events page reads what the command read.
- 2:33Opening the receipt shows its body.
- 2:40Now an integration in the project finance,
- 2:42the payment reader, reads receipts in production.
- 2:46It takes them from the channel payments.
- 2:51The webhook version stores every call's body in the channel payments.
- 2:55The provider has its ok, and the payment reader has the receipts.