paygate icon indicating copy to clipboard operation
paygate copied to clipboard

inbound: webhooks on NOC files

Open adamdecaf opened this issue 4 years ago • 3 comments

PayGate Version: v0.8.0

What were you trying to do? When PayGate processes an inbound file which has NOC batches there should be a way to notify an external application. This allows extensibility of what PayGate can offer right now.

What did you expect to see? Offer a webhook for notifying an external application.

adamdecaf avatar Jul 22 '20 16:07 adamdecaf

I can see us offering a file config where we can specify targets to notify. ~~The payload would be an ACH file's JSON representation.~~ The payload would be a URI to download the file. PayGate would retry sending this until an 200 OK is returned by the receiving service.

inbound:
  interval: <duration> # moved from odfi.inbound
  webhooks:
    notificationOfChange:
      - target: <address>
        authToken: <secret>
        [ insecure: <boolean> ]

adamdecaf avatar Jul 22 '20 16:07 adamdecaf

Would an admin endpoint for registering a webhook be useful? I can see us supporting something like this:

$ curl -X POST http://paygate:9092/webhooks
{
  "type": "inbound",
  "target": "<address>",
  "authToken": "<secret>",
  "insecure": false
}

// responds with 
{
  "webhookID": "<string>"
}

// offer deletion / disablement 
$ curl -X DELETE http://paygate:8082/webhooks/$webhookID

adamdecaf avatar Jul 22 '20 16:07 adamdecaf

David Z in slack mentioned webhooks having a URL to the file rather than shipping the JSON body. This would require endpoints to list/retrieve downloaded files.

Webhook body

{
   "fileURL": "https://paygate:9092/inbound/<filepath>"
}

https vs http would be determined by the bind file configs. -- https://github.com/moov-io/paygate/blob/master/docs/config.md#http

Edit: That fileURL could be determined by the odfi.storage value as well to reference an ftps:// or gcs:// URI instead of serving the files from PayGate.

adamdecaf avatar Jul 22 '20 17:07 adamdecaf