Created
July 4, 2023 07:42
-
-
Save dlip/30127dd6683693358b26d186951f21bf to your computer and use it in GitHub Desktop.
Replay stripe events bash script
This file contains 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
#!/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