Skip to content

Instantly share code, notes, and snippets.

Created June 26, 2022 15:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LucaTNT/b146c15ec391c00d76700673b6439e14 to your computer and use it in GitHub Desktop.
Shell script to sign a Stripe webhook event
#!/usr/bin/env bash
if [[ ! "$#" -eq 1 ]]; then
echo "USAGE: $0 /path/to/event.json";
exit 1;
timestamp="$(date +%s)."
echo -n $timestamp > sign.tmp
cat $1 >> sign.tmp
signature="$(cat sign.tmp | openssl dgst -hmac "$WEBHOOK_SECRET" -sha256)"
-H "Stripe-Signature: t=$timestamp,v1=$signature" \
-H "Content-Type: application/json" \
--data-binary @"$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment