Created
April 16, 2018 08:39
-
-
Save jenbennings/556880f031e914491a27dc76cc6321d9 to your computer and use it in GitHub Desktop.
Coinbase Commerce to Slack WebHook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
const request = require('request'); | |
admin.initializeApp(functions.config().firebase); | |
exports.saleAlert = functions.https.onRequest((req, res) => { | |
const product = req.body.event.data.checkout.id; | |
const id = req.body.event.data.code; | |
if (product === 'YOUR-PRODUCT-ID-HERE') { | |
request.post( | |
"YOUR-SLACK-WEBHOOK-URL-HERE", | |
{ json: { text: `Someone just purchased 1 × *:black_medium_square: Genesis Block Poster* (ID: #${id})`} } | |
); | |
} | |
res.status(200).send('ok'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment