Skip to content

Instantly share code, notes, and snippets.

@dlip
Created July 4, 2023 07:42
Show Gist options
  • Save dlip/30127dd6683693358b26d186951f21bf to your computer and use it in GitHub Desktop.
Save dlip/30127dd6683693358b26d186951f21bf to your computer and use it in GitHub Desktop.
Replay stripe events bash script
#!/usr/bin/env bash
set -euo pipefail
LAST_EVENT=""
API_KEY=""
WEBHOOK_ENDPOINT=""
while true; do
OUTPUT=$(stripe --api-key $API_KEY events list --ending-before $LAST_EVENT --limit 100)
EVENTS=$(echo $OUTPUT | jq -r '.data[] | .id')
while IFS= read -r EVENT; do
echo "resending $EVENT"
stripe --api-key $API_KEY events resend $EVENT --webhook-endpoint $WEBHOOK_ENDPOINT
done <<< "$EVENTS"
HAS_MORE=$(echo $OUTPUT | jq -r '.has_more')
if [[ "$HAS_MORE" == "true" ]]; then
LAST_EVENT=$(echo $OUTPUT | jq -r '.data[0] | .id')
else
exit 0
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment