piekarnikgosipl/dev.sh
2026-11-09 16:29:52 +01:00

29 lines
667 B
Bash
Executable file

#!/bin/bash
exec 3< <(stripe listen --events checkout.session.completed,checkout.session.async_payment_succeeded --forward-to localhost:8000/webhook 2>&1)
CHILD_PID=$!
trap "kill -TERM $CHILD_PID 2>/dev/null; exec 3<&-" EXIT
if [ -f .env ]; then
export $(cat .env | xargs)
fi
export DEV_ENV="TRUE"
export WEBHOOK_SECRET=""
while IFS= read -r line <&3; do
matched_value=$(echo "$line" | grep -oP 'whsec_[a-zA-Z0-9]+')
if [ -n "$matched_value" ]; then
WEBHOOK_SECRET=$matched_value
break
fi
done
exec 3<&-
if [ -z "$WEBHOOK_SECRET" ]; then
echo "Error: can't get the webhook secret"
exit 1
fi
go tool templ generate
go run .