diff options
| author | Derrick <[email protected]> | 2021-07-09 14:25:51 -0600 |
|---|---|---|
| committer | Derrick <[email protected]> | 2021-07-09 14:25:51 -0600 |
| commit | bf37962b00b323c412c2ea89bf60d24fbe4aa87b (patch) | |
| tree | 70ca171462fa40108495542c1b02c9844200859e /lib/webhooks.js | |
| parent | d7ef5e9ab7c6e04267bd1797466add8f57673598 (diff) | |
| parent | 4bde8faf1b9d91898447bdf2c63b0afd227f978c (diff) | |
| download | coinos-server-masterZ.tar.gz coinos-server-masterZ.zip | |
Merge branch 'master' into masterZmasterZ
Diffstat (limited to 'lib/webhooks.js')
| -rw-r--r-- | lib/webhooks.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/webhooks.js b/lib/webhooks.js new file mode 100644 index 00000000..f21607fb --- /dev/null +++ b/lib/webhooks.js @@ -0,0 +1,28 @@ +const wretch = require("wretch"); +const fetch = require("node-fetch"); +wretch().polyfills({ fetch }); + +callWebhook = (invoice, payment) => { + if (!invoice || !payment) return; + + let { address, text, webhook } = invoice; + + if (webhook) { + let { amount, confirmed, hash, memo } = payment; + + l.info("calling webhook", webhook); + return wretch() + .url(webhook) + .post({ + address, + amount, + hash, + memo, + confirmed, + text, + webhook + }) + .json() + .catch(console.log); + } +}; |
