Created
October 25, 2016 05:52
-
-
Save robjshaw/5d38b2ec2f26a54d417ea9e6e4538a5f to your computer and use it in GitHub Desktop.
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 express = require('express') | |
const bodyParser = require('body-parser') | |
const crypto = require('crypto') | |
const app = express() | |
const port = 3000 | |
app.use(bodyParser()); | |
app.post('/', (request, response) => { | |
var bodyMessage = JSON.stringify(request.body) | |
bodyMessage = bodyMessage.split('/').join('\\/') | |
bodyMessage = bodyMessage.split('&').join('\\u0026') | |
var calculated_signature = crypto.createHmac('sha256', 'shopify_shared_secret') | |
.update(bodyMessage.toString('utf8')) | |
.digest('base64'); | |
console.log(request.headers['x-shopify-hmac-sha256']) | |
console.log(calculated_signature) | |
}) | |
app.get('/', (request, response) => { | |
response.json({ | |
chance: request.chance | |
}) | |
}) | |
app.listen(port, (err) => { | |
if (err) { | |
return console.log('something bad happened', err) | |
} | |
console.log(`server is listening on ${port}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment