Skip to content

fix(store): country dropdown + require state on checkout#137

Merged
sktbrd merged 1 commit into
mainfrom
fix/store-checkout-address-validation
Jul 16, 2026
Merged

fix(store): country dropdown + require state on checkout#137
sktbrd merged 1 commit into
mainfrom
fix/store-checkout-address-validation

Conversation

@sktbrd

@sktbrd sktbrd commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the 400 "Invalid input" users hit at checkout. Two root causes:

  1. Country was free text → browser autofill fills "United States", failing the ISO-2 rule. Now a country <select> (ISO-2 values), with a normalizeCountry() name→code helper as a safety net.
  2. KeepKey rejects an empty state on every country (verified US, BR, GB in sandbox — even the UK), not just US. The form now requires State/Province for all countries, so it's caught client-side before the API call.

Also maps KeepKey's opaque invalid_address / "Invalid input" to an actionable message.

Changes

  • src/lib/store/countries.ts (+ test) — country list + normalizeCountry.
  • src/components/store/CheckoutFlow.tsx — country dropdown; state always required; friendlier server-error surfacing.
  • i18n EN + PT-BR error strings.

Test plan

  • pnpm test — 126 passing
  • Sandbox: US/BR/GB with state → 201; empty state → blocked client-side; full country name impossible via dropdown
  • pnpm lint + tsc clean

Generated with Claude Code

Two real causes of a 400 "Invalid input" at checkout:

- Country was a free-text 2-char input; browser autofill fills "United States",
  which fails the ISO-2 rule. Replaced with a country <select> (ISO-2 values);
  added a countries list + normalizeCountry() name→code helper.
- KeepKey rejects an empty state/province on EVERY country (verified US, BR, GB
  in sandbox), not just US. Client now requires state for all countries, so it's
  caught before the API call.

Also map KeepKey's opaque `invalid_address`/"Invalid input" to an actionable
message pointing at the address fields. i18n EN + PT-BR; tests for the country
helpers.

Verified in sandbox: valid US/BR/GB (with state) → 201; empty state blocked
client-side; full country name no longer possible via the dropdown.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
gnars-shadcn Ignored Ignored Jul 16, 2026 8:10pm
hackertestdao Ignored Ignored Jul 16, 2026 8:10pm

@sktbrd
sktbrd merged commit 0d35628 into main Jul 16, 2026
4 checks passed
@sktbrd
sktbrd deleted the fix/store-checkout-address-validation branch July 16, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant