Loading...
Loading...
Run /check-stripe, then fix the highest priority Stripe issue. Creates one fix per invocation. Invoke again for next issue. Use /log-stripe-issues to create issues without fixing.
npx skill4agent add phrazzld/claude-config fix-stripe/check-stripe/stripe/check-stripe.env.localSTRIPE_WEBHOOK_SECRET=whsec_...stripe listen --print-secret// Before
const stripe = new Stripe('sk_test_...', { apiVersion: '2024-12-18.acacia' });
// After
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { apiVersion: '2024-12-18.acacia' });export async function POST(req: Request) {
const body = await req.text();
const signature = req.headers.get('stripe-signature')!;
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
} catch (err) {
return new Response('Webhook signature verification failed', { status: 400 });
}
// Handle event...
}// app/api/stripe/portal/route.ts
export async function POST(req: Request) {
const { customerId } = await req.json();
const session = await stripe.billingPortal.sessions.create({
customer: customerId,
return_url: `${process.env.NEXT_PUBLIC_APP_URL}/settings`,
});
return Response.json({ url: session.url });
}async function requireActiveSubscription(userId: string) {
const subscription = await getSubscription(userId);
if (!subscription || subscription.status !== 'active') {
throw new Error('Active subscription required');
}
}# Test webhook verification
stripe trigger checkout.session.completed
# Check portal works
curl -X POST http://localhost:3000/api/stripe/portal \
-H "Content-Type: application/json" \
-d '{"customerId": "cus_test"}'Fixed: [P0] Webhook signature not verified
Updated: app/api/webhooks/stripe/route.ts
- Added signature verification with constructEvent()
- Added error handling for invalid signatures
Verified: stripe trigger checkout.session.completed → verified
Next highest priority: [P1] No customer portal
Run /fix-stripe again to continue.git checkout -b fix/stripe-$(date +%Y%m%d)/fix-stripe/check-stripe/log-stripe-issues/stripe/stripe-health