Stripe Webhook Replay Lab
Use this skill to replay the same signed Stripe webhook event multiple times against your endpoint and validate idempotency behavior.
What this skill does
- - Loads a Stripe event payload from a JSON file or inline env var
- Generates valid Stripe
Stripe-Signature headers using your webhook secret (whsec_...) - Replays the exact same payload N times to simulate duplicate deliveries/retries
- Prints per-attempt HTTP status and latency with a pass/fail summary
Inputs
Required:
- -
STRIPE_WEBHOOK_URL (target endpoint) - INLINECODE3 (Stripe endpoint secret used to verify signatures)
Payload source (choose one):
- -
STRIPE_EVENT_PATH (default: fixtures/sample-checkout-session-completed.json) - INLINECODE6 (inline JSON payload; overrides
STRIPE_EVENT_PATH)
Optional:
- -
REPLAY_COUNT (default: 2) - INLINECODE10 (default:
0) - INLINECODE12 (default:
15) - INLINECODE14 (comma-separated exact HTTP codes accepted as success; default empty = any 2xx)
Run
CODEBLOCK0
Force five duplicate deliveries with a small delay:
CODEBLOCK1
Use inline payload JSON:
CODEBLOCK2
Output contract
- - Prints payload event id/type when available
- Logs each replay attempt: status code + elapsed milliseconds
- Exit
0 if all attempts pass success criteria - Exit
1 if any attempt fails or inputs are invalid
Stripe Webhook 重放实验
使用此技能可多次向你的端点重放相同的已签名 Stripe Webhook 事件,并验证幂等性行为。
技能功能
- - 从 JSON 文件或内联环境变量加载 Stripe 事件负载
- 使用你的 Webhook 密钥(whsec_...)生成有效的 Stripe Stripe-Signature 标头
- 将完全相同的负载重放 N 次,以模拟重复投递/重试
- 打印每次尝试的 HTTP 状态码和延迟时间,并附上通过/失败摘要
输入参数
必需参数:
- - STRIPEWEBHOOKURL(目标端点)
- STRIPEWEBHOOKSECRET(用于验证签名的 Stripe 端点密钥)
负载来源(二选一):
- - STRIPEEVENTPATH(默认值:fixtures/sample-checkout-session-completed.json)
- STRIPEEVENTJSON(内联 JSON 负载;将覆盖 STRIPEEVENTPATH)
可选参数:
- - REPLAYCOUNT(默认值:2)
- REPLAYDELAYSECONDS(默认值:0)
- REQUESTTIMEOUTSECONDS(默认值:15)
- ACCEPTHTTP_CODES(以逗号分隔的精确 HTTP 状态码,视为成功;默认空值表示任何 2xx 状态码)
运行
bash
STRIPEWEBHOOKURL=http://localhost:8000/webhooks/stripe \
STRIPEWEBHOOKSECRET=whsectest123 \
bash scripts/replay-stripe-webhook.sh
强制进行五次重复投递并添加小延迟:
bash
STRIPEWEBHOOKURL=http://localhost:8000/webhooks/stripe \
STRIPEWEBHOOKSECRET=whsectest123 \
REPLAY_COUNT=5 \
REPLAYDELAYSECONDS=0.2 \
bash scripts/replay-stripe-webhook.sh
使用内联 JSON 负载:
bash
STRIPEWEBHOOKURL=http://localhost:8000/webhooks/stripe \
STRIPEWEBHOOKSECRET=whsectest123 \
STRIPEEVENTJSON={id:evttest,type:checkout.session.completed,object:event,data:{object:{id:cstest}}} \
bash scripts/replay-stripe-webhook.sh
输出约定
- - 在可用时打印负载事件 ID/类型
- 记录每次重放尝试:状态码 + 耗时(毫秒)
- 如果所有尝试均通过成功标准,则退出代码为 0
- 如果任何尝试失败或输入无效,则退出代码为 1