Last active
January 29, 2021 19:11
-
-
Save alexweissman/b9b892df62af81a51e69f4fd894b3ec5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var CryptoJS = require('crypto-js'); | |
var timestamp = Date.now().valueOf(); | |
var secret = pm.collectionVariables.get('secret'); | |
var payload = pm.request.body.raw; | |
var signature = CryptoJS.HmacSHA256(timestamp + '.' + payload, secret); | |
pm.request.headers.add({ | |
key: 'Stripe-Signature', | |
value: 't=' + timestamp + ',v1=' + signature | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy this to "Pre-request Scripts" in your Postman collection. Then in the "Variables" tab, set
secret
to the value of your webhook secret retrieved from Stripe Dashboard.This script will automatically generate the timestamp and signature and insert them into the
Stripe-Signature
header for your request.