Fix KiloClaw early bird checkout to link payments to existing Stripe customer#773
Merged
pandemicsyn merged 10 commits intomainfrom Mar 3, 2026
Merged
Conversation
Contributor
Author
Code Review SummaryStatus: No New Issues Found | Recommendation: Address existing comments before merge OverviewThis PR adds a KiloClaw Early Bird checkout flow with server-side Stripe Checkout Session creation, webhook-based purchase recording, and proper GDPR compliance. The implementation is well-structured. Positive observations:
Previously flagged issues (from existing comments) still worth addressing:
Other Observations (not in diff)
Files Reviewed (9 files)
|
jrf0110
reviewed
Mar 3, 2026
src/routers/kiloclaw-router.ts
Outdated
Comment on lines
+404
to
+412
| const priceId = getEnvVariable('STRIPE_KILOCLAW_EARLYBIRD_PRICE_ID'); | ||
| if (!priceId) { | ||
| throw new TRPCError({ | ||
| code: 'INTERNAL_SERVER_ERROR', | ||
| message: 'Early bird pricing is not configured.', | ||
| }); | ||
| } | ||
|
|
||
| const couponId = getEnvVariable('STRIPE_KILOCLAW_EARLYBIRD_COUPON_ID'); |
Contributor
There was a problem hiding this comment.
These env vars should be validated at server startup time - can put them in src/lib/config.server.ts
jrf0110
approved these changes
Mar 3, 2026
…ession Replace the static Stripe Payment Link with a server-side Stripe Checkout Session that passes the user's existing stripe_customer_id. This prevents duplicate/guest Stripe customer accounts from being created during early bird purchases.
…lfillment - Add kiloclaw_earlybird_purchases table to record earlybird payments - Record purchases in charge.succeeded webhook (replaces no-op skip) - Add duplicate purchase check and Stripe idempotency key to mutation - Add payment_intent_data.metadata for reliable webhook traceability - Add getEarlybirdStatus query; hide banner/block checkout after purchase - Update GDPR soft-delete to clean up earlybird purchases - Let webhook DB errors propagate so Stripe retries on failure
85134eb to
5145a0f
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
The early bird checkout used a static Stripe Payment Link with only prefilled_email, which is cosmetic and does not link the payment to the user's existing Stripe customer record. This caused:
Additionally, there was no server-side record of earlybird purchases, no duplicate purchase prevention, and no webhook fulfillment handler.
Changes
packages/db/src/schema.ts
Added kiloclaw_earlybird_purchases table with:
packages/db/src/migrations/0039_mushy_darkhawk.sql
Migration for the new table.
src/routers/kiloclaw-router.ts
src/lib/stripe.ts
src/app/(app)/claw/earlybird/page.tsx
src/app/(app)/claw/components/ClawDashboard.tsx
src/lib/user.ts / src/lib/user.test.ts
.env.test
Setup required
The following environment variables must be set in Vercel/production:
Built for Brendan by Kilo for Slack and FlorianBot