added google sheets
This commit is contained in:
parent
37ca207b92
commit
c4b06eb6c4
7 changed files with 304 additions and 28 deletions
28
dev.sh
28
dev.sh
|
|
@ -1,29 +1,35 @@
|
|||
#!/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
|
||||
LOG_FILE=$(mktemp)
|
||||
trap "rm -f $LOG_FILE; kill $(jobs -p) 2>/dev/null" 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
|
||||
echo "Starting Stripe CLI listener..."
|
||||
|
||||
stripe listen --events checkout.session.completed,checkout.session.async_payment_succeeded --forward-to localhost:8000/webhook > "$LOG_FILE" 2>&1 &
|
||||
|
||||
WEBHOOK_SECRET=""
|
||||
for i in {1..10}; do
|
||||
if grep -q "whsec_" "$LOG_FILE"; then
|
||||
# Extract the exact whsec_ token
|
||||
WEBHOOK_SECRET=$(grep -oE 'whsec_[a-zA-Z0-9]+' "$LOG_FILE" | head -n 1)
|
||||
break
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
exec 3<&-
|
||||
|
||||
if [ -z "$WEBHOOK_SECRET" ]; then
|
||||
echo "Error: can't get the webhook secret"
|
||||
echo "Error: can't get the webhook secret from Stripe CLI"
|
||||
cat "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully captured webhook secret: $WEBHOOK_SECRET"
|
||||
export WEBHOOK_SECRET
|
||||
|
||||
go tool templ generate
|
||||
go run .
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue